diff options
author | Volker Lendecke <vl@samba.org> | 2007-12-19 15:02:59 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2007-12-19 21:09:10 +0100 |
commit | e518e19bc0000019f131354f55e9f5b55f6a2c5e (patch) | |
tree | 5c8723a1510ebb17ff4bd21068aa67159ad3a68d /source3/smbd | |
parent | 042201bcc1b7ffc88cdc22b64c70c653b2433703 (diff) | |
download | samba-e518e19bc0000019f131354f55e9f5b55f6a2c5e.tar.gz samba-e518e19bc0000019f131354f55e9f5b55f6a2c5e.tar.bz2 samba-e518e19bc0000019f131354f55e9f5b55f6a2c5e.zip |
Remove Get_Pwnam and its associated static variable
All callers are replaced by Get_Pwnam_alloc
(This used to be commit 735f59315497113aebadcf9ad387e3dbfffa284a)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/chgpasswd.c | 6 | ||||
-rw-r--r-- | source3/smbd/map_username.c | 2 | ||||
-rw-r--r-- | source3/smbd/password.c | 5 | ||||
-rw-r--r-- | source3/smbd/service.c | 11 |
4 files changed, 18 insertions, 6 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index e478122e9b..fb228f9e2a 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -1142,7 +1142,7 @@ NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passw return NT_STATUS_PASSWORD_RESTRICTION; } - pass = Get_Pwnam(username); + pass = Get_Pwnam_alloc(talloc_tos(), username); if (!pass) { DEBUG(1, ("change_oem_password: Username %s does not exist in system !?!\n", username)); return NT_STATUS_ACCESS_DENIED; @@ -1160,6 +1160,7 @@ NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passw if (samr_reject_reason) { *samr_reject_reason = REJECT_REASON_NOT_COMPLEX; } + TALLOC_FREE(pass); return NT_STATUS_PASSWORD_RESTRICTION; } } @@ -1178,9 +1179,12 @@ NTSTATUS change_oem_password(struct samu *hnd, char *old_passwd, char *new_passw if(lp_unix_password_sync() && !chgpasswd(username, pass, old_passwd, new_passwd, as_root)) { + TALLOC_FREE(pass); return NT_STATUS_ACCESS_DENIED; } + TALLOC_FREE(pass); + if (!pdb_set_plaintext_passwd (hnd, new_passwd)) { return NT_STATUS_ACCESS_DENIED; } diff --git a/source3/smbd/map_username.c b/source3/smbd/map_username.c index bde755eff6..7290f70547 100644 --- a/source3/smbd/map_username.c +++ b/source3/smbd/map_username.c @@ -28,7 +28,7 @@ any incoming or new username - in order to canonicalize the name. This is being done to de-couple the case conversions from the user mapping function. Previously, the map_username was being called - every time Get_Pwnam was called. + every time Get_Pwnam_alloc was called. Returns True if username was changed, false otherwise. ********************************************************************/ diff --git a/source3/smbd/password.c b/source3/smbd/password.c index b3005ba082..6b517c3d86 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -837,9 +837,11 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password, /* check for a normal guest connection */ if (!ok && GUEST_OK(snum)) { + struct passwd *guest_pw; fstring guestname; fstrcpy(guestname,lp_guestaccount()); - if (Get_Pwnam(guestname)) { + guest_pw = Get_Pwnam_alloc(talloc_tos(), guestname); + if (guest_pw != NULL) { fstrcpy(user,guestname); ok = True; DEBUG(3,("authorise_login: ACCEPTED: guest account " @@ -848,6 +850,7 @@ bool authorise_login(int snum, fstring user, DATA_BLOB password, DEBUG(0,("authorise_login: Invalid guest account " "%s??\n",guestname)); } + TALLOC_FREE(guest_pw); *guest = True; } diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 88ab9f0048..ed43528c76 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -357,6 +357,7 @@ void load_registry_shares(void) int find_service(fstring service) { int iService; + TALLOC_CTX *frame = talloc_stackframe(); all_string_sub(service,"\\","/",0); @@ -364,7 +365,7 @@ int find_service(fstring service) /* now handle the special case of a home directory */ if (iService < 0) { - char *phome_dir = get_user_home_dir(service); + char *phome_dir = get_user_home_dir(talloc_tos(), service); if(!phome_dir) { /* @@ -372,7 +373,8 @@ int find_service(fstring service) * be a Windows to unix mapped user name. */ if(map_username(service)) - phome_dir = get_user_home_dir(service); + phome_dir = get_user_home_dir( + talloc_tos(), service); } DEBUG(3,("checking for home directory %s gave %s\n",service, @@ -461,6 +463,8 @@ int find_service(fstring service) if (iService < 0) DEBUG(3,("find_service() failed to find service %s\n", service)); + TALLOC_FREE(frame); + return (iService); } @@ -744,11 +748,12 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, *status = NT_STATUS_WRONG_PASSWORD; return NULL; } - pass = Get_Pwnam(user); + pass = Get_Pwnam_alloc(talloc_tos(), user); status2 = create_token_from_username(conn->mem_ctx, pass->pw_name, True, &conn->uid, &conn->gid, &found_username, &conn->nt_user_token); + TALLOC_FREE(pass); if (!NT_STATUS_IS_OK(status2)) { conn_free(conn); *status = status2; |