X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fnamespace.c;h=7e33d84156348497d574308a7557f7e330aa9b7f;hp=ceeed2e1aede3ed09f143620eeb2fecf1cb5422b;hb=abb26902e424c4142b68ead35676028b12249b77;hpb=c17ec25e4d9bd6c8e8617416f813e25b2ebbafc5 diff --git a/src/core/namespace.c b/src/core/namespace.c index ceeed2e1a..7e33d8415 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -183,22 +183,20 @@ int setup_tmpdirs(char **tmp_dir, assert(tmp_dir); assert(var_tmp_dir); - r = create_tmp_dir(tmp_dir_template, 0000, true, tmp_dir); + r = create_tmp_dir(tmp_dir_template, tmp_dir); if (r < 0) - goto fail2; + return r; - r = create_tmp_dir(var_tmp_dir_template, 0000, true, var_tmp_dir); - if (r < 0) - goto fail1; - - return 0; + r = create_tmp_dir(var_tmp_dir_template, var_tmp_dir); + if (r == 0) + return 0; -fail1: + /* failure */ rmdir(*tmp_dir); + rmdir(tmp_dir_template); free(*tmp_dir); *tmp_dir = NULL; -fail2: return r; } @@ -220,16 +218,14 @@ int setup_namespace(char** read_write_dirs, if (!mount_flags) mount_flags = MS_SHARED; - if (unshare(CLONE_NEWNS) < 0) { - r = -errno; - goto fail; - } + if (unshare(CLONE_NEWNS) < 0) + return -errno; m = mounts = (BindMount *) alloca(n * sizeof(BindMount)); if ((r = append_mounts(&m, read_write_dirs, READWRITE)) < 0 || (r = append_mounts(&m, read_only_dirs, READONLY)) < 0 || (r = append_mounts(&m, inaccessible_dirs, INACCESSIBLE)) < 0) - goto fail; + return r; if (private_tmp) { m->path = "/tmp"; @@ -248,10 +244,8 @@ int setup_namespace(char** read_write_dirs, /* Remount / as SLAVE so that nothing now mounted in the namespace shows up in the parent */ - if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { - r = -errno; - goto fail; - } + if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) + return -errno; for (m = mounts; m < mounts + n; ++m) { r = apply_mount(m, tmp_dir, var_tmp_dir); @@ -279,6 +273,5 @@ undo_mounts: umount2(m->path, MNT_DETACH); } -fail: return r; }