src/sd-daemon.c \
src/cgroup-show.c \
src/cgroup-util.c \
- src/exit-status.c
+ src/exit-status.c \
+ src/unit-name.c
systemctl_CFLAGS = \
$(AM_CFLAGS) \
* verify ordering of random-seed-load and base.target!
-* systemctl enable /lib/systemd/system/?*.service
- creates wrong subdirs in /etc/ssytemd/system/ which prevent further bootup
-
later:
* do not throw error when .service file is linked to /dev/null
* document locale.conf, vconsole.conf and possibly the tempfiles.d and modules-load.d mechanism.
-* when /proc/self/mountinfo is not parsable, proceed with next line
-
* beefed up tmpwatch that reads tmpfiles.d
* /lib/systemd/system/systemd-readahead-replay.service
* Restart=on-failure and Restart=on-abort
+* kill sessions on shutdown
+
+* when processes remain in a service even though the start command failed enter active
+
External:
* place /etc/inittab with explaining blurb.
#include "exit-status.h"
#include "bus-errors.h"
#include "build.h"
+#include "unit-name.h"
static const char *arg_type = NULL;
static char **arg_property = NULL;
hashmap_free(m);
}
-static bool unit_name_valid(const char *name) {
-
- /* This is a minimal version of unit_name_valid() from
- * unit-name.c */
-
- if (!*name)
- return false;
-
- if (ignore_file(name))
- return false;
-
- return true;
-}
-
static int install_info_add(const char *name) {
InstallInfo *i;
int r;
assert(will_install);
- if (!unit_name_valid(name))
+ if (!unit_name_is_valid_no_type(name)) {
+ log_warning("Unit name %s is not a valid unit name.", name);
return -EINVAL;
+ }
if (hashmap_get(have_installed, name) ||
hashmap_get(will_install, name))
if (!(n = strndup(w, l)))
return -ENOMEM;
- r = install_info_add(n);
- free(n);
-
- if (r < 0)
+ if ((r = install_info_add(n)) < 0) {
+ log_warning("Cannot install unit %s: %s", n, strerror(-r));
+ free(n);
return r;
+ }
+
+ free(n);
}
return 0;
STRV_FOREACH(s, i->aliases) {
- if (!unit_name_valid(*s)) {
+ if (!unit_name_is_valid_no_type(*s)) {
log_error("Invalid name %s.", *s);
r = -EINVAL;
goto finish;
if (streq(verb, "disable"))
rmdir_parents(alias_path, config_path);
}
-
r = 0;
finish:
assert(config_path);
STRV_FOREACH(s, i->wanted_by) {
- if (!unit_name_valid(*s)) {
+ if (!unit_name_is_valid_no_type(*s)) {
log_error("Invalid name %s.", *s);
r = -EINVAL;
goto finish;
}
for (j = 1; j < n; j++)
- if ((r = install_info_add(args[j])) < 0)
+ if ((r = install_info_add(args[j])) < 0) {
+ log_warning("Cannot install unit %s: %s", args[j], strerror(-r));
goto finish;
+ }
while ((i = hashmap_first(will_install))) {
int q;
#include <errno.h>
#include <string.h>
+#include <assert.h>
-#include "unit.h"
+#include "util.h"
#include "unit-name.h"
#define VALID_CHARS \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
":-_.\\"
-UnitType unit_name_to_type(const char *n) {
- UnitType t;
-
- assert(n);
-
- for (t = 0; t < _UNIT_TYPE_MAX; t++)
- if (endswith(n, unit_vtable[t]->suffix))
- return t;
-
- return _UNIT_TYPE_INVALID;
-}
-
-bool unit_name_is_valid(const char *n) {
- UnitType t;
+bool unit_name_is_valid_no_type(const char *n) {
const char *e, *i, *at;
/* Valid formats:
if (strlen(n) >= UNIT_NAME_MAX)
return false;
- t = unit_name_to_type(n);
- if (t < 0 || t >= _UNIT_TYPE_MAX)
- return false;
-
- assert_se(e = strrchr(n, '.'));
-
- if (e == n)
+ e = strrchr(n, '.');
+ if (!e || e == n)
return false;
for (i = n, at = NULL; i < e; i++) {
size_t a, b;
assert(n);
- assert(unit_name_is_valid(n));
+ assert(unit_name_is_valid_no_type(n));
assert(suffix);
assert_se(e = strrchr(n, '.'));
assert(unit_prefix_is_valid(prefix));
assert(!instance || unit_instance_is_valid(instance));
assert(suffix);
- assert(unit_name_to_type(suffix) >= 0);
if (!instance)
return strappend(prefix, suffix);
assert(prefix);
assert(suffix);
- assert(unit_name_to_type(suffix) >= 0);
/* Takes a arbitrary string for prefix and instance plus a
* suffix and makes a nice string suitable as unit name of it,
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "unit.h"
+#include <stdbool.h>
-UnitType unit_name_to_type(const char *n);
+#define UNIT_NAME_MAX 256
int unit_name_to_instance(const char *n, char **instance);
char* unit_name_to_prefix(const char *n);
char* unit_name_to_prefix_and_instance(const char *n);
-bool unit_name_is_valid(const char *n);
+bool unit_name_is_valid_no_type(const char *n);
bool unit_prefix_is_valid(const char *p);
bool unit_instance_is_valid(const char *i);
return false;
}
+UnitType unit_name_to_type(const char *n) {
+ UnitType t;
+
+ assert(n);
+
+ for (t = 0; t < _UNIT_TYPE_MAX; t++)
+ if (endswith(n, unit_vtable[t]->suffix))
+ return t;
+
+ return _UNIT_TYPE_INVALID;
+}
+
+bool unit_name_is_valid(const char *n) {
+ UnitType t;
+
+ t = unit_name_to_type(n);
+ if (t < 0 || t >= _UNIT_TYPE_MAX)
+ return false;
+
+ return unit_name_is_valid_no_type(n);
+}
+
static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
[UNIT_STUB] = "stub",
[UNIT_LOADED] = "loaded",
#include "socket-util.h"
#include "execute.h"
-#define UNIT_NAME_MAX 256
#define DEFAULT_TIMEOUT_USEC (60*USEC_PER_SEC)
#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
int unit_add_default_target_dependency(Unit *u, Unit *target);
+UnitType unit_name_to_type(const char *n);
+bool unit_name_is_valid(const char *n);
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);