summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-08-15 14:06:39 +0100
committerDaniel Golle <daniel@makrotopia.org>2021-08-15 15:16:39 +0100
commit104b49d6ab25a8cf067e6d8d1f2da7defb9876d4 (patch)
tree808957e9fe7e85472599af58ab1ee6364f975cd5
parentff9002fd3e168fe2161e7c6f8697216e2beda5a2 (diff)
downloadprocd-104b49d6ab25a8cf067e6d8d1f2da7defb9876d4.tar.gz
uxc: support config in uvol
In case '/var/state/uxc' exists and is a directory (or symlink pointing to a directory), use that instead of '/etc/uxc'. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--uxc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/uxc.c b/uxc.c
index 35036dd..5163b9a 100644
--- a/uxc.c
+++ b/uxc.c
@@ -37,9 +37,11 @@
#define UXC_VERSION "0.2"
#define OCI_VERSION_STRING "1.0.2"
-#define UXC_CONFDIR "/etc/uxc"
+#define UXC_ETC_CONFDIR "/etc/uxc"
+#define UXC_VOL_CONFDIR "/var/state/uxc"
static bool verbose = false;
+static char *confdir = UXC_ETC_CONFDIR;
struct runtime_state {
struct avl_node avl;
@@ -134,8 +136,14 @@ static int conf_load(void)
glob_t gl;
char *globstr;
void *c, *o;
+ struct stat sb;
+
+ if (!stat(UXC_VOL_CONFDIR, &sb)) {
+ if (sb.st_mode & S_IFDIR)
+ confdir = UXC_VOL_CONFDIR;
+ }
- if (asprintf(&globstr, "%s/*.json", UXC_CONFDIR) == -1)
+ if (asprintf(&globstr, "%s/*.json", confdir) == -1)
return ENOMEM;
blob_buf_init(&conf, 0);
@@ -642,12 +650,12 @@ static int uxc_set(char *name, char *path, bool autostart, bool add, char *pidfi
return ENOTDIR;
}
- ret = mkdir(UXC_CONFDIR, 0755);
+ ret = mkdir(confdir, 0755);
if (ret && errno != EEXIST)
return ret;
- if (asprintf(&fname, "%s/%s.json", UXC_CONFDIR, name) == -1)
+ if (asprintf(&fname, "%s/%s.json", confdir, name) == -1)
return ENOMEM;
f = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0644);