The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1234

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@canonical.com>

Closes https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1302053.
From 1702996ab9f52b453f18ef344597b02fb9415074 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@canonical.com>
Date: Fri, 14 Oct 2016 15:27:24 +0200
Subject: [PATCH] tools: better error reporting for lxc-start

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
---
 src/lxc/tools/lxc_start.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/lxc/tools/lxc_start.c b/src/lxc/tools/lxc_start.c
index 25d8f19..32a78c4 100644
--- a/src/lxc/tools/lxc_start.c
+++ b/src/lxc/tools/lxc_start.c
@@ -86,7 +86,7 @@ static int ensure_path(char **confpath, const char *path)
                        goto err;
                }
        }
-       err = 0;
+       err = EXIT_SUCCESS;
 
 err:
        free(fullpath);
@@ -231,6 +231,14 @@ int main(int argc, char *argv[])
                exit(err);
        lxc_log_options_no_override();
 
+       if (geteuid()) {
+               if (access(my_args.lxcpath[0], O_RDWR) < 0) {
+                       if (!my_args.quiet)
+                               fprintf(stderr, "You lack access to %s\n", 
my_args.lxcpath[0]);
+                       exit(err);
+               }
+       }
+
        const char *lxcpath = my_args.lxcpath[0];
 
        /*
@@ -275,9 +283,19 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (!c->may_control(c)) {
+               fprintf(stderr, "Insufficent privileges to control %s\n", 
c->name);
+               goto out;
+       }
+
+       if (!c->is_defined(c)) {
+               fprintf(stderr, "Error: container %s is not defined\n", 
c->name);
+               goto out;
+       }
+
        if (c->is_running(c)) {
                ERROR("Container is already running.");
-               err = 0;
+               err = EXIT_SUCCESS;
                goto out;
        }
        /*
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to