summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-01-10 11:28:14 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-01-10 11:28:14 +0000
commit7d6dd0b3a0f6d1c7f2737f90e3099a21bf4a55b5 (patch)
treeb2564eee672dc14c121662c9f2da120e7efbbfcd /source3/nsswitch
parentcf00e41421793d042f24d0b0ecf47237a3cfc7c2 (diff)
downloadsamba-7d6dd0b3a0f6d1c7f2737f90e3099a21bf4a55b5.tar.gz
samba-7d6dd0b3a0f6d1c7f2737f90e3099a21bf4a55b5.tar.bz2
samba-7d6dd0b3a0f6d1c7f2737f90e3099a21bf4a55b5.zip
Return the winbind separator over the socket, so programs don't have to parse
smb.conf to get it right. While wb_client needs its lp_load() for samba dependency reasons, it now uses the new method both to example and test the new code. Also add an interface version function, and return the winbind's samba version string. In preperation for default domains, its now up to winbindd to reject plaintext auths that don't have a seperator, but NTLM (CRAP) auths now have two feilds, hence need parsing. Andrew Bartlett (This used to be commit 2bd2a092ee3d49a74d896385688d7c7256aa297e)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c54
-rw-r--r--source3/nsswitch/winbindd.c2
-rw-r--r--source3/nsswitch/winbindd_misc.c28
-rw-r--r--source3/nsswitch/winbindd_nss.h10
-rw-r--r--source3/nsswitch/winbindd_proto.h2
5 files changed, 78 insertions, 18 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index 56cccee3b8..08b444a7c8 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -4,7 +4,8 @@
Winbind status program.
- Copyright (C) Tim Potter 2000
+ Copyright (C) Tim Potter 2000
+ Copyright (C) Andrew Bartlett 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -31,12 +32,39 @@ NSS_STATUS winbindd_request(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
+static char get_winbind_separator(void)
+{
+ struct winbindd_response response;
+ char winbind_separator;
+
+ ZERO_STRUCT(response);
+
+ /* Send off request */
+
+ if (winbindd_request(WINBINDD_INFO, NULL, &response) !=
+ NSS_STATUS_SUCCESS) {
+ printf("could not obtain winbind seperator!\n");
+ exit(1);
+ }
+
+ winbind_separator = response.data.info.winbind_separator;
+
+ if (!winbind_separator) {
+ printf("winbind separator was NULL!\n");
+ exit(1);
+ }
+
+ return winbind_separator;
+
+}
+
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN/user into a domain and a user */
-static BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
+static BOOL parse_wbinfo_domain_user(const char *domuser, fstring domain, fstring user)
{
- char *p = strchr(domuser,*lp_winbind_separator());
+
+ char *p = strchr(domuser,get_winbind_separator());
if (!p)
return False;
@@ -265,7 +293,7 @@ static BOOL wbinfo_lookupname(char *name)
* Don't do the lookup if the name has no separator.
*/
- if (!strchr(name, *lp_winbind_separator()))
+ if (!strchr(name, get_winbind_separator()))
return False;
/* Send off request */
@@ -295,15 +323,6 @@ static BOOL wbinfo_auth(char *username)
NSS_STATUS result;
char *p;
- /*
- * Don't do the lookup if the name has no separator.
- */
-
- if (!strchr(username, *lp_winbind_separator())) {
- printf("no domain seperator (%s) in username - failing\n", lp_winbind_separator());
- return False;
- }
-
/* Send off request */
ZERO_STRUCT(request);
@@ -340,13 +359,14 @@ static BOOL wbinfo_auth_crap(char *username)
fstring name_domain;
fstring pass;
char *p;
+ char sep = get_winbind_separator();
/*
* Don't do the lookup if the name has no separator.
*/
- if (!strchr(username, *lp_winbind_separator())) {
- printf("no domain seperator (%s) in username - failing\n", lp_winbind_separator());
+ if (!strchr(username, sep)) {
+ printf("no domain seperator (%c) in username - failing\n", sep);
return False;
}
@@ -362,7 +382,7 @@ static BOOL wbinfo_auth_crap(char *username)
fstrcpy(pass, p + 1);
}
- parse_domain_user(username, name_domain, name_user);
+ parse_wbinfo_domain_user(username, name_domain, name_user);
fstrcpy(request.data.auth_crap.user, name_user);
@@ -562,7 +582,7 @@ int main(int argc, char **argv)
dyn_CONFIGFILE, strerror(errno));
exit(1);
}
-
+
load_interfaces();
/* Parse command line options */
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index 631b71961d..0cbdb34033 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -330,6 +330,8 @@ static struct dispatch_table dispatch_table[] = {
{ WINBINDD_CHECK_MACHACC, winbindd_check_machine_acct, "CHECK_MACHACC" },
{ WINBINDD_PING, winbindd_ping, "PING" },
+ { WINBINDD_INFO, winbindd_info, "INFO" },
+ { WINBINDD_INTERFACE_VERSION, winbindd_interface_version, "INTERFACE_VERSION" },
/* End of list */
diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c
index 2cfea9bbb6..d820bb35dc 100644
--- a/source3/nsswitch/winbindd_misc.c
+++ b/source3/nsswitch/winbindd_misc.c
@@ -4,7 +4,8 @@
Winbind daemon - miscellaneous other functions
- Copyright (C) Tim Potter 2000
+ Copyright (C) Tim Potter 2000
+ Copyright (C) Andrew Bartlett 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -149,3 +150,28 @@ enum winbindd_result winbindd_ping(struct winbindd_cli_state
return WINBINDD_OK;
}
+
+/* List various tidbits of information */
+
+enum winbindd_result winbindd_info(struct winbindd_cli_state *state)
+{
+
+ DEBUG(3, ("[%5d]: request misc info\n", state->pid));
+
+ state->response.data.info.winbind_separator = *lp_winbind_separator();
+ fstrcpy(state->response.data.info.samba_version, VERSION);
+
+ return WINBINDD_OK;
+}
+
+/* List various tidbits of information */
+
+enum winbindd_result winbindd_interface_version(struct winbindd_cli_state *state)
+{
+
+ DEBUG(3, ("[%5d]: request interface version\n", state->pid));
+
+ state->response.data.interface_version = WINBIND_INTERFACE_VERSION;
+
+ return WINBINDD_OK;
+}
diff --git a/source3/nsswitch/winbindd_nss.h b/source3/nsswitch/winbindd_nss.h
index 4d836a21cf..bac07fc42d 100644
--- a/source3/nsswitch/winbindd_nss.h
+++ b/source3/nsswitch/winbindd_nss.h
@@ -37,6 +37,9 @@
/* Socket commands */
+/* Update this when you change the interface. */
+#define WINBIND_INTERFACE_VERSION 1
+
enum winbindd_cmd {
/* Get users and groups */
@@ -84,6 +87,8 @@ enum winbindd_cmd {
WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
WINBINDD_PING, /* Just tell me winbind is running */
+ WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
+ WINBINDD_INTERFACE_VERSION, /* *TRY* to keep this in the same place... */
/* Placeholder for end of cmd list */
@@ -145,6 +150,7 @@ struct winbindd_response {
/* Fixed length return data */
union {
+ int interface_version; /* Try to ensure this is always in the same spot... */
/* getpwnam, getpwuid */
@@ -179,6 +185,10 @@ struct winbindd_response {
} name;
uid_t uid; /* sid_to_uid */
gid_t gid; /* sid_to_gid */
+ struct winbindd_info {
+ char winbind_separator;
+ fstring samba_version;
+ } info;
} data;
/* Variable length return data */
diff --git a/source3/nsswitch/winbindd_proto.h b/source3/nsswitch/winbindd_proto.h
index bedd5a0352..fa5fec1b48 100644
--- a/source3/nsswitch/winbindd_proto.h
+++ b/source3/nsswitch/winbindd_proto.h
@@ -70,6 +70,8 @@ enum winbindd_result winbindd_list_trusted_domains(struct winbindd_cli_state
*state);
enum winbindd_result winbindd_ping(struct winbindd_cli_state
*state);
+enum winbindd_result winbindd_info(struct winbindd_cli_state *state);
+enum winbindd_result winbindd_interface_version(struct winbindd_cli_state *state);
/* The following definitions come from nsswitch/winbindd_pam.c */