[PATCH 04/13] ipcs: add new permissions printing function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function has silly name which eventually will be fixed, once the
current print_perms() that uses legacy structures is obsoleted.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/ipcs.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 4737f28..8ac7e1c 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -439,6 +439,31 @@ static void print_perms (int id, struct ipc_perm *ipcp)
 	else
 		printf(" %-10u\n", ipcp->gid);
 }
+static void FIXED_print_perms(struct ipc_stat *is)
+{
+	struct passwd *pw;
+	struct group *gr;
+
+	printf("%-10d %-10o", is->id, is->mode & 0777);
+
+	if ((pw = getpwuid(is->cuid)))
+		printf(" %-10s", pw->pw_name);
+	else
+		printf(" %-10u", is->cuid);
+	if ((gr = getgrgid(is->cgid)))
+		printf(" %-10s", gr->gr_name);
+	else
+		printf(" %-10u", is->cgid);
+
+	if ((pw = getpwuid(is->uid)))
+		printf(" %-10s", pw->pw_name);
+	else
+		printf(" %-10u", is->uid);
+	if ((gr = getgrgid(is->gid)))
+		printf(" %-10s\n", gr->gr_name);
+	else
+		printf(" %-10u\n", is->gid);
+}
 
 void do_shm (char format, int use_proc)
 {
-- 
1.7.12.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux