40#include "xbps_api_impl.h"
43pfcexec(
struct xbps_handle *xhp,
const char *file,
const char **argv)
55 if (strcmp(xhp->
rootdir,
"/")) {
56 if ((geteuid() == 0) && (access(
"bin/sh", X_OK) == 0)) {
57 if (chroot(xhp->
rootdir) == -1) {
58 xbps_dbg_printf(
"%s: chroot() "
59 "failed: %s\n", *argv, strerror(errno));
62 if (chdir(
"/") == -1) {
63 xbps_dbg_printf(
"%s: chdir() "
64 "failed: %s\n", *argv, strerror(errno));
70 (void)execv(file, __UNCONST(argv));
77 while (waitpid(child, &status, 0) < 0) {
82 if (!WIFEXITED(status))
85 return WEXITSTATUS(status);
89vfcexec(
struct xbps_handle *xhp,
const char *arg, va_list ap)
92 size_t argv_size, argc;
96 if ((argv = malloc(argv_size *
sizeof(*argv))) == NULL) {
105 if (argc == argv_size) {
107 argv = realloc(argv, argv_size *
sizeof(*argv));
114 arg = va_arg(ap,
const char *);
117 }
while (arg != NULL);
119 retval = pfcexec(xhp, argv[0], argv);
126xbps_file_exec(
struct xbps_handle *xhp,
const char *arg, ...)
132 result = vfcexec(xhp, arg, ap);
char rootdir[XBPS_MAXPATH]
Generic XBPS structure handler for initialization.