[systemd-commits] 4 commits - fixme .gitignore Makefile.am src/auto-console-getty.c src/conf-parser.h src/device.c src/initctl.c src/load-fragment.c src/log.c src/main.c units/.gitignore units/systemd-auto-console-getty.service.in units/systemd-random-seed-load.service.in units/systemd-random-seed-save.service.in units/systemd-update-utmp-runlevel.service.in units/systemd-update-utmp-shutdown.service.in

Lennart Poettering lennart at kemper.freedesktop.org
Mon Aug 16 18:31:53 PDT 2010


 .gitignore                                    |    1 
 Makefile.am                                   |   23 ++-
 fixme                                         |    6 
 src/auto-console-getty.c                      |  189 ++++++++++++++++++++++++++
 src/conf-parser.h                             |    5 
 src/device.c                                  |    3 
 src/initctl.c                                 |    2 
 src/load-fragment.c                           |  176 ++++++++++++------------
 src/log.c                                     |   18 +-
 src/main.c                                    |   39 -----
 units/.gitignore                              |    1 
 units/systemd-auto-console-getty.service.in   |   16 ++
 units/systemd-random-seed-load.service.in     |    2 
 units/systemd-random-seed-save.service.in     |    2 
 units/systemd-update-utmp-runlevel.service.in |    2 
 units/systemd-update-utmp-shutdown.service.in |    2 
 16 files changed, 346 insertions(+), 141 deletions(-)

New commits:
commit 9499b235b9817720af506e7898f0df2efb249939
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 17 03:31:45 2010 +0200

    log: print at to one target at max

diff --git a/src/log.c b/src/log.c
index d6f4e34..d0d98dd 100644
--- a/src/log.c
+++ b/src/log.c
@@ -331,7 +331,7 @@ static int log_dispatch(
 
         do {
                 char *e;
-                int k;
+                int k = 0;
 
                 buffer += strspn(buffer, NEWLINE);
 
@@ -344,24 +344,26 @@ static int log_dispatch(
                 if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
                     log_target == LOG_TARGET_SYSLOG) {
 
-                        if ((r = write_to_syslog(level, file, line, func, buffer)) < 0) {
+                        if ((k = write_to_syslog(level, file, line, func, buffer)) < 0) {
                                 log_close_syslog();
                                 log_open_kmsg();
-                        } else if (r > 0)
+                        } else if (k > 0)
                                 r++;
                 }
 
-                if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
-                    log_target == LOG_TARGET_KMSG) {
+                if (k <= 0 &&
+                    (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
+                     log_target == LOG_TARGET_KMSG)) {
 
-                        if ((r = write_to_kmsg(level, file, line, func, buffer)) < 0) {
+                        if ((k = write_to_kmsg(level, file, line, func, buffer)) < 0) {
                                 log_close_kmsg();
                                 log_open_console();
-                        } else if (r > 0)
+                        } else if (k > 0)
                                 r++;
                 }
 
-                if ((k = write_to_console(level, file, line, func, buffer)) < 0)
+                if (k <= 0 &&
+                    (k = write_to_console(level, file, line, func, buffer)) < 0)
                         return k;
 
                 buffer = e;
commit 8630d370239482b6e4913e81011440b173e41b79
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 17 03:31:31 2010 +0200

    device: be more verbose of udev confuses us

diff --git a/src/device.c b/src/device.c
index c1d1b9a..7323192 100644
--- a/src/device.c
+++ b/src/device.c
@@ -190,7 +190,8 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
 
         /* If this is a different unit, then let's not merge things */
         if (u && DEVICE(u)->sysfs && !path_equal(DEVICE(u)->sysfs, sysfs)) {
-                log_error("Hmm, something's broken. Asked to create two devices with same name but different sysfs paths.");
+                log_error("Hmm, something's broken. Asked to create two devices with same name but different sysfs paths. (%s vs %s)",
+                          DEVICE(u)->sysfs, sysfs);
                 return -EEXIST;
         }
 
commit c0b346969d79c6b405f9ca23ce18655fda1651d6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 17 03:30:53 2010 +0200

    load-fragment: make parser more forgiving

diff --git a/src/conf-parser.h b/src/conf-parser.h
index 2797076..43469a3 100644
--- a/src/conf-parser.h
+++ b/src/conf-parser.h
@@ -71,8 +71,8 @@ int config_parse_path_strv(const char *filename, unsigned line, const char *sect
                 assert(data);                                           \
                                                                         \
                 if ((x = name##_from_string(rvalue)) < 0) {             \
-                        log_error("[%s:%u] " msg ": %s", filename, line, rvalue); \
-                        return -EBADMSG;                                \
+                        log_error("[%s:%u] " msg ", ignoring: %s", filename, line, rvalue); \
+                        return 0;                                       \
                 }                                                       \
                                                                         \
                 *i = x;                                                 \
@@ -80,5 +80,4 @@ int config_parse_path_strv(const char *filename, unsigned line, const char *sect
                 return 0;                                               \
         }
 
-
 #endif
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 0c58ed1..185c077 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -77,10 +77,14 @@ static int config_parse_deps(
                         return -ENOMEM;
 
                 r = unit_add_dependency_by_name(u, d, k, NULL, true);
-                free(k);
 
-                if (r < 0)
-                        return r;
+                if (r < 0) {
+                        log_error("Failed to add dependency on %s, ignoring: %s", k, strerror(-r));
+                        free(k);
+                        return 0;
+                }
+
+                free(k);
         }
 
         return 0;
@@ -119,10 +123,14 @@ static int config_parse_names(
                         return -ENOMEM;
 
                 r = unit_merge_by_name(u, k);
-                free(k);
 
-                if (r < 0)
-                        return r;
+                if (r < 0) {
+                        log_error("Failed to add name %s, ignoring: %s", k, strerror(-r));
+                        free(k);
+                        return 0;
+                }
+
+                free(k);
         }
 
         return 0;
@@ -197,9 +205,9 @@ static int config_parse_listen(
                 p->type = SOCKET_SOCKET;
 
                 if ((r = socket_address_parse(&p->address, rvalue)) < 0) {
-                        log_error("[%s:%u] Failed to parse address value: %s", filename, line, rvalue);
+                        log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue);
                         free(p);
-                        return r;
+                        return 0;
                 }
 
                 if (streq(lvalue, "ListenStream"))
@@ -212,8 +220,9 @@ static int config_parse_listen(
                 }
 
                 if (socket_address_family(&p->address) != AF_LOCAL && p->address.type == SOCK_SEQPACKET) {
+                        log_error("[%s:%u] Address family not supported, ignoring: %s", filename, line, rvalue);
                         free(p);
-                        return -EPROTONOSUPPORT;
+                        return 0;
                 }
         }
 
@@ -246,8 +255,8 @@ static int config_parse_socket_bind(
                 int r;
 
                 if ((r = parse_boolean(rvalue)) < 0) {
-                        log_error("[%s:%u] Failed to parse bind IPv6 only value: %s", filename, line, rvalue);
-                        return -EBADMSG;
+                        log_error("[%s:%u] Failed to parse bind IPv6 only value, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
 
                 s->bind_ipv6_only = r ? SOCKET_ADDRESS_IPV6_ONLY : SOCKET_ADDRESS_BOTH;
@@ -275,13 +284,13 @@ static int config_parse_nice(
         assert(data);
 
         if ((r = safe_atoi(rvalue, &priority)) < 0) {
-                log_error("[%s:%u] Failed to parse nice priority: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse nice priority, ignoring: %s. ", filename, line, rvalue);
+                return 0;
         }
 
         if (priority < PRIO_MIN || priority >= PRIO_MAX) {
-                log_error("[%s:%u] Nice priority out of range: %s", filename, line, rvalue);
-                return -ERANGE;
+                log_error("[%s:%u] Nice priority out of range, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->nice = priority;
@@ -308,13 +317,13 @@ static int config_parse_oom_adjust(
         assert(data);
 
         if ((r = safe_atoi(rvalue, &oa)) < 0) {
-                log_error("[%s:%u] Failed to parse OOM adjust value: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse OOM adjust value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (oa < OOM_DISABLE || oa > OOM_ADJUST_MAX) {
-                log_error("[%s:%u] OOM adjust value out of range: %s", filename, line, rvalue);
-                return -ERANGE;
+                log_error("[%s:%u] OOM adjust value out of range, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->oom_adjust = oa;
@@ -344,13 +353,13 @@ static int config_parse_mode(
         errno = 0;
         l = strtol(rvalue, &x, 8);
         if (!x || *x || errno) {
-                log_error("[%s:%u] Failed to parse mode value: %s", filename, line, rvalue);
-                return errno ? -errno : -EINVAL;
+                log_error("[%s:%u] Failed to parse mode value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (l < 0000 || l > 07777) {
-                log_error("[%s:%u] mode value out of range: %s", filename, line, rvalue);
-                return -ERANGE;
+                log_error("[%s:%u] mode value out of range, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         *m = (mode_t) l;
@@ -405,8 +414,8 @@ static int config_parse_exec(
                 }
 
                 if (*rvalue != '/') {
-                        log_error("[%s:%u] Invalid executable path in command line: %s", filename, line, rvalue);
-                        return -EINVAL;
+                        log_error("[%s:%u] Invalid executable path in command line, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
 
                 k = 0;
@@ -438,9 +447,9 @@ static int config_parse_exec(
                 n[k] = NULL;
 
                 if (!n[0]) {
-                        log_error("[%s:%u] Invalid command line: %s", filename, line, rvalue);
+                        log_error("[%s:%u] Invalid command line, ignoring: %s", filename, line, rvalue);
                         strv_free(n);
-                        return -EINVAL;
+                        return 0;
                 }
 
                 if (!path)
@@ -492,8 +501,8 @@ static int config_parse_usec(
         assert(data);
 
         if ((r = parse_usec(rvalue, usec)) < 0) {
-                log_error("[%s:%u] Failed to parse time value: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         return 0;
@@ -552,8 +561,8 @@ static int config_parse_facility(
         assert(data);
 
         if ((x = log_facility_from_string(rvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse log facility: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse log facility, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         *o = LOG_MAKEPRI(x, LOG_PRI(*o));
@@ -579,8 +588,8 @@ static int config_parse_level(
         assert(data);
 
         if ((x = log_level_from_string(rvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse log level: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse log level, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         *o = LOG_MAKEPRI(LOG_FAC(*o), x);
@@ -605,8 +614,8 @@ static int config_parse_io_class(
         assert(data);
 
         if ((x = ioprio_class_from_string(rvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse IO scheduling class: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse IO scheduling class, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->ioprio = IOPRIO_PRIO_VALUE(x, IOPRIO_PRIO_DATA(c->ioprio));
@@ -633,8 +642,8 @@ static int config_parse_io_priority(
         assert(data);
 
         if (safe_atoi(rvalue, &i) < 0 || i < 0 || i >= IOPRIO_BE_NR) {
-                log_error("[%s:%u] Failed to parse io priority: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse io priority, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_PRIO_CLASS(c->ioprio), i);
@@ -662,8 +671,8 @@ static int config_parse_cpu_sched_policy(
         assert(data);
 
         if ((x = sched_policy_from_string(rvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse CPU scheduling policy: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse CPU scheduling policy, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->cpu_sched_policy = x;
@@ -691,8 +700,8 @@ static int config_parse_cpu_sched_prio(
 
         /* On Linux RR/FIFO have the same range */
         if (safe_atoi(rvalue, &i) < 0 || i < sched_get_priority_min(SCHED_RR) || i > sched_get_priority_max(SCHED_RR)) {
-                log_error("[%s:%u] Failed to parse CPU scheduling priority: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse CPU scheduling priority, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->cpu_sched_priority = i;
@@ -736,8 +745,8 @@ static int config_parse_cpu_affinity(
                                 return -ENOMEM;
 
                 if (r < 0 || cpu >= c->cpuset_ncpus) {
-                        log_error("[%s:%u] Failed to parse CPU affinity: %s", filename, line, rvalue);
-                        return -EBADMSG;
+                        log_error("[%s:%u] Failed to parse CPU affinity, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
 
                 CPU_SET_S(cpu, CPU_ALLOC_SIZE(c->cpuset_ncpus), c->cpuset);
@@ -767,8 +776,8 @@ static int config_parse_capabilities(
                 if (errno == ENOMEM)
                         return -ENOMEM;
 
-                log_error("[%s:%u] Failed to parse capabilities: %s", filename, line, rvalue);
-                return -EBADMSG;
+                log_error("[%s:%u] Failed to parse capabilities, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (c->capabilities)
@@ -811,8 +820,8 @@ static int config_parse_secure_bits(
                 else if (first_word(w, "noroot-locked"))
                         c->secure_bits |= SECURE_NOROOT_LOCKED;
                 else {
-                        log_error("[%s:%u] Failed to parse secure bits: %s", filename, line, rvalue);
-                        return -EBADMSG;
+                        log_error("[%s:%u] Failed to parse secure bits, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
         }
 
@@ -850,8 +859,8 @@ static int config_parse_bounding_set(
                 free(t);
 
                 if (r < 0) {
-                        log_error("[%s:%u] Failed to parse capability bounding set: %s", filename, line, rvalue);
-                        return -EBADMSG;
+                        log_error("[%s:%u] Failed to parse capability bounding set, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
 
                 c->capability_bounding_set_drop |= 1 << cap;
@@ -879,8 +888,8 @@ static int config_parse_timer_slack_nsec(
         assert(data);
 
         if ((r = safe_atolu(rvalue, &u)) < 0) {
-                log_error("[%s:%u] Failed to parse time slack value: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         c->timer_slack_nsec = u;
@@ -907,8 +916,8 @@ static int config_parse_limit(
         assert(data);
 
         if ((r = safe_atollu(rvalue, &u)) < 0) {
-                log_error("[%s:%u] Failed to parse resource value: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (!*rl)
@@ -943,8 +952,10 @@ static int config_parse_cgroup(
                 r = unit_add_cgroup_from_text(u, t);
                 free(t);
 
-                if (r < 0)
-                        return r;
+                if (r < 0) {
+                        log_error("[%s:%u] Failed to parse cgroup value, ignoring: %s", filename, line, rvalue);
+                        return 0;
+                }
         }
 
         return 0;
@@ -968,8 +979,8 @@ static int config_parse_sysv_priority(
         assert(data);
 
         if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) {
-                log_error("[%s:%u] Failed to parse SysV start priority: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse SysV start priority, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         *priority = (int) i;
@@ -1000,8 +1011,8 @@ static int config_parse_kill_signal(
                         r = signal_from_string(rvalue+3);
 
         if (r <= 0) {
-                log_error("[%s:%u] Failed to parse kill signal: %s", filename, line, rvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Failed to parse kill signal, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         *sig = r;
@@ -1036,8 +1047,8 @@ static int config_parse_mount_flags(
                 else if (strncmp(w, "private", l) == 0)
                         flags |= MS_PRIVATE;
                 else {
-                        log_error("[%s:%u] Failed to parse mount flags: %s", filename, line, rvalue);
-                        return -EINVAL;
+                        log_error("[%s:%u] Failed to parse mount flags, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
         }
 
@@ -1066,13 +1077,13 @@ static int config_parse_timer(
         assert(data);
 
         if ((b = timer_base_from_string(lvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse timer base: %s", filename, line, lvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Failed to parse timer base, ignoring: %s", filename, line, lvalue);
+                return 0;
         }
 
         if ((r = parse_usec(rvalue, &u)) < 0) {
-                log_error("[%s:%u] Failed to parse timer value: %s", filename, line, rvalue);
-                return r;
+                log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (!(v = new0(TimerValue, 1)))
@@ -1107,14 +1118,14 @@ static int config_parse_timer_unit(
         dbus_error_init(&error);
 
         if (endswith(rvalue, ".timer")) {
-                log_error("[%s:%u] Unit cannot be of type timer: %s", filename, line, rvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Unit cannot be of type timer, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &t->unit)) < 0) {
-                log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
+                log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
                 dbus_error_free(&error);
-                return r;
+                return 0;
         }
 
         return 0;
@@ -1139,13 +1150,13 @@ static int config_parse_path_spec(
         assert(data);
 
         if ((b = path_type_from_string(lvalue)) < 0) {
-                log_error("[%s:%u] Failed to parse path type: %s", filename, line, lvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Failed to parse path type, ignoring: %s", filename, line, lvalue);
+                return 0;
         }
 
         if (!path_is_absolute(rvalue)) {
-                log_error("[%s:%u] Path is not absolute: %s", filename, line, rvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Path is not absolute, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if (!(s = new0(PathSpec, 1)))
@@ -1187,14 +1198,14 @@ static int config_parse_path_unit(
         dbus_error_init(&error);
 
         if (endswith(rvalue, ".path")) {
-                log_error("[%s:%u] Unit cannot be of type path: %s", filename, line, rvalue);
-                return -EINVAL;
+                log_error("[%s:%u] Unit cannot be of type path, ignoring: %s", filename, line, rvalue);
+                return 0;
         }
 
         if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &t->unit)) < 0) {
-                log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
+                log_error("[%s:%u] Failed to load unit %s, ignoring: %s", filename, line, rvalue, bus_error(&error, r));
                 dbus_error_free(&error);
-                return r;
+                return 0;
         }
 
         return 0;
@@ -1219,8 +1230,8 @@ static int config_parse_env_file(
         assert(data);
 
         if (!(f = fopen(rvalue, "re"))) {
-                log_error("[%s:%u] Failed to open environment file '%s': %m", filename, line, rvalue);
-                return -errno;
+                log_error("[%s:%u] Failed to open environment file '%s', ignoring: %m", filename, line, rvalue);
+                return 0;
         }
 
         while (!feof(f)) {
@@ -1232,7 +1243,8 @@ static int config_parse_env_file(
                                 break;
 
                         r = -errno;
-                        log_error("[%s:%u] Failed to read environment file '%s': %m", filename, line, rvalue);
+                        log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue);
+                        r = 0;
                         goto finish;
                 }
 
@@ -1277,8 +1289,8 @@ static int config_parse_ip_tos(
 
         if ((x = ip_tos_from_string(rvalue)) < 0)
                 if ((r = safe_atoi(rvalue, &x)) < 0) {
-                        log_error("[%s:%u] Failed to parse IP TOS value: %s", filename, line, rvalue);
-                        return r;
+                        log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue);
+                        return 0;
                 }
 
         *ip_tos = x;
diff --git a/units/.gitignore b/units/.gitignore
index 9ac3401..2a5e24d 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -1,3 +1,4 @@
+systemd-auto-console-getty.service
 systemd-shutdownd.service
 systemd-random-seed-load.service
 systemd-random-seed-save.service
commit 5192bd1945f59254b3d260ded15dd9f2b8cc2de7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Aug 17 03:29:46 2010 +0200

    auto-getty: rework auto console getty logic to work in conjunction with single user mode

diff --git a/.gitignore b/.gitignore
index 6b8edf5..7a20505 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+systemd-auto-console-getty
 systemd-shutdownd
 systemd-random-seed
 systemd-update-utmp
diff --git a/Makefile.am b/Makefile.am
index 013a603..de85b79 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,7 +72,8 @@ rootlibexec_PROGRAMS = \
 	systemd-initctl \
 	systemd-update-utmp \
 	systemd-random-seed \
-	systemd-shutdownd
+	systemd-shutdownd \
+	systemd-auto-console-getty
 
 noinst_PROGRAMS = \
 	test-engine \
@@ -139,6 +140,7 @@ dist_systemunit_DATA = \
 	units/systemd-initctl.socket \
 	units/systemd-logger.socket \
 	units/systemd-shutdownd.socket \
+	units/systemd-auto-console-getty.service \
 	units/dev-hugepages.automount \
 	units/dev-hugepages.mount \
 	units/dev-mqueue.automount \
@@ -164,6 +166,7 @@ nodist_systemunit_DATA = \
 	units/systemd-initctl.service \
 	units/systemd-logger.service \
 	units/systemd-shutdownd.service \
+	units/systemd-auto-console-getty.service \
 	units/systemd-update-utmp-runlevel.service \
 	units/systemd-update-utmp-shutdown.service \
 	units/systemd-random-seed-save.service \
@@ -186,6 +189,7 @@ EXTRA_DIST = \
 	units/systemd-initctl.service.in \
 	units/systemd-logger.service.in \
 	units/systemd-shutdownd.service.in \
+	units/systemd-auto-console-getty.service.in \
 	units/systemd-update-utmp-runlevel.service.in \
 	units/systemd-update-utmp-shutdown.service.in \
 	units/systemd-random-seed-save.service.in \
@@ -545,6 +549,18 @@ systemd_shutdownd_CFLAGS = \
 systemd_shutdownd_LDADD = \
 	libsystemd-basic.la
 
+systemd_auto_console_getty_SOURCES = \
+	src/auto-console-getty.c \
+	src/dbus-common.c
+
+systemd_auto_console_getty_CFLAGS = \
+	$(AM_CFLAGS) \
+	$(DBUS_CFLAGS)
+
+systemd_auto_console_getty_LDADD = \
+	libsystemd-basic.la \
+	$(DBUS_LIBS)
+
 systemd_cgroups_agent_SOURCES = \
 	src/cgroups-agent.c \
 	src/dbus-common.c
@@ -825,13 +841,14 @@ install-data-hook:
 		$(LN_S) $(systemunitdir)/reboot.target ctrl-alt-del.target && \
 		$(LN_S) $(systemunitdir)/rescue.target kbrequest.target )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/getty.target.wants && \
-		rm -f getty at tty1.service getty at tty2.service getty at tty3.service getty at tty4.service getty at tty5.service getty at tty6.service && \
+		rm -f getty at tty1.service getty at tty2.service getty at tty3.service getty at tty4.service getty at tty5.service getty at tty6.service systemd-auto-console-getty.service && \
 		$(LN_S) $(systemunitdir)/getty at .service getty at tty1.service && \
 		$(LN_S) $(systemunitdir)/getty at .service getty at tty2.service && \
 		$(LN_S) $(systemunitdir)/getty at .service getty at tty3.service && \
 		$(LN_S) $(systemunitdir)/getty at .service getty at tty4.service && \
 		$(LN_S) $(systemunitdir)/getty at .service getty at tty5.service && \
-		$(LN_S) $(systemunitdir)/getty at .service getty at tty6.service )
+		$(LN_S) $(systemunitdir)/getty at .service getty at tty6.service && \
+		$(LN_S) $(systemunitdir)/systemd-auto-console-getty.service systemd-auto-console-getty.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/multi-user.target.wants && \
 		rm -f getty.target remote-fs.target && \
 		$(LN_S) $(systemunitdir)/getty.target getty.target && \
diff --git a/fixme b/fixme
index 2df43c3..30f77e8 100644
--- a/fixme
+++ b/fixme
@@ -63,13 +63,13 @@
 
 * io priority during initialization
 
-* if a service fails too often, make the service enter maintainence mode, and the socket, too.
+* if a service fails too often, make the service enter maintenance mode, and the socket, too.
 
 * Ray: plymouth after/before getty? https://bugzilla.redhat.com/show_bug.cgi?id=623430
 
-* be more forgiving when parsing unit files, when encountering incorrect lines with assignments
+* add no-tab header to .h
 
-* agetty darf nicht mit emergency.service kollidieren
+* fix systemctl daemon-reload in part of boot
 
 External:
 
diff --git a/src/auto-console-getty.c b/src/auto-console-getty.c
new file mode 100644
index 0000000..44d2eff
--- /dev/null
+++ b/src/auto-console-getty.c
@@ -0,0 +1,189 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <dbus/dbus.h>
+
+#include "util.h"
+#include "log.h"
+#include "dbus-common.h"
+
+static int spawn_getty(DBusConnection *bus, const char *console) {
+        DBusMessage *m = NULL, *reply = NULL;
+        DBusError error;
+        const char *fail = "fail";
+        char *name;
+        int r = -EIO;
+
+        dbus_error_init(&error);
+
+        assert(bus);
+        assert(console);
+
+        /* FIXME: we probably should escape the tty name properly here */
+        if (asprintf(&name, "getty@%s.service", console) < 0)
+                return -ENOMEM;
+
+        if (!(m = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartUnit"))) {
+                log_error("Could not allocate message.");
+                goto finish;
+        }
+
+        if (!dbus_message_append_args(m,
+                                      DBUS_TYPE_STRING, &name,
+                                      DBUS_TYPE_STRING, &fail,
+                                      DBUS_TYPE_INVALID)) {
+                log_error("Could not attach target and flag information to message.");
+                goto finish;
+        }
+
+        if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) {
+                log_error("Failed to start unit: %s", error.message);
+                goto finish;
+        }
+
+        r = 0;
+
+finish:
+        if (m)
+                dbus_message_unref(m);
+
+        if (reply)
+                dbus_message_unref(reply);
+
+        dbus_error_free(&error);
+
+        free(name);
+
+        return r;
+}
+
+static int parse_proc_cmdline_word(const char *word, char **console) {
+        assert(word);
+
+        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(*console);
+                *console = w;
+        }
+
+        return 0;
+}
+
+static int parse_proc_cmdline(char **console) {
+        char *line;
+        int r;
+        char *w;
+        size_t l;
+        char *state;
+
+        assert(console);
+
+        if ((r = read_one_line_file("/tmp/cmdline", &line)) < 0) {
+                log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+                return 0;
+        }
+
+        FOREACH_WORD_QUOTED(w, l, line, state) {
+                char *word;
+
+                if (!(word = strndup(w, l))) {
+                        r = -ENOMEM;
+                        goto finish;
+                }
+
+                r = parse_proc_cmdline_word(word, console);
+                free(word);
+
+                if (r < 0)
+                        goto finish;
+        }
+
+        r = 0;
+
+finish:
+        free(line);
+        return r;
+}
+
+int main(int argc, char *argv[]) {
+        DBusError error;
+        int r = 1;
+        char *console = NULL;
+        DBusConnection *bus = NULL;
+
+        dbus_error_init(&error);
+
+        if (argc > 1) {
+                log_error("This program does not take arguments.");
+                return 1;
+        }
+
+        log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
+        log_parse_environment();
+        log_open();
+
+        if (bus_connect(DBUS_BUS_SYSTEM, &bus, NULL, &error) < 0) {
+                log_error("Failed to get D-Bus connection: %s", error.message);
+                goto finish;
+        }
+
+        if (parse_proc_cmdline(&console) < 0)
+                goto finish;
+
+        if (console)
+                if (spawn_getty(bus, console) < 0)
+                        goto finish;
+
+        r = 0;
+
+finish:
+        free(console);
+
+        if (bus) {
+               dbus_connection_close(bus);
+               dbus_connection_unref(bus);
+        }
+
+        dbus_error_free(&error);
+
+        dbus_shutdown();
+
+        return r;
+}
diff --git a/src/initctl.c b/src/initctl.c
index 115452e..7b478a7 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -119,7 +119,7 @@ static void change_runlevel(Server *s, int runlevel) {
                                       DBUS_TYPE_STRING, &target,
                                       DBUS_TYPE_STRING, &replace,
                                       DBUS_TYPE_INVALID)) {
-                log_error("Could not attach target and flag information to signal message.");
+                log_error("Could not attach target and flag information to message.");
                 goto finish;
         }
 
diff --git a/src/main.c b/src/main.c
index 5b5c05a..51253c6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,7 +57,6 @@ static enum {
 } 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;
@@ -245,6 +244,8 @@ static int parse_proc_cmdline_word(const char *word) {
                 "5",      SPECIAL_RUNLEVEL5_TARGET
         };
 
+        assert(word);
+
         if (startswith(word, "systemd.unit="))
                 return set_default_unit(word + 13);
 
@@ -336,26 +337,8 @@ static int parse_proc_cmdline_word(const char *word) {
 
         } else if (streq(word, "nomodules"))
                 arg_nomodules = true;
-        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")) {
+        else if (streq(word, "quiet")) {
                 arg_show_status = false;
                 arg_sysv_console = false;
         } else {
@@ -1061,21 +1044,6 @@ int main(int argc, char *argv[]) {
                         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");
@@ -1121,7 +1089,6 @@ finish:
                 manager_free(m);
 
         free(arg_default_unit);
-        free(arg_console);
 
         dbus_shutdown();
 
diff --git a/units/systemd-auto-console-getty.service.in b/units/systemd-auto-console-getty.service.in
new file mode 100644
index 0000000..6542cab
--- /dev/null
+++ b/units/systemd-auto-console-getty.service.in
@@ -0,0 +1,16 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Automatically Spawn getty on Kernel Console
+
+[Service]
+Type=oneshot
+ExecStart=@rootlibexecdir@/systemd-auto-console-getty
+
+[Install]
+WantedBy=getty.target
diff --git a/units/systemd-random-seed-load.service.in b/units/systemd-random-seed-load.service.in
index 4d5841d..965da06 100644
--- a/units/systemd-random-seed-load.service.in
+++ b/units/systemd-random-seed-load.service.in
@@ -14,7 +14,7 @@ Before=shutdown.target
 
 [Service]
 Type=oneshot
-ExecStart=- at rootlibexecdir@/systemd-random-seed load
+ExecStart=@rootlibexecdir@/systemd-random-seed load
 
 [Install]
 WantedBy=sysinit.target
diff --git a/units/systemd-random-seed-save.service.in b/units/systemd-random-seed-save.service.in
index 654c859..70cb31d 100644
--- a/units/systemd-random-seed-save.service.in
+++ b/units/systemd-random-seed-save.service.in
@@ -13,7 +13,7 @@ Conflicts=systemd-random-seed-save.service
 
 [Service]
 Type=oneshot
-ExecStart=- at rootlibexecdir@/systemd-random-seed save
+ExecStart=@rootlibexecdir@/systemd-random-seed save
 
 [Install]
 WantedBy=shutdown.target
diff --git a/units/systemd-update-utmp-runlevel.service.in b/units/systemd-update-utmp-runlevel.service.in
index 0b4c83d..a288d6e 100644
--- a/units/systemd-update-utmp-runlevel.service.in
+++ b/units/systemd-update-utmp-runlevel.service.in
@@ -14,4 +14,4 @@ Before=shutdown.target
 
 [Service]
 Type=oneshot
-ExecStart=- at rootlibexecdir@/systemd-update-utmp runlevel
+ExecStart=@rootlibexecdir@/systemd-update-utmp runlevel
diff --git a/units/systemd-update-utmp-shutdown.service.in b/units/systemd-update-utmp-shutdown.service.in
index 4c48c8b..e071285 100644
--- a/units/systemd-update-utmp-shutdown.service.in
+++ b/units/systemd-update-utmp-shutdown.service.in
@@ -13,4 +13,4 @@ Conflicts=systemd-update-utmp-runlevel.service
 
 [Service]
 Type=oneshot
-ExecStart=- at rootlibexecdir@/systemd-update-utmp shutdown
+ExecStart=@rootlibexecdir@/systemd-update-utmp shutdown


More information about the systemd-commits mailing list