summaryrefslogtreecommitdiff
path: root/source3/nsswitch/wbinfo.c
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/wbinfo.c
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/wbinfo.c')
-rw-r--r--source3/nsswitch/wbinfo.c54
1 files changed, 37 insertions, 17 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 */