summaryrefslogtreecommitdiff
path: root/source/nsswitch
diff options
context:
space:
mode:
Diffstat (limited to 'source/nsswitch')
-rw-r--r--source/nsswitch/.cvsignore1
-rw-r--r--source/nsswitch/hp_nss_common.h7
-rw-r--r--source/nsswitch/hp_nss_dbdefs.h3
-rw-r--r--source/nsswitch/winbindd_cm.c84
-rw-r--r--source/nsswitch/winbindd_wins.c30
5 files changed, 52 insertions, 73 deletions
diff --git a/source/nsswitch/.cvsignore b/source/nsswitch/.cvsignore
index 090b859b372..5f2a5c4cf75 100644
--- a/source/nsswitch/.cvsignore
+++ b/source/nsswitch/.cvsignore
@@ -1,3 +1,2 @@
*.po
*.po32
-diffs
diff --git a/source/nsswitch/hp_nss_common.h b/source/nsswitch/hp_nss_common.h
index 5f39e9abb05..7ce67ed81fa 100644
--- a/source/nsswitch/hp_nss_common.h
+++ b/source/nsswitch/hp_nss_common.h
@@ -2,7 +2,8 @@
#define _HP_NSS_COMMON_H
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.2
Donated by HP to enable Winbindd to build on HPUX 11.x.
Copyright (C) Jeremy Allison 2002.
@@ -23,8 +24,12 @@
Boston, MA 02111-1307, USA.
*/
+#ifdef HAVE_SYNCH_H
#include <synch.h>
+#endif
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
+#endif
typedef enum {
NSS_SUCCESS,
diff --git a/source/nsswitch/hp_nss_dbdefs.h b/source/nsswitch/hp_nss_dbdefs.h
index bd24772e339..c6951277356 100644
--- a/source/nsswitch/hp_nss_dbdefs.h
+++ b/source/nsswitch/hp_nss_dbdefs.h
@@ -2,7 +2,8 @@
#define _HP_NSS_DBDEFS_H
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.2
Donated by HP to enable Winbindd to build on HPUX 11.x.
Copyright (C) Jeremy Allison 2002.
diff --git a/source/nsswitch/winbindd_cm.c b/source/nsswitch/winbindd_cm.c
index c1b5b27af89..af03826ad07 100644
--- a/source/nsswitch/winbindd_cm.c
+++ b/source/nsswitch/winbindd_cm.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 3.0
Winbind daemon connection manager
@@ -72,7 +73,7 @@ struct winbindd_cm_conn {
POLICY_HND pol;
};
-static struct winbindd_cm_conn *cm_conns = NULL;
+struct winbindd_cm_conn *cm_conns = NULL;
/* Get a domain controller name. Cache positive and negative lookups so we
don't go to the network too often when something is badly broken. */
@@ -146,64 +147,38 @@ static BOOL cm_get_dc_name(char *domain, fstring srv_name)
DEBUG(3, ("Could not look up dc's for domain %s\n", domain));
return False;
}
-
- /* Pick a nice close server */
-
- if (strequal(lp_passwordserver(), "*")) {
- /* Look for DC on local net */
-
- for (i = 0; i < count; i++) {
- if (is_local_net(ip_list[i]) &&
- name_status_find(domain, 0x1c, 0x20,
- ip_list[i], srv_name)) {
- dc_ip = ip_list[i];
- goto done;
- }
- zero_ip(&ip_list[i]);
- }
-
- /* Look for other DCs */
-
- for (i = 0; i < count; i++) {
- if (!is_zero_ip(ip_list[i]) &&
- name_status_find(domain, 0x1c, 0x20,
- ip_list[i], srv_name)) {
- dc_ip = ip_list[i];
- goto done;
- }
- }
-
- /* No-one to talk to )-: */
+ /* Firstly choose a PDC/BDC who has the same network address as any
+ of our interfaces. */
+
+ for (i = 0; i < count; i++) {
+ if(is_local_net(ip_list[i]))
+ goto got_ip;
+ }
+ if (count == 0) {
+ DEBUG(3, ("No domain controllers for domain %s\n", domain));
return False;
}
+
+ i = (sys_random() % count);
+
+ got_ip:
+ dc_ip = ip_list[i];
+ SAFE_FREE(ip_list);
+
+ /* We really should be doing a GETDC call here rather than a node
+ status lookup. */
- /* Return first DC that we can contact */
-
- for (i = 0; i < count; i++) {
- if (name_status_find(domain, 0x1c, 0x20, ip_list[i],
- srv_name)) {
- dc_ip = ip_list[i];
- goto done;
- }
+ if (!name_status_find(domain, 0x1c, 0x20, dc_ip, srv_name)) {
+ DEBUG(3, ("Error looking up DC name for %s in domain %s\n", inet_ntoa(dc_ip), domain));
+ return False;
}
- return False; /* Boo-hoo */
-
- done:
- /* We have the netbios name and IP address of a domain controller.
- Ideally we should sent a SAMLOGON request to determine whether
- the DC is alive and kicking. If we can catch a dead DC before
- performing a cli_connect() we can avoid a 30-second timeout. */
-
/* We have a name so make the cache entry positive now */
fstrcpy(dcc->srv_name, srv_name);
- DEBUG(3, ("Returning DC %s (%s) for domain %s\n", srv_name,
- inet_ntoa(dc_ip), domain));
-
return True;
}
@@ -225,6 +200,7 @@ void cm_init_creds(struct ntuser_creds *creds)
if (username && *username) {
pwd_set_cleartext(&creds->pwd, password);
+ pwd_make_lm_nt_16(&creds->pwd, password);
fstrcpy(creds->user_name, username);
fstrcpy(creds->domain, lp_workgroup());
@@ -264,14 +240,14 @@ static BOOL cm_open_connection(char *domain, char *pipe_name,
fstrcpy(new_conn->pipe_name, pipe_name);
/* Look for a domain controller for this domain. Negative results
- are cached so don't bother applying the caching for this
- function just yet. */
+ are cached so don't bother applying the caching for this
+ function just yet. */
if (!cm_get_dc_name(domain, new_conn->controller))
goto done;
/* Return false if we have tried to look up this domain and netbios
- name before and failed. */
+ name before and failed. */
for (occ = open_connection_cache; occ; occ = occ->next) {
@@ -287,7 +263,7 @@ static BOOL cm_open_connection(char *domain, char *pipe_name,
DEBUG(10, ("cm_open_connection cache entry expired for %s, %s\n", domain, new_conn->controller));
DLIST_REMOVE(open_connection_cache, occ);
- free(occ);
+ SAFE_FREE(occ);
break;
}
@@ -709,7 +685,7 @@ NTSTATUS cm_get_netlogon_cli(char *domain, unsigned char *trust_passwd,
return result;
}
- result = new_cli_nt_setup_creds(conn.cli, trust_passwd);
+ result = cli_nt_setup_creds(conn.cli, trust_passwd);
if (!NT_STATUS_IS_OK(result)) {
DEBUG(0, ("error connecting to domain password server: %s\n",
diff --git a/source/nsswitch/winbindd_wins.c b/source/nsswitch/winbindd_wins.c
index 0aab4ddd650..ca21ccb4853 100644
--- a/source/nsswitch/winbindd_wins.c
+++ b/source/nsswitch/winbindd_wins.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.0
Winbind daemon - WINS related functions
@@ -125,14 +126,14 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
enum winbindd_result winbindd_wins_byip(struct winbindd_cli_state *state)
{
char response[1024];
- int i, count, len, size;
+ int i, count, len, size, maxsize;
struct node_status *status;
DEBUG(3, ("[%5d]: wins_byip %s\n", state->pid,
state->request.data.name));
*response = '\0';
- len = sizeof(response) - 2;
+ maxsize = len = sizeof(response) - 1;
if ((status = lookup_byaddr_backend(state->request.data.name, &count))){
size = strlen(state->request.data.name) + 1;
@@ -141,8 +142,8 @@ enum winbindd_result winbindd_wins_byip(struct winbindd_cli_state *state)
return WINBINDD_ERROR;
}
len -= size;
- safe_strcat(response,state->request.data.name,size);
- safe_strcat(response,"\t",1);
+ safe_strcat(response,state->request.data.name,maxsize);
+ safe_strcat(response,"\t",maxsize);
for (i = 0; i < count; i++) {
/* ignore group names */
if (status[i].flags & 0x80) continue;
@@ -153,11 +154,10 @@ enum winbindd_result winbindd_wins_byip(struct winbindd_cli_state *state)
return WINBINDD_ERROR;
}
len -= size;
- safe_strcat(response, status[i].name, size);
- safe_strcat(response, " ", 1);
+ safe_strcat(response, status[i].name, maxsize);
+ safe_strcat(response, " ", maxsize);
}
}
- response[strlen(response)-1] = '\n';
SAFE_FREE(status);
}
fstrcpy(state->response.data.name.name,response);
@@ -169,7 +169,7 @@ enum winbindd_result winbindd_wins_byip(struct winbindd_cli_state *state)
enum winbindd_result winbindd_wins_byname(struct winbindd_cli_state *state)
{
struct in_addr *ip_list;
- int i, count, len, size;
+ int i, count, len, size, maxsize;
char response[1024];
char * addr;
@@ -177,7 +177,7 @@ enum winbindd_result winbindd_wins_byname(struct winbindd_cli_state *state)
state->request.data.name));
*response = '\0';
- len = sizeof(response) - 2;
+ maxsize = len = sizeof(response) - 1;
if ((ip_list = lookup_byname_backend(state->request.data.name,&count))){
for (i = count; i ; i--) {
@@ -188,18 +188,16 @@ enum winbindd_result winbindd_wins_byname(struct winbindd_cli_state *state)
return WINBINDD_ERROR;
}
len -= size;
- if (i != 0)
- response[strlen(response)-1] = ' ';
- safe_strcat(response,addr,size);
- safe_strcat(response,"\t",1);
+ safe_strcat(response,addr,maxsize);
+ safe_strcat(response," ",maxsize);
}
size = strlen(state->request.data.name) + 1;
if (size > len) {
SAFE_FREE(ip_list);
return WINBINDD_ERROR;
}
- safe_strcat(response,state->request.data.name,size);
- safe_strcat(response,"\n",1);
+ response[strlen(response)-1] = '\t';
+ safe_strcat(response,state->request.data.name,maxsize);
SAFE_FREE(ip_list);
} else
return WINBINDD_ERROR;