Compare commits

..

9 Commits

Author SHA1 Message Date
Lennart Poettering a434236acc systemctl: fix indentation of cgroup tree
Follow-up for 0d588deae2.

In that commit the output got moved a 2 chars to the right, hence make
sure to also shift the cgroup tree to the right, so that it gets
properly aligned under the cgroup path again.
2019-11-27 18:34:53 +01:00
Michal Sekletár 408c81f624 cryptsetup: reduce the chance that we will be OOM killed
cryptsetup introduced optional locking scheme that should serialize
unlocking keyslots which use memory hard key derivation
function (argon2). Using the serialization should prevent OOM situation
in early boot while unlocking encrypted volumes.
2019-11-27 18:34:36 +01:00
Lennart Poettering 6cf5c3318f
Merge pull request #14164 from poettering/exec-start-transient-fix
fix ExecStart= line generation for transient units
2019-11-27 18:32:30 +01:00
Zbigniew Jędrzejewski-Szmek cddaeae6f4
Merge pull request #14145 from poettering/process-bypass
/proc bypass in various process-util.c calls
2019-11-27 14:53:39 +01:00
Lennart Poettering 540ac9338e core: prefer non-@ syntax for ExecStart=
If the zeroth and first argv[] element on the same we don't need to
generate the "@" syntax for ExecStart= and friends.
2019-11-27 12:32:14 +01:00
Lennart Poettering f14bf01312 core: write out correct field name when creating transient service units 2019-11-27 12:23:00 +01:00
Lennart Poettering 5c7b99745a process-util: shortcut get_process_state() for our own process 2019-11-25 19:23:31 +01:00
Lennart Poettering cde93ba2a5 process-util: shortcut get_process_comm() for our own process
Let's bypass /proc if we can.
2019-11-25 19:23:31 +01:00
Lennart Poettering aad3a64d63 process-util: tweak get_process_cwd() when calling for own process
Let's bypass /proc if we can.
2019-11-25 15:01:53 +01:00
4 changed files with 52 additions and 21 deletions

View File

@ -21,8 +21,8 @@
#include "alloc-util.h"
#include "architecture.h"
#include "escape.h"
#include "env-util.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
@ -34,6 +34,7 @@
#include "missing_sched.h"
#include "missing_syscall.h"
#include "namespace-util.h"
#include "path-util.h"
#include "process-util.h"
#include "raw-clone.h"
#include "rlimit-util.h"
@ -51,13 +52,17 @@
#define COMM_MAX_LEN 128
static int get_process_state(pid_t pid) {
_cleanup_free_ char *line = NULL;
const char *p;
char state;
int r;
_cleanup_free_ char *line = NULL;
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");
r = read_one_line_file(p, &line);
@ -80,23 +85,34 @@ static int get_process_state(pid_t pid) {
int get_process_comm(pid_t pid, char **ret) {
_cleanup_free_ char *escaped = NULL, *comm = NULL;
const char *p;
int r;
assert(ret);
assert(pid >= 0);
escaped = new(char, COMM_MAX_LEN);
if (!escaped)
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);
if (!escaped)
return -ENOMEM;
/* Escape unprintable characters, just in case, but don't grow the string beyond the underlying size */
cellescape(escaped, COMM_MAX_LEN, comm);
@ -500,6 +516,9 @@ int get_process_cwd(pid_t pid, char **cwd) {
assert(pid >= 0);
if (pid == 0 || pid == getpid_cached())
return safe_getcwd(cwd);
p = procfs_file_alloca(pid, "cwd");
return get_process_link_contents(p, cwd);

View File

@ -1095,26 +1095,32 @@ int bus_set_transient_exec_command(
if (!f)
return -ENOMEM;
fputs("ExecStart=\n", f);
fprintf(f, "%s=\n", name);
LIST_FOREACH(command, c, *exec_command) {
_cleanup_free_ char *a = NULL, *t = NULL, *exec_chars = NULL;
const char *p;
_cleanup_free_ char *a = NULL, *exec_chars = NULL;
p = unit_escape_setting(c->path, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS, &t);
if (!p)
exec_chars = exec_command_flags_to_exec_chars(c->flags);
if (!exec_chars)
return -ENOMEM;
a = unit_concat_strv(c->argv, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS);
if (!a)
return -ENOMEM;
exec_chars = exec_command_flags_to_exec_chars(c->flags);
if (!exec_chars)
if (streq_ptr(c->path, c->argv ? c->argv[0] : NULL))
fprintf(f, "%s=%s%s\n", name, exec_chars, a);
else {
_cleanup_free_ char *t = NULL;
const char *p;
p = unit_escape_setting(c->path, UNIT_ESCAPE_C|UNIT_ESCAPE_SPECIFIERS, &t);
if (!p)
return -ENOMEM;
fprintf(f, "%s=%s@%s %s\n", name, exec_chars, p, a);
}
}
r = fflush_and_check(f);
if (r < 0)

View File

@ -599,6 +599,12 @@ static uint32_t determine_flags(void) {
if (arg_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;
}