We only want to wait on the context if we created it.
[util-vserver.git] / src / rpm-fake.c
1 // $Id$    --*- c++ -*--
2
3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //  
18
19 #ifdef HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include "pathconfig.h"
24 #include "util.h"
25
26 #include <lib/vserver.h>
27 #include <lib/internal.h>
28 #include <lib_internal/sys_clone.h>
29
30 #include <sys/socket.h>
31 #include <dlfcn.h>
32 #include <stdlib.h>
33 #include <stdint.h>
34 #include <stdio.h>
35 #include <unistd.h>
36 #include <asm/unistd.h>
37 #include <string.h>
38 #include <stdbool.h>
39 #include <errno.h>
40 #include <fcntl.h>
41 #include <stdarg.h>
42 #include <sys/mount.h>
43 #include <linux/fs.h>
44 #include <sched.h>
45 #include <signal.h>
46 #include <sys/types.h>
47 #include <sys/wait.h>
48 #include <sys/un.h>
49 #include <fcntl.h>
50 #include <pwd.h>
51 #include <grp.h>
52
53
54   // from selinux.h
55   // FIXME: add configure autodetection and include <selinux.h> directly
56 int rpm_execcon(unsigned int verified,
57                 const char *filename,
58                 char *const argv[], char *const envp[]);
59
60
61 #define ENSC_WRAPPERS_PREFIX    "rpm-fake.so: "
62 #define ENSC_WRAPPERS_VSERVER   1
63 #define ENSC_WRAPPERS_UNISTD    1
64 #include <wrappers.h>
65
66 #undef _POSIX_SOURCE
67 #include "capability-compat.h"
68
69 #define LIBNAME         "rpm-fake.so"
70 #define PLATFORM_FILE   "/etc/rpm/platform"
71
72 #define INIT(FILE,FUNC) FUNC##_func = ((__typeof__(FUNC) *) (xdlsym(FILE, #FUNC)))
73 #define DECLARE(FUNC)   static __typeof__(FUNC) *       FUNC##_func = 0
74
75 #define DEBUG 1
76
77 #define DBG_INIT        0x0001
78 #define DBG_VARIABLES   0x0002
79 #define DBG_RESOLVER    0x0004
80 #define DBG_EXECV       0x0008
81 #define DBG_ENV         0x0010
82 #define DBG_VERBOSE0    0x8000
83 #define DBG_VERBOSE1    (0x4000 | DBG_VERBOSE0)
84 #define DBG_VERBOSE2    (0x2000 | DBG_VERBOSE1)
85
86 int                     wrapper_exit_code = 255;
87
88 static xid_t            ctx   = VC_NOCTX;
89 static uint32_t         caps  = ~0;
90 static int              flags = 0;
91 static char const *     mnts  = 0;
92 static char const *     root  = 0;
93 static int              pw_sock   = -1;
94 static int              sync_sock = -1;
95 static unsigned int     debug_level = 0;
96
97 static bool             is_initialized = false;
98
99 static bool             ctx_created = false;
100
101   //DECLARE(rpm_execcon);
102   //DECLARE(execv);
103 DECLARE(getpwnam);
104 DECLARE(getgrnam);
105 DECLARE(endpwent);
106 DECLARE(endgrent);
107
108 static void             initRPMFake() __attribute__((__constructor__));
109 static void             exitRPMFake() __attribute__((__destructor__));
110
111 static inline bool
112 isDbgLevel(unsigned int level)
113 {
114   return ((debug_level&level)==level);
115 }
116
117 static void *
118 xdlsym(void *handle, const char *symbol)
119 {
120   void  *res = dlsym(handle, symbol);
121   if (res==0) {
122     char const  *error = dlerror();
123     Vwrite(2, symbol, strlen(symbol));
124     Vwrite(2, ": ", 2);
125     Vwrite(2, error, strlen(error));
126     Vwrite(2, "\n", 2);
127
128     _exit(255);
129   }
130
131   return res;
132 }
133
134 static void
135 showHelp()
136 {
137   WRITE_MSG(1,
138             "Usage: LD_PRELOAD=" LIBNAME " <executable> <args>*\n\n"
139             LIBNAME " unterstands the following environment variables:\n"
140             "  $RPM_FAKE_RESOLVER     ...  program which does the NSS resolving (defaults\n"
141             "                              to " RESOLVER_PROG ")\n"
142             "  $RPM_FAKE_RESOLVER_UID ...  uid of the resolver program\n"
143             "  $RPM_FAKE_RESOLVER_GID ...  gid of the resolver program\n"
144             "  $RPM_FAKE_CTX          ...  vserver context which shall be used for resolver\n"
145             "                              and scriptlets\n"
146             "  $RPM_FAKE_CAP          ...  linux capability remove-mask for the context\n"
147             "  $RPM_FAKE_FLAGS        ...  vserver flags of the context\n"
148             "  $RPM_FAKE_CHROOT       ...  directory of the chroot environment\n"
149             "  $RPM_FAKE_NAMESPACE_MOUNTS\n"
150             "                          ... colon separated list of directories which will\n"
151             "                              umounted before scriptlet execution\n\n"
152             "  $RPM_FAKE_HELP          ... shows this message\n"
153             "  $RPM_FAKE_VERSION       ... shows the version of this program\n\n"
154             "  $RPM_FAKE_DEBUG         ... sets the debuglevel bitmask\n\n"
155             "Please report bugs to " PACKAGE_BUGREPORT "\n");
156   exit(0);
157 }
158
159 static void
160 showVersion()
161 {
162   WRITE_MSG(1,
163             LIBNAME " " VERSION " -- wrapper around rpm\n"
164             "This program is part of " PACKAGE_STRING "\n\n"
165             "Copyright (C) 2003 Enrico Scholz\n"
166             VERSION_COPYRIGHT_DISCLAIMER);
167   exit(0);
168 }
169
170 static void
171 unsetPreloadEnv()
172 {
173   char                  *env = getenv("LD_PRELOAD");
174   char                  *pos;
175
176     // the const <-> non-const assignment is not an issue since the following
177     // modifying operations will not be executed in the const-case
178   env = env ? env : "";
179   pos = strstr(env, LIBNAME);
180
181   if (pos!=0) {
182     char        *end_pos = pos + sizeof(LIBNAME);
183     bool        is_end = (end_pos[-1]=='\0');
184     char        *start_pos;
185
186     end_pos[-1] = '\0';
187     start_pos   = strrchr(env, ':');
188     if (start_pos==0) start_pos = env;
189     else if (!is_end) ++start_pos;
190
191     if (is_end) *start_pos = '\0';
192     else        memmove(start_pos, end_pos, strlen(end_pos)+1);
193   }
194
195 #ifdef DEBUG
196   if (isDbgLevel(DBG_VERBOSE1|DBG_VARIABLES)) {
197     WRITE_MSG(2, "env='");
198     WRITE_STR(2, env);
199     WRITE_MSG(2, "'\n");
200   }
201 #endif
202
203   if (*env=='\0') unsetenv("LD_PRELOAD");
204 }
205
206 static void
207 clearEnv()
208 {
209   if (isDbgLevel(DBG_ENV)) WRITE_MSG(2, "clearEnv()\n");
210   
211   unsetenv("RPM_FAKE_S_CONTEXT_REV");
212   unsetenv("RPM_FAKE_S_CONTEXT_NR");
213   unsetenv("RPM_FAKE_CTX");
214   unsetenv("RPM_FAKE_FLAGS");
215   unsetenv("RPM_FAKE_CHROOT");
216   unsetenv("RPM_FAKE_NAMESPACE_MOUNTS");
217
218   unsetenv("RPM_FAKE_RESOLVER_GID");
219   unsetenv("RPM_FAKE_RESOLVER_UID");
220   unsetenv("RPM_FAKE_RESOLVER");    
221   unsetenv("RPM_FAKE_PWSOCKET");
222
223   unsetenv("RPM_FAKE_DEBUG");
224
225   unsetPreloadEnv();
226 }
227
228 static int
229 getDefaultEnv(char const *key, int dflt)
230 {
231   char          *env = getenv(key);
232   int           res;
233
234   if (env==0 || env[0]=='\0') res = dflt;
235   else                        res = atoi(env);
236
237   return res;
238 }
239
240   /// \returns true iff we are in ctx after leaving this function
241 static bool
242 setupContext(xid_t xid, char const **xid_str)
243 {
244   bool          res = false;
245   
246   if (vc_isSupported(vcFEATURE_MIGRATE)) {
247     xid_t       rc=VC_NOCTX;
248
249     if ((xid==VC_DYNAMIC_XID || !vc_is_dynamic_xid(xid)) &&
250         (rc=vc_ctx_create(xid, NULL))==VC_NOCTX &&
251         errno!=EEXIST) {
252       perror(ENSC_WRAPPERS_PREFIX "vc_ctx_create()");
253       exit(255);
254     }
255
256     if (rc!=VC_NOCTX) {
257       char                      buf[sizeof(xid_t)*3 + 128];
258       size_t                    l;
259       struct vc_ctx_caps        caps;
260       
261       strcpy(buf, "rpm-fake.so #");
262       l = utilvserver_fmt_uint(buf+sizeof("rpm-fake.so #")-1, getppid());
263       Evc_set_vhi_name(rc, vcVHI_CONTEXT, buf, sizeof("rpm-fake.so #")+l-1);
264
265       caps.ccaps =  0ull;
266       caps.cmask = ~0ull;
267       caps.bcaps = ~vc_get_insecurebcaps();
268       caps.bmask = ~0ull;
269       Evc_set_ccaps(rc, &caps);
270       
271         // context will be activated later...
272
273       xid = rc;
274       res = true;
275       ctx_created = true;
276     }
277   }
278
279   if (xid==VC_DYNAMIC_XID)
280     *xid_str = 0;
281   else {
282     char                buf[sizeof(xid_t)*3 + 2];
283     size_t              l;
284     
285     l        = utilvserver_fmt_uint(buf, xid); buf[l] = '\0';
286     *xid_str = strdup(buf);
287   }
288  
289   Ewrite(3, &xid, sizeof xid);
290   return res;
291 }
292
293 #if 0
294 static void
295 initPwSocket()
296 {
297   char const *  sock_name = getenv("RPM_FAKE_PWSOCKET");
298   if (sock_name!=0) {
299     int flag;
300     struct sockaddr_un  addr = {
301       .sun_family = AF_UNIX,
302     };
303
304     strncpy(addr.sun_path, sock_name, sizeof(addr.sun_path)-1);
305     addr.sun_path[sizeof(addr.sun_path)-1]='\0';
306     
307     if ((pw_sock=socket(AF_UNIX, SOCK_STREAM, 0))==-1 ||
308         connect(pw_sock, (struct sockaddr *)(&addr), sizeof addr)==-1 ||
309         (flag=fcntl(pw_sock, F_GETFD))==-1 ||
310         fcntl(pw_sock, F_SETFD, flag | FD_CLOEXEC)==-1) {
311       perror(ENSC_WRAPPERS_PREFIX "error while initializing pw-socket");
312       exit(255);
313     }
314   }
315 }
316 #else
317 static void
318 initPwSocket()
319 {
320   char const *  resolver = getenv("RPM_FAKE_RESOLVER");
321   if (resolver==0) resolver=RESOLVER_PROG;
322   
323   if (resolver!=0 && *resolver!='\0') {
324     int                 res_sock[2];
325     int                 sync_pipe[2];
326     pid_t               pid;
327     char const *        uid=0;
328     char const *        gid=0;
329
330     uid=getenv("RPM_FAKE_RESOLVER_UID");
331     gid=getenv("RPM_FAKE_RESOLVER_GID");
332
333     if (socketpair(AF_UNIX, SOCK_STREAM, 0, res_sock)==-1 ||
334         pipe(sync_pipe)==-1 ||
335         fcntl(res_sock[0],  F_SETFD, FD_CLOEXEC)==-1 ||
336         fcntl(sync_pipe[0], F_SETFD, FD_CLOEXEC)==-1) {
337       perror(ENSC_WRAPPERS_PREFIX "failed to create/initialize resolver-socket or pipe");
338       exit(255);
339     }
340
341     pid = fork();
342     if (pid==-1) {
343       perror(ENSC_WRAPPERS_PREFIX "fork()");
344       exit(255);
345     }
346
347     if (pid==0) {
348       char const        *args[20];
349       char const        **ptr  = args;
350       char const        *env[] = { "HOME=/", "PATH=/bin:/usr/bin", 0 };
351       char const        *xid_str;
352       char              flag_str[ sizeof(flags)*3 + 2];
353       char              caps_str[ sizeof(caps)*3  + 2];
354
355       clearEnv();
356       
357       setsid();
358       dup2(res_sock[1],  0);
359       dup2(res_sock[1],  1);
360       if (sync_pipe[1]!=3) {
361         close(3);
362         dup2(sync_pipe[1], 3);
363         close(sync_pipe[1]);
364       }
365       close(res_sock[1]);
366         /* ... *socket[0] are marked as close-on-exec ...*/
367
368       flag_str[utilvserver_fmt_uint(flag_str, flags)] = '\0';
369       caps_str[utilvserver_fmt_uint(caps_str, caps)]  = '\0';
370
371       *ptr++ = resolver;
372       *ptr++ = "-F"; *ptr++ = flag_str;
373       *ptr++ = "-C"; *ptr++ = caps_str;
374       if (root)  { *ptr++ = "-r"; *ptr++ = ".";   }
375       if (uid)   { *ptr++ = "-u"; *ptr++ = uid;   }
376       if (gid)   { *ptr++ = "-g"; *ptr++ = gid;   }
377
378       if (root) Echdir(root);
379
380       if (setupContext(ctx, &xid_str)) { *ptr++ = "-s"; }
381       else if (xid_str)                { *ptr++ = "-c"; *ptr++ = xid_str; }
382       
383       *ptr++ = 0;
384       execve(resolver, (char **)args, (char **)env);
385       perror(ENSC_WRAPPERS_PREFIX "failed to exec resolver");
386       exit(255);
387     }
388     else {
389       uint8_t           c;
390
391       close(res_sock[1]);
392       close(sync_pipe[1]);
393       pw_sock   = res_sock[0];
394       sync_sock = sync_pipe[0];
395
396       if (read(sync_sock, &ctx, sizeof ctx)!=sizeof(ctx) ||
397           read(sync_sock, &c, 1)!=1 ||
398           write(pw_sock, ".", 1)!=1 ||
399           read(pw_sock, &c,   1)!=1 ||
400           c!='.') {
401         WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "failed to initialize communication with resolver\n");
402         exit(255);
403       }
404
405       if (wait4(pid, 0, WNOHANG,0)==-1) {
406         WRITE_MSG(2, ENSC_WRAPPERS_PREFIX" unexpected initialization-error of resolver\n");
407         exit(255);
408       }
409     }
410   }
411 }
412 #endif
413
414 static void
415 reduceCapabilities()
416 {
417   struct __user_cap_header_struct header;
418   struct __user_cap_data_struct user;
419   
420   header.version = _LINUX_CAPABILITY_VERSION;
421   header.pid     = 0;
422
423   if (capget(&header, &user)==-1) {
424     perror("capget()");
425     exit(wrapper_exit_code);
426   }
427
428   user.effective   &= ~(1<<CAP_MKNOD);
429   user.permitted   &= ~(1<<CAP_MKNOD);
430   user.inheritable &= ~(1<<CAP_MKNOD);
431
432   if (capset(&header, &user)==-1) {
433     perror("capset()");
434     exit(wrapper_exit_code);
435   }
436 }
437
438 static void
439 initEnvironment()
440 {
441   int           syscall_rev;
442   int           syscall_nr;
443   
444   if (is_initialized) return;
445
446   syscall_rev = getDefaultEnv("RPM_FAKE_S_CONTEXT_REV", 0);
447   syscall_nr  = getDefaultEnv("RPM_FAKE_S_CONTEXT_NR",  273);
448   
449 #ifdef VC_ENABLE_API_LEGACY
450   {
451     extern void vc_init_internal_legacy(int ctx_rev, int ctx_number,
452                                         int ipv4_rev, int ipv4_number);
453   
454     vc_init_internal_legacy(syscall_rev, syscall_nr, 3, 274);
455   }
456 #endif
457
458   ctx       = getDefaultEnv("RPM_FAKE_CTX",  VC_DYNAMIC_XID);
459   caps      = getDefaultEnv("RPM_FAKE_CAP",  ~0x3404040f);
460   flags     = getDefaultEnv("RPM_FAKE_FLAGS", 0);
461   root      = getenv("RPM_FAKE_CHROOT");
462   mnts      = getenv("RPM_FAKE_NAMESPACE_MOUNTS");
463   if (mnts && *mnts) mnts = strdup(mnts);
464   else               mnts = 0;
465
466 #if DEBUG
467   if (isDbgLevel(DBG_VERBOSE1))
468     dprintf(2, "ctx=%u, caps=%016x, flags=%016x,\nroot='%s',\nmnts='%s'\n",
469             ctx, caps, flags, root, mnts);
470 #endif
471   
472   is_initialized = true;
473 }
474
475 static void
476 initSymbols()
477 {
478     //INIT(RTLD_NEXT, rpm_execcon);
479     //INIT(RTLD_NEXT, execv);
480   INIT(RTLD_NEXT, getgrnam);
481   INIT(RTLD_NEXT, getpwnam);
482   INIT(RTLD_NEXT, endpwent);
483   INIT(RTLD_NEXT, endgrent);
484 }
485
486 void
487 initRPMFake()
488 {
489   if (getenv("RPM_FAKE_VERSION")) showVersion();
490   if (getenv("RPM_FAKE_HELP"))    showHelp();
491   
492   debug_level = getDefaultEnv("RPM_FAKE_DEBUG", 0);
493
494   if (isDbgLevel(DBG_INIT)) WRITE_MSG(2, ">>>>> initRPMFake <<<<<\n");
495   
496   reduceCapabilities();
497   initSymbols();
498   initEnvironment();
499   initPwSocket();
500
501 #if 0
502   if (isDbgLevel(DBG_VARIABLES|DBG_VERBOSE2)) {
503     
504   }
505 #endif
506 }
507
508 void
509 exitRPMFake()
510
511   if (isDbgLevel(DBG_INIT)) WRITE_MSG(2, ">>>>> exitRPMFake <<<<<\n");
512   if (pw_sock!=-1) {
513     uint8_t     c;
514     if (read(sync_sock, &c, 1)!=1) { /*...*/ }
515     if (write(pw_sock, "Q", 1)!=1) { /*...*/ }
516     if (ctx_created) {
517       if (vc_isSupported(vcFEATURE_VWAIT)) {
518         if (vc_wait_exit(ctx)==-1) { /*...*/ }
519       }
520       else {
521         /* this can race */
522         if (read(sync_sock, &c, 1)!=0) { /*...*/}
523       }
524     }
525   }
526 }
527
528
529   //============   the worker part   ===========
530
531
532 static bool
533 doPwStringRequest(uint32_t *result, char style, char const *name)
534 {
535   uint32_t      len = strlen(name);
536   uint8_t       code;
537   uint8_t       c;
538
539   return (TEMP_FAILURE_RETRY(read (sync_sock, &c, 1))==1 &&
540           TEMP_FAILURE_RETRY(write(pw_sock, &style, 1))==1 &&
541           TEMP_FAILURE_RETRY(write(pw_sock, &len,   sizeof len))==sizeof(len) &&
542           TEMP_FAILURE_RETRY(write(pw_sock, name,   len))==(ssize_t)(len) &&
543           TEMP_FAILURE_RETRY(read (pw_sock, &code,  sizeof code))==sizeof(code) &&
544           TEMP_FAILURE_RETRY(read (pw_sock, result, sizeof *result))==sizeof(*result) &&
545           code!=0);
546 }
547
548 struct passwd *
549 getpwnam(const char * name)
550 {
551   if (pw_sock==-1) return getpwnam_func(name);
552   else {
553     uint32_t                    id;
554     static struct passwd        res = {
555       .pw_passwd = "*",
556       .pw_gid    = -1,
557       .pw_gecos  = "",
558       .pw_dir    = "/",
559       .pw_shell  = "/bin/false"
560     };
561
562     res.pw_name = (char *)(name);
563     if (!doPwStringRequest(&id, 'P', name)) return 0;
564     res.pw_uid = id;
565     
566     return &res;
567   }
568 }
569
570 struct group *
571 getgrnam(const char * name)
572 {
573   if (pw_sock==-1) return getgrnam_func(name);
574   else {
575     uint32_t                    id;
576     static struct group         res = {
577       .gr_passwd = "*",
578       .gr_mem    = 0
579     };
580
581     res.gr_name = (char *)(name);
582     if (!doPwStringRequest(&id, 'G', name)) return 0;
583     res.gr_gid = id;
584
585     return &res;
586   }
587 }
588
589 void
590 endgrent()
591 {
592   if (pw_sock==-1) endgrent_func();
593   TEMP_FAILURE_RETRY(write(pw_sock, "Cg", 2));
594 }
595
596 void
597 endpwent()
598 {
599   if (pw_sock==-1) endpwent_func();
600   TEMP_FAILURE_RETRY(write(pw_sock, "Cp", 2));
601 }
602
603
604 static int
605 execvWorker(char const *path, char * const argv[], char * const envp[])
606 {
607   int           res = -1;
608
609   if (vc_isSupported(vcFEATURE_MIGRATE))
610     res = vc_ctx_migrate(ctx, 0);
611   else {
612 #ifdef VC_ENABLE_API_COMPAT  
613     res = vc_new_s_context(ctx,caps,flags);
614 #else
615     WRITE_MSG(2, ENSC_WRAPPERS_PREFIX "can not change context: migrate kernel feature missing and 'compat' API disabled\n");
616 #endif
617   }
618
619   clearEnv();    
620     
621   if (res!=-1)
622     res=execve(path, argv, envp);
623
624   return res;
625 }
626
627 struct ExecvParams
628 {
629     char const *        path;
630     char * const *      argv;
631     char * const *      envp;
632     char const *        mnts;
633 };
634
635 static int
636 removeNamespaceMountsChild(struct ExecvParams const *params)
637 {
638   char                  buf[strlen(params->mnts)+1], *ptr;
639
640   strcpy(buf, params->mnts);
641   ptr = strtok(buf, ":");
642   while (ptr) {
643     if (umount2(ptr, 0)==-1) {
644         // FIXME: What is the semantic for CLONE_NEWNS? Is it ok that mounts in
645         // chroots are visible only, when chroot is on /dev/root?
646         //
647         // For now, ignore any errors, but future versions should handle them.
648
649         //return -1;
650     }
651     ptr = strtok(0, ":");
652   }
653
654   return execvWorker(params->path, params->argv, params->envp);
655 }
656
657 static int
658 removeNamespaceMounts(char const *path,
659                       char * const argv[], char * const envp[])
660 {
661   if (mnts==0) return execvWorker(path, argv, envp);
662
663   {
664     int                         status;
665     pid_t                       p, pid;
666     struct ExecvParams          params;
667
668     params.path = path;
669     params.argv = argv;
670     params.envp = envp;
671     params.mnts = mnts;
672
673       // the rpmlib signal-handler is still active; use the default one to
674       // make wait4() working...
675     signal(SIGCHLD, SIG_DFL);
676
677 #ifdef NDEBUG
678     pid = sys_clone(CLONE_NEWNS|SIGCHLD|CLONE_VFORK, 0);
679 #else
680     pid = sys_clone(CLONE_NEWNS|SIGCHLD, 0);
681 #endif
682
683     switch (pid) {
684       case -1   :  return -1;
685       case 0    :  _exit(removeNamespaceMountsChild(&params));
686       default   :  break;
687     }
688         
689     while ((p=wait4(pid, &status, 0,0))==-1 &&
690            (errno==EINTR || errno==EAGAIN)) ;
691
692     if (p==-1)   return -1;
693
694     if (WIFEXITED(status))   _exit(WEXITSTATUS(status));
695     if (WIFSIGNALED(status)) kill(getpid(), WTERMSIG(status));
696
697     return -1;
698   }
699 }
700
701
702 int
703 execv(char const *path, char * const argv[])
704 {
705   extern char **environ;
706
707   if (isDbgLevel(DBG_EXECV)) {
708     WRITE_MSG(2, "execv('");
709     WRITE_STR(2, path);
710     WRITE_MSG(2, "', ...)\n");
711   }
712
713   return removeNamespaceMounts(path, argv, environ);
714 }
715
716 int
717 rpm_execcon(unsigned int UNUSED verified,
718             const char *filename,
719             char *const argv[], char *const envp[])
720 {
721   if (isDbgLevel(DBG_EXECV)) {
722     WRITE_MSG(2, "rpm_execcon(..., '");
723     WRITE_STR(2, filename);
724     WRITE_MSG(2, "', ...)\n");
725   }
726
727   return removeNamespaceMounts(filename, argv, envp);
728 }
729
730 int
731 is_selinux_enabled()
732 {
733   return 0;
734 }