mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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 commit is contained in:
parent
6df29bfe33
commit
2bd2a092ee
@ -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 */
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user