mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-24 01:58:05 +07:00
service: when resolving sysv names drop leading $
This commit is contained in:
parent
15917fb09b
commit
a7d3cc26f9
6
fixme
6
fixme
@ -97,7 +97,11 @@
|
|||||||
|
|
||||||
* LSB provides should only create targets, never aliases
|
* LSB provides should only create targets, never aliases
|
||||||
|
|
||||||
* s/tempfiles/volatile-files/
|
* stability promise must say that #ifdef TARGET_XXX style distro compatibility will go away one day
|
||||||
|
|
||||||
|
* drop empty assignments for parse_env_file
|
||||||
|
|
||||||
|
* #include "fanotify.h"
|
||||||
|
|
||||||
External:
|
External:
|
||||||
|
|
||||||
|
@ -252,48 +252,62 @@ static char *sysv_translate_name(const char *name) {
|
|||||||
|
|
||||||
static int sysv_translate_facility(const char *name, char **_r) {
|
static int sysv_translate_facility(const char *name, char **_r) {
|
||||||
|
|
||||||
|
/* We silently ignore the $ prefix here. According to the LSB
|
||||||
|
* spec it simply indicates whether something is a
|
||||||
|
* standardized name or a distribution-specific one. Since we
|
||||||
|
* just follow what already exists and do not introduce new
|
||||||
|
* uses or names we don't care who introduced a new name. */
|
||||||
|
|
||||||
static const char * const table[] = {
|
static const char * const table[] = {
|
||||||
/* LSB defined facilities */
|
/* LSB defined facilities */
|
||||||
"$local_fs", SPECIAL_LOCAL_FS_TARGET,
|
"local_fs", SPECIAL_LOCAL_FS_TARGET,
|
||||||
"$network", SPECIAL_NETWORK_TARGET,
|
"network", SPECIAL_NETWORK_TARGET,
|
||||||
"$named", SPECIAL_NSS_LOOKUP_TARGET,
|
"named", SPECIAL_NSS_LOOKUP_TARGET,
|
||||||
"$portmap", SPECIAL_RPCBIND_TARGET,
|
"portmap", SPECIAL_RPCBIND_TARGET,
|
||||||
"$remote_fs", SPECIAL_REMOTE_FS_TARGET,
|
"remote_fs", SPECIAL_REMOTE_FS_TARGET,
|
||||||
"$syslog", SPECIAL_SYSLOG_TARGET,
|
"syslog", SPECIAL_SYSLOG_TARGET,
|
||||||
"$time", SPECIAL_RTC_SET_TARGET,
|
"time", SPECIAL_RTC_SET_TARGET,
|
||||||
|
|
||||||
/* Debian extensions */
|
/* Debian extensions */
|
||||||
#ifdef TARGET_DEBIAN
|
#ifdef TARGET_DEBIAN
|
||||||
"$mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
"mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
||||||
#endif
|
#endif
|
||||||
"$mail-transfer-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
"mail-transfer-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
||||||
"$x-display-manager", SPECIAL_DISPLAY_MANAGER_SERVICE,
|
"x-display-manager", SPECIAL_DISPLAY_MANAGER_SERVICE,
|
||||||
|
|
||||||
#ifdef TARGET_FEDORA
|
#ifdef TARGET_FEDORA
|
||||||
/* Fedora extensions, lacking the $ prefix */
|
/* Fedora extensions */
|
||||||
"MTA", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
"MTA", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
||||||
"smtpdaemon", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
"smtpdaemon", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
|
||||||
"httpd", SPECIAL_HTTP_DAEMON_TARGET,
|
"httpd", SPECIAL_HTTP_DAEMON_TARGET,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* SuSE extensions */
|
||||||
|
"null", NULL
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char *r;
|
char *r;
|
||||||
|
|
||||||
/* SuSE insserv extension */
|
|
||||||
if (streq(name, "$null"))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < ELEMENTSOF(table); i += 2)
|
for (i = 0; i < ELEMENTSOF(table); i += 2)
|
||||||
if (streq(table[i], name)) {
|
|
||||||
|
if (streq(table[i], name) ||
|
||||||
|
(*name == '$' && streq(table[i], name+1))) {
|
||||||
|
|
||||||
|
if (!table[i+1])
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!(r = strdup(table[i+1])))
|
if (!(r = strdup(table[i+1])))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we don't know this name, fallback heuristics to figure
|
||||||
|
* out whether something is a target or an service alias. */
|
||||||
|
|
||||||
if (*name == '$')
|
if (*name == '$')
|
||||||
/* This is a heuristic. */
|
|
||||||
r = unit_name_build(name+1, NULL, ".target");
|
r = unit_name_build(name+1, NULL, ".target");
|
||||||
else
|
else
|
||||||
r = sysv_translate_name(name);
|
r = sysv_translate_name(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user