summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/lib/util.c54
-rw-r--r--source3/param/loadparm.c11
-rw-r--r--source3/pipenetlog.c19
-rw-r--r--source3/smbd/ipc.c31
-rw-r--r--source3/smbd/password.c35
6 files changed, 75 insertions, 78 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 024917a0d8..e12ea4002d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -155,6 +155,8 @@ char *lp_username_map(void);
char *lp_character_set(void);
char *lp_logon_script(void);
char *lp_logon_path(void);
+char *lp_logon_drive(void);
+char *lp_logon_home(void);
char *lp_remote_announce(void);
char *lp_wins_server(void);
char *lp_interfaces(void);
@@ -1088,6 +1090,7 @@ BOOL zero_ip(struct in_addr ip);
void reset_globals_after_fork();
char *client_name(void);
char *client_addr(void);
+char *automount_server(char *username);
void standard_sub_basic(char *str);
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
int PutUniCode(char *dst,char *src);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 5c243204d0..9295d9ae73 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -21,6 +21,10 @@
#include "includes.h"
+#if (defined(NETGROUP) && defined (AUTOMOUNT))
+#include "rpcsvc/ypclnt.h"
+#endif
+
pstring scope = "";
int DEBUGLEVEL = 1;
@@ -3602,6 +3606,55 @@ char *client_addr(void)
return addr_buf;
}
+char *automount_server(char *user_name)
+{
+ static pstring server_name;
+
+#if (defined(NETGROUP) && defined (AUTOMOUNT))
+ int nis_error; /* returned by yp all functions */
+ char *nis_result; /* yp_match inits this */
+ int nis_result_len; /* and set this */
+ char *nis_domain; /* yp_get_default_domain inits this */
+ char *nis_map = (char *)lp_nis_home_map_name();
+ int home_server_len;
+
+ /* set to default of no string */
+ server_name[0] = 0;
+
+ if ((nis_error = yp_get_default_domain(&nis_domain)) != 0)
+ {
+ DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
+ }
+
+ DEBUG(5, ("NIS Domain: %s\n", nis_domain));
+
+ if ((nis_error = yp_match(nis_domain, nis_map,
+ user_name, strlen(user_name),
+ &nis_result, &nis_result_len)) != 0)
+ {
+ DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
+ }
+
+ if (!nis_error && lp_nis_home_map())
+ {
+ home_server_len = strcspn(nis_result,":");
+ DEBUG(5, ("NIS lookup succeeded. Home server length: %d\n",home_server_len));
+ if (home_server_len > sizeof(pstring))
+ {
+ home_server_len = sizeof(pstring);
+ }
+ strncpy(server_name, nis_result, home_server_len);
+ }
+#else
+ /* use the local machine name instead of the auto-map server */
+ pstrcpy(server_name, local_machine);
+#endif
+
+ DEBUG(4,("Home server: %s\n", server_name));
+
+ return server_name;
+}
+
/*******************************************************************
sub strings with useful parameters
Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and
@@ -3630,6 +3683,7 @@ void standard_sub_basic(char *str)
}
break;
}
+ case 'N' : string_sub(p,"%N", automount_server(username)); break;
case 'I' : string_sub(p,"%I", client_addr()); break;
case 'L' : string_sub(p,"%L", local_machine); break;
case 'M' : string_sub(p,"%M", client_name()); break;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 9f47f14be5..9a26819397 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -132,6 +132,8 @@ typedef struct
char *szCharacterSet;
char *szLogonScript;
char *szLogonPath;
+ char *szLogonDrive;
+ char *szLogonHome;
char *szSmbrun;
char *szWINSserver;
char *szInterfaces;
@@ -445,6 +447,8 @@ struct parm_struct
{"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set},
{"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL},
{"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL},
+ {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL},
+ {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL},
{"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL},
{"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL},
{"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL},
@@ -620,6 +624,11 @@ static void init_globals(void)
string_set(&Globals.szServerString,s);
sprintf(s,"%d.%d", DEFAULT_MAJOR_VERSION, DEFAULT_MINOR_VERSION);
string_set(&Globals.szAnnounceVersion,s);
+
+ string_set(&Globals.szLogonDrive, "");
+ /* %N is the NIS auto.home server if -DAUTOHOME is used, else same as %L */
+ string_set(&Globals.szLogonHome, "\\\\%N\\%U");
+ string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
Globals.bLoadPrinters = True;
Globals.bUseRhosts = False;
Globals.max_packet = 65535;
@@ -838,6 +847,8 @@ FN_GLOBAL_STRING(lp_username_map,&Globals.szUsernameMap)
FN_GLOBAL_STRING(lp_character_set,&Globals.szCharacterSet)
FN_GLOBAL_STRING(lp_logon_script,&Globals.szLogonScript)
FN_GLOBAL_STRING(lp_logon_path,&Globals.szLogonPath)
+FN_GLOBAL_STRING(lp_logon_drive,&Globals.szLogonDrive)
+FN_GLOBAL_STRING(lp_logon_home,&Globals.szLogonHome)
FN_GLOBAL_STRING(lp_remote_announce,&Globals.szRemoteAnnounce)
FN_GLOBAL_STRING(lp_wins_server,&Globals.szWINSserver)
FN_GLOBAL_STRING(lp_interfaces,&Globals.szInterfaces)
diff --git a/source3/pipenetlog.c b/source3/pipenetlog.c
index 0dac804834..d407e00661 100644
--- a/source3/pipenetlog.c
+++ b/source3/pipenetlog.c
@@ -524,20 +524,14 @@ static void api_lsa_sam_logon( user_struct *vuser,
pstrcpy(dom_sid , lp_domainsid ());
pstrcpy(my_workgroup, lp_workgroup ());
- pstrcpy(my_name , myname );
- strupper(my_name);
-
- pstrcpy(home_drive , "a:" );
-
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
- pstrcpy(home_dir , vuser->home_share);
-#else
- pstrcpy(home_dir , "\\\\%L\\%U");
-#endif
- standard_sub_basic(home_dir);
+ pstrcpy(home_drive , lp_logon_drive ());
+ pstrcpy(home_dir , lp_logon_home ());
sam_logon_in_ssb = False;
+ pstrcpy(my_name , myname );
+ strupper(my_name);
+
make_lsa_user_info(&usr_info,
&dummy_time, /* logon_time */
@@ -603,9 +597,6 @@ BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data,
if ((vuser = get_valid_user_struct(uid)) == NULL) return False;
DEBUG(3,("Username of UID %d is %s\n", vuser->uid, vuser->name));
-#if defined(NETGROUP) && defined(AUTOMOUNT)
- DEBUG(3,("HOMESHR for %s is %s\n", vuser->name, vuser->home_share));
-#endif
switch (opnum)
{
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 142f139d26..466781c58c 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -1999,9 +1999,6 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
/* get NIS home of a previously validated user - simeon */
user_struct *vuser = get_valid_user_struct(vuid);
DEBUG(3,(" Username of UID %d is %s\n", vuser->uid, vuser->name));
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
- DEBUG(3,(" HOMESHR for %s is %s\n", vuser->name, vuser->home_share));
-#endif
*rparam_len = 6;
*rparam = REALLOC(*rparam,*rparam_len);
@@ -2059,19 +2056,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
SIVAL(p,usri11_auth_flags,AF_OP_PRINT); /* auth flags */
SIVALS(p,usri11_password_age,0xffffffff); /* password age */
SIVAL(p,usri11_homedir,PTR_DIFF(p2,p)); /* home dir */
- if (*lp_logon_path())
- {
- strcpy(p2,lp_logon_path());
- }
- else
- {
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
- strcpy(p2, vuser->home_share);
-#else
- strcpy(p2,"\\\\%L\\%U");
-#endif
- }
- standard_sub_basic(p2);
+ strcpy(p2, lp_logon_path());
p2 = skip_string(p2,1);
SIVAL(p,usri11_parms,PTR_DIFF(p2,p)); /* parms */
strcpy(p2,"");
@@ -2107,19 +2092,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
SSVAL(p,42,
Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER);
SIVAL(p,44,PTR_DIFF(p2,*rdata)); /* home dir */
- if (*lp_logon_path())
- {
- strcpy(p2,lp_logon_path());
- }
- else
- {
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
- strcpy(p2, vuser->home_share);
-#else
- strcpy(p2,"\\\\%L\\%U");
-#endif
- }
- standard_sub_basic(p2);
+ strcpy(p2,lp_logon_path());
p2 = skip_string(p2,1);
SIVAL(p,48,PTR_DIFF(p2,*rdata)); /* comment */
*p2++ = 0;
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 2da8a8f936..311ef47679 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -155,15 +155,6 @@ tell random client vuid's (normally zero) from valid vuids.
uint16 register_vuid(int uid,int gid, char *name,BOOL guest)
{
user_struct *vuser;
-
-#if (defined(NETGROUP) && defined (AUTOMOUNT))
- int nis_error; /* returned by yp all functions */
- char *nis_result; /* yp_match inits this */
- int nis_result_len; /* and set this */
- char *nis_domain; /* yp_get_default_domain inits this */
- char *nis_map = (char *)lp_nis_home_map_name();
- int home_server_len;
-#endif
struct passwd *pwfile; /* for getting real name from passwd file */
#if 0
@@ -224,32 +215,6 @@ uint16 register_vuid(int uid,int gid, char *name,BOOL guest)
DEBUG(3,("uid %d registered to name %s\n",uid,name));
-#if (defined(NETGROUP) && defined (AUTOMOUNT))
- vuser->home_share = NULL;
- DEBUG(3, ("Setting default HOMESHR to: \\\\logon server\\HOMES\n"));
- vuser->home_share = Realloc(vuser->home_share, 32);
- strcpy(vuser->home_share,"\\\\%L\\%U");
-
- if ((nis_error = yp_get_default_domain(&nis_domain)) != 0)
- DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
- DEBUG(3, ("NIS Domain: %s\n", nis_domain));
-
- if ((nis_error = yp_match(nis_domain, nis_map, vuser->name, strlen(vuser->name),
- &nis_result, &nis_result_len)) != 0)
- DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
- if (!nis_error && lp_nis_home_map()) {
- home_server_len = strcspn(nis_result,":");
- DEBUG(3, ("NIS lookup succeeded\n\tHome server length: %d\n",home_server_len));
- vuser->home_share = (char *)Realloc(vuser->home_share, home_server_len+12);
- DEBUG(3, ("\tAllocated %d bytes for HOMESHR\n",home_server_len+12 ));
- strcpy(vuser->home_share,"\\\\");
- strncat(vuser->home_share, nis_result, home_server_len);
- strcat(vuser->home_share,"\\homes");
- DEBUG(2,("\tUser = %s\n\tUID = %d\n\tNIS result = %s\n\tHOMESHR = %s\n",
- vuser->name, vuser->uid, nis_result, vuser->home_share));
- }
-#endif
-
DEBUG(3, ("Clearing default real name\n"));
fstrcpy(vuser->real_name, "<Full Name>\0");
if (lp_unix_realname()) {