Revert "xbps-uchroot: make sure to cleanup tempdir with overlayfs."

This reverts commit f6a6385b42.

Does not work as expected, and does not fix the real issue
which is still not understood.
This commit is contained in:
Juan RP 2020-02-08 20:43:23 +01:00
parent c4019aa923
commit 71a594f681
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2020 Juan Romero Pardines. * Copyright (c) 2014-2015 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -109,34 +109,22 @@ die(const char *fmt, ...)
} }
static int static int
ftw_perms_cb(const char *fpath, const struct stat *sb UNUSED, ftw_cb(const char *fpath, const struct stat *sb UNUSED, int type,
int type UNUSED, struct FTW *ftwbuf UNUSED) struct FTW *ftwbuf UNUSED)
{ {
chmod(fpath, 0755); int sverrno = 0;
return 0;
}
static int if (type == FTW_F || type == FTW_SL || type == FTW_SLN) {
ftw_cb(const char *fpath, const struct stat *sb UNUSED, if (unlink(fpath) == -1)
int type UNUSED, struct FTW *ftwbuf UNUSED) sverrno = errno;
{ } else if (type == FTW_D || type == FTW_DNR || type == FTW_DP) {
switch (type) { if (rmdir(fpath) == -1)
case FTW_F: sverrno = errno;
case FTW_SL: } else {
case FTW_SLN: return 0;
if (unlink(fpath) != 0) { }
fprintf(stderr, "failed to remove %s: %s\n", fpath, strerror(errno)); if (sverrno != 0) {
} fprintf(stderr, "Failed to remove %s: %s\n", fpath, strerror(sverrno));
break;
case FTW_D:
case FTW_DP:
case FTW_DNR:
if (rmdir(fpath) != 0) {
fprintf(stderr, "failed to remove %s: %s\n", fpath, strerror(errno));
}
break;
default:
break;
} }
return 0; return 0;
} }
@ -144,39 +132,17 @@ ftw_cb(const char *fpath, const struct stat *sb UNUSED,
static void static void
cleanup_overlayfs(void) cleanup_overlayfs(void)
{ {
char *workdir;
if (tmpdir == NULL) if (tmpdir == NULL)
return; return;
if (!overlayfs_on_tmpfs) { if (!overlayfs_on_tmpfs) {
/* /* recursively remove the temporary dir */
* nftw() runs twice because the first run if (nftw(tmpdir, ftw_cb, 20, FTW_MOUNT|FTW_PHYS|FTW_DEPTH) != 0) {
* chmods all files and directories to be 755,
* so that second run can remove all them.
*
* Go modules in xbps-src seem to have too
* restrictive permissions and this cleans up
* this mess.
*/
if (nftw(tmpdir, ftw_perms_cb, 256, FTW_MOUNT|FTW_PHYS|FTW_DEPTH) != 0) {
fprintf(stderr, "Failed to remove directory tree %s: %s\n",
tmpdir, strerror(errno));
exit(EXIT_FAILURE);
}
if (nftw(tmpdir, ftw_cb, 256, FTW_MOUNT|FTW_PHYS|FTW_DEPTH) != 0) {
fprintf(stderr, "Failed to remove directory tree %s: %s\n", fprintf(stderr, "Failed to remove directory tree %s: %s\n",
tmpdir, strerror(errno)); tmpdir, strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
workdir = xbps_xasprintf("%s/workdir/work", tmpdir);
chmod(workdir, 0755);
rmdir(workdir);
free(workdir);
workdir = xbps_xasprintf("%s/workdir", tmpdir);
rmdir(workdir);
free(workdir);
rmdir(tmpdir); rmdir(tmpdir);
} }
@ -376,16 +342,17 @@ main(int argc, char **argv)
die("failed to create tmpdir directory"); die("failed to create tmpdir directory");
if (chown(tmpdir, ruid, rgid) == -1) if (chown(tmpdir, ruid, rgid) == -1)
die("chown tmpdir %s", tmpdir); die("chown tmpdir %s", tmpdir);
/*
* Register a signal handler to clean up temporary masterdir.
*/
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sighandler_cleanup;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
} }
/*
* Register a signal handler to clean up temporary masterdir.
*/
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sighandler_cleanup;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
clone_flags = (SIGCHLD|CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID); clone_flags = (SIGCHLD|CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID);
container_flags = clone_flags & ~(CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID); container_flags = clone_flags & ~(CLONE_NEWNS|CLONE_NEWIPC|CLONE_NEWUTS|CLONE_NEWPID);