void fs_var_lock(void) { if (is_dir("/var/lock")) { if (arg_debug) printf("Mounting tmpfs on /var/lock\n"); if (mount("tmpfs", "/var/lock", "tmpfs", MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=1777,gid=0") < 0) errExit("mounting /lock"); fs_logger("tmpfs /var/lock"); } else { char *lnk = realpath("/var/lock", NULL); if (lnk) { if (!is_dir(lnk)) { // create directory mkdir_attr(lnk, S_IRWXU|S_IRWXG|S_IRWXO, 0, 0); } if (arg_debug) printf("Mounting tmpfs on %s on behalf of /var/lock\n", lnk); if (mount("tmpfs", lnk, "tmpfs", MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=1777,gid=0") < 0) errExit("mounting /var/lock"); free(lnk); fs_logger("tmpfs /var/lock"); } else { fwarning("/var/lock not mounted\n"); dbg_test_dir("/var/lock"); } } }
void fs_var_lock(void) { if (is_dir("/var/lock")) { if (arg_debug) printf("Mounting tmpfs on /var/lock\n"); if (mount("tmpfs", "/var/lock", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) errExit("mounting /lock"); } else { char *lnk = realpath("/var/lock", NULL); if (lnk) { if (!is_dir(lnk)) { // create directory if (mkdir(lnk, S_IRWXU|S_IRWXG|S_IRWXO)) errExit("mkdir"); if (chown(lnk, 0, 0)) errExit("chown"); if (chmod(lnk, S_IRWXU|S_IRWXG|S_IRWXO)) errExit("chmod"); } if (arg_debug) printf("Mounting tmpfs on %s on behalf of /var/lock\n", lnk); if (mount("tmpfs", lnk, "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) errExit("mounting /var/lock"); free(lnk); } else { fprintf(stderr, "Warning: /var/lock not mounted\n"); dbg_test_dir("/var/lock"); } } }
static void mount_dev_shm(void) { mkdir_attr("/dev/shm", 01777, 0, 0); int rv = mount(RUN_DEV_DIR "/shm", "/dev/shm", "none", MS_BIND, "mode=01777,gid=0"); if (rv == -1) { fwarning("cannot mount the old /dev/shm in private-dev\n"); dbg_test_dir(RUN_DEV_DIR "/shm"); empty_dev_shm(); return; } }
void fs_var_tmp(void) { if (!is_link("/var/tmp")) { if (arg_debug) printf("Mounting tmpfs on /var/tmp\n"); if (mount("tmpfs", "/var/tmp", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) errExit("mounting /var/tmp"); } else { fprintf(stderr, "Warning: /var/tmp not mounted\n"); dbg_test_dir("/var/tmp"); } }
void fs_var_tmp(void) { struct stat s; if (stat("/var/tmp", &s) == 0) { if (!is_link("/var/tmp")) { if (arg_debug) printf("Mounting tmpfs on /var/tmp\n"); if (mount("tmpfs", "/var/tmp", "tmpfs", MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME | MS_REC, "mode=1777,gid=0") < 0) errExit("mounting /var/tmp"); fs_logger("tmpfs /var/tmp"); } } else { fwarning("/var/tmp not mounted\n"); dbg_test_dir("/var/tmp"); } }
void fs_dev_shm(void) { uid_t uid = getuid(); // set a new shm only if we started as root if (uid) return; if (is_dir("/dev/shm")) { if (arg_debug) printf("Mounting tmpfs on /dev/shm\n"); if (mount("tmpfs", "/dev/shm", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) errExit("mounting /dev/shm"); } else { char *lnk = get_link("/dev/shm"); if (lnk) { // convert a link such as "../shm" into "/shm" char *lnk2 = lnk; int cnt = 0; while (strncmp(lnk2, "../", 3) == 0) { cnt++; lnk2 = lnk2 + 3; } if (cnt != 0) lnk2 = lnk + (cnt - 1) * 3 + 2; if (!is_dir(lnk2)) { // create directory if (mkdir(lnk2, S_IRWXU|S_IRWXG|S_IRWXO)) errExit("mkdir"); if (chown(lnk2, 0, 0)) errExit("chown"); if (chmod(lnk2, S_IRWXU|S_IRWXG|S_IRWXO)) errExit("chmod"); } if (arg_debug) printf("Mounting tmpfs on %s on behalf of /dev/shm\n", lnk2); if (mount("tmpfs", lnk2, "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=777,gid=0") < 0) errExit("mounting /var/tmp"); free(lnk); } else { fprintf(stderr, "Warning: /dev/shm not mounted\n"); dbg_test_dir("/dev/shm"); } } }
void fs_dev_shm(void) { uid_t uid = getuid(); // set a new shm only if we started as root if (uid) return; if (is_dir("/dev/shm")) { if (arg_debug) printf("Mounting tmpfs on /dev/shm\n"); if (mount("tmpfs", "/dev/shm", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=1777,gid=0") < 0) errExit("mounting /dev/shm"); fs_logger("tmpfs /dev/shm"); } else { char *lnk = realpath("/dev/shm", NULL); if (lnk) { if (!is_dir(lnk)) { // create directory if (mkdir(lnk, 01777)) errExit("mkdir"); // mkdir sets only the file permission bits if (chmod(lnk, 01777)) errExit("chmod"); ASSERT_PERMS(lnk, 0, 0, 01777); } if (arg_debug) printf("Mounting tmpfs on %s on behalf of /dev/shm\n", lnk); if (mount("tmpfs", lnk, "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=1777,gid=0") < 0) errExit("mounting /var/tmp"); fs_logger2("tmpfs", lnk); free(lnk); } else { fprintf(stderr, "Warning: /dev/shm not mounted\n"); dbg_test_dir("/dev/shm"); } } }