]> git.proxmox.com Git - mirror_lxc.git/commitdiff
fix lxc-attach returned error
authorDaniel Lezcano <daniel.lezcano@free.fr>
Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)
When we try to attach to a container belonging to another user than us,
the command fails as expected but the return code is wrong, so we have
an "unknown error" instead of "permission denied".

The culprit is:

-                     strerror(command.answer.ret));
+                     strerror(-command.answer.ret));

The rest of the code is indentation without code impact.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
src/lxc/commands.c
src/lxc/lxc_attach.c
src/lxc/start.c

index fe055ed1035fe7bd5bc4302c7b89c54d8cf7cdd4..54e1826035ebdbfaf9adcde1ae1ef0b1022bddf3 100644 (file)
@@ -149,7 +149,7 @@ static int command_handler(int fd, void *data, struct lxc_epoll_descr *descr)
        struct lxc_handler *handler = data;
 
        ret = lxc_af_unix_rcv_credential(fd, &request, sizeof(request));
-       if (ret < 0 && ret == -EACCES) {
+       if (ret == -EACCES) {
                /* we don't care for the peer, just send and close */
                struct lxc_answer answer = { .ret = ret };
                send(fd, &answer, sizeof(answer), 0);
@@ -196,7 +196,8 @@ static int incoming_command_handler(int fd, void *data,
                return -1;
        }
 
-       if (setsockopt(connection, SOL_SOCKET, SO_PASSCRED, &opt, sizeof(opt))) {
+       if (setsockopt(connection, SOL_SOCKET,
+                      SO_PASSCRED, &opt, sizeof(opt))) {
                SYSERROR("failed to enable credential on socket");
                goto out_close;
        }
@@ -215,7 +216,8 @@ out_close:
        goto out;
 }
 
-extern int lxc_command_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
+extern int lxc_command_mainloop_add(const char *name,
+                                   struct lxc_epoll_descr *descr,
                                    struct lxc_handler *handler)
 {
        int ret, fd;
@@ -230,7 +232,8 @@ extern int lxc_command_mainloop_add(const char *name, struct lxc_epoll_descr *de
                return -1;
        }
 
-       ret = lxc_mainloop_add_handler(descr, fd, incoming_command_handler, handler);
+       ret = lxc_mainloop_add_handler(descr, fd, incoming_command_handler,
+                                      handler);
        if (ret) {
                ERROR("failed to add handler for command socket");
                close(fd);
index 1d32332996f2c10dc652c81fd82ef2084bd4591e..a012c2c6e0a69dc434ca83027fc8dfa8d9b9e1a8 100644 (file)
@@ -71,7 +71,7 @@ pid_t get_init_pid(const char *name)
 
        if (command.answer.ret) {
                ERROR("failed to retrieve the init pid: %s",
-                     strerror(command.answer.ret));
+                     strerror(-command.answer.ret));
                return -1;
        }
 
index 4a4755d059ac328779dfbe9ff3656df324c069d4..ec084493b946922ae1f394a557a0f25916f59ad7 100644 (file)
@@ -204,7 +204,8 @@ static int sigchld_handler(int fd, void *data,
        return 1;
 }
 
-int lxc_pid_callback(int fd, struct lxc_request *request, struct lxc_handler *handler)
+int lxc_pid_callback(int fd, struct lxc_request *request,
+                    struct lxc_handler *handler)
 {
        struct lxc_answer answer;
        int ret;