Commit 2b2d6732 authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

cr-service: setup_opts_from_req: use single error exit point

Signed-off-by: 's avatarRuslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0437606e
...@@ -186,15 +186,15 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -186,15 +186,15 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) { if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
pr_perror("Can't get socket options"); pr_perror("Can't get socket options");
return -1; goto err;
} }
if (restrict_uid(ids.uid, ids.gid)) if (restrict_uid(ids.uid, ids.gid))
return -1; goto err;
if (fstat(sk, &st)) { if (fstat(sk, &st)) {
pr_perror("Can't get socket stat"); pr_perror("Can't get socket stat");
return -1; goto err;
} }
BUG_ON(st.st_ino == -1); BUG_ON(st.st_ino == -1);
...@@ -208,13 +208,13 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -208,13 +208,13 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (open_image_dir(images_dir_path) < 0) { if (open_image_dir(images_dir_path) < 0) {
pr_perror("Can't open images directory"); pr_perror("Can't open images directory");
return -1; goto err;
} }
/* get full path to images_dir to use in process title */ /* get full path to images_dir to use in process title */
if (readlink(images_dir_path, images_dir, PATH_MAX) == -1) { if (readlink(images_dir_path, images_dir, PATH_MAX) == -1) {
pr_perror("Can't readlink %s", images_dir_path); pr_perror("Can't readlink %s", images_dir_path);
return -1; goto err;
} }
/* chdir to work dir */ /* chdir to work dir */
...@@ -225,14 +225,14 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -225,14 +225,14 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (chdir(work_dir_path)) { if (chdir(work_dir_path)) {
pr_perror("Can't chdir to work_dir"); pr_perror("Can't chdir to work_dir");
return -1; goto err;
} }
/* initiate log file in work dir */ /* initiate log file in work dir */
if (req->log_file) { if (req->log_file) {
if (strchr(req->log_file, '/')) { if (strchr(req->log_file, '/')) {
pr_perror("No subdirs are allowed in log_file name"); pr_perror("No subdirs are allowed in log_file name");
return -1; goto err;
} }
opts.output = req->log_file; opts.output = req->log_file;
...@@ -242,7 +242,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -242,7 +242,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
log_set_loglevel(req->log_level); log_set_loglevel(req->log_level);
if (log_init(opts.output) == -1) { if (log_init(opts.output) == -1) {
pr_perror("Can't initiate log"); pr_perror("Can't initiate log");
return -1; goto err;
} }
/* checking flags from client */ /* checking flags from client */
...@@ -263,7 +263,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -263,7 +263,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->has_rst_sibling) { if (req->has_rst_sibling) {
if (!opts.swrk_restore) { if (!opts.swrk_restore) {
pr_err("rst_sibling is not allowed in standalone service\n"); pr_err("rst_sibling is not allowed in standalone service\n");
return -1; goto err;
} }
opts.restore_sibling = req->rst_sibling; opts.restore_sibling = req->rst_sibling;
...@@ -306,7 +306,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -306,7 +306,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->ps->has_fd) { if (req->ps->has_fd) {
if (!opts.swrk_restore) if (!opts.swrk_restore)
return -1; goto err;
opts.ps_socket = req->ps->fd; opts.ps_socket = req->ps->fd;
} }
...@@ -314,22 +314,22 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -314,22 +314,22 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->notify_scripts && if (req->notify_scripts &&
add_script(SCRIPT_RPC_NOTIFY, sk)) add_script(SCRIPT_RPC_NOTIFY, sk))
return -1; goto err;
for (i = 0; i < req->n_veths; i++) { for (i = 0; i < req->n_veths; i++) {
if (veth_pair_add(req->veths[i]->if_in, req->veths[i]->if_out)) if (veth_pair_add(req->veths[i]->if_in, req->veths[i]->if_out))
return -1; goto err;
} }
for (i = 0; i < req->n_ext_mnt; i++) { for (i = 0; i < req->n_ext_mnt; i++) {
if (ext_mount_add(req->ext_mnt[i]->key, req->ext_mnt[i]->val)) if (ext_mount_add(req->ext_mnt[i]->key, req->ext_mnt[i]->val))
return -1; goto err;
} }
for (i = 0; i < req->n_cg_root; i++) { for (i = 0; i < req->n_cg_root; i++) {
if (new_cg_root_add(req->cg_root[i]->ctrl, if (new_cg_root_add(req->cg_root[i]->ctrl,
req->cg_root[i]->path)) req->cg_root[i]->path))
return -1; goto err;
} }
if (req->has_cpu_cap) if (req->has_cpu_cap)
...@@ -339,6 +339,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -339,6 +339,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
opts.manage_cgroups = req->manage_cgroups; opts.manage_cgroups = req->manage_cgroups;
return 0; return 0;
err:
return -1;
} }
static int dump_using_req(int sk, CriuOpts *req) static int dump_using_req(int sk, CriuOpts *req)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment