aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-06-09 20:46:47 -0300
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-10-19 10:56:54 +0200
commit5a1cd9545164d978ded996ac6d673fd6d480a2fe (patch)
tree1002f7bdfb5b823aa8cdbe4502ebcb61bba97e7e /src/shared
parentb8613baa85965cbdf5fbe262b9464d5c0d98614f (diff)
openrc: rework pathing functions
this simplifies the allocation of path string. also fixes some memory leaks from the ealier commit also changes the log path for users to XDG_CACHE_HOME, default ~/.cache/openrc Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/misc.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/src/shared/misc.c b/src/shared/misc.c
index 9b40ce36..fbb50b59 100644
--- a/src/shared/misc.c
+++ b/src/shared/misc.c
@@ -259,21 +259,11 @@ svc_lock(const char *applet, bool ignore_lock_failure)
{
char *file = NULL;
int fd;
- char *svcdir = RC_SVCDIR;
-
-#ifdef RC_USER_SERVICES
- if (rc_is_user()) {
- svcdir = rc_user_svcdir();
- }
-#endif
+ char *svcdir = rc_svcdir();
xasprintf(&file, "%s/exclusive/%s", svcdir, applet);
-#ifdef RC_USER_SERVICES
- if (rc_is_user()) {
- free(svcdir);
- }
-#endif
+ free(svcdir);
fd = open(file, O_WRONLY | O_CREAT | O_NONBLOCK, 0664);
free(file);
@@ -299,21 +289,11 @@ int
svc_unlock(const char *applet, int fd)
{
char *file = NULL;
- char *svcdir = RC_SVCDIR;
-
-#ifdef RC_USER_SERVICES
- if (rc_is_user()) {
- svcdir = rc_user_svcdir();
- }
-#endif
+ char *svcdir = rc_svcdir();
xasprintf(&file, "%s/exclusive/%s", svcdir, applet);
-#ifdef RC_USER_SERVICES
- if (rc_is_user()) {
- free(svcdir);
- }
-#endif
+ free(svcdir);
close(fd);
unlink(file);
@@ -425,17 +405,14 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen)
struct stat st;
struct utimbuf ut;
FILE *fp;
- char *cache = RC_DEPTREE_CACHE;
- char *skew = RC_DEPTREE_SKEWED;
-#ifdef RC_USER_SERVICES
- char *user_svcdir;
- if (rc_is_user()) {
- user_svcdir = rc_user_svcdir();
- xasprintf(&cache, "%s%s", user_svcdir, RC_DEPTREE_CACHE_FILE);
- xasprintf(&skew, "%s%s", user_svcdir, RC_DEPTREE_SKEWED_FILE);
- free(user_svcdir);
- }
-#endif
+ char *cache = NULL;
+ char *skew = NULL;
+ char *svcdir = rc_svcdir();
+
+ xasprintf(&cache, "%s%s", svcdir, RC_DEPTREE_CACHE_FILE);
+ xasprintf(&skew, "%s%s", svcdir, RC_DEPTREE_SKEWED_FILE);
+
+ free(svcdir);
t = 0;
if (rc_deptree_update_needed(&t, file) || force != 0) {