diff options
author | Björn Baumbach <bb@sernet.de> | 2013-07-09 12:32:34 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-07-10 01:18:30 +0200 |
commit | 577cef82c776759c9f3cad7d33057ac865c40769 (patch) | |
tree | d6ff41abd0c693a24a98f5fdb7743bd0f4b5a85a /source3 | |
parent | c52e61f7ba215da28cbb7b8e328aea110ad79b11 (diff) | |
download | samba-577cef82c776759c9f3cad7d33057ac865c40769.tar.gz samba-577cef82c776759c9f3cad7d33057ac865c40769.tar.xz samba-577cef82c776759c9f3cad7d33057ac865c40769.zip |
s3-smbstatus: display [u|g]id of -1 as "-1" in connection list
In order to avoid displayed uid or gid of "4294967295" instead of "-1", we
need to fetch the special case -1.
The id can be -1 if we are reading e.g. incomplete session information.
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul 10 01:18:30 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/status.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/source3/utils/status.c b/source3/utils/status.c index f4b5f4e2c3..be7c52fac4 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -283,13 +283,29 @@ static int traverse_sessionid(const char *key, struct sessionid *session, Ucrit_addPid(session->pid); - fstr_sprintf(uid_str, "%u", (unsigned int)session->uid); - fstr_sprintf(gid_str, "%u", (unsigned int)session->gid); + fstrcpy(uid_str, "-1"); + + if (session->uid != -1) { + if (numeric_only) { + fstr_sprintf(uid_str, "%u", (unsigned int)session->uid); + } else { + fstrcpy(uid_str, uidtoname(session->uid)); + } + } + + fstrcpy(gid_str, "-1"); + + if (session->gid != -1) { + if (numeric_only) { + fstr_sprintf(gid_str, "%u", (unsigned int)session->gid); + } else { + fstrcpy(gid_str, gidtoname(session->gid)); + } + } d_printf("%-7s %-12s %-12s %-12s (%s)\n", procid_str_static(&session->pid), - numeric_only ? uid_str : uidtoname(session->uid), - numeric_only ? gid_str : gidtoname(session->gid), + uid_str, gid_str, session->remote_machine, session->hostname); return 0; |