diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-03-20 23:45:47 +0100 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-07-19 20:40:28 +0200 |
commit | c34fcd63f05044f9034b26c52f19c91e04668da7 (patch) | |
tree | 8ef449218cf736057197cd39fba1dac6117216c3 /src/librc/rc.h.in | |
parent | 917a7031d946c0b608517936fab0f54689167265 (diff) |
openrc: dynamic paths for user services
add two api functions, `rc_service_dir` and `rc_sysconf_dir`, both are
generate paths (and sub-paths) for resources, and meant to replace the
hardcoded variables like `RC_SVCDIR`.
those functions differ by dynamically switching between the system path,
or the user path, set in their home folder or runtime directory.
this lays out the intial support for user services.
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/librc/rc.h.in')
-rw-r--r-- | src/librc/rc.h.in | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index 69d9d0e4..59fdfda3 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -34,18 +34,27 @@ extern "C" { #else #define RC_SVCDIR RC_LIBEXECDIR "/init.d" #endif -#define RC_RUNLEVELDIR RC_SYSCONFDIR "/runlevels" -#define RC_INITDIR RC_SYSCONFDIR "/init.d" -#define RC_CONFDIR RC_SYSCONFDIR "/conf.d" + +#define RC_RUNLEVEL_SUBDIR "runlevels" +#define RC_INIT_SUBDIR "init.d" +#define RC_CONF_SUBDIR "conf.d" +#define RC_USER_SUBDIR "user.d" + +#define RC_RUNLEVELDIR RC_SYSCONFDIR "/" RC_RUNLEVEL_SUBDIR +#define RC_INITDIR RC_SYSCONFDIR "/" RC_INIT_SUBDIR +#define RC_CONFDIR RC_SYSCONFDIR "/" RC_CONF_SUBDIR #define RC_PLUGINDIR RC_LIBDIR "/plugins" +#define RC_CONF_FILE "rc.conf" +#define RC_CONF_D_SUBDIR "rc.conf.d" + #define RC_INIT_FIFO RC_SVCDIR"/init.ctl" #define RC_PROFILE_ENV RC_SYSCONFDIR "/profile.env" #define RC_SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist" #define RC_USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist" -#define RC_CONF RC_SYSCONFDIR "/rc.conf" -#define RC_CONF_D RC_SYSCONFDIR "/rc.conf.d" -#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc" +#define RC_CONF RC_SYSCONFDIR "/" RC_CONF_FILE +#define RC_CONF_D RC_SYSCONFDIR "/" RC_CONF_D_SUBDIR +#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc" #define RC_PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" @@ -123,6 +132,10 @@ typedef TAILQ_HEAD(rc_stringlist, rc_string) RC_STRINGLIST; #define RC_LEVEL_SINGLE "single" #define RC_LEVEL_SHUTDOWN "shutdown" +/* !TODO: documentation */ +void rc_set_user(void); +bool rc_is_user(void); + /*! Return the current runlevel. * @return the current runlevel */ char *rc_runlevel_get(void); @@ -192,6 +205,22 @@ typedef enum RC_SERVICE_CRASHED = 0x1000, } RC_SERVICE; +/*! Returns a path to the system configuration directory + * @return path string */ +const char *rc_sysconf_dir(void); + +/*! Returns a path to the current user's configuration directory + * @return path string */ +const char *rc_userconf_dir(void); + +/*! Returns a path to the runlevel directory, systemwide or for the current user + * @return path string */ +const char *rc_runlevel_dir(void); + +/*! Returns a path to the services directory, systemwide or for the current user + * @return path string */ +const char *rc_service_dir(void); + /*! Add the service to the runlevel * @param runlevel to add to * @param service to add |