summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/libsystemd.sym.m41
-rw-r--r--src/libsystemd/sd-bus/bus-control.c8
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c30
-rw-r--r--src/libsystemd/sd-bus/bus-creds.h1
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c4
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c17
-rw-r--r--src/libsystemd/sd-bus/kdbus.h11
-rw-r--r--src/shared/util.c50
-rw-r--r--src/shared/util.h1
-rw-r--r--src/systemd/sd-bus.h62
-rw-r--r--src/test/test-util.c4
11 files changed, 43 insertions, 146 deletions
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index baa1a6f585..de8bec3098 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -318,7 +318,6 @@ global:
sd_bus_creds_get_uid;
sd_bus_creds_get_gid;
sd_bus_creds_get_pid;
- sd_bus_creds_get_pid_starttime;
sd_bus_creds_get_tid;
sd_bus_creds_get_comm;
sd_bus_creds_get_tid_comm;
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 261cf0d044..813c97f650 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -405,11 +405,6 @@ static int bus_populate_creds_from_items(
c->mask |= SD_BUS_CREDS_TID;
}
- if (mask & SD_BUS_CREDS_PID_STARTTIME && item->pids.starttime > 0) {
- c->pid_starttime = item->pids.starttime;
- c->mask |= SD_BUS_CREDS_PID_STARTTIME;
- }
-
break;
case KDBUS_ITEM_CREDS:
@@ -751,8 +746,7 @@ static int bus_get_name_creds_dbus1(
if ((mask & SD_BUS_CREDS_PID) ||
((mask & SD_BUS_CREDS_AUGMENT) &&
- (mask & (SD_BUS_CREDS_PID_STARTTIME|
- SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
+ (mask & (SD_BUS_CREDS_EUID|SD_BUS_CREDS_SUID|SD_BUS_CREDS_FSUID|
SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID|
SD_BUS_CREDS_COMM|SD_BUS_CREDS_EXE|SD_BUS_CREDS_CMDLINE|
SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_CREDS_OWNER_UID|
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 886e212fbf..9978ddfa38 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -294,18 +294,6 @@ _public_ int sd_bus_creds_get_tid(sd_bus_creds *c, pid_t *tid) {
return 0;
}
-_public_ int sd_bus_creds_get_pid_starttime(sd_bus_creds *c, uint64_t *usec) {
- assert_return(c, -EINVAL);
- assert_return(usec, -EINVAL);
-
- if (!(c->mask & SD_BUS_CREDS_PID_STARTTIME))
- return -ENODATA;
-
- assert(c->pid_starttime > 0);
- *usec = c->pid_starttime;
- return 0;
-}
-
_public_ int sd_bus_creds_get_selinux_context(sd_bus_creds *c, const char **ret) {
assert_return(c, -EINVAL);
@@ -859,19 +847,6 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
}
}
- if (missing & (SD_BUS_CREDS_PID_STARTTIME)) {
- unsigned long long st;
-
- r = get_starttime_of_pid(pid, &st);
- if (r < 0) {
- if (r != -EPERM && r != -EACCES)
- return r;
- } else {
- c->pid_starttime = ((usec_t) st * USEC_PER_SEC) / (usec_t) sysconf(_SC_CLK_TCK);
- c->mask |= SD_BUS_CREDS_PID_STARTTIME;
- }
- }
-
if (missing & SD_BUS_CREDS_SELINUX_CONTEXT) {
const char *p;
@@ -1052,11 +1027,6 @@ int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret)
n->mask |= SD_BUS_CREDS_TID;
}
- if (c->mask & mask & SD_BUS_CREDS_PID_STARTTIME) {
- n->pid_starttime = c->pid_starttime;
- n->mask |= SD_BUS_CREDS_PID_STARTTIME;
- }
-
if (c->mask & mask & SD_BUS_CREDS_COMM) {
n->comm = strdup(c->comm);
if (!n->comm)
diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h
index 5267170ff5..48453e2afd 100644
--- a/src/libsystemd/sd-bus/bus-creds.h
+++ b/src/libsystemd/sd-bus/bus-creds.h
@@ -44,7 +44,6 @@ struct sd_bus_creds {
unsigned n_supplementary_gids;
pid_t pid;
- usec_t pid_starttime;
pid_t tid;
char *comm;
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 722a65448d..9d2aaa8293 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -346,12 +346,10 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
if (c->mask & SD_BUS_CREDS_PID)
fprintf(f, "%sPID=%s"PID_FMT"%s", prefix, color, c->pid, suffix);
- if (c->mask & SD_BUS_CREDS_PID_STARTTIME)
- fprintf(f, "%sPIDStartTime=%s"USEC_FMT"%s", prefix, color, c->pid_starttime, suffix);
if (c->mask & SD_BUS_CREDS_TID)
fprintf(f, "%sTID=%s"PID_FMT"%s", prefix, color, c->tid, suffix);
- if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))))
+ if (terse && ((c->mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID))))
fputs("\n", f);
if (c->mask & SD_BUS_CREDS_UID)
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 98fd4fd3ec..6cb279ea9d 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -553,22 +553,17 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
case KDBUS_ITEM_PIDS:
- /* The PID starttime/TID might be missing,
- * when the data is faked by some data bus
- * proxy and it lacks that information about
- * the real client since SO_PEERCRED is used
- * for that. */
+ /* The PID/TID might be missing, when the data
+ * is faked by some data bus proxy and it
+ * lacks that information about the real
+ * client since SO_PEERCRED is used for
+ * that. */
if (d->pids.pid > 0) {
m->creds.pid = (pid_t) d->pids.pid;
m->creds.mask |= SD_BUS_CREDS_PID & bus->creds_mask;
}
- if (d->pids.starttime > 0) {
- m->creds.pid_starttime = d->pids.starttime / NSEC_PER_USEC;
- m->creds.mask |= SD_BUS_CREDS_PID_STARTTIME & bus->creds_mask;
- }
-
if (d->pids.tid > 0) {
m->creds.tid = (pid_t) d->pids.tid;
m->creds.mask |= SD_BUS_CREDS_TID & bus->creds_mask;
@@ -1421,7 +1416,7 @@ uint64_t attach_flags_to_kdbus(uint64_t mask) {
SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID))
m |= KDBUS_ATTACH_CREDS;
- if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))
+ if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID))
m |= KDBUS_ATTACH_PIDS;
if (mask & SD_BUS_CREDS_COMM)
diff --git a/src/libsystemd/sd-bus/kdbus.h b/src/libsystemd/sd-bus/kdbus.h
index 2bfd0f98e6..e2262de6ba 100644
--- a/src/libsystemd/sd-bus/kdbus.h
+++ b/src/libsystemd/sd-bus/kdbus.h
@@ -84,12 +84,8 @@ struct kdbus_creds {
* struct kdbus_pids - process identifiers
* @pid: Process ID
* @tid: Thread ID
- * @starttime: Starttime of the process
*
- * The PID, TID and starttime of a process. The start tmie is useful to detect
- * PID overruns from the client side. i.e. if you use the PID to look something
- * up in /proc/$PID/ you can afterwards check the starttime field of it, to
- * ensure you didn't run into a PID overrun.
+ * The PID and TID of a process.
*
* Attached to:
* KDBUS_ITEM_PIDS
@@ -97,7 +93,6 @@ struct kdbus_creds {
struct kdbus_pids {
__u64 pid;
__u64 tid;
- __u64 starttime;
};
/**
@@ -773,6 +768,7 @@ enum kdbus_name_list_flags {
* @offset: The returned offset in the caller's pool buffer.
* The user must use KDBUS_CMD_FREE to free the
* allocated memory.
+ * @size: Output buffer to report size of data at @offset.
*
* This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
*/
@@ -780,6 +776,7 @@ struct kdbus_cmd_name_list {
__u64 flags;
__u64 kernel_flags;
__u64 offset;
+ __u64 size;
} __attribute__((aligned(8)));
/**
@@ -806,6 +803,7 @@ struct kdbus_name_list {
* @offset: Returned offset in the caller's pool buffer where the
* kdbus_info struct result is stored. The user must
* use KDBUS_CMD_FREE to free the allocated memory.
+ * @info_size: Output buffer to report size of data at @offset.
* @items: The optional item list, containing the
* well-known name to look up as a KDBUS_ITEM_NAME.
* Only needed in case @id is zero.
@@ -820,6 +818,7 @@ struct kdbus_cmd_info {
__u64 kernel_flags;
__u64 id;
__u64 offset;
+ __u64 info_size;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
diff --git a/src/shared/util.c b/src/shared/util.c
index f01cdd7451..8c1cf52c0a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -618,56 +618,6 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
return 0;
}
-int get_starttime_of_pid(pid_t pid, unsigned long long *st) {
- int r;
- _cleanup_free_ char *line = NULL;
- const char *p;
-
- assert(pid >= 0);
- assert(st);
-
- p = procfs_file_alloca(pid, "stat");
- r = read_one_line_file(p, &line);
- if (r < 0)
- return r;
-
- /* Let's skip the pid and comm fields. The latter is enclosed
- * in () but does not escape any () in its value, so let's
- * skip over it manually */
-
- p = strrchr(line, ')');
- if (!p)
- return -EIO;
-
- p++;
-
- if (sscanf(p, " "
- "%*c " /* state */
- "%*d " /* ppid */
- "%*d " /* pgrp */
- "%*d " /* session */
- "%*d " /* tty_nr */
- "%*d " /* tpgid */
- "%*u " /* flags */
- "%*u " /* minflt */
- "%*u " /* cminflt */
- "%*u " /* majflt */
- "%*u " /* cmajflt */
- "%*u " /* utime */
- "%*u " /* stime */
- "%*d " /* cutime */
- "%*d " /* cstime */
- "%*d " /* priority */
- "%*d " /* nice */
- "%*d " /* num_threads */
- "%*d " /* itrealvalue */
- "%llu " /* starttime */,
- st) != 1)
- return -EIO;
-
- return 0;
-}
-
int fchmod_umask(int fd, mode_t m) {
mode_t u;
int r;
diff --git a/src/shared/util.h b/src/shared/util.h
index 0b7c77b1d4..b6fdf83302 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -263,7 +263,6 @@ const char* split(const char **state, size_t *l, const char *separator, bool quo
for ((state) = (s), (word) = split(&(state), &(length), (separator), (quoted)); (word); (word) = split(&(state), &(length), (separator), (quoted)))
pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
-int get_starttime_of_pid(pid_t pid, unsigned long long *st);
char *strappend(const char *s, const char *suffix);
char *strnappend(const char *s, const char *suffix, size_t length);
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 3636d66fbb..c27537f862 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -55,37 +55,36 @@ typedef struct {
enum {
SD_BUS_CREDS_PID = 1ULL << 0,
- SD_BUS_CREDS_PID_STARTTIME = 1ULL << 1,
- SD_BUS_CREDS_TID = 1ULL << 2,
- SD_BUS_CREDS_UID = 1ULL << 3,
- SD_BUS_CREDS_EUID = 1ULL << 4,
- SD_BUS_CREDS_SUID = 1ULL << 5,
- SD_BUS_CREDS_FSUID = 1ULL << 6,
- SD_BUS_CREDS_GID = 1ULL << 7,
- SD_BUS_CREDS_EGID = 1ULL << 8,
- SD_BUS_CREDS_SGID = 1ULL << 9,
- SD_BUS_CREDS_FSGID = 1ULL << 10,
- SD_BUS_CREDS_SUPPLEMENTARY_GIDS = 1ULL << 11,
- SD_BUS_CREDS_COMM = 1ULL << 12,
- SD_BUS_CREDS_TID_COMM = 1ULL << 13,
- SD_BUS_CREDS_EXE = 1ULL << 14,
- SD_BUS_CREDS_CMDLINE = 1ULL << 15,
- SD_BUS_CREDS_CGROUP = 1ULL << 16,
- SD_BUS_CREDS_UNIT = 1ULL << 17,
- SD_BUS_CREDS_USER_UNIT = 1ULL << 18,
- SD_BUS_CREDS_SLICE = 1ULL << 19,
- SD_BUS_CREDS_SESSION = 1ULL << 20,
- SD_BUS_CREDS_OWNER_UID = 1ULL << 21,
- SD_BUS_CREDS_EFFECTIVE_CAPS = 1ULL << 22,
- SD_BUS_CREDS_PERMITTED_CAPS = 1ULL << 23,
- SD_BUS_CREDS_INHERITABLE_CAPS = 1ULL << 24,
- SD_BUS_CREDS_BOUNDING_CAPS = 1ULL << 25,
- SD_BUS_CREDS_SELINUX_CONTEXT = 1ULL << 26,
- SD_BUS_CREDS_AUDIT_SESSION_ID = 1ULL << 27,
- SD_BUS_CREDS_AUDIT_LOGIN_UID = 1ULL << 28,
- SD_BUS_CREDS_UNIQUE_NAME = 1ULL << 29,
- SD_BUS_CREDS_WELL_KNOWN_NAMES = 1ULL << 30,
- SD_BUS_CREDS_DESCRIPTION = 1ULL << 31,
+ SD_BUS_CREDS_TID = 1ULL << 1,
+ SD_BUS_CREDS_UID = 1ULL << 2,
+ SD_BUS_CREDS_EUID = 1ULL << 3,
+ SD_BUS_CREDS_SUID = 1ULL << 4,
+ SD_BUS_CREDS_FSUID = 1ULL << 5,
+ SD_BUS_CREDS_GID = 1ULL << 6,
+ SD_BUS_CREDS_EGID = 1ULL << 7,
+ SD_BUS_CREDS_SGID = 1ULL << 8,
+ SD_BUS_CREDS_FSGID = 1ULL << 9,
+ SD_BUS_CREDS_SUPPLEMENTARY_GIDS = 1ULL << 10,
+ SD_BUS_CREDS_COMM = 1ULL << 11,
+ SD_BUS_CREDS_TID_COMM = 1ULL << 12,
+ SD_BUS_CREDS_EXE = 1ULL << 13,
+ SD_BUS_CREDS_CMDLINE = 1ULL << 14,
+ SD_BUS_CREDS_CGROUP = 1ULL << 15,
+ SD_BUS_CREDS_UNIT = 1ULL << 16,
+ SD_BUS_CREDS_USER_UNIT = 1ULL << 17,
+ SD_BUS_CREDS_SLICE = 1ULL << 18,
+ SD_BUS_CREDS_SESSION = 1ULL << 19,
+ SD_BUS_CREDS_OWNER_UID = 1ULL << 20,
+ SD_BUS_CREDS_EFFECTIVE_CAPS = 1ULL << 21,
+ SD_BUS_CREDS_PERMITTED_CAPS = 1ULL << 22,
+ SD_BUS_CREDS_INHERITABLE_CAPS = 1ULL << 23,
+ SD_BUS_CREDS_BOUNDING_CAPS = 1ULL << 24,
+ SD_BUS_CREDS_SELINUX_CONTEXT = 1ULL << 25,
+ SD_BUS_CREDS_AUDIT_SESSION_ID = 1ULL << 26,
+ SD_BUS_CREDS_AUDIT_LOGIN_UID = 1ULL << 27,
+ SD_BUS_CREDS_UNIQUE_NAME = 1ULL << 28,
+ SD_BUS_CREDS_WELL_KNOWN_NAMES = 1ULL << 29,
+ SD_BUS_CREDS_DESCRIPTION = 1ULL << 30,
SD_BUS_CREDS_AUGMENT = 1ULL << 63, /* special flag, if on sd-bus will augment creds struct, in a potentially race-full way. */
_SD_BUS_CREDS_ALL = (1ULL << 32) -1,
};
@@ -327,7 +326,6 @@ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c);
uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c);
int sd_bus_creds_get_pid(sd_bus_creds *c, pid_t *pid);
-int sd_bus_creds_get_pid_starttime(sd_bus_creds *c, uint64_t *usec);
int sd_bus_creds_get_tid(sd_bus_creds *c, pid_t *tid);
int sd_bus_creds_get_uid(sd_bus_creds *c, uid_t *uid);
int sd_bus_creds_get_euid(sd_bus_creds *c, uid_t *euid);
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 1602aa6393..20e711d415 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -492,7 +492,6 @@ static void test_get_process_comm(void) {
struct stat st;
_cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL;
_cleanup_free_ char *env = NULL;
- unsigned long long b;
pid_t e;
uid_t u;
gid_t g;
@@ -507,9 +506,6 @@ static void test_get_process_comm(void) {
log_warning("/proc/1/comm does not exist.");
}
- assert_se(get_starttime_of_pid(1, &b) >= 0);
- log_info("pid1 starttime: '%llu'", b);
-
assert_se(get_process_cmdline(1, 0, true, &c) >= 0);
log_info("pid1 cmdline: '%s'", c);