Compare commits
No commits in common. "a434236accc8bf072f919bb4c6e85b0dbc36e71f" and "403e4b47286548bfd4102159bfc0dcf2f306bc1b" have entirely different histories.
a434236acc
...
403e4b4728
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
#include "env-util.h"
|
|
||||||
#include "escape.h"
|
#include "escape.h"
|
||||||
|
#include "env-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
|
@ -34,7 +34,6 @@
|
||||||
#include "missing_sched.h"
|
#include "missing_sched.h"
|
||||||
#include "missing_syscall.h"
|
#include "missing_syscall.h"
|
||||||
#include "namespace-util.h"
|
#include "namespace-util.h"
|
||||||
#include "path-util.h"
|
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "raw-clone.h"
|
#include "raw-clone.h"
|
||||||
#include "rlimit-util.h"
|
#include "rlimit-util.h"
|
||||||
|
@ -52,17 +51,13 @@
|
||||||
#define COMM_MAX_LEN 128
|
#define COMM_MAX_LEN 128
|
||||||
|
|
||||||
static int get_process_state(pid_t pid) {
|
static int get_process_state(pid_t pid) {
|
||||||
_cleanup_free_ char *line = NULL;
|
|
||||||
const char *p;
|
const char *p;
|
||||||
char state;
|
char state;
|
||||||
int r;
|
int r;
|
||||||
|
_cleanup_free_ char *line = NULL;
|
||||||
|
|
||||||
assert(pid >= 0);
|
assert(pid >= 0);
|
||||||
|
|
||||||
/* Shortcut: if we are enquired about our own state, we are obviously running */
|
|
||||||
if (pid == 0 || pid == getpid_cached())
|
|
||||||
return (unsigned char) 'R';
|
|
||||||
|
|
||||||
p = procfs_file_alloca(pid, "stat");
|
p = procfs_file_alloca(pid, "stat");
|
||||||
|
|
||||||
r = read_one_line_file(p, &line);
|
r = read_one_line_file(p, &line);
|
||||||
|
@ -85,35 +80,24 @@ static int get_process_state(pid_t pid) {
|
||||||
|
|
||||||
int get_process_comm(pid_t pid, char **ret) {
|
int get_process_comm(pid_t pid, char **ret) {
|
||||||
_cleanup_free_ char *escaped = NULL, *comm = NULL;
|
_cleanup_free_ char *escaped = NULL, *comm = NULL;
|
||||||
|
const char *p;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
assert(pid >= 0);
|
assert(pid >= 0);
|
||||||
|
|
||||||
if (pid == 0 || pid == getpid_cached()) {
|
|
||||||
comm = new0(char, TASK_COMM_LEN + 1); /* Must fit in 16 byte according to prctl(2) */
|
|
||||||
if (!comm)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (prctl(PR_GET_NAME, comm) < 0)
|
|
||||||
return -errno;
|
|
||||||
} else {
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
p = procfs_file_alloca(pid, "comm");
|
|
||||||
|
|
||||||
/* Note that process names of kernel threads can be much longer than TASK_COMM_LEN */
|
|
||||||
r = read_one_line_file(p, &comm);
|
|
||||||
if (r == -ENOENT)
|
|
||||||
return -ESRCH;
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
escaped = new(char, COMM_MAX_LEN);
|
escaped = new(char, COMM_MAX_LEN);
|
||||||
if (!escaped)
|
if (!escaped)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
p = procfs_file_alloca(pid, "comm");
|
||||||
|
|
||||||
|
r = read_one_line_file(p, &comm);
|
||||||
|
if (r == -ENOENT)
|
||||||
|
return -ESRCH;
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
/* Escape unprintable characters, just in case, but don't grow the string beyond the underlying size */
|
/* Escape unprintable characters, just in case, but don't grow the string beyond the underlying size */
|
||||||
cellescape(escaped, COMM_MAX_LEN, comm);
|
cellescape(escaped, COMM_MAX_LEN, comm);
|
||||||
|
|
||||||
|
@ -516,9 +500,6 @@ int get_process_cwd(pid_t pid, char **cwd) {
|
||||||
|
|
||||||
assert(pid >= 0);
|
assert(pid >= 0);
|
||||||
|
|
||||||
if (pid == 0 || pid == getpid_cached())
|
|
||||||
return safe_getcwd(cwd);
|
|
||||||
|
|
||||||
p = procfs_file_alloca(pid, "cwd");
|
p = procfs_file_alloca(pid, "cwd");
|
||||||
|
|
||||||
return get_process_link_contents(p, cwd);
|
return get_process_link_contents(p, cwd);
|
||||||
|
|
|
@ -1095,31 +1095,25 @@ int bus_set_transient_exec_command(
|
||||||
if (!f)
|
if (!f)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
fprintf(f, "%s=\n", name);
|
fputs("ExecStart=\n", f);
|
||||||
|
|
||||||
LIST_FOREACH(command, c, *exec_command) {
|
LIST_FOREACH(command, c, *exec_command) {
|
||||||
_cleanup_free_ char *a = NULL, *exec_chars = NULL;
|
_cleanup_free_ char *a = NULL, *t = NULL, *exec_chars = NULL;
|
||||||
|
const char *p;
|
||||||
|
|
||||||
exec_chars = exec_command_flags_to_exec_chars(c->flags);
|
p = unit_escape_setting(c->path, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS, &t);
|
||||||
if (!exec_chars)
|
if (!p)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
a = unit_concat_strv(c->argv, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS);
|
a = unit_concat_strv(c->argv, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS);
|
||||||
if (!a)
|
if (!a)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (streq_ptr(c->path, c->argv ? c->argv[0] : NULL))
|
exec_chars = exec_command_flags_to_exec_chars(c->flags);
|
||||||
fprintf(f, "%s=%s%s\n", name, exec_chars, a);
|
if (!exec_chars)
|
||||||
else {
|
return -ENOMEM;
|
||||||
_cleanup_free_ char *t = NULL;
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
p = unit_escape_setting(c->path, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS, &t);
|
fprintf(f, "%s=%s@%s %s\n", name, exec_chars, p, a);
|
||||||
if (!p)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
fprintf(f, "%s=%s@%s %s\n", name, exec_chars, p, a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = fflush_and_check(f);
|
r = fflush_and_check(f);
|
||||||
|
|
|
@ -599,12 +599,6 @@ static uint32_t determine_flags(void) {
|
||||||
if (arg_submit_from_crypt_cpus)
|
if (arg_submit_from_crypt_cpus)
|
||||||
flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS;
|
flags |= CRYPT_ACTIVATE_SUBMIT_FROM_CRYPT_CPUS;
|
||||||
|
|
||||||
#ifdef CRYPT_ACTIVATE_SERIALIZE_MEMORY_HARD_PBKDF
|
|
||||||
/* Try to decrease the risk of OOM event if memory hard key derivation function is in use */
|
|
||||||
/* https://gitlab.com/cryptsetup/cryptsetup/issues/446/ */
|
|
||||||
flags |= CRYPT_ACTIVATE_SERIALIZE_MEMORY_HARD_PBKDF;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4576,7 +4576,7 @@ static void print_status_info(
|
||||||
|
|
||||||
if (i->control_group) {
|
if (i->control_group) {
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
static const char prefix[] = " ";
|
static const char prefix[] = " ";
|
||||||
unsigned c;
|
unsigned c;
|
||||||
|
|
||||||
printf(" CGroup: %s\n", i->control_group);
|
printf(" CGroup: %s\n", i->control_group);
|
||||||
|
|
Loading…
Reference in New Issue