diff options
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | TODO | 8 | ||||
-rw-r--r-- | configure.ac | 24 | ||||
-rw-r--r-- | docs/gudev/Makefile.am | 8 | ||||
-rw-r--r-- | man/systemd.service.xml | 46 | ||||
-rw-r--r-- | src/core/dbus-service.c | 4 | ||||
-rw-r--r-- | src/core/load-fragment-gperf.gperf.m4 | 4 | ||||
-rw-r--r-- | src/core/load-fragment.c | 12 | ||||
-rw-r--r-- | src/core/service.c | 35 | ||||
-rw-r--r-- | src/core/service.h | 5 | ||||
-rw-r--r-- | src/udev/udev-builtin-kmod.c | 23 | ||||
-rw-r--r-- | src/udev/udev-builtin.c | 14 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 7 | ||||
-rw-r--r-- | src/udev/udevd.c | 5 |
14 files changed, 137 insertions, 66 deletions
diff --git a/Makefile.am b/Makefile.am index b1a8cc1990..278da18e11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -148,10 +148,11 @@ AM_CPPFLAGS = \ -I $(top_builddir)/src/core \ -I $(top_srcdir)/src/core \ -I $(top_srcdir)/src/libudev \ - -I $(top_srcdir)/src/udev + -I $(top_srcdir)/src/udev \ + $(OUR_CPPFLAGS) -AM_CFLAGS = $(WARNINGFLAGS) -AM_LDFLAGS = $(GCLDFLAGS) +AM_CFLAGS = $(OUR_CFLAGS) +AM_LDFLAGS = $(OUR_LDFLAGS) # ------------------------------------------------------------------------------ if TARGET_GENTOO @@ -1397,6 +1398,7 @@ systemd_remount_fs_SOURCES = \ src/core/mount-setup.h systemd_remount_fs_LDADD = \ + libsystemd-label.la \ libsystemd-shared.la # ------------------------------------------------------------------------------ @@ -1,4 +1,10 @@ Bugfixes: +* there is nothing to warn about here :) + $ systemctl stop systemd-udevd.service systemd-udevd-kernel.socket systemd-udevd-control.socket + Warning: Stopping systemd-udevd.service, but it can still be activated by: + systemd-udevd-control.socket + systemd-udevd-kernel.socket + * kill /etc/timezone handling entirely? What does it provide? - /etc/localtime carries the same information already: $ ls -l /etc/localtime; cat /etc/timezone @@ -47,6 +53,8 @@ Bugfixes: Features: +* properly handle loop back mounts via fstab, especially regards to fsck/passno + * allow services with no ExecStart= but with an ExecStop= * add proper journal support to "systemctl --user status ..." diff --git a/configure.ac b/configure.ac index 5145298204..679214ad33 100644 --- a/configure.ac +++ b/configure.ac @@ -86,7 +86,6 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :]) CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\ -pipe \ -Wall \ - -W \ -Wextra \ -Wno-inline \ -Wundef \ @@ -117,20 +116,27 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\ -Wno-missing-field-initializers \ -Wno-unused-result \ -Werror=overflow \ - -Wp,-D_FORTIFY_SOURCE=2 \ -ffast-math \ -fno-common \ -fdiagnostics-show-option \ -fno-strict-aliasing \ -fvisibility=hidden \ -ffunction-sections \ - -fdata-sections]) -AC_SUBST([WARNINGFLAGS], $with_cflags) + -fdata-sections \ + -fstack-protector \ + --param=ssp-buffer-size=4]) +AC_SUBST([OUR_CFLAGS], $with_cflags) + +CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\ + -Wp,-D_FORTIFY_SOURCE=2]) +AC_SUBST([OUR_CPPFLAGS], $with_cppflags) CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\ -Wl,--as-needed \ - -Wl,--gc-sections]) -AC_SUBST([GCLDFLAGS], $with_ldflags) + -Wl,--gc-sections \ + -Wl,-z,relro \ + -Wl,-z,now]) +AC_SUBST([OUR_LDFLAGS], $with_ldflags) AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])]) AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])]) @@ -753,7 +759,7 @@ AC_MSG_RESULT([ Split /usr: ${enable_split_usr} man pages: ${have_manpages} - CFLAGS: ${CFLAGS} - CPPLAGS: ${CPPFLAGS} - LDFLAGS: ${LDFLAGS} + CFLAGS: ${OUR_CFLAGS} ${CFLAGS} + CPPLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} + LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS} ]) diff --git a/docs/gudev/Makefile.am b/docs/gudev/Makefile.am index 586dd8d190..152cd3c018 100644 --- a/docs/gudev/Makefile.am +++ b/docs/gudev/Makefile.am @@ -72,6 +72,14 @@ content_files = version.xml # e.g. expand_content_files=running.sgml expand_content_files= +# Hack, hack. You silly gtk-doc, you must not add CFLAGS multiple +# times when calling gcc; it surely can not work with options that must +# be listed only once. +# Kill CFLAGS here because gtk-doc thinks adding CFLAGS to CC _and_ also +# adding CFLAGS itself again would work. +CFLAGS= +LDFLAGS= + # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget # signals and properties. diff --git a/man/systemd.service.xml b/man/systemd.service.xml index f43201dc7e..1946d85f48 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -463,27 +463,49 @@ </varlistentry> <varlistentry> - <term><varname>TimeoutSec=</varname></term> + <term><varname>TimeoutStartSec=</varname></term> <listitem><para>Configures the time to - wait for start-up and stop. If a + wait for start-up. If a daemon service does not signal start-up completion within the - configured time the service will be + configured time, the service will be considered failed and be shut down - again. If a service is asked to stop - but does not terminate in the - specified time it will be terminated + again. + Takes a unit-less value in seconds, or a + time span value such as "5min + 20s". Pass 0 to disable the timeout + logic. Defaults to 90s, except when + <varname>Type=oneshot</varname> is + used in which case the timeout + is disabled by default. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><varname>TimeoutStopSec=</varname></term> + <listitem><para>Configures the time to + wait for stop. If a service is asked + to stop but does not terminate in the + specified time, it will be terminated forcibly via SIGTERM, and after another delay of this time with - SIGKILL. (See + SIGKILL (See <varname>KillMode=</varname> - in <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>) Takes a unit-less value in seconds, or a + in <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). + Takes a unit-less value in seconds, or a time span value such as "5min 20s". Pass 0 to disable the timeout - logic. Defaults to - 90s, except when <varname>Type=oneshot</varname> is - used in which case the timeout - is disabled by default.</para></listitem> + logic. Defaults to 90s. + </para></listitem> + </varlistentry> + + <varlistentry> + <term><varname>TimeoutSec=</varname></term> + <listitem><para>A shorthand for configuring + both <varname>TimeoutStartSec=</varname> + and <varname>TimeoutStopSec=</varname> + to the specified value. + </para></listitem> </varlistentry> <varlistentry> diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index c0fac16d2b..129e131a65 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -115,7 +115,9 @@ static const BusProperty bus_service_properties[] = { { "PIDFile", bus_property_append_string, "s", offsetof(Service, pid_file), true }, { "NotifyAccess", bus_service_append_notify_access, "s", offsetof(Service, notify_access) }, { "RestartUSec", bus_property_append_usec, "t", offsetof(Service, restart_usec) }, - { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Service, timeout_usec) }, + { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Service, timeout_start_usec) }, + { "TimeoutStartUSec", bus_property_append_usec, "t", offsetof(Service, timeout_start_usec) }, + { "TimeoutStopUSec", bus_property_append_usec, "t", offsetof(Service, timeout_stop_usec) }, { "WatchdogUSec", bus_property_append_usec, "t", offsetof(Service, watchdog_usec) }, { "WatchdogTimestamp", bus_property_append_usec, "t", offsetof(Service, watchdog_timestamp.realtime) }, { "WatchdogTimestampMonotonic",bus_property_append_usec, "t", offsetof(Service, watchdog_timestamp.monotonic) }, diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4 index 2b1cfa073c..e738213e27 100644 --- a/src/core/load-fragment-gperf.gperf.m4 +++ b/src/core/load-fragment-gperf.gperf.m4 @@ -145,7 +145,9 @@ Service.ExecReload, config_parse_exec, SERVICE_EXE Service.ExecStop, config_parse_exec, SERVICE_EXEC_STOP, offsetof(Service, exec_command) Service.ExecStopPost, config_parse_exec, SERVICE_EXEC_STOP_POST, offsetof(Service, exec_command) Service.RestartSec, config_parse_usec, 0, offsetof(Service, restart_usec) -Service.TimeoutSec, config_parse_service_timeout, 0, offsetof(Service, timeout_usec) +Service.TimeoutSec, config_parse_service_timeout, 0, offsetof(Service, timeout_start_usec) +Service.TimeoutStartSec, config_parse_service_timeout, 0, offsetof(Service, timeout_start_usec) +Service.TimeoutStopSec, config_parse_service_timeout, 0, offsetof(Service, timeout_stop_usec) Service.WatchdogSec, config_parse_usec, 0, offsetof(Service, watchdog_usec) Service.StartLimitInterval, config_parse_usec, 0, offsetof(Service, start_limit.interval) Service.StartLimitBurst, config_parse_unsigned, 0, offsetof(Service, start_limit.burst) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index bbd82b9d24..10681307cf 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1376,10 +1376,16 @@ int config_parse_service_timeout( r = config_parse_usec(filename, line, section, lvalue, ltype, rvalue, data, userdata); - if (!r) - s->timeout_defined = true; + if (r) + return r; - return r; + if (streq(lvalue, "TimeoutSec")) { + s->start_timeout_defined = true; + s->timeout_stop_usec = s->timeout_start_usec; + } else if (streq(lvalue, "TimeoutStartSec")) + s->start_timeout_defined = true; + + return 0; } int config_parse_unit_env_file( diff --git a/src/core/service.c b/src/core/service.c index 1c127bdbcb..e74da54eac 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -134,7 +134,8 @@ static void service_init(Unit *u) { assert(u); assert(u->load_state == UNIT_STUB); - s->timeout_usec = DEFAULT_TIMEOUT_USEC; + s->timeout_start_usec = DEFAULT_TIMEOUT_USEC; + s->timeout_stop_usec = DEFAULT_TIMEOUT_USEC; s->restart_usec = DEFAULT_RESTART_USEC; s->type = _SERVICE_TYPE_INVALID; @@ -914,9 +915,13 @@ static int service_load_sysv_path(Service *s, const char *path) { UNIT(s)->default_dependencies = false; /* Don't timeout special services during boot (like fsck) */ - s->timeout_usec = 0; - } else - s->timeout_usec = DEFAULT_SYSV_TIMEOUT_USEC; + s->timeout_start_usec = 0; + s->timeout_stop_usec = 0; + } else { + s->timeout_start_usec = DEFAULT_SYSV_TIMEOUT_USEC; + s->timeout_stop_usec = DEFAULT_SYSV_TIMEOUT_USEC; + } + /* Special setting for all SysV services */ s->type = SERVICE_FORKING; @@ -1241,9 +1246,9 @@ static int service_load(Unit *u) { if (s->type == _SERVICE_TYPE_INVALID) s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE; - /* Oneshot services have disabled timeout by default */ - if (s->type == SERVICE_ONESHOT && !s->timeout_defined) - s->timeout_usec = 0; + /* Oneshot services have disabled start timeout by default */ + if (s->type == SERVICE_ONESHOT && !s->start_timeout_defined) + s->timeout_start_usec = 0; service_fix_output(s); @@ -1603,11 +1608,10 @@ static int service_coldplug(Unit *u) { s->deserialized_state == SERVICE_FINAL_SIGTERM || s->deserialized_state == SERVICE_FINAL_SIGKILL || s->deserialized_state == SERVICE_AUTO_RESTART) { - - if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_usec > 0) { + if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) { usec_t k; - k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_usec; + k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_start_usec; if ((r = unit_watch_timer(UNIT(s), k, &s->timer_watch)) < 0) return r; @@ -1753,8 +1757,9 @@ static int service_spawn( } } - if (timeout && s->timeout_usec) { - if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0) + if (timeout && s->timeout_start_usec) { + r = unit_watch_timer(UNIT(s), s->timeout_start_usec, &s->timer_watch); + if (r < 0) goto fail; } else unit_unwatch_timer(UNIT(s), &s->timer_watch); @@ -2011,9 +2016,11 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f } if (wait_for_exit) { - if (s->timeout_usec > 0) - if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0) + if (s->timeout_stop_usec > 0) { + r = unit_watch_timer(UNIT(s), s->timeout_stop_usec, &s->timer_watch); + if (r < 0) goto fail; + } service_set_state(s, state); } else if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL) diff --git a/src/core/service.h b/src/core/service.h index cc63347c76..c78de79a09 100644 --- a/src/core/service.h +++ b/src/core/service.h @@ -120,7 +120,8 @@ struct Service { char *pid_file; usec_t restart_usec; - usec_t timeout_usec; + usec_t timeout_start_usec; + usec_t timeout_stop_usec; dual_timestamp watchdog_timestamp; usec_t watchdog_usec; @@ -166,7 +167,7 @@ struct Service { bool bus_name_good:1; bool forbid_restart:1; bool got_socket_fd:1; - bool timeout_defined:1; + bool start_timeout_defined:1; #ifdef HAVE_SYSV_COMPAT bool is_sysv:1; bool sysv_has_lsb:1; diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index 87a81bfaab..9d3605bc6b 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -1,7 +1,7 @@ /* * load kernel modules * - * Copyright (C) 2011 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (C) 2011-2012 Kay Sievers <kay.sievers@vrfy.org> * Copyright (C) 2011 ProFUSION embedded systems * * This program is free software: you can redistribute it and/or modify @@ -39,6 +39,8 @@ static int load_module(struct udev *udev, const char *alias) struct kmod_list *l; int err; + assert(ctx); + err = kmod_module_new_from_lookup(ctx, alias, &list); if (err < 0) return err; @@ -70,22 +72,11 @@ static void udev_kmod_log(void *data, int priority, const char *file, int line, udev_main_log(data, priority, file, line, fn, format, args); } -/* needs to re-instantiate the context after a reload */ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) { struct udev *udev = udev_device_get_udev(dev); int i; - if (!ctx) { - ctx = kmod_new(NULL, NULL); - if (!ctx) - return -ENOMEM; - - log_debug("load module index\n"); - kmod_set_log_fn(ctx, udev_kmod_log, udev); - kmod_load_resources(ctx); - } - if (argc < 3 || strcmp(argv[1], "load")) { log_error("expect: %s load <module>\n", argv[0]); return EXIT_FAILURE; @@ -99,7 +90,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te return EXIT_SUCCESS; } -/* called at udev startup */ +/* called at udev startup and reload */ static int builtin_kmod_init(struct udev *udev) { if (ctx) @@ -126,9 +117,9 @@ static void builtin_kmod_exit(struct udev *udev) static bool builtin_kmod_validate(struct udev *udev) { log_debug("validate module index\n"); - if (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK) - return true; - return false; + if (!ctx) + return false; + return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK); } const struct udev_builtin udev_builtin_kmod = { diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index 6509f5881d..7d89f22792 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (C) 2007-2012 Kay Sievers <kay.sievers@vrfy.org> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ #include "udev.h" +static bool initialized; + static const struct udev_builtin *builtins[] = { [UDEV_BUILTIN_BLKID] = &udev_builtin_blkid, [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware, @@ -44,6 +46,9 @@ int udev_builtin_init(struct udev *udev) unsigned int i; int err = 0; + if (initialized) + return 0; + for (i = 0; i < ELEMENTSOF(builtins); i++) { if (builtins[i]->init) { err = builtins[i]->init(udev); @@ -51,6 +56,8 @@ int udev_builtin_init(struct udev *udev) break; } } + + initialized = true; return err; } @@ -58,9 +65,14 @@ void udev_builtin_exit(struct udev *udev) { unsigned int i; + if (!initialized) + return; + for (i = 0; i < ELEMENTSOF(builtins); i++) if (builtins[i]->exit) builtins[i]->exit(udev); + + initialized = false; } bool udev_builtin_validate(struct udev *udev) diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index d3b33e4bbf..d86e6bc578 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2010 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (C) 2003-2012 Kay Sievers <kay.sievers@vrfy.org> * Copyright (C) 2008 Alan Jenkins <alan-jenkins@tuffmail.co.uk> * * This program is free software: you can redistribute it and/or modify @@ -1770,12 +1770,15 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) return NULL; } strv_uniq(rules->dirs); + + rules->dirs_ts_usec = calloc(strv_length(rules->dirs), sizeof(long long)); + udev_rules_check_timestamp(rules); + r = conf_files_list_strv(&files, ".rules", (const char **)rules->dirs); if (r < 0) { log_error("failed to enumerate rules files: %s\n", strerror(-r)); return NULL; } - rules->dirs_ts_usec = calloc(strv_length(rules->dirs), sizeof(long long)); /* * The offset value in the rules strct is limited; add all diff --git a/src/udev/udevd.c b/src/udev/udevd.c index b78c18f20a..23351aebd5 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1107,7 +1107,7 @@ int main(int argc, char *argv[]) case 'D': debug = true; log_set_max_level(LOG_DEBUG); - udev_set_log_priority(udev, LOG_INFO); + udev_set_log_priority(udev, LOG_DEBUG); break; case 'N': if (strcmp (optarg, "early") == 0) { @@ -1486,7 +1486,7 @@ int main(int argc, char *argv[]) worker_kill(udev); rules = udev_rules_unref(rules); udev_builtin_exit(udev); - reload = 0; + reload = false; } /* event has finished */ @@ -1506,6 +1506,7 @@ int main(int argc, char *argv[]) /* start new events */ if (!udev_list_node_is_empty(&event_list) && !udev_exit && !stop_exec_queue) { + udev_builtin_init(udev); if (rules == NULL) rules = udev_rules_new(udev, resolve_names); if (rules != NULL) |