}
if (mkdir_p(bdev->src, 0755) < 0) {
- ERROR("Error creating %s\n", bdev->src);
+ ERROR("Error creating %s", bdev->src);
return -1;
}
if (mkdir_p(bdev->dest, 0755) < 0) {
- ERROR("Error creating %s\n", bdev->dest);
+ ERROR("Error creating %s", bdev->dest);
return -1;
}
return -1;
if (mkdir_p(bdev->dest, 0755) < 0) {
- ERROR("Error creating %s\n", bdev->dest);
+ ERROR("Error creating %s", bdev->dest);
return -1;
}
return btrfs_snapshot(orig->dest, new->dest);
if (rmdir(new->dest) < 0 && errno != -ENOENT) {
- SYSERROR("removing %s\n", new->dest);
+ SYSERROR("removing %s", new->dest);
return -1;
}
ffd = open(bdev->src + 5, O_RDWR);
if (ffd < 0) {
- SYSERROR("Error opening backing file %s\n", bdev->src);
+ SYSERROR("Error opening backing file %s", bdev->src);
goto out;
}
memset(&lo, 0, sizeof(lo));
lo.lo_flags = LO_FLAGS_AUTOCLEAR;
if (ioctl(lfd, LOOP_SET_STATUS64, &lo) < 0) {
- SYSERROR("Error setting autoclear on loop dev\n");
+ SYSERROR("Error setting autoclear on loop dev");
goto out;
}
ret = mount_unknown_fs(loname, bdev->dest, bdev->mntopts);
if (ret < 0)
- ERROR("Error mounting %s\n", bdev->src);
+ ERROR("Error mounting %s", bdev->src);
else
bdev->lofd = lfd;
return -1;
if (mkdir_p(bdev->dest, 0755) < 0) {
- ERROR("Error creating %s\n", bdev->dest);
+ ERROR("Error creating %s", bdev->dest);
return -1;
}
strcpy(delta+len-6, "delta0");
if (mkdir_p(delta, 0755) < 0) {
- ERROR("Error creating %s\n", delta);
+ ERROR("Error creating %s", delta);
return -1;
}
return -1;
if (mkdir_p(bdev->dest, 0755) < 0) {
- ERROR("Error creating %s\n", bdev->dest);
+ ERROR("Error creating %s", bdev->dest);
return -1;
}
// If not a snapshot, copy the fs.
if (orig->ops->mount(orig) < 0) {
- ERROR("failed mounting %s onto %s\n", orig->src, orig->dest);
+ ERROR("failed mounting %s onto %s", orig->src, orig->dest);
return -1;
}
if (new->ops->mount(new) < 0) {
- ERROR("failed mounting %s onto %s\n", new->src, new->dest);
+ ERROR("failed mounting %s onto %s", new->src, new->dest);
return -1;
}
if (setgid(0) < 0) {
return -1;
}
if (do_rsync(orig->dest, new->dest) < 0) {
- ERROR("rsyncing %s to %s\n", orig->src, new->src);
+ ERROR("rsyncing %s to %s", orig->src, new->src);
return -1;
}
orig = bdev_init(src, NULL, NULL);
if (!orig) {
- ERROR("failed to detect blockdev type for %s\n", src);
+ ERROR("failed to detect blockdev type for %s", src);
return NULL;
}
}
if (new->ops->clone_paths(orig, new, oldname, cname, oldpath, lxcpath, snap, newsize) < 0) {
- ERROR("failed getting pathnames for cloned storage: %s\n", src);
+ ERROR("failed getting pathnames for cloned storage: %s", src);
bdev_put(orig);
bdev_put(new);
return NULL;
ret = cap_get_flag(caps, cap, CAP_PERMITTED, &flag);
if (ret) {
if (errno == EINVAL) {
- INFO("Last supported cap was %d\n", cap-1);
+ INFO("Last supported cap was %d", cap-1);
break;
} else {
ERROR("failed to cap_get_flag: %m");
cgroup_devices_has_allow_or_deny(d, cg->value, true))
continue;
if (lxc_cgroup_set_data(cg->subsystem, cg->value, d)) {
- ERROR("Error setting %s to %s for %s\n",
+ ERROR("Error setting %s to %s for %s",
cg->subsystem, cg->value, d->name);
goto out;
}
*p = '\0';
if (cgm_do_set(controller, cg->subsystem, d->cgroup_path
, cg->value) < 0) {
- ERROR("Error setting %s to %s for %s\n",
+ ERROR("Error setting %s to %s for %s",
cg->subsystem, cg->value, d->name);
goto out;
}
}
ret = creat(lxcpath, 0660);
if (ret==-1 && errno != EEXIST) {
- SYSERROR("error creating %s\n", lxcpath);
+ SYSERROR("error creating %s", lxcpath);
return -1;
}
if (ret >= 0)
close(ret);
ret = unlink(path);
if (ret && errno != ENOENT) {
- SYSERROR("error unlinking %s\n", path);
+ SYSERROR("error unlinking %s", path);
return -1;
}
}
ret = symlink(lxcpath, path);
if (ret) {
- SYSERROR("failed to create symlink for tty %d\n", i+1);
+ SYSERROR("failed to create symlink for tty %d", i+1);
return -1;
}
} else {
if (access(path, F_OK)) {
ret = creat(path, 0660);
if (ret==-1) {
- SYSERROR("error creating %s\n", path);
+ SYSERROR("error creating %s", path);
/* this isn't fatal, continue */
} else {
close(ret);
int found_fs = 0;
char *p2;
- DEBUG("entering mount_check_fs for %s\n", dir);
+ DEBUG("entering mount_check_fs for %s", dir);
if ( 0 != access(dir, F_OK) || 0 != stat(dir, &s) || 0 == S_ISDIR(s.st_mode) ) {
return 0;
fclose(f);
- DEBUG("mount_check_fs returning %d last %s\n", found_fs, fstype);
+ DEBUG("mount_check_fs returning %d last %s", found_fs, fstype);
return found_fs;
}
char host_path[MAXPATHLEN];
char devtmpfs_path[MAXPATHLEN];
- INFO("Mounting /dev under %s\n", root);
+ INFO("Mounting /dev under %s", root);
ret = snprintf(host_path, MAXPATHLEN, "%s/%s/rootfs.dev", lxcpath, name);
if (ret < 0 || ret > MAXPATHLEN)
ret = symlink(devtmpfs_path, host_path);
if ( ret < 0 ) {
- SYSERROR("WARNING: Failed to create symlink '%s'->'%s'\n", host_path, devtmpfs_path);
+ SYSERROR("WARNING: Failed to create symlink '%s'->'%s'", host_path, devtmpfs_path);
}
DEBUG("Bind mounting %s to %s", devtmpfs_path , path );
ret = mount(devtmpfs_path, path, NULL, MS_BIND, 0 );
}
}
if (ret) {
- SYSERROR("Failed to mount /dev at %s\n", root);
+ SYSERROR("Failed to mount /dev at %s", root);
return -1;
}
ret = snprintf(path, MAXPATHLEN, "%s/dev/pts", root);
}
}
- INFO("Mounted /dev under %s\n", root);
+ INFO("Mounted /dev under %s", root);
return 0;
}
int i;
mode_t cmask;
- INFO("Creating initial consoles under %s/dev\n", root);
+ INFO("Creating initial consoles under %s/dev", root);
ret = snprintf(path, MAXPATHLEN, "%s/dev", root);
if (ret < 0 || ret >= MAXPATHLEN) {
return -1;
}
- INFO("Populating /dev under %s\n", root);
+ INFO("Populating /dev under %s", root);
cmask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
for (i = 0; i < sizeof(lxc_devs) / sizeof(lxc_devs[0]); i++) {
const struct lxc_devs *d = &lxc_devs[i];
return -1;
ret = mknod(path, d->mode, makedev(d->maj, d->min));
if (ret && errno != EEXIST) {
- SYSERROR("Error creating %s\n", d->name);
+ SYSERROR("Error creating %s", d->name);
return -1;
}
}
umask(cmask);
- INFO("Populated /dev under %s\n", root);
+ INFO("Populated /dev under %s", root);
return 0;
}
SYSERROR("Failed to chroot into tmp-/");
return -1;
}
- INFO("Chrooted into tmp-/ at %s\n", path);
+ INFO("Chrooted into tmp-/ at %s", path);
return 0;
}
ret = snprintf(path, sizeof(path), "%s/dev/console", rootfs->mount);
if (ret >= sizeof(path)) {
- ERROR("console path too long\n");
+ ERROR("console path too long");
return -1;
}
return -1;
ret = mkdir(path, 0755);
if (ret && errno != EEXIST) {
- SYSERROR("failed with errno %d to create %s\n", errno, path);
+ SYSERROR("failed with errno %d to create %s", errno, path);
return -1;
}
- INFO("created %s\n", path);
+ INFO("created %s", path);
ret = snprintf(lxcpath, sizeof(lxcpath), "%s/dev/%s/console",
rootfs->mount, ttydir);
if (ret >= sizeof(lxcpath)) {
- ERROR("console path too long\n");
+ ERROR("console path too long");
return -1;
}
snprintf(path, sizeof(path), "%s/dev/console", rootfs->mount);
ret = unlink(path);
if (ret && errno != ENOENT) {
- SYSERROR("error unlinking %s\n", path);
+ SYSERROR("error unlinking %s", path);
return -1;
}
ret = creat(lxcpath, 0660);
if (ret==-1 && errno != EEXIST) {
- SYSERROR("error %d creating %s\n", errno, lxcpath);
+ SYSERROR("error %d creating %s", errno, lxcpath);
return -1;
}
if (ret >= 0)
ret = unlink(kpath);
if (ret && errno != ENOENT) {
- SYSERROR("error unlinking %s\n", kpath);
+ SYSERROR("error unlinking %s", kpath);
return -1;
}
char *ptr;
int i, capid;
int numcaps = lxc_caps_last_cap() + 1;
- INFO("found %d capabilities\n", numcaps);
+ INFO("found %d capabilities", numcaps);
if (numcaps <= 0 || numcaps > 200)
return -1;
INFO("running to reset %d nic names", conf->num_savednics);
for (i=0; i<conf->num_savednics; i++) {
struct saved_nic *s = &conf->saved_nics[i];
- INFO("resetting nic %d to %s\n", s->ifindex, s->orig_name);
+ INFO("resetting nic %d to %s", s->ifindex, s->orig_name);
lxc_netdev_rename_by_index(s->ifindex, s->orig_name);
free(s->orig_name);
}
if( arg && arg->argv[0] ) {
command = arg->argv[0];
- DEBUG("Set exec command to %s\n", command );
+ DEBUG("Set exec command to %s", command );
}
strncpy( path, command, MAXPATHLEN-1 );
return -1;
}
if (dropcaps_except(&lxc_conf->keepcaps)) {
- ERROR("failed to keep requested caps\n");
+ ERROR("failed to keep requested caps");
return -1;
}
} else if (setup_caps(&lxc_conf->caps)) {
again:
f = fopen(path, "r");
if (!f) {
- SYSERROR("opening %s\n", path);
+ SYSERROR("opening %s", path);
if (buf)
free(buf);
return NULL;
ret = fread(buf, 1, sz - 1, f);
fclose(f);
if (ret < 0) {
- ERROR("reading %s\n", path);
+ ERROR("reading %s", path);
free(buf);
return NULL;
}
return -1;
}
- INFO("Created snapshot snap%d\n", ret);
+ INFO("Created snapshot snap%d", ret);
return 0;
}
if (errno == EEXIST)
ret = 0;
else
- SYSERROR("failed to create container path for %s\n", c->name);
+ SYSERROR("failed to create container path for %s", c->name);
}
free(s);
return ret == 0;
bdev = bdev_create(dest, type, c->name, specs);
if (!bdev) {
- ERROR("Failed to create backing store type %s\n", type);
+ ERROR("Failed to create backing store type %s", type);
return NULL;
}
if (geteuid() != 0) {
if (chown_mapped_root(bdev->dest, c->lxc_conf) < 0) {
- ERROR("Error chowning %s to container root\n", bdev->dest);
+ ERROR("Error chowning %s to container root", bdev->dest);
bdev_put(bdev);
return NULL;
}
return NULL;
}
if (access(tpath, X_OK) < 0) {
- SYSERROR("bad template: %s\n", t);
+ SYSERROR("bad template: %s", t);
free(tpath);
return NULL;
}
pid = fork();
if (pid < 0) {
- SYSERROR("failed to fork task for container creation template\n");
+ SYSERROR("failed to fork task for container creation template");
return false;
}
}
if (wait_for_pid(pid) != 0) {
- ERROR("container creation template for %s failed\n", c->name);
+ ERROR("container creation template for %s failed", c->name);
return false;
}
#if HAVE_LIBGNUTLS
tpath = get_template_path(t);
if (!tpath) {
- ERROR("bad template: %s\n", t);
+ ERROR("bad template: %s", t);
goto out_free_contents;
}
if (t) {
tpath = get_template_path(t);
if (!tpath) {
- ERROR("bad template: %s\n", t);
+ ERROR("bad template: %s", t);
goto out;
}
}
if (!c->lxc_conf) {
if (!c->load_config(c, lxc_global_config_value("lxc.default_config"))) {
- ERROR("Error loading default configuration file %s\n", lxc_global_config_value("lxc.default_config"));
+ ERROR("Error loading default configuration file %s", lxc_global_config_value("lxc.default_config"));
goto free_tpath;
}
}
*/
pid = fork();
if (pid < 0) {
- SYSERROR("failed to fork task for container creation template\n");
+ SYSERROR("failed to fork task for container creation template");
goto out_unlock;
}
/* save config file again to store the new rootfs location */
if (!c->save_config(c, NULL)) {
- ERROR("failed to save starting configuration for %s\n", c->name);
+ ERROR("failed to save starting configuration for %s", c->name);
// parent task won't see bdev in config so we delete it
bdev->ops->umount(bdev);
bdev->ops->destroy(bdev);
pid = fork();
if (pid < 0) {
- SYSERROR("failed to fork task to get interfaces information\n");
+ SYSERROR("failed to fork task to get interfaces information");
close(pipefd[0]);
close(pipefd[1]);
return NULL;
pid = fork();
if (pid < 0) {
- SYSERROR("failed to fork task to get container ips\n");
+ SYSERROR("failed to fork task to get container ips");
close(pipefd[0]);
close(pipefd[1]);
return NULL;
// If we haven't yet loaded a config, load the stock config
if (!c->lxc_conf) {
if (!c->load_config(c, lxc_global_config_value("lxc.default_config"))) {
- ERROR("Error loading default configuration file %s while saving %s\n", lxc_global_config_value("lxc.default_config"), c->name);
+ ERROR("Error loading default configuration file %s while saving %s", lxc_global_config_value("lxc.default_config"), c->name);
return false;
}
}
return;
while (getline(&lxcpath, &pathlen, f) != -1) {
if (getline(&lxcname, &namelen, f) == -1) {
- ERROR("badly formatted file %s\n", path);
+ ERROR("badly formatted file %s", path);
goto out;
}
strip_newline(lxcpath);
if (!file_exists(path))
return 0;
if (!(fout = fopen(path, "w"))) {
- SYSERROR("unable to open %s: ignoring\n", path);
+ SYSERROR("unable to open %s: ignoring", path);
return 0;
}
if (fprintf(fout, "%s", c->name) < 0) {
*p = '\0';
ret = mkdir(path, 0755);
if (ret && errno != EEXIST)
- SYSERROR("creating container path %s\n", path);
+ SYSERROR("creating container path %s", path);
*p = '/';
return ret;
}
if (am_unpriv()) {
if (chown_mapped_root(newpath, c->lxc_conf) < 0) {
- ERROR("Error chowning %s to container root\n", newpath);
+ ERROR("Error chowning %s to container root", newpath);
goto out;
}
}
LXC_CLONE_KEEPBDEVTYPE | LXC_CLONE_MAYBE_SNAPSHOT;
c2 = c->clone(c, newname, snappath, flags, NULL, NULL, 0, NULL);
if (!c2) {
- ERROR("clone of %s:%s failed\n", c->config_path, c->name);
+ ERROR("clone of %s:%s failed", c->config_path, c->name);
return -1;
}
sprintf(dfnam, "%s/%s/ts", snappath, newname);
f = fopen(dfnam, "w");
if (!f) {
- ERROR("Failed to open %s\n", dfnam);
+ ERROR("Failed to open %s", dfnam);
return -1;
}
if (fprintf(f, "%s", buffer) < 0) {
#endif
SCMP_ACT_ALLOW, nr, 0);
if (ret < 0) {
- ERROR("failed loading allow rule for %d\n", nr);
+ ERROR("failed loading allow rule for %d", nr);
return ret;
}
}
conf->seccomp_ctx,
#endif
SCMP_FLTATR_CTL_NNP, 0)) {
- ERROR("failed to turn off n-new-privs\n");
+ ERROR("failed to turn off n-new-privs");
return -1;
}
f = fopen(conf->seccomp, "r");
if (!f) {
- SYSERROR("failed to open seccomp policy file %s\n", conf->seccomp);
+ SYSERROR("failed to open seccomp policy file %s", conf->seccomp);
return -1;
}
ret = parse_config(f, conf);
goto out_mainloop_open;
}
#else
- DEBUG("not starting utmp handler as cap_sys_boot cannot be dropped without capabilities support\n");
+ DEBUG("not starting utmp handler as cap_sys_boot cannot be dropped without capabilities support");
#endif
}
flags |= CLONE_NEWUSER;
#ifdef __ia64__
- pid = __clone2(container_reboot_supported, stack, stack_size, flags, &cmd);
+ pid = __clone2(container_reboot_supported, stack, stack_size, flags, &cmd);
#else
- stack += stack_size;
- pid = clone(container_reboot_supported, stack, flags, &cmd);
+ stack += stack_size;
+ pid = clone(container_reboot_supported, stack, flags, &cmd);
#endif
- if (pid < 0) {
- SYSERROR("failed to clone\n");
- return -1;
- }
- if (wait(&status) < 0) {
- SYSERROR("unexpected wait error: %m\n");
- return -1;
- }
+ if (pid < 0) {
+ SYSERROR("failed to clone");
+ return -1;
+ }
+ if (wait(&status) < 0) {
+ SYSERROR("unexpected wait error: %m");
+ return -1;
+ }
if (WEXITSTATUS(status) != 1)
return 1;
SYSERROR("failed to remove CAP_SYS_BOOT capability");
goto out_warn_father;
}
- DEBUG("Dropped cap_sys_boot\n");
+ DEBUG("Dropped cap_sys_boot");
}
#endif
SYSERROR("failed to allocate memory");
return -1;
}
- INFO("stored saved_nic #%d idx %d name %s\n", conf->num_savednics,
+ INFO("stored saved_nic #%d idx %d name %s", conf->num_savednics,
conf->saved_nics[conf->num_savednics].ifindex,
conf->saved_nics[conf->num_savednics].orig_name);
conf->num_savednics++;
if (must_drop_cap_sys_boot(handler->conf)) {
#if HAVE_SYS_CAPABILITY_H
- DEBUG("Dropping cap_sys_boot\n");
+ DEBUG("Dropping cap_sys_boot");
#else
- DEBUG("Can't drop cap_sys_boot as capabilities aren't supported\n");
+ DEBUG("Can't drop cap_sys_boot as capabilities aren't supported");
#endif
} else {
- DEBUG("Not dropping cap_sys_boot or watching utmp\n");
+ DEBUG("Not dropping cap_sys_boot or watching utmp");
handler->conf->need_utmp_watch = 0;
}
handler->conf->reboot = 1;
break;
default:
- DEBUG("unknown exit status for init: %d\n", WTERMSIG(status));
+ DEBUG("unknown exit status for init: %d", WTERMSIG(status));
break;
}
}
makeme = strndup(orig, dir - orig);
if (*makeme) {
if (mkdir(makeme, mode) && errno != EEXIST) {
- SYSERROR("failed to create directory '%s'\n", makeme);
+ SYSERROR("failed to create directory '%s'", makeme);
free(makeme);
return -1;
}
struct lxc_container *c = clist[i];
printf("%-10s Got container struct %s, name %s\n", type, c->name, names[i]);
if (strcmp(c->name, names[i]))
- fprintf(stderr, "ERROR: name mismatch!\n");
+ fprintf(stderr, "ERROR: name mismatch!");
free(names[i]);
lxc_container_put(c);
}