1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-16 00:23:52 +03:00

loadparm.c: Added #ifdef USE_LDAP around ldap code.

server.c: Moved %U, %G and %N into standard_sub() from standard_sub_basic()
          as only smbd knows about usernames. Also fixes problem with calling
          standard_sub_basic() from loadparm.c.
smbpass.c: Partial tidyup of machine_password_lock() code - not finished yet.
util.c: Moved %U, %G and %N into standard_sub() from standard_sub_basic()
          as only smbd knows about usernames. Also fixes problem with calling
          standard_sub_basic() from loadparm.c.
lib/rpc/server/srv_ldap_helpers.c: Added #ifdef USE_LDAP around ldap code.
lib/rpc/server/srv_samr.c: Added #ifdef USE_LDAP around ldap code.
Jeremy.
This commit is contained in:
Jeremy Allison
-
parent 18a0a10dcb
commit 446b98ca07
6 changed files with 43 additions and 38 deletions

View File

@@ -4000,32 +4000,16 @@ void standard_sub_basic(char *str)
{
char *s, *p;
char pidstr[10];
struct passwd *pass;
char *username = sam_logon_in_ssb ? samlogon_user : sesssetup_user;
for (s = str ; s && *s && (p = strchr(s,'%')); s = p )
{
switch (*(p+1))
{
case 'G' :
{
if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
{
string_sub(p,"%G",gidtoname(pass->pw_gid));
}
else
{
p += 2;
}
break;
}
case 'N' : string_sub(p,"%N", automount_server(username)); break;
case 'I' : string_sub(p,"%I", client_addr(Client)); break;
case 'L' : string_sub(p,"%L", local_machine); break;
case 'M' : string_sub(p,"%M", client_name(Client)); break;
case 'R' : string_sub(p,"%R", remote_proto); break;
case 'T' : string_sub(p,"%T", timestring()); break;
case 'U' : string_sub(p,"%U", username); break;
case 'a' : string_sub(p,"%a", remote_arch); break;
case 'd' :
{

View File

@@ -172,7 +172,9 @@ typedef struct
int shmem_size;
int client_code_page;
int announce_as; /* This is initialised in init_globals */
#ifdef USE_LDAP
int ldap_port;
#endif /* USE_LDAP */
BOOL bDNSproxy;
BOOL bWINSsupport;
BOOL bWINSproxy;
@@ -622,6 +624,7 @@ static struct parm_struct parm_table[] =
{"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_GLOBAL},
{"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, 0},
#ifdef USE_LDAP
{"Ldap Options", P_SEP, P_SEPARATOR},
{"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, 0},
{"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, 0},
@@ -629,7 +632,7 @@ static struct parm_struct parm_table[] =
{"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, 0},
{"ldap root", P_STRING, P_GLOBAL, &Globals.szLdapRoot, NULL, NULL, 0},
{"ldap root passwd", P_STRING, P_GLOBAL, &Globals.szLdapRootPassword,NULL, NULL, 0},
#endif /* USE_LDAP */
{"Miscellaneous Options", P_SEP, P_SEPARATOR},
@@ -776,10 +779,11 @@ static void init_globals(void)
Globals.bUnixPasswdSync = False;
Globals.bPasswdChatDebug = False;
#ifdef USE_LDAP
/* default values for ldap */
string_set(&Globals.szLdapServer, "localhost");
Globals.ldap_port=389;
#endif /* USE_LDAP */
/* these parameters are set to defaults that are more appropriate
for the increasing samba install base:
@@ -983,11 +987,13 @@ FN_GLOBAL_STRING(lp_domain_guest_users,&Globals.szDomainGuestUsers)
FN_GLOBAL_STRING(lp_domain_hostsallow,&Globals.szDomainHostsallow)
FN_GLOBAL_STRING(lp_domain_hostsdeny,&Globals.szDomainHostsdeny)
#ifdef USE_LDAP
FN_GLOBAL_STRING(lp_ldap_server,&Globals.szLdapServer);
FN_GLOBAL_STRING(lp_ldap_suffix,&Globals.szLdapSuffix);
FN_GLOBAL_STRING(lp_ldap_filter,&Globals.szLdapFilter);
FN_GLOBAL_STRING(lp_ldap_root,&Globals.szLdapRoot);
FN_GLOBAL_STRING(lp_ldap_rootpasswd,&Globals.szLdapRootPassword);
#endif /* USE_LDAP */
FN_GLOBAL_BOOL(lp_dns_proxy,&Globals.bDNSproxy)
FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport)
@@ -1044,7 +1050,9 @@ FN_GLOBAL_INTEGER(lp_announce_as,&Globals.announce_as)
FN_GLOBAL_INTEGER(lp_lm_announce,&Globals.lm_announce)
FN_GLOBAL_INTEGER(lp_lm_interval,&Globals.lm_interval)
#ifdef USE_LDAP
FN_GLOBAL_INTEGER(lp_ldap_port,&Globals.ldap_port)
#endif /* USE_LDAP */
FN_LOCAL_STRING(lp_preexec,szPreExec)
FN_LOCAL_STRING(lp_postexec,szPostExec)

View File

@@ -556,7 +556,7 @@ struct smb_passwd *getsmbpwnam(char *name)
{
#ifdef USE_LDAP
return ldap_get_smbpwd_entry(name, 0);
#else
#else /* USE_LDAP */
return get_smbpwd_entry(name, 0);
#endif /* USE_LDAP */
}
@@ -569,7 +569,7 @@ struct smb_passwd *getsmbpwuid(unsigned int uid)
{
#ifdef USE_LDAP
return ldap_get_smbpwd_entry(NULL, uid);
#else
#else /* USE_DLAP */
return get_smbpwd_entry(NULL, uid);
#endif /* USE_LDAP */
}
@@ -1141,7 +1141,6 @@ void *machine_password_lock( char *domain, char *name, BOOL update)
}
chmod(mac_file, 0600);
}
if(!pw_file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK),
60, &mach_passwd_lock_depth))
@@ -1151,6 +1150,8 @@ void *machine_password_lock( char *domain, char *name, BOOL update)
return NULL;
}
}
return (void *)fp;
}

View File

@@ -159,4 +159,7 @@ BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid)
return(True);
}
#else /* USE_LDAP */
/* this keeps fussy compilers happy */
void ldap_helper_dummy(void) {}
#endif

View File

@@ -469,7 +469,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u,
got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0);
unbecome_root(True);
#endif
#endif /* USE_LDAP */
switch (q_u->switch_level)
{
@@ -485,7 +485,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u,
MAX_SAM_ENTRIES,
0,
switch_level);
#endif
#endif /* USE_DLAP */
make_sam_info_1(&info1, ACB_NORMAL,
q_u->start_idx, num_entries, pass);
@@ -504,7 +504,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u,
MAX_SAM_ENTRIES,
0,
switch_level);
#endif
#endif /* USE_LDAP */
make_sam_info_2(&info2, ACB_WSTRUST,
q_u->start_idx, num_entries, pass);
@@ -1046,9 +1046,9 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
info = (void*)&id21;
#ifdef USE_LDAP
status = ldap_get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER;
#else
#else /* USE_LDAP */
status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER;
#endif
#endif /* USE_LDAP */
break;
}

View File

@@ -4340,10 +4340,14 @@ do some standard substitutions in a string
****************************************************************************/
void standard_sub(int cnum,char *str,uint16 vuid)
{
user_struct *vuser = get_valid_user_struct(vuid);
if (VALID_CNUM(cnum)) {
char *p, *s, *home;
struct passwd *pass;
char *username = sesssetup_user;
user_struct *vuser = get_valid_user_struct(vuid);
if(vuser != NULL)
pstrcpy( sesssetup_user, vuser->requested_name);
for ( s=str ; (p=strchr(s, '%')) != NULL ; s=p ) {
switch (*(p+1)) {
@@ -4355,24 +4359,29 @@ void standard_sub(int cnum,char *str,uint16 vuid)
case 'P' : string_sub(p,"%P",Connections[cnum].connectpath); break;
case 'S' : string_sub(p,"%S",lp_servicename(Connections[cnum].service)); break;
case 'g' : string_sub(p,"%g",gidtoname(Connections[cnum].gid)); break;
case 'G' :
{
if ((pass = Get_Pwnam(sesssetup_user,False))!=NULL)
string_sub(p,"%G",gidtoname(pass->pw_gid));
else
p += 2;
break;
}
case 'u' : string_sub(p,"%u",Connections[cnum].user); break;
case 'U' : string_sub(p,"%U", username); break;
/*
* Patch from jkf@soton.ac.uk
* Left the %N (NIS server name) in standard_sub_basic as it
* is a feature for logon servers, hence uses the username.
* The %p (NIS server path) code is here as it is used
* instead of the default "path =" string in [homes] and so
* needs the service name, not the username.
*/
case 'N' : string_sub(p,"%N", automount_server(username)); break;
case 'p' : string_sub(p,"%p",automount_path(lp_servicename(Connections[cnum].service))); break;
case '\0' : p++; break; /* don't run off the end of the string */
default : p+=2; break;
}
}
}
if(vuser != NULL)
pstrcpy( sesssetup_user, vuser->requested_name);
standard_sub_basic(str);
}