chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
execute: properly enforce group
[elogind.git]
/
src
/
service.c
diff --git
a/src/service.c
b/src/service.c
index 5c7e62f3b0f3f24cf7430ba5c769891468d23e12..4e3b6e719c5c6eac33d320a0f15d26ac5ba94ae8 100644
(file)
--- a/
src/service.c
+++ b/
src/service.c
@@
-635,7
+635,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
char *d = NULL;
if (chkconfig_description)
char *d = NULL;
if (chkconfig_description)
-
asprintf(&d, "%s %s", chkconfig_description, j
);
+
d = join(chkconfig_description, " ", j, NULL
);
else
d = strdup(j);
else
d = strdup(j);
@@
-805,7
+805,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
char *d = NULL;
if (long_description)
char *d = NULL;
if (long_description)
-
asprintf(&d, "%s %s", long_description, t
);
+
d = join(long_description, " ", t, NULL
);
else
d = strdup(j);
else
d = strdup(j);
@@
-921,7
+921,8
@@
static int service_load_sysv_name(Service *s, const char *name) {
char *path;
int r;
char *path;
int r;
- if (asprintf(&path, "%s/%s", *p, name) < 0)
+ path = join(*p, "/", name, NULL);
+ if (!path)
return -ENOMEM;
assert(endswith(path, ".service"));
return -ENOMEM;
assert(endswith(path, ".service"));
@@
-942,7
+943,8
@@
static int service_load_sysv_name(Service *s, const char *name) {
if (r >= 0 && s->meta.load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
if (r >= 0 && s->meta.load_state == UNIT_STUB) {
/* Try SUSE style boot.* init scripts */
- if (asprintf(&path, "%s/boot.%s", *p, name) < 0)
+ path = join(*p, "/boot.", name, NULL);
+ if (!path)
return -ENOMEM;
/* Drop .service suffix */
return -ENOMEM;
/* Drop .service suffix */
@@
-956,7
+958,8
@@
static int service_load_sysv_name(Service *s, const char *name) {
if (r >= 0 && s->meta.load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */
if (r >= 0 && s->meta.load_state == UNIT_STUB) {
/* Try Frugalware style rc.* init scripts */
- if (asprintf(&path, "%s/rc.%s", *p, name) < 0)
+ path = join(*p, "/rc.", name, NULL);
+ if (!path)
return -ENOMEM;
/* Drop .service suffix */
return -ENOMEM;
/* Drop .service suffix */
@@
-1496,7
+1499,7
@@
static void service_set_state(Service *s, ServiceState state) {
/* For the inactive states unit_notify() will trim the cgroup,
* but for exit we have to do that ourselves... */
/* For the inactive states unit_notify() will trim the cgroup,
* but for exit we have to do that ourselves... */
- if (state == SERVICE_EXITED && s->meta.manager->n_
deserializ
ing <= 0)
+ if (state == SERVICE_EXITED && s->meta.manager->n_
reload
ing <= 0)
cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
if (old_state != state)
cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
if (old_state != state)
@@
-2987,8
+2990,8
@@
static int service_enumerate(Manager *m) {
struct dirent *de;
free(path);
struct dirent *de;
free(path);
- path =
NULL
;
- if (
asprintf(&path, "%s/%s", *p, rcnd_table[i].path) < 0
) {
+ path =
join(*p, "/", rcnd_table[i].path, NULL)
;
+ if (
!path
) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}
@@
-3022,8
+3025,8
@@
static int service_enumerate(Manager *m) {
continue;
free(fpath);
continue;
free(fpath);
- fpath =
NULL
;
- if (
asprintf(&fpath, "%s/%s/%s", *p, rcnd_table[i].path, de->d_name) < 0
) {
+ fpath =
join(path, "/", de->d_name, NULL)
;
+ if (
!path
) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}
@@
-3262,23
+3265,25
@@
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
if (s->main_pid <= 0 && who == KILL_MAIN) {
dbus_set_error(error, BUS_ERROR_NO_SUCH_PROCESS, "No main process to kill");
if (s->main_pid <= 0 && who == KILL_MAIN) {
dbus_set_error(error, BUS_ERROR_NO_SUCH_PROCESS, "No main process to kill");
- return -E
INVAL
;
+ return -E
SRCH
;
}
if (s->control_pid <= 0 && who == KILL_CONTROL) {
dbus_set_error(error, BUS_ERROR_NO_SUCH_PROCESS, "No control process to kill");
}
if (s->control_pid <= 0 && who == KILL_CONTROL) {
dbus_set_error(error, BUS_ERROR_NO_SUCH_PROCESS, "No control process to kill");
- return -E
NOENT
;
+ return -E
SRCH
;
}
}
- if (s->control_pid > 0)
- if (kill(s->control_pid, signo) < 0)
- r = -errno;
+ if (who == KILL_CONTROL || who == KILL_ALL)
+ if (s->control_pid > 0)
+ if (kill(s->control_pid, signo) < 0)
+ r = -errno;
- if (s->main_pid > 0)
- if (kill(s->main_pid, signo) < 0)
- r = -errno;
+ if (who == KILL_MAIN || who == KILL_ALL)
+ if (s->main_pid > 0)
+ if (kill(s->main_pid, signo) < 0)
+ r = -errno;
- if (mode == KILL_CONTROL_GROUP) {
+ if (
who == KILL_ALL &&
mode == KILL_CONTROL_GROUP) {
int q;
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
int q;
if (!(pid_set = set_new(trivial_hash_func, trivial_compare_func)))
@@
-3298,7
+3303,7
@@
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
}
if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
}
if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, false, pid_set)) < 0)
- if (
r != -EAGAIN && r != -ESRCH && r
!= -ENOENT)
+ if (
q != -EAGAIN && q != -ESRCH && q
!= -ENOENT)
r = q;
}
r = q;
}
@@
-3370,6
+3375,10
@@
DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess);
const UnitVTable service_vtable = {
.suffix = ".service",
const UnitVTable service_vtable = {
.suffix = ".service",
+ .sections =
+ "Unit\0"
+ "Service\0"
+ "Install\0",
.show_status = true,
.init = service_init,
.show_status = true,
.init = service_init,