chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: require $XDG_RUNTIME_DIR to be set for user instances
[elogind.git]
/
src
/
core
/
main.c
diff --git
a/src/core/main.c
b/src/core/main.c
index b21fb493da5db9006a05c0372aca381747749809..d161968bb39125c690f576af5c99dd69c7dbb6c6 100644
(file)
--- a/
src/core/main.c
+++ b/
src/core/main.c
@@
-691,19
+691,14
@@
static int parse_config_file(void) {
static int parse_proc_cmdline(void) {
_cleanup_free_ char *line = NULL;
char *w, *state;
static int parse_proc_cmdline(void) {
_cleanup_free_ char *line = NULL;
char *w, *state;
- int r;
size_t l;
size_t l;
+ int r;
- /* Don't read /proc/cmdline if we are in a container, since
- * that is only relevant for the host system */
- if (detect_container(NULL) > 0)
- return 0;
-
- r = read_one_line_file("/proc/cmdline", &line);
- if (r < 0) {
+ r = proc_cmdline(&line);
+ if (r < 0)
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ if (r <= 0)
return 0;
return 0;
- }
FOREACH_WORD_QUOTED(w, l, line, state) {
_cleanup_free_ char *word;
FOREACH_WORD_QUOTED(w, l, line, state) {
_cleanup_free_ char *word;
@@
-979,11
+974,13
@@
static int parse_argv(int argc, char *argv[]) {
* relevant for the container, hence we rely on argv[]
* instead. */
* relevant for the container, hence we rely on argv[]
* instead. */
- for (a = argv; a < argv + argc; a++)
- if ((r = parse_proc_cmdline_word(*a)) < 0) {
+ for (a = argv; a < argv + argc; a++) {
+ r = parse_proc_cmdline_word(*a);
+ if (r < 0) {
log_error("Failed on cmdline argument %s: %s", *a, strerror(-r));
return r;
}
log_error("Failed on cmdline argument %s: %s", *a, strerror(-r));
return r;
}
+ }
}
return 0;
}
return 0;
@@
-1386,6
+1383,12
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
+ if (arg_running_as == SYSTEMD_USER &&
+ !getenv("XDG_RUNTIME_DIR")) {
+ log_error("Trying to run as user instance, but \$XDG_RUNTIME_DIR is not set.");
+ goto finish;
+ }
+
if (arg_running_as == SYSTEMD_SYSTEM &&
arg_action == ACTION_RUN &&
running_in_chroot() > 0) {
if (arg_running_as == SYSTEMD_SYSTEM &&
arg_action == ACTION_RUN &&
running_in_chroot() > 0) {