X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Frpm-fake.c;h=dbb4b4c12e23762cd6c823d7f6a1b8c09dd04edd;hb=bea242e7bfd39989a3a748aea2577f831986fcbf;hp=eb1d7211c0bd5baa7adc8eee45f17c707babfeba;hpb=a7079774d8c30a1a2eafce390b1f1689fb2f1539;p=util-vserver.git diff --git a/src/rpm-fake.c b/src/rpm-fake.c index eb1d721..dbb4b4c 100644 --- a/src/rpm-fake.c +++ b/src/rpm-fake.c @@ -96,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); @@ -245,7 +247,7 @@ 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_ctx_create()"); exit(255); @@ -270,6 +272,7 @@ setupContext(xid_t xid, char const **xid_str) xid = rc; res = true; + ctx_created = true; } } @@ -510,6 +513,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) { /*...*/} + } + } } } @@ -595,7 +607,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);