#include "pathconfig.h"
#include "util.h"
+#include "sys_clone.h"
#include <vserver.h>
+#include <sys/socket.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <stdint.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include <pwd.h>
connect(pw_sock, (struct sockaddr *)(&addr), sizeof addr)==-1 ||
(flag=fcntl(pw_sock, F_GETFD))==-1 ||
fcntl(pw_sock, F_SETFD, flag | FD_CLOEXEC)==-1) {
- perror("error while initializing pw-socket");
+ perror("rpm-fake.so: error while initializing pw-socket");
exit(255);
}
}
setsid();
dup2(res_sock[1], 0);
dup2(res_sock[1], 1);
- dup2(sync_pipe[1], 2);
- close(sync_pipe[1]);
+ if (sync_pipe[1]!=3) {
+ close(3);
+ dup2(sync_pipe[1], 3);
+ close(sync_pipe[1]);
+ }
close(res_sock[1]);
/* ... *socket[0] are marked as close-on-exec ...*/
write(pw_sock, ".", 1)!=1 ||
read(pw_sock, &c, 1)!=1 ||
c!='.') {
- WRITE_MSG(2, "rpm-fake.so: failed to initialize communication with resolver");
+ WRITE_MSG(2, "rpm-fake.so: failed to initialize communication with resolver\n");
+ exit(255);
+ }
+
+ if (wait4(pid, 0, WNOHANG,0)==-1) {
+ WRITE_MSG(2, "rpm-fake.so: unexpected initialization-error of resolver\n");
exit(255);
}
}
#endif
ctx_s = getenv("RPM_FAKE_CTX");
- if (ctx_s) ctx_s = strdup(ctx_s);
+ if (ctx_s && *ctx_s) ctx_s = strdup(ctx_s);
+ else ctx_s = 0;
ctx = getAndClearEnv("RPM_FAKE_CTX", VC_RANDCTX);
caps = getAndClearEnv("RPM_FAKE_CAP", ~0x3404040f);
flags = getAndClearEnv("RPM_FAKE_FLAGS", 0);
root = getenv("RPM_FAKE_CHROOT");
mnts = getenv("RPM_FAKE_NAMESPACE_MOUNTS");
- if (mnts!=0) mnts = strdup(mnts);
+ if (mnts && *mnts) mnts = strdup(mnts);
+ else mnts = 0;
unsetenv("RPM_FAKE_CHROOT");
unsetenv("RPM_FAKE_NAMESPACE_MOUNTS");
void
exitRPMFake()
{
- write(2, ">>>>> exitRPMFake <<<<<\n", 24);
+ if (isDbgLevel(DBG_INIT)) WRITE_MSG(2, ">>>>> exitRPMFake <<<<<\n");
if (pw_sock!=-1) {
uint8_t c;
read(sync_sock, &c, 1);
// make wait4() working...
signal(SIGCHLD, SIG_DFL);
- pid = syscall(__NR_clone, CLONE_NEWNS|SIGCHLD|CLONE_VFORK, 0);
+#ifdef NDEBUG
+ pid = sys_clone(CLONE_NEWNS|SIGCHLD|CLONE_VFORK, 0);
+#else
+ pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0);
+#endif
switch (pid) {
case -1 : return -1;