1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 04:04:46 +02:00

Compare commits

..

No commits in common. "91a96a564f5fc0dbad15f1c23a0fbda157a03558" and "6b1ed5e7e68fc5992a7bdabe4a05a7a3e1e1d898" have entirely different histories.

4 changed files with 131 additions and 280 deletions

372
po/nl.po

File diff suppressed because it is too large Load Diff

View File

@ -124,10 +124,14 @@ int get_process_comm(pid_t pid, char **ret) {
}
int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags, char **line) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *t = NULL, *ans = NULL;
const char *p;
size_t k;
int r;
size_t k;
/* This is supposed to be a safety guard against runaway command lines. */
size_t max_length = sc_arg_max();
assert(line);
assert(pid >= 0);
@ -143,18 +147,36 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags
* comm_fallback is false). Returns 0 and sets *line otherwise. */
p = procfs_file_alloca(pid, "cmdline");
r = read_full_virtual_file(p, &t, &k);
r = fopen_unlocked(p, "re", &f);
if (r == -ENOENT)
return -ESRCH;
if (r < 0)
return r;
/* We assume that each four-byte character uses one or two columns. If we ever check for combining
* characters, this assumption will need to be adjusted. */
if ((size_t) 4 * max_columns + 1 < max_columns)
max_length = MIN(max_length, (size_t) 4 * max_columns + 1);
t = new(char, max_length);
if (!t)
return -ENOMEM;
k = fread(t, 1, max_length, f);
if (k > 0) {
/* Arguments are separated by NULs. Let's replace those with spaces. */
for (size_t i = 0; i < k - 1; i++)
if (t[i] == '\0')
t[i] = ' ';
t[k] = '\0'; /* Normally, t[k] is already NUL, so this is just a guard in case of short read */
} else {
/* We only treat getting nothing as an error. We *could* also get an error after reading some
* data, but we ignore that case, as such an error is rather unlikely and we prefer to get
* some data rather than none. */
if (ferror(f))
return -errno;
if (!(flags & PROCESS_CMDLINE_COMM_FALLBACK))
return -ENOENT;
@ -165,7 +187,7 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags
if (r < 0)
return r;
free(t);
mfree(t);
t = strjoin("[", t2, "]");
if (!t)
return -ENOMEM;

View File

@ -405,7 +405,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
j->unit->id,
unit_id == array ? "ordering cycle" : "dependency",
*unit_id, *job_type,
"%s", unit_ids);
unit_ids);
if (delete) {
const char *status;
@ -414,7 +414,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
"MESSAGE=%s: Job %s/%s deleted to break ordering cycle starting with %s/%s",
j->unit->id, delete->unit->id, job_type_to_string(delete->type),
j->unit->id, job_type_to_string(j->type),
"%s", unit_ids);
unit_ids);
if (log_get_show_color())
status = ANSI_HIGHLIGHT_RED " SKIP " ANSI_NORMAL;
@ -432,7 +432,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
log_struct(LOG_ERR,
"MESSAGE=%s: Unable to break cycle starting with %s/%s",
j->unit->id, j->unit->id, job_type_to_string(j->type),
"%s", unit_ids);
unit_ids);
return sd_bus_error_setf(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC,
"Transaction order is cyclic. See system logs for details.");

View File

@ -236,11 +236,6 @@ static void test_get_process_cmdline_harder(void) {
return;
}
/* Set RLIMIT_STACK to infinity to test we don't try to allocate unncessarily large values to read
* the cmdline. */
if (setrlimit(RLIMIT_STACK, &RLIMIT_MAKE_CONST(RLIM_INFINITY)) < 0)
log_warning("Testing without RLIMIT_STACK=infinity");
assert_se(unlink(path) >= 0);
assert_se(prctl(PR_SET_NAME, "testa") >= 0);