summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-05-06 18:14:02 +0000
committerJeremy Allison <jra@samba.org>1998-05-06 18:14:02 +0000
commitb54509045d7186fc0526d91bcf429659cba8be1d (patch)
treeaaf529823ffb62ad2b350c156885ab849b38db9a
parent2b4d426726cad43db6ef2889c83d898b52a2018f (diff)
downloadsamba-b54509045d7186fc0526d91bcf429659cba8be1d.tar.gz
samba-b54509045d7186fc0526d91bcf429659cba8be1d.tar.bz2
samba-b54509045d7186fc0526d91bcf429659cba8be1d.zip
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 used to be commit 446b98ca071170fc950bad86ad96b58308a5b75c)
-rw-r--r--source3/lib/util.c16
-rw-r--r--source3/param/loadparm.c12
-rw-r--r--source3/passdb/smbpass.c17
-rw-r--r--source3/rpc_server/srv_ldap_helpers.c3
-rw-r--r--source3/rpc_server/srv_samr.c10
-rw-r--r--source3/smbd/server.c23
6 files changed, 43 insertions, 38 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index a081cf0368..f5cfb974a2 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -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' :
{
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 7483af54a4..9ae845486a 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -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)
diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c
index cb3a4a9a99..2fc0c3fb89 100644
--- a/source3/passdb/smbpass.c
+++ b/source3/passdb/smbpass.c
@@ -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,14 +1141,15 @@ 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),
+ if(!pw_file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK),
60, &mach_passwd_lock_depth))
- {
- DEBUG(0,("machine_password_lock: cannot lock file %s\n", mac_file));
- fclose(fp);
- return NULL;
+ {
+ DEBUG(0,("machine_password_lock: cannot lock file %s\n", mac_file));
+ fclose(fp);
+ return NULL;
+ }
+
}
return (void *)fp;
diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c
index d1c091c6c9..945c06ad27 100644
--- a/source3/rpc_server/srv_ldap_helpers.c
+++ b/source3/rpc_server/srv_ldap_helpers.c
@@ -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
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index aa240ad3c6..353da9bd29 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -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;
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 29ee8c9fc5..6f5527714d 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -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);
}