From 577cef82c776759c9f3cad7d33057ac865c40769 Mon Sep 17 00:00:00 2001 From: Björn Baumbach Date: Tue, 9 Jul 2013 12:32:34 +0200 Subject: s3-smbstatus: display [u|g]id of -1 as "-1" in connection list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Jul 10 01:18:30 CEST 2013 on sn-devel-104 --- source3/utils/status.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'source3') 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; -- cgit