core: move ManagerRunningAs to shared

Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the
patch quite verbose. Nevertheless, keeping MANAGER prefix in some
places, and SYSTEMD prefix in others would just lead to confusion down
the road. Better to rip off the band-aid now.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2012-09-18 19:53:34 +02:00
parent e872b43c7e
commit 67445f4e22
21 changed files with 105 additions and 108 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ static int lookup_paths_init_from_scope(LookupPaths *paths, UnitFileScope scope)
zero(*paths);
return lookup_paths_init(paths,
scope == UNIT_FILE_SYSTEM ? MANAGER_SYSTEM : MANAGER_USER,
scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,
scope == UNIT_FILE_USER,
NULL, NULL, NULL);
}
+11 -3
View File
@@ -22,6 +22,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
@@ -31,6 +32,13 @@
#include "path-util.h"
#include "path-lookup.h"
static const char* const systemd_running_as_table[_SYSTEMD_RUNNING_AS_MAX] = {
[SYSTEMD_SYSTEM] = "system",
[SYSTEMD_USER] = "user"
};
DEFINE_STRING_TABLE_LOOKUP(systemd_running_as, SystemdRunningAs);
int user_config_home(char **config_home) {
const char *e;
@@ -224,7 +232,7 @@ fail:
int lookup_paths_init(
LookupPaths *p,
ManagerRunningAs running_as,
SystemdRunningAs running_as,
bool personal,
const char *generator,
const char *generator_early,
@@ -256,7 +264,7 @@ int lookup_paths_init(
* for the system stuff but avoid it for user
* stuff. */
if (running_as == MANAGER_USER) {
if (running_as == SYSTEMD_USER) {
if (personal)
p->unit_path = user_dirs(generator, generator_early, generator_late);
@@ -323,7 +331,7 @@ int lookup_paths_init(
p->unit_path = NULL;
}
if (running_as == MANAGER_SYSTEM) {
if (running_as == SYSTEMD_SYSTEM) {
#ifdef HAVE_SYSV_COMPAT
/* /etc/init.d/ compatibility does not matter to users */
+10 -2
View File
@@ -29,9 +29,17 @@ typedef struct LookupPaths {
#endif
} LookupPaths;
#include "manager.h"
typedef enum SystemdRunningAs {
SYSTEMD_SYSTEM,
SYSTEMD_USER,
_SYSTEMD_RUNNING_AS_MAX,
_SYSTEMD_RUNNING_AS_INVALID = -1
} SystemdRunningAs;
const char* systemd_running_as_to_string(SystemdRunningAs i);
SystemdRunningAs systemd_running_as_from_string(const char *s);
int user_config_home(char **config_home);
int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as, bool personal, const char *generator, const char *generator_early, const char *generator_late);
int lookup_paths_init(LookupPaths *p, SystemdRunningAs running_as, bool personal, const char *generator, const char *generator_early, const char *generator_late);
void lookup_paths_free(LookupPaths *p);