1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

Merge pull request #14080 from poettering/table-uid-pid

format-table: introduce TABLE_UID/TABLE_GID to match TABLE_PID and use it
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-11-19 15:35:25 +01:00 committed by GitHub
commit c336dc29ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -114,9 +114,9 @@ static int print_inhibitors(sd_bus *bus) {
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, who, TABLE_STRING, who,
TABLE_UINT32, uid, TABLE_UID, (uid_t) uid,
TABLE_STRING, strna(u), TABLE_STRING, strna(u),
TABLE_UINT32, pid, TABLE_PID, (pid_t) pid,
TABLE_STRING, strna(comm), TABLE_STRING, strna(comm),
TABLE_STRING, what, TABLE_STRING, what,
TABLE_STRING, why, TABLE_STRING, why,

View File

@ -184,7 +184,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, id, TABLE_STRING, id,
TABLE_UINT32, uid, TABLE_UID, (uid_t) uid,
TABLE_STRING, user, TABLE_STRING, user,
TABLE_STRING, seat, TABLE_STRING, seat,
TABLE_STRING, strna(tty)); TABLE_STRING, strna(tty));
@ -243,7 +243,7 @@ static int list_users(int argc, char *argv[], void *userdata) {
break; break;
r = table_add_many(table, r = table_add_many(table,
TABLE_UINT32, uid, TABLE_UID, (uid_t) uid,
TABLE_STRING, user); TABLE_STRING, user);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to add row to table: %m"); return log_error_errno(r, "Failed to add row to table: %m");

View File

@ -53,6 +53,12 @@ typedef enum TableDataType {
#define TABLE_PID TABLE_INT32 #define TABLE_PID TABLE_INT32
assert_cc(sizeof(pid_t) == sizeof(int32_t)); 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 Table Table;
typedef struct TableCell TableCell; typedef struct TableCell TableCell;