Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:jsegitz:staging_o
rpm
private_tmp2.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File private_tmp2.patch of Package rpm
Index: rpm-4.18.0/lib/transaction.c =================================================================== --- rpm-4.18.0.orig/lib/transaction.c +++ rpm-4.18.0/lib/transaction.c @@ -10,6 +10,11 @@ #include <sys/statvfs.h> #include <fcntl.h> +#define _GNU_SOURCE +#include <sched.h> +#include <sys/mount.h> +#include <stdbool.h> + /* duplicated from cpio.c */ #if MAJOR_IN_MKDEV #include <sys/mkdev.h> @@ -65,6 +70,8 @@ struct diskspaceInfo_s { #define adj_fs_blocks(_nb) (((_nb) * 21) / 20) #define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block)) +static bool unshared_namespace=false; + static char *getMntPoint(const char *dirName, dev_t dev) { char mntPoint[PATH_MAX]; @@ -1680,6 +1687,39 @@ rpmRC rpmtsSetupTransactionPlugins(rpmts return rc; } + +static int setupPrivateTempDirectory( void ) +{ + if (!unshared_namespace) { + /* fprintf(stdout, _("setupPrivateTempDirectory unshare\n")); */ + if (unshare(CLONE_NEWNS) < 0) { + rpmlog(RPMLOG_ERR, _("can't unshare mount namespace: %s\n"), strerror(errno)); + return -1; + } + if (mount("/", "/", NULL, MS_REC | MS_PRIVATE, NULL) == -1) { + rpmlog(RPMLOG_ERR, _("can't change mount flags for /: %s\n"), strerror(errno)); + return -1; + } + unshared_namespace=true; + } + /* fprintf(stdout, _("setupPrivateTempDirectory setting up private tmp\n")); */ + if (mount("none", "/tmp", "tmpfs", 0, NULL) == -1) { + rpmlog(RPMLOG_ERR, _("can't mount private tmp: %s\n"), strerror(errno)); + return -1; + } + /* fprintf(stdout, _("setupPrivateTempDirectory done\n")); */ + return 0; +} + +static int teardownPrivateTempDirectory( void ) +{ + if (umount("/tmp") == -1) { + rpmlog(RPMLOG_ERR, _("can't umount private tmp: %s\n"), strerror(errno)); + return -1; + } + return 0; +} + /** * Run a scriptlet with args. * @@ -1719,8 +1759,10 @@ rpmRC runScript(rpmts ts, rpmte te, Head sfd = rpmtsScriptFd(ts); rpmswEnter(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0); + setupPrivateTempDirectory(); rc = rpmScriptRun(script, arg1, arg2, sfd, prefixes, rpmtsPlugins(ts)); + teardownPrivateTempDirectory(); rpmswExit(rpmtsOp(ts, RPMTS_OP_SCRIPTLETS), 0); /* Map warn-only errors to "notfound" for script stop callback */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor