]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Revert "ucm: confine sysw and cfg-save paths with realpath()"
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 Oct 2026 07:13:19 +0000 (09:13 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 Oct 2026 13:53:40 +0000 (15:53 +0200)
This reverts commit a47c8bc3fef190e7eb463283230263c82208597a.

The sysw change is too expensive and cfg-save saves data to /var/lib/alsa tree.

Link: https://github.com/alsa-project/alsa-lib/pull/527
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/ucm/main.c

index b27e71f0a0059a863eb345a3a1fe209149fae992..d2b3c2d93b82167edc4937de1be77d6bfbda4196 100644 (file)
@@ -523,20 +523,6 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
        return err;
 }
 
-static bool check_realpath(const char *path, const char *target)
-{
-       char *resolved = realpath(path, NULL);
-
-       if (!resolved)
-               return false;
-       if (strncmp(resolved, target, strlen(target)) != 0) {
-               free(resolved);
-               return false;
-       }
-       free(resolved);
-       return true;
-}
-
 static int execute_sysw(const char *sysw)
 {
        char path[PATH_MAX];
@@ -584,12 +570,6 @@ static int execute_sysw(const char *sysw)
        }
        snprintf(path, sizeof(path), "%s/%s", e, s);
 
-       if (!check_realpath(path, e)) {
-               free(s);
-               snd_error(UCM, "sysw path escapes sysfs root: '%s'", path);
-               return -EINVAL;
-       }
-
        fd = open(path, O_WRONLY|O_CLOEXEC);
        if (fd < 0) {
                free(s);
@@ -623,7 +603,6 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
        snd_config_t *config = uc_mgr->local_config;
        char *file, *root;
        snd_output_t *out;
-       const char *runtime;
        bool with_root = false;
        int err = 0;
 
@@ -646,13 +625,6 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
                }
        }
 
-       runtime = getenv("XDG_RUNTIME_DIR");
-       if (!runtime)
-               runtime = "/tmp";
-       if (!check_realpath(file, runtime)) {
-               snd_error(UCM, "cfg-save path escapes runtime dir: '%s'", file);
-               return -EINVAL;
-       }
        err = snd_output_stdio_open(&out, file, "w+");
        if (err < 0) {
                snd_error(UCM, "unable to open file '%s': %s", file, snd_strerror(err));