data.orig = orig;
data.new = new;
if (am_unpriv())
- ret = userns_exec_1(c0->lxc_conf, rsync_rootfs_wrapper, &data);
+ ret = userns_exec_1(c0->lxc_conf, rsync_rootfs_wrapper, &data, "rsync_rootfs_wrapper");
else
ret = rsync_rootfs(&data);
rdata.src = odelta;
rdata.dest = ndelta;
if (am_unpriv())
- ret = userns_exec_1(conf, rsync_delta_wrapper, &rdata);
+ ret = userns_exec_1(conf, rsync_delta_wrapper, &rdata,
+ "rsync_delta_wrapper");
else
ret = rsync_delta(&rdata);
if (ret) {
return btrfs_snapshot(orig->dest, new->dest);
sdata.dest = new->dest;
sdata.src = orig->dest;
- return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata);
+ return userns_exec_1(conf, btrfs_snapshot_wrapper, &sdata,
+ "btrfs_snapshot_wrapper");
}
if (rmdir(new->dest) < 0 && errno != ENOENT) {
rdata.orig = orig;
rdata.new = new;
if (am_unpriv())
- ret = userns_exec_1(conf, ovl_rsync_wrapper, &rdata);
+ ret = userns_exec_1(conf, ovl_rsync_wrapper, &rdata,
+ "ovl_rsync_wrapper");
else
ret = ovl_rsync(&rdata);
if (ret)
return 0;
if (recurse) {
if (conf && !lxc_list_empty(&conf->id_map))
- r = userns_exec_1(conf, rmdir_wrapper, buf);
+ r = userns_exec_1(conf, rmdir_wrapper, buf,
+ "rmdir_wrapper");
else
r = cgroup_rmdir(buf);
} else
/* Unpriv users can't chown it themselves, so chown from
* a child namespace mapping both our own and the target uid
*/
- if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
+ if (userns_exec_1(conf, chown_cgroup_wrapper, &data,
+ "chown_cgroup_wrapper") < 0) {
ERROR("Error requesting cgroup chown in new namespace");
return false;
}
{
int r;
if (conf && !lxc_list_empty(&conf->id_map))
- r = userns_exec_1(conf, rmdir_wrapper, path);
+ r = userns_exec_1(conf, rmdir_wrapper, path, "rmdir_wrapper");
else
r = cgroup_rmdir(path);
wrap.d = d;
wrap.origuid = geteuid();
- if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap) < 0) {
+ if (userns_exec_1(conf, chown_cgroup_wrapper, &wrap,
+ "chown_cgroup_wrapper") < 0) {
ERROR("Error requesting cgroup chown in new namespace");
return false;
}
/* Unpriv users can't chown it themselves, so chown from
* a child namespace mapping both our own and the target uid
*/
- if (userns_exec_1(conf, chown_cgroup_wrapper, &data) < 0) {
+ if (userns_exec_1(conf, chown_cgroup_wrapper, &data,
+ "chown_cgroup_wrapper") < 0) {
ERROR("Error requesting cgroup chown in new namespace");
return false;
}
struct userns_fn_data {
int (*fn)(void *);
+ const char *fn_name;
void *arg;
int p[2];
};
/* Close read end of the pipe. */
close(d->p[0]);
+ if (d->fn_name)
+ TRACE("calling function \"%s\"", d->fn_name);
/* Call function to run. */
return d->fn(d->arg);
}
* retrieve from the ontainer's configured {g,u}id mappings as it must have been
* there to start the container in the first place.
*/
-int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data)
+int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
+ const char *fn_name)
{
pid_t pid;
uid_t euid, egid;
return -1;
}
d.fn = fn;
+ d.fn_name = fn_name;
d.arg = data;
d.p[0] = p[0];
d.p[1] = p[1];
extern int mapped_hostid(unsigned id, struct lxc_conf *conf, enum idtype idtype);
extern int chown_mapped_root(char *path, struct lxc_conf *conf);
extern int ttys_shift_ids(struct lxc_conf *c);
-extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data);
+extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
+ const char *fn_name);
extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
char **mntdata);
extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
static bool do_destroy_container(struct lxc_conf *conf) {
if (am_unpriv()) {
- if (userns_exec_1(conf, bdev_destroy_wrapper, conf) < 0)
+ if (userns_exec_1(conf, bdev_destroy_wrapper, conf,
+ "bdev_destroy_wrapper") < 0)
return false;
return true;
}
char *path = alloca(strlen(p1) + strlen(c->name) + 2);
sprintf(path, "%s/%s", p1, c->name);
if (am_unpriv())
- ret = userns_exec_1(conf, lxc_rmdir_onedev_wrapper, path);
+ ret = userns_exec_1(conf, lxc_rmdir_onedev_wrapper, path,
+ "lxc_rmdir_onedev_wrapper");
else
ret = lxc_rmdir_onedev(path, "snaps");
if (ret < 0) {
data.hookargs = hookargs;
if (am_unpriv())
ret = userns_exec_1(c->lxc_conf, clone_update_rootfs_wrapper,
- &data);
+ &data, "clone_update_rootfs_wrapper");
else
ret = clone_update_rootfs(&data);
if (ret < 0)
}
if (am_unpriv())
- ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper, destroy);
+ ret = userns_exec_1(handler->conf, lxc_rmdir_onedev_wrapper,
+ destroy, "lxc_rmdir_onedev_wrapper");
else
ret = lxc_rmdir_onedev(destroy, NULL);
static bool do_destroy_container(struct lxc_conf *conf) {
if (am_unpriv()) {
- if (userns_exec_1(conf, bdev_destroy_wrapper, conf) < 0)
+ if (userns_exec_1(conf, bdev_destroy_wrapper, conf,
+ "bdev_destroy_wrapper") < 0)
return false;
return true;
}