diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/ipc.c | 32 | ||||
-rw-r--r-- | source3/smbd/password.c | 55 |
2 files changed, 77 insertions, 10 deletions
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 3a2df56b3e..9a80a8d062 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -1947,6 +1947,7 @@ There is no auxiliary data in the response. #define AF_OP_SERVER 2 #define AF_OP_ACCOUNTS 3 + static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, int mdrcnt,int mprcnt, char **rdata,char **rparam, @@ -1959,10 +1960,17 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, int uLevel = SVAL(p,0); char *p2; - *rparam_len = 6; - *rparam = REALLOC(*rparam,*rparam_len); + /* 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 - /* check it's a supported varient */ + *rparam_len = 6; + *rparam = REALLOC(*rparam,*rparam_len); + + /* check it's a supported variant */ if (strcmp(str1,"zWrLh") != 0) return False; switch( uLevel ) { @@ -2005,12 +2013,10 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, /* EEK! the cifsrap.txt doesn't have this in!!!! */ SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */ -#if 0 - strcpy(p2,"FullName"); -#endif - strcpy(p2,UserName); /* suggest copying the user name, for now... */ + strcpy(p2,vuser->real_name); /* simeon */ p2 = skip_string(p2,1); } + if (uLevel == 11) /* modelled after NTAS 3.51 reply */ { SSVAL(p,usri11_priv,Connections[cnum].admin_user?USER_PRIV_ADMIN:USER_PRIV_USER); @@ -2023,7 +2029,11 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, } else { +#if (defined(NETGROUP) && defined(AUTOMOUNT)) + strcpy(p2, vuser->home_share); +#else strcpy(p2,"\\\\%L\\%U"); +#endif } standard_sub_basic(p2); p2 = skip_string(p2,1); @@ -2067,7 +2077,11 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, } else { +#if (defined(NETGROUP) && defined(AUTOMOUNT)) + strcpy(p2, vuser->home_share); +#else strcpy(p2,"\\\\%L\\%U"); +#endif } standard_sub_basic(p2); p2 = skip_string(p2,1); @@ -2079,7 +2093,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data, { SIVAL(p,60,0); /* auth_flags */ SIVAL(p,64,PTR_DIFF(p2,*rdata)); /* full_name */ - strcpy(p2,"<Full Name>"); + strcpy(p2,vuser->real_name); /* simeon */ p2 = skip_string(p2,1); SIVAL(p,68,0); /* urs_comment */ SIVAL(p,72,PTR_DIFF(p2,*rdata)); /* parms */ @@ -3066,5 +3080,3 @@ int reply_trans(char *inbuf,char *outbuf) return(outsize); } - - diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 3ccc1e4cfd..2c24913c86 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -21,6 +21,10 @@ #include "includes.h" +#if (defined(NETGROUP) && defined (AUTOMOUNT)) +#include "rpcsvc/ypclnt.h" +#endif + extern int DEBUGLEVEL; extern int Protocol; @@ -138,6 +142,17 @@ 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 */ + int real_name_len; + int i; for(i = 0; i < num_validated_users; i++) { vuser = &validated_users[i]; @@ -177,6 +192,46 @@ 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\\HOMES"); + + if (nis_error = yp_get_default_domain(&nis_domain)) + 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)) + 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 + + vuser->real_name = NULL; + DEBUG(3, ("Clearing default real name\n")); + vuser->real_name = Realloc(vuser->real_name, 15); + strcpy(vuser->real_name, "<Full Name>\0"); + if (lp_unix_realname()) { + pwfile=getpwnam(vuser->name); + DEBUG(3, ("User name: %s\tReal name: %s\n",vuser->name,pwfile->pw_gecos)); + real_name_len = strcspn(pwfile->pw_gecos, ","); + DEBUG(3, ("Real name length: %d\n", real_name_len)); + vuser->real_name = (char *)Realloc(vuser->real_name, real_name_len+1); + strncpy(vuser->real_name, pwfile->pw_gecos, real_name_len); + vuser->real_name[real_name_len]='\0'; + } + return (uint16)((num_validated_users - 1) + VUID_OFFSET); } |