mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-04 20:51:33 +00:00
sysv-generator: handle Provides: for non-virtual facility names
The list of provided facility names as specified via Provides: in the LSB header was originally implemented by adding those facilities to the Names= property via unit_add_name(). In commit95ed3294c6the internal SysV support was replaced by a generator and support for parsing the Names= option had been removed from the unit file parsing in v186. As a result, Provides: for non-virtual facility was dropped when introducing the sysv-generator. Since quite a few SysV init scripts still use that functionality (at least in distros like Debian which have a large body of SysV init scripts), add back support by making those facility names available via symlinks to the unit filename to ensure correct orderings between SysV init scripts which use those facility names. Bug-Debian: https://bugs.debian.org/774335 (cherry picked from commitb7e7184634)
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
d76b52b66d
commit
5bf11a0f2e
@@ -112,6 +112,27 @@ static int add_symlink(const char *service, const char *where) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int add_alias(const char *service, const char *alias) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
assert(service);
|
||||
assert(alias);
|
||||
|
||||
link = strjoin(arg_dest, "/", alias, NULL);
|
||||
if (!link)
|
||||
return log_oom();
|
||||
|
||||
r = symlink(service, link);
|
||||
if (r < 0) {
|
||||
if (errno == EEXIST)
|
||||
return 0;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int generate_unit_file(SysvStub *s) {
|
||||
char **p;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
@@ -462,7 +483,9 @@ static int load_sysv(SysvStub *s) {
|
||||
if (r == 0)
|
||||
continue;
|
||||
|
||||
if (unit_name_to_type(m) != UNIT_SERVICE) {
|
||||
if (unit_name_to_type(m) == UNIT_SERVICE) {
|
||||
r = add_alias(s->name, m);
|
||||
} else {
|
||||
/* NB: SysV targets
|
||||
* which are provided
|
||||
* by a service are
|
||||
|
||||
Reference in New Issue
Block a user