From b26c0b68a4fb98f1f18a3d918bf2d48d37bc1dc8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Aug 2019 12:50:42 +0200 Subject: [PATCH 1/2] format-table: add UID/GID output support to format-table.h --- src/shared/format-table.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/format-table.h b/src/shared/format-table.h index aacf978978..80f319d054 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -53,6 +53,12 @@ typedef enum TableDataType { #define TABLE_PID TABLE_INT32 assert_cc(sizeof(pid_t) == sizeof(int32_t)); +/* UIDs/GIDs are just 32bit unsigned integers on Linux */ +#define TABLE_UID TABLE_UINT32 +#define TABLE_GID TABLE_UINT32 +assert_cc(sizeof(uid_t) == sizeof(uint32_t)); +assert_cc(sizeof(gid_t) == sizeof(uint32_t)); + typedef struct Table Table; typedef struct TableCell TableCell; From 805f2df11f6ad72d34aebf694213055b848263c4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 7 Aug 2019 14:50:01 +0200 Subject: [PATCH 2/2] login: port tables over to use TABLE_UID/TABLE_PID --- src/login/inhibit.c | 4 ++-- src/login/loginctl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 72d455e3e4..e2e1e03605 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -114,9 +114,9 @@ static int print_inhibitors(sd_bus *bus) { r = table_add_many(table, TABLE_STRING, who, - TABLE_UINT32, uid, + TABLE_UID, (uid_t) uid, TABLE_STRING, strna(u), - TABLE_UINT32, pid, + TABLE_PID, (pid_t) pid, TABLE_STRING, strna(comm), TABLE_STRING, what, TABLE_STRING, why, diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 33c96dc858..61f619de9c 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -184,7 +184,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) { r = table_add_many(table, TABLE_STRING, id, - TABLE_UINT32, uid, + TABLE_UID, (uid_t) uid, TABLE_STRING, user, TABLE_STRING, seat, TABLE_STRING, strna(tty)); @@ -243,7 +243,7 @@ static int list_users(int argc, char *argv[], void *userdata) { break; r = table_add_many(table, - TABLE_UINT32, uid, + TABLE_UID, (uid_t) uid, TABLE_STRING, user); if (r < 0) return log_error_errno(r, "Failed to add row to table: %m");