static bool is_initialized = false;
+static bool ctx_created = false;
+
//DECLARE(rpm_execcon);
//DECLARE(execv);
DECLARE(getpwnam);
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);
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());
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;
}
}
static void
reduceCapabilities()
{
+ int retried = 0;
struct __user_cap_header_struct header;
- struct __user_cap_data_struct user;
+ struct __user_cap_data_struct user[2];
- header.version = _LINUX_CAPABILITY_VERSION;
+ header.version = _LINUX_CAPABILITY_VERSION_3;
header.pid = 0;
- if (capget(&header, &user)==-1) {
+retry:
+ if (capget(&header, user)==-1) {
+ if (!retried &&
+ header.version != _LINUX_CAPABILITY_VERSION_3) {
+ header.version = _LINUX_CAPABILITY_VERSION_1;
+ retried = 1;
+ goto retry;
+ }
perror("capget()");
exit(wrapper_exit_code);
}
- user.effective &= ~(1<<CAP_MKNOD);
- user.permitted &= ~(1<<CAP_MKNOD);
- user.inheritable &= ~(1<<CAP_MKNOD);
+ user[0].effective &= ~(1<<CAP_MKNOD);
+ user[0].permitted &= ~(1<<CAP_MKNOD);
+ user[0].inheritable &= ~(1<<CAP_MKNOD);
- if (capset(&header, &user)==-1) {
+ if (capset(&header, user)==-1) {
perror("capset()");
exit(wrapper_exit_code);
}
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) { /*...*/}
+ }
+ }
}
}
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);