#include "special.h"
#include "conf-parser.h"
#include "bus-errors.h"
+#include "missing.h"
static enum {
ACTION_RUN,
} arg_action = ACTION_RUN;
static char *arg_default_unit = NULL;
+static char *arg_console = NULL;
static ManagerRunningAs arg_running_as = _MANAGER_RUNNING_AS_INVALID;
static bool arg_dump_core = true;
} else if (streq(word, "nomodules"))
arg_nomodules = true;
- else if (streq(word, "quiet")) {
+ else if (startswith(word, "console=")) {
+ const char *k;
+ size_t l;
+ char *w = NULL;
+
+ k = word + 8;
+ l = strcspn(k, ",");
+
+ if (l < 4 ||
+ !startswith(k, "tty") ||
+ k[3+strspn(k+3, "0123456789")] != 0) {
+
+ if (!(w = strndup(k, l)))
+ return -ENOMEM;
+ }
+
+ free(arg_console);
+ arg_console = w;
+
+ } else if (streq(word, "quiet")) {
if (!ignore_quiet)
arg_show_status = false;
} else {
assert(_f);
assert(_fds);
- if ((r = manager_open_serialization(&f)) < 0) {
+ if ((r = manager_open_serialization(m, &f)) < 0) {
log_error("Failed to create serialization faile: %s", strerror(-r));
goto fail;
}
int main(int argc, char *argv[]) {
Manager *m = NULL;
Unit *target = NULL;
- Job *job = NULL;
int r, retval = 1;
FDSet *fds = NULL;
bool reexecute = false;
return 1;
}
- log_show_color(true);
+ log_show_color(isatty(STDERR_FILENO) > 0);
log_show_location(false);
log_set_max_level(LOG_INFO);
if (getpid() == 1) {
arg_running_as = MANAGER_SYSTEM;
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
+
+ if (label_init() < 0)
+ goto finish;
} else {
arg_running_as = MANAGER_SESSION;
log_set_target(LOG_TARGET_CONSOLE);
log_info(PACKAGE_STRING " running in %s mode.", manager_running_as_to_string(arg_running_as));
- if (arg_running_as == MANAGER_SYSTEM && !serialization) {
- if (arg_show_status)
- status_welcome();
- modprobe_setup(arg_nomodules);
- kmod_setup();
- hostname_setup();
- loopback_setup();
+ if (arg_running_as == MANAGER_SYSTEM) {
+
+ /* Disable nscd, to avoid deadlocks when systemd uses
+ * NSS and the nscd socket is maintained by us. */
+ /* if (nss_disable_nscd) { */
+ /* log_debug("Disabling nscd"); */
+ /* nss_disable_nscd(); */
+ /* } else */
+ /* log_debug("Hmm, can't disable nscd."); */
+
+ if (!serialization) {
+ if (arg_show_status)
+ status_welcome();
+ modprobe_setup(arg_nomodules);
+ kmod_setup();
+ hostname_setup();
+ loopback_setup();
+ }
}
if ((r = manager_new(arg_running_as, &m)) < 0) {
manager_dump_units(m, stdout, "\t");
}
- if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, &job)) < 0) {
+ if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, NULL)) < 0) {
log_error("Failed to start default target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
}
+ if (arg_console && arg_running_as == MANAGER_SYSTEM) {
+ char *name;
+
+ if (asprintf(&name, "getty@%s.service", arg_console) < 0)
+ log_error("Out of memory while generating console getty service name.");
+ else {
+ if ((r = manager_add_job_by_name(m, JOB_START, name, JOB_FAIL, false, &error, NULL)) < 0) {
+ log_error("Failed to start console getty target: %s", bus_error(&error, r));
+ dbus_error_free(&error);
+ }
+
+ free(name);
+ }
+ }
+
if (arg_action == ACTION_TEST) {
printf("-> By jobs:\n");
manager_dump_jobs(m, stdout, "\t");
manager_free(m);
free(arg_default_unit);
+ free(arg_console);
dbus_shutdown();
if (getpid() == 1)
freeze();
+ label_finish();
+
return retval;
}