Beispiel #1
0
static int do_child(void *vargv)
{
	int ret;
	char **argv = (char **)vargv;

	/* Assume we want to become root */
	if (!lxc_switch_uid_gid(0, 0))
		return -1;

	if (!lxc_setgroups(0, NULL))
		return -1;

	ret = unshare(CLONE_NEWNS);
	if (ret < 0) {
		CMD_SYSERROR("Failed to unshare mount namespace");
		return -1;
	}

	if (detect_shared_rootfs()) {
		ret = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL);
		if (ret < 0) {
			CMD_SYSINFO("Failed to make \"/\" rslave");
			return -1;
		}
	}

	execvp(argv[0], argv);
	CMD_SYSERROR("Failed to execute \"%s\"", argv[0]);
	return -1;
}
Beispiel #2
0
Datei: aufs.c Projekt: d4s/lxc
int lxc_rsync_delta(struct rsync_data_char *data)
{
	int ret;

	ret = lxc_switch_uid_gid(0, 0);
	if (ret < 0)
		return -1;

	ret = lxc_setgroups(0, NULL);
	if (ret < 0)
		return -1;

	ret = lxc_rsync_exec(data->src, data->dest);
	if (ret < 0) {
		ERROR("Failed to rsync from \"%s\" into \"%s\"", data->src,
		      data->dest);
		return -1;
	}

	return 0;
}