From a119058e87f8b6a25ca5a59e25837410caa118f7 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Tue, 10 Jan 2017 14:19:45 -0500 Subject: copy_file cleanup --- src/firejail/fs.c | 2 +- src/firejail/fs_home.c | 14 +++++++------- src/firejail/ls.c | 8 ++++---- src/firejail/preproc.c | 8 ++++---- src/firejail/pulseaudio.c | 2 +- src/firejail/util.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/firejail/fs.c b/src/firejail/fs.c index e2fc09533..0c643af4a 100644 --- a/src/firejail/fs.c +++ b/src/firejail/fs.c @@ -1129,7 +1129,7 @@ void fs_chroot(const char *rootdir) { fprintf(stderr, "Error: invalid %s file\n", fname); exit(1); } - if (copy_file("/etc/resolv.conf", fname, 0, 0, 0644) == -1) + if (copy_file("/etc/resolv.conf", fname, 0, 0, 0644) == -1) // root needed fprintf(stderr, "Warning: /etc/resolv.conf not initialized\n"); } diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index e4b19d5cc..8a52314ed 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c @@ -47,7 +47,7 @@ static void skel(const char *homedir, uid_t u, gid_t g) { exit(1); } if (stat("/etc/skel/.zshrc", &s) == 0) { - copy_file_as_user("/etc/skel/.zshrc", fname, u, g, 0644); + copy_file_as_user("/etc/skel/.zshrc", fname, u, g, 0644); // regular user fs_logger("clone /etc/skel/.zshrc"); } else { @@ -71,7 +71,7 @@ static void skel(const char *homedir, uid_t u, gid_t g) { exit(1); } if (stat("/etc/skel/.cshrc", &s) == 0) { - copy_file_as_user("/etc/skel/.cshrc", fname, u, g, 0644); + copy_file_as_user("/etc/skel/.cshrc", fname, u, g, 0644); // regular user fs_logger("clone /etc/skel/.cshrc"); } else { @@ -94,7 +94,7 @@ static void skel(const char *homedir, uid_t u, gid_t g) { exit(1); } if (stat("/etc/skel/.bashrc", &s) == 0) { - copy_file_as_user("/etc/skel/.bashrc", fname, u, g, 0644); + copy_file_as_user("/etc/skel/.bashrc", fname, u, g, 0644); // regular user fs_logger("clone /etc/skel/.bashrc"); } free(fname); @@ -123,7 +123,7 @@ static int store_xauthority(void) { return 0; } - copy_file_as_user(src, dest, getuid(), getgid(), 0600); + copy_file_as_user(src, dest, getuid(), getgid(), 0600); // regular user fs_logger2("clone", dest); return 1; // file copied } @@ -163,7 +163,7 @@ static int store_asoundrc(void) { free(rp); } - copy_file_as_user(src, dest, getuid(), getgid(), 0644); + copy_file_as_user(src, dest, getuid(), getgid(), 0644); // regular user fs_logger2("clone", dest); return 1; // file copied } @@ -184,7 +184,7 @@ static void copy_xauthority(void) { exit(1); } - copy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR); + copy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR); // regular user fs_logger2("clone", dest); // delete the temporary file @@ -204,7 +204,7 @@ static void copy_asoundrc(void) { exit(1); } - copy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR); + copy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR); // regular user fs_logger2("clone", dest); // delete the temporary file diff --git a/src/firejail/ls.c b/src/firejail/ls.c index 77eb35f97..1af56751a 100644 --- a/src/firejail/ls.c +++ b/src/firejail/ls.c @@ -336,7 +336,7 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { drop_privs(0); // copy the file - if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) + if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) // already a regular user _exit(1); #ifdef HAVE_GCOV __gcov_flush(); @@ -362,7 +362,7 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { drop_privs(0); // copy the file - if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) + if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) // already a regular user _exit(1); #ifdef HAVE_GCOV __gcov_flush(); @@ -411,7 +411,7 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { drop_privs(0); // copy the file - if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) + if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600)) // already a regular user _exit(1); #ifdef HAVE_GCOV __gcov_flush(); @@ -443,7 +443,7 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) { drop_privs(0); // copy the file - if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) + if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600)) // already a regular user _exit(1); #ifdef HAVE_GCOV __gcov_flush(); diff --git a/src/firejail/preproc.c b/src/firejail/preproc.c index d2db7d3dd..e17f39caa 100644 --- a/src/firejail/preproc.c +++ b/src/firejail/preproc.c @@ -76,12 +76,12 @@ void preproc_mount_mnt_dir(void) { fs_logger2("tmpfs", RUN_MNT_DIR); //copy defaultl seccomp files - copy_file(PATH_SECCOMP_I386, RUN_SECCOMP_I386, getuid(), getgid(), 0644); - copy_file(PATH_SECCOMP_AMD64, RUN_SECCOMP_AMD64, getuid(), getgid(), 0644); + copy_file(PATH_SECCOMP_I386, RUN_SECCOMP_I386, getuid(), getgid(), 0644); // root needed + copy_file(PATH_SECCOMP_AMD64, RUN_SECCOMP_AMD64, getuid(), getgid(), 0644); // root needed if (arg_allow_debuggers) - copy_file(PATH_SECCOMP_DEFAULT_DEBUG, RUN_SECCOMP_CFG, getuid(), getgid(), 0644); + copy_file(PATH_SECCOMP_DEFAULT_DEBUG, RUN_SECCOMP_CFG, getuid(), getgid(), 0644); // root needed else - copy_file(PATH_SECCOMP_DEFAULT, RUN_SECCOMP_CFG, getuid(), getgid(), 0644); + copy_file(PATH_SECCOMP_DEFAULT, RUN_SECCOMP_CFG, getuid(), getgid(), 0644); // root needed // as root, create an empty RUN_SECCOMP_PROTOCOL file create_empty_file_as_root(RUN_SECCOMP_PROTOCOL, 0644); diff --git a/src/firejail/pulseaudio.c b/src/firejail/pulseaudio.c index f0f95a80e..4ec84ec61 100644 --- a/src/firejail/pulseaudio.c +++ b/src/firejail/pulseaudio.c @@ -114,7 +114,7 @@ void pulseaudio_init(void) { char *pulsecfg = NULL; if (asprintf(&pulsecfg, "%s/client.conf", RUN_PULSE_DIR) == -1) errExit("asprintf"); - if (copy_file("/etc/pulse/client.conf", pulsecfg, -1, -1, 0644)) + if (copy_file("/etc/pulse/client.conf", pulsecfg, -1, -1, 0644)) // root needed errExit("copy_file"); FILE *fp = fopen(pulsecfg, "a+"); if (!fp) diff --git a/src/firejail/util.c b/src/firejail/util.c index 2d3563093..763e6b58b 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c @@ -229,7 +229,7 @@ void copy_file_as_user(const char *srcname, const char *destname, uid_t uid, gid drop_privs(0); // copy, set permissions and ownership - int rv = copy_file(srcname, destname, uid, gid, mode); + int rv = copy_file(srcname, destname, uid, gid, mode); // already a regular user if (rv) fprintf(stderr, "Warning: cannot transfer .Xauthority in private home directory\n"); #ifdef HAVE_GCOV -- cgit v1.2.3-70-g09d2