diff options
author | Andrew Bartlett <abartlet@samba.org> | 2002-08-17 04:51:27 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2002-08-17 04:51:27 +0000 |
commit | a27ec4a0118e4443e76f706b715c95c17ce60595 (patch) | |
tree | 6988ee3b47c021dc7c0e25e7ee1a810460a445b7 /source3/passdb/pdb_unix.c | |
parent | f56e06476fed5dda04ce12734aeb6efc9bf2d0a4 (diff) | |
download | samba-a27ec4a0118e4443e76f706b715c95c17ce60595.tar.gz samba-a27ec4a0118e4443e76f706b715c95c17ce60595.tar.bz2 samba-a27ec4a0118e4443e76f706b715c95c17ce60595.zip |
Rework the 'guest account get's RID 501' code again...
This moves it right into the passdb subsystem, where we can do this in
just one (or 2) places. Due to the fact that this code can be in a tight loop,
I've had to make 'guest account' a 'const' paramater, where % macros cannot be
used. In any case, if the 'guest account' varies, we are in for some nasty
cases in the other code, so it's useful anyway.
Andrew Bartlett
(This used to be commit 8718e5e7b2651edad15f52a4262dc745df7ad70f)
Diffstat (limited to 'source3/passdb/pdb_unix.c')
-rw-r--r-- | source3/passdb/pdb_unix.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source3/passdb/pdb_unix.c b/source3/passdb/pdb_unix.c index 88334f2b70..06f12164eb 100644 --- a/source3/passdb/pdb_unix.c +++ b/source3/passdb/pdb_unix.c @@ -49,19 +49,32 @@ static BOOL unixsam_getsampwrid (struct pdb_methods *methods, { struct passwd *pass; BOOL ret = False; + const char *guest_account = lp_guestaccount(); + if (!(guest_account && *guest_account)) { + DEBUG(1, ("NULL guest account!?!?\n")); + return False; + } + if (!methods) { DEBUG(0,("invalid methods\n")); return False; } - - if (pdb_rid_is_user(rid)) { - pass = getpwuid_alloc(fallback_pdb_user_rid_to_uid (rid)); - - if (pass) { - ret = NT_STATUS_IS_OK(pdb_fill_sam_pw(user, pass)); - passwd_free(&pass); + + if (rid == DOMAIN_USER_RID_GUEST) { + pass = getpwnam_alloc(guest_account); + if (!pass) { + DEBUG(1, ("guest account %s does not seem to exist...\n", guest_account)); + return False; } + } else if (pdb_rid_is_user(rid)) { + pass = getpwuid_alloc(fallback_pdb_user_rid_to_uid (rid)); + } else { + return False; } + + ret = NT_STATUS_IS_OK(pdb_fill_sam_pw(user, pass)); + passwd_free(&pass); + return ret; } |