chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test1: add service for testing priv dropping
[elogind.git]
/
unit.c
diff --git
a/unit.c
b/unit.c
index c27e4ec902c74ed793b5f9fbaf1837900ad75c1c..39c9e5e7e83d86156ca6440a67bbf8ddae706c97 100644
(file)
--- a/
unit.c
+++ b/
unit.c
@@
-284,7
+284,7
@@
void unit_free(Unit *u) {
bidi_set_free(u, u->meta.dependencies[d]);
free(u->meta.description);
bidi_set_free(u, u->meta.dependencies[d]);
free(u->meta.description);
- free(u->meta.
load
_path);
+ free(u->meta.
fragment
_path);
while ((t = set_steal_first(u->meta.names)))
free(t);
while ((t = set_steal_first(u->meta.names)))
free(t);
@@
-397,8
+397,8
@@
void unit_dump(Unit *u, FILE *f, const char *prefix) {
prefix, yes_no(u->meta.recursive_stop),
prefix, yes_no(u->meta.stop_when_unneeded));
prefix, yes_no(u->meta.recursive_stop),
prefix, yes_no(u->meta.stop_when_unneeded));
- if (u->meta.
load
_path)
- fprintf(f, "%s\t
Load Path: %s\n", prefix, u->meta.load
_path);
+ if (u->meta.
fragment
_path)
+ fprintf(f, "%s\t
Fragment Path: %s\n", prefix, u->meta.fragment
_path);
SET_FOREACH(t, u->meta.names, i)
fprintf(f, "%s\tName: %s\n", prefix, t);
SET_FOREACH(t, u->meta.names, i)
fprintf(f, "%s\tName: %s\n", prefix, t);
@@
-478,13
+478,18
@@
int unit_start(Unit *u) {
assert(u);
assert(u);
- if (!UNIT_VTABLE(u)->start)
- return -EBADR;
-
+ /* If this is already (being) started, then this will
+ * succeed. Note that this will even succeed if this unit is
+ * not startable by the user. This is relied on to detect when
+ * we need to wait for units and when waiting is finished. */
state = unit_active_state(u);
if (UNIT_IS_ACTIVE_OR_RELOADING(state))
return -EALREADY;
state = unit_active_state(u);
if (UNIT_IS_ACTIVE_OR_RELOADING(state))
return -EALREADY;
+ /* If it is stopped, but we cannot start it, then fail */
+ if (!UNIT_VTABLE(u)->start)
+ return -EBADR;
+
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto
/* We don't suppress calls to ->start() here when we are
* already starting, to allow this request to be used as a
* "hurry up" call, for example when the unit is in some "auto
@@
-511,13
+516,13
@@
int unit_stop(Unit *u) {
assert(u);
assert(u);
- if (!UNIT_VTABLE(u)->stop)
- return -EBADR;
-
state = unit_active_state(u);
if (state == UNIT_INACTIVE)
return -EALREADY;
state = unit_active_state(u);
if (state == UNIT_INACTIVE)
return -EALREADY;
+ if (!UNIT_VTABLE(u)->stop)
+ return -EBADR;
+
if (state == UNIT_DEACTIVATING)
return 0;
if (state == UNIT_DEACTIVATING)
return 0;
@@
-967,16
+972,6
@@
int unit_add_dependency_by_name(Unit *u, UnitDependency d, const char *name) {
return 0;
}
return 0;
}
-const char *unit_path(void) {
- char *e;
-
- if ((e = getenv("UNIT_PATH")))
- if (path_is_absolute(e))
- return e;
-
- return UNIT_PATH;
-}
-
int set_unit_path(const char *p) {
char *cwd, *c;
int r;
int set_unit_path(const char *p) {
char *cwd, *c;
int r;
@@
-997,7
+992,7
@@
int set_unit_path(const char *p) {
return -ENOMEM;
}
return -ENOMEM;
}
- if (setenv("UNIT_PATH", c, 0) < 0) {
+ if (setenv("
SYSTEMD_
UNIT_PATH", c, 0) < 0) {
r = -errno;
free(c);
return r;
r = -errno;
free(c);
return r;
@@
-1006,10
+1001,10
@@
int set_unit_path(const char *p) {
return 0;
}
return 0;
}
-char *unit_name_escape_path(const char *p
refix, const char *p
ath, const char *suffix) {
+char *unit_name_escape_path(const char *path, const char *suffix) {
char *r, *t;
const char *f;
char *r, *t;
const char *f;
- size_t a, b
, c
;
+ size_t a, b;
assert(path);
assert(path);
@@
-1022,22
+1017,16
@@
char *unit_name_escape_path(const char *prefix, const char *path, const char *su
* escaping is hence reversible.
*/
* escaping is hence reversible.
*/
- if (!prefix)
- prefix = "";
-
if (!suffix)
suffix = "";
if (!suffix)
suffix = "";
- a = strlen(prefix);
- b = strlen(path);
- c = strlen(suffix);
+ a = strlen(path);
+ b = strlen(suffix);
- if (!(r = new(char, a
+b*4+c
+1)))
+ if (!(r = new(char, a
*4+b
+1)))
return NULL;
return NULL;
- memcpy(r, prefix, a);
-
- for (f = path, t = r+a; *f; f++) {
+ for (f = path, t = r; *f; f++) {
if (*f == '/')
*(t++) = '.';
else if (*f == '.' || *f == '\\' || !strchr(VALID_CHARS, *f)) {
if (*f == '/')
*(t++) = '.';
else if (*f == '.' || *f == '\\' || !strchr(VALID_CHARS, *f)) {
@@
-1049,7
+1038,7
@@
char *unit_name_escape_path(const char *prefix, const char *path, const char *su
*(t++) = *f;
}
*(t++) = *f;
}
- memcpy(t, suffix,
c
+1);
+ memcpy(t, suffix,
b
+1);
return r;
}
return r;
}