X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fjournald-server.c;h=ef6189e22d68de36b2c7834808e8d1840135170b;hp=53e38301108b140bc286e342c195eab3a97e0837;hb=e8e581bf256b8c0fbd430935af79fa0e8ee570a1;hpb=7120511888321c40810a36c8da96c7d09e464f5b diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 53e383011..ef6189e22 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -420,36 +420,6 @@ void server_vacuum(Server *s) { s->cached_available_space_timestamp = 0; } -static char *shortened_cgroup_path(pid_t pid) { - int r; - char _cleanup_free_ *process_path = NULL, *init_path = NULL; - char *path; - - assert(pid > 0); - - r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, pid, &process_path); - if (r < 0) - return NULL; - - r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &init_path); - if (r < 0) - return NULL; - - if (endswith(init_path, "/system")) - init_path[strlen(init_path) - 7] = 0; - else if (streq(init_path, "/")) - init_path[0] = 0; - - if (startswith(process_path, init_path)) { - path = strdup(process_path + strlen(init_path)); - } else { - path = process_path; - process_path = NULL; - } - - return path; -} - bool shall_try_append_again(JournalFile *f, int r) { /* -E2BIG Hit configured limit @@ -538,7 +508,7 @@ static void dispatch_message_real( char pid[sizeof("_PID=") + DECIMAL_STR_MAX(ucred->pid)], uid[sizeof("_UID=") + DECIMAL_STR_MAX(ucred->uid)], gid[sizeof("_GID=") + DECIMAL_STR_MAX(ucred->gid)], - source_time[sizeof("_SOURCE_REALTIME_TIMESTAMP=" + DECIMAL_STR_MAX(usec_t))], + source_time[sizeof("_SOURCE_REALTIME_TIMESTAMP=") + DECIMAL_STR_MAX(usec_t)], boot_id[sizeof("_BOOT_ID=") + 32] = "_BOOT_ID=", machine_id[sizeof("_MACHINE_ID=") + 32] = "_MACHINE_ID="; @@ -620,8 +590,8 @@ static void dispatch_message_real( IOVEC_SET_STRING(iovec[n++], audit_loginuid); #endif - t = shortened_cgroup_path(ucred->pid); - if (t) { + r = cg_pid_get_path(NULL, ucred->pid, &t); + if (r >= 0) { cgroup = strappend("_SYSTEMD_CGROUP=", t); free(t); @@ -630,7 +600,8 @@ static void dispatch_message_real( } #ifdef HAVE_LOGIND - if (sd_pid_get_session(ucred->pid, &t) >= 0) { + r = cg_pid_get_session(ucred->pid, &t); + if (r >= 0) { session = strappend("_SYSTEMD_SESSION=", t); free(t); @@ -699,7 +670,7 @@ static void dispatch_message_real( r = sd_id128_get_machine(&id); if (r >= 0) { - sd_id128_to_string(id, machine_id + sizeof("_MACHINE_ID") - 1); + sd_id128_to_string(id, machine_id + sizeof("_MACHINE_ID=") - 1); IOVEC_SET_STRING(iovec[n++], machine_id); } @@ -773,7 +744,7 @@ void server_dispatch_message( const char *unit_id, int priority) { - int rl; + int rl, r; char _cleanup_free_ *path = NULL; char *c; @@ -789,8 +760,8 @@ void server_dispatch_message( if (!ucred) goto finish; - path = shortened_cgroup_path(ucred->pid); - if (!path) + r = cg_pid_get_path_shifted(ucred->pid, NULL, &path); + if (r < 0) goto finish; /* example: /user/lennart/3/foobar @@ -1338,7 +1309,7 @@ static int server_parse_config_file(Server *s) { return -errno; } - r = config_parse(fn, f, "Journal\0", config_item_perf_lookup, + r = config_parse(NULL, fn, f, "Journal\0", config_item_perf_lookup, (void*) journald_gperf_lookup, false, s); if (r < 0) log_warning("Failed to parse configuration file: %s", strerror(-r));