From 66f8107330d3e1ebea6566f4288b8f41d8f36621 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Thu, 9 Mar 2023 16:42:04 -0500 Subject: allow symlinks for .asoundrc (5709) --- src/firejail/fs_home.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index 624e74fe4..ac80456da 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c @@ -185,20 +185,10 @@ static int store_asoundrc(void) { errExit("asprintf"); struct stat s; - if (lstat(src, &s) == 0) { - if (S_ISLNK(s.st_mode)) { - // make sure the real path of the file is inside the home directory - /* coverity[toctou] */ - char *rp = realpath(src, NULL); - if (!rp) { - fprintf(stderr, "Error: Cannot access %s\n", src); - exit(1); - } - if (strncmp(rp, cfg.homedir, strlen(cfg.homedir)) != 0 || rp[strlen(cfg.homedir)] != '/') { - fprintf(stderr, "Error: .asoundrc is a symbolic link pointing to a file outside home directory\n"); - exit(1); - } - free(rp); + if (stat(src, &s) == 0) { + if (s.st_uid != getuid() || s.st_gid != getgid()) { + fwarning(".asoundrc is not owned by the current user, skipping...\n"); + return 0; } // create an empty file as root, and change ownership to user -- cgit v1.2.3-70-g09d2