REG_set(ID_FGROUP, str, fgroup)
REG_set(ID_FUID, u_int, fuid)
REG_set(ID_FUSER, str, fuser)
+REG_set(ID_LOGIN, s_int, luid)
REG_set(ID_PGRP, s_int, pgrp)
REG_set(ID_PID, s_int, tid)
REG_set(ID_PPID, s_int, ppid)
#define f_either PROC_SPARE_1 // either status or stat (favor stat)
#define f_grp PROC_FILLGRP
+#define f_login PROC_FILL_LUID
#define f_lxc PROC_FILL_LXC
#define f_ns PROC_FILLNS
#define f_oom PROC_FILLOOM
{ RS(ID_FGROUP), x_ogroup, NULL, QS(str), 0, TS(str) },
{ RS(ID_FUID), f_status, NULL, QS(u_int), 0, TS(u_int) },
{ RS(ID_FUSER), x_ouser, NULL, QS(str), 0, TS(str) }, // freefunc NULL w/ cached string
+ { RS(ID_LOGIN), f_login, NULL, QS(s_int), 0, TS(s_int) },
{ RS(ID_PGRP), f_stat, NULL, QS(s_int), 0, TS(s_int) },
{ RS(ID_PID), 0, NULL, QS(s_int), 0, TS(s_int) }, // oldflags: free w/ simple_nextpid
{ RS(ID_PPID), f_either, NULL, QS(s_int), 0, TS(s_int) },
}
return lxc_none;
}
+
+
+ // Provide the user id at login (or -1 if not available)
+static int login_uid (const char *path) {
+ char buf[PROCPATHLEN];
+ int fd, id, in;
+
+ id = -1;
+ snprintf(buf, sizeof(buf), "%s/loginuid", path);
+ if ((fd = open(buf, O_RDONLY, 0)) != -1) {
+ in = read(fd, buf, sizeof(buf) - 1);
+ close(fd);
+ if (in > 0) {
+ buf[in] = '\0';
+ id = atoi(buf);
+ }
+ }
+ return id;
+}
///////////////////////////////////////////////////////////////////////
if (flags & PROC_FILL_LXC) // value the lxc name
p->lxcname = lxc_containers(path);
+ if (flags & PROC_FILL_LUID) // value the login user id
+ p->luid = login_uid(path);
+
if (rc == 0) return p;
errno = ENOMEM;
next_proc:
if (flags & PROC_FILL_LXC)
t->lxcname = lxc_containers(path);
+ if (flags & PROC_FILL_LUID)
+ t->luid = login_uid(path);
+
if (rc == 0) return t;
errno = ENOMEM;
next_task:
*sd_uunit; // n/a systemd user unit id
char
*lxcname; // n/a lxc container name
+ int
+ luid; // loginuid user id at login
} proc_t;
// PROCTAB: data structure holding the persistent information readproc needs
#define PROC_FILLNS 0x8000 // fill in proc_t namespace information
#define PROC_FILLSYSTEMD 0x80000 // fill in proc_t systemd information
#define PROC_FILL_LXC 0x800000 // fill in proc_t lxcname, if possible
+#define PROC_FILL_LUID 0x400000 // fill in proc_t luid (login user id)
#define PROC_LOOSE_TASKS 0x2000 // treat threads as if they were processes