diff options
Diffstat (limited to 'source3/smbd/lanman.c')
-rw-r--r-- | source3/smbd/lanman.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 61288e0167..43b5d9e55f 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -109,14 +109,14 @@ static char* Expand(connection_struct *conn, int snum, char* s) /******************************************************************* check a API string for validity when we only need to check the prefix ******************************************************************/ -static BOOL prefix_ok(const char *str, const char *prefix) +static BOOL prefix_ok(char *str,char *prefix) { return(strncmp(str,prefix,strlen(prefix)) == 0); } struct pack_desc { - const char* format; /* formatstring for structure */ - const char* subformat; /* subformat for structure */ + char* format; /* formatstring for structure */ + char* subformat; /* subformat for structure */ char* base; /* baseaddress of buffer */ int buflen; /* remaining size for fixed part; on init: length of base */ int subcount; /* count of substructures */ @@ -125,11 +125,11 @@ struct pack_desc { char* stringbuf; /* pointer into buffer for remaining variable part */ int neededlen; /* total needed size */ int usedlen; /* total used size (usedlen <= neededlen and usedlen <= buflen) */ - const char* curpos; /* current position; pointer into format or subformat */ + char* curpos; /* current position; pointer into format or subformat */ int errcode; }; -static int get_counter(const char** p) +static int get_counter(char** p) { int i, n; if (!p || !(*p)) return(1); @@ -144,7 +144,7 @@ static int get_counter(const char** p) } } -static int getlen(const char* p) +static int getlen(char* p) { int n = 0; if (!p) return(0); @@ -329,7 +329,7 @@ static int package(struct pack_desc* p, ...) #define PACKl(desc,t,v,l) package(desc,v,l) #endif -static void PACKI(struct pack_desc* desc, const char *t,int v) +static void PACKI(struct pack_desc* desc,char *t,int v) { PACK(desc,t,v); } @@ -1704,7 +1704,7 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para char *UserName = skip_string(str2,1); char *p = skip_string(UserName,1); int uLevel = SVAL(p,0); - const char *level_string; + char *p2; int count=0; *rparam_len = 8; @@ -1715,13 +1715,13 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para return False; switch( uLevel ) { case 0: - level_string = "B21"; + p2 = "B21"; break; default: return False; } - if (strcmp(level_string,str2) != 0) + if (strcmp(p2,str2) != 0) return False; *rdata_len = mdrcnt + 1024; @@ -1930,7 +1930,25 @@ static BOOL api_SetUserPassword(connection_struct *conn,uint16 vuid, char *param DATA_BLOB password = data_blob(pass1, strlen(pass1)+1); if (NT_STATUS_IS_OK(check_plaintext_password(user,password,&server_info))) { - if (NT_STATUS_IS_OK(change_oem_password(server_info->sam_account, pass1, pass2))) + /* + * If unix password sync was requested, attempt to change + * the /etc/passwd database first. Return failure if this cannot + * be done. + * + * This occurs before the oem change, becouse we don't want to + * update it if chgpasswd failed. + * + * Conditional on lp_unix_password_sync() becouse we don't want + * to touch the unix db unless we have admin permission. + */ + + if(lp_unix_password_sync() && IS_SAM_UNIX_USER(server_info->sam_account) + && !chgpasswd(pdb_get_username(server_info->sam_account), + pass1,pass2,False)) { + SSVAL(*rparam,0,NERR_badpass); + } + + if (change_oem_password(server_info->sam_account,pass2)) { SSVAL(*rparam,0,NERR_Success); } @@ -2013,7 +2031,7 @@ static BOOL api_SamOEMChangePassword(connection_struct *conn,uint16 vuid, char * (void)map_username(user); - if (NT_STATUS_IS_OK(pass_oem_change(user, (uchar*) data, (uchar *)&data[516], NULL, NULL))) + if (pass_oem_change(user, (uchar*) data, (uchar *)&data[516], NULL, NULL)) { SSVAL(*rparam,0,NERR_Success); } @@ -2584,7 +2602,6 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param char *p = skip_string(UserName,1); int uLevel = SVAL(p,0); char *p2; - const char *level_string; /* get NIS home of a previously validated user - simeon */ /* With share level security vuid will always be zero. @@ -2603,15 +2620,15 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param if (strcmp(str1,"zWrLh") != 0) return False; switch( uLevel ) { - case 0: level_string = "B21"; break; - case 1: level_string = "B21BB16DWzzWz"; break; - case 2: level_string = "B21BB16DWzzWzDzzzzDDDDWb21WWzWW"; break; - case 10: level_string = "B21Bzzz"; break; - case 11: level_string = "B21BzzzWDDzzDDWWzWzDWb21W"; break; + case 0: p2 = "B21"; break; + case 1: p2 = "B21BB16DWzzWz"; break; + case 2: p2 = "B21BB16DWzzWzDzzzzDDDDWb21WWzWW"; break; + case 10: p2 = "B21Bzzz"; break; + case 11: p2 = "B21BzzzWDDzzDDWWzWzDWb21W"; break; default: return False; } - if (strcmp(level_string,str2) != 0) return False; + if (strcmp(p2,str2) != 0) return False; *rdata_len = mdrcnt + 1024; *rdata = REALLOC(*rdata,*rdata_len); @@ -3408,9 +3425,9 @@ static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,cha -static const struct +const static struct { - const char *name; + char *name; int id; BOOL (*fn)(connection_struct *,uint16,char *,char *, int,int,char **,char **,int *,int *); |