From 113038bceda865c61f55d10a56e287dba4f72a52 Mon Sep 17 00:00:00 2001 From: smitsohu Date: Fri, 12 Jul 2019 11:19:22 +0200 Subject: private-home: remove redundancy --- src/firejail/fs_home.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index 01a807883..75c4b7da3 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c @@ -272,7 +272,7 @@ void fs_private_homedir(void) { MountData *mptr = get_last_mount(); size_t len = strlen(homedir); if (strncmp(mptr->dir, homedir, len) != 0 || - (*(mptr->dir + len) != '\0' && *(mptr->dir + len) != '/')) + (*(mptr->dir + len) != '\0' && *(mptr->dir + len) != '/')) errLogExit("invalid private mount"); fs_logger3("mount-bind", private_homedir, homedir); @@ -443,17 +443,15 @@ static char *check_dir_or_file(const char *name) { goto errexit; } else { - // check the file is in user home directory, a full home directory is not allowed + // check the file is in user home directory char *rname = realpath(fname, NULL); - if (!rname || - strncmp(rname, cfg.homedir, strlen(cfg.homedir)) != 0 || - strcmp(rname, cfg.homedir) == 0) + if (!rname || strncmp(rname, cfg.homedir, strlen(cfg.homedir)) != 0) goto errexit; - - // only top files and directories in user home are allowed + // a full home directory is not allowed char *ptr = rname + strlen(cfg.homedir); if (*ptr != '/') goto errexit; + // only top files and directories in user home are allowed ptr = strchr(++ptr, '/'); if (ptr) { fprintf(stderr, "Error: only top files and directories in user home are allowed\n"); -- cgit v1.2.3-70-g09d2