X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Frpm-fake.c;h=26c5fa8cbd04cb9babe03281b71b47d27597ce8e;hb=4ccc41ab34bc162da50e9b2ebf72f3aa89a05566;hp=2c1310639fca46623a44620571a6fc0a1646ed94;hpb=9c78378bebc1a9f3d400f422df8ede9efea57dea;p=util-vserver.git diff --git a/src/rpm-fake.c b/src/rpm-fake.c index 2c13106..26c5fa8 100644 --- a/src/rpm-fake.c +++ b/src/rpm-fake.c @@ -66,10 +66,6 @@ int rpm_execcon(unsigned int verified, #undef _POSIX_SOURCE #include "capability-compat.h" -#ifndef CLONE_NEWNS -# define CLONE_NEWNS 0x00020000 -#endif - #define LIBNAME "rpm-fake.so" #define PLATFORM_FILE "/etc/rpm/platform" @@ -100,6 +96,8 @@ static unsigned int debug_level = 0; static bool is_initialized = false; +static bool ctx_created = false; + //DECLARE(rpm_execcon); //DECLARE(execv); DECLARE(getpwnam); @@ -249,9 +247,9 @@ setupContext(xid_t xid, char const **xid_str) xid_t rc=VC_NOCTX; if ((xid==VC_DYNAMIC_XID || !vc_is_dynamic_xid(xid)) && - (rc=vc_ctx_create(xid))==VC_NOCTX && + (rc=vc_ctx_create(xid, NULL))==VC_NOCTX && errno!=EEXIST) { - perror(ENSC_WRAPPERS_PREFIX "vc_create_context()"); + perror(ENSC_WRAPPERS_PREFIX "vc_ctx_create()"); exit(255); } @@ -259,6 +257,7 @@ setupContext(xid_t xid, char const **xid_str) char buf[sizeof(xid_t)*3 + 128]; size_t l; struct vc_ctx_caps caps; + struct vc_ctx_flags flags; strcpy(buf, "rpm-fake.so #"); l = utilvserver_fmt_uint(buf+sizeof("rpm-fake.so #")-1, getppid()); @@ -269,11 +268,16 @@ setupContext(xid_t xid, char const **xid_str) caps.bcaps = ~vc_get_insecurebcaps(); caps.bmask = ~0ull; Evc_set_ccaps(rc, &caps); + + flags.flagword = 0; + flags.mask = VC_VXF_SC_HELPER; + Evc_set_cflags(rc, &flags); // context will be activated later... xid = rc; res = true; + ctx_created = true; } } @@ -514,6 +518,15 @@ exitRPMFake() uint8_t c; if (read(sync_sock, &c, 1)!=1) { /*...*/ } if (write(pw_sock, "Q", 1)!=1) { /*...*/ } + if (ctx_created) { + if (vc_isSupported(vcFEATURE_VWAIT)) { + if (vc_wait_exit(ctx)==-1) { /*...*/ } + } + else { + /* this can race */ + if (read(sync_sock, &c, 1)!=0) { /*...*/} + } + } } } @@ -599,7 +612,7 @@ execvWorker(char const *path, char * const argv[], char * const envp[]) int res = -1; if (vc_isSupported(vcFEATURE_MIGRATE)) - res = vc_ctx_migrate(ctx); + res = vc_ctx_migrate(ctx, 0); else { #ifdef VC_ENABLE_API_COMPAT res = vc_new_s_context(ctx,caps,flags);