From: Thomas Parrott Date: Thu, 13 Oct 2022 14:33:30 +0000 (+0100) Subject: lxc/attach: Detect EACCES from execvp and convert to 126 exit status X-Git-Tag: v6.0.0~93^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4207%2Fhead;p=thirdparty%2Flxc.git lxc/attach: Detect EACCES from execvp and convert to 126 exit status Before: sudo lxc-attach -n test /etc/passwd ; echo $? lxc-attach: test: ../src/lxc/attach.c: lxc_attach_run_command: 1841 Permission denied - Failed to exec "/etc/passwd" 255 After: sudo lxc-attach -n test /etc/passwd ; echo $? lxc-attach: test: ../src/lxc/attach.c: lxc_attach_run_command: 1841 Permission denied - Failed to exec "/etc/passwd" 126 Which better aligns with bash: /etc/passwd; echo $? bash: /etc/passwd: Permission denied 126 Signed-off-by: Thomas Parrott --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 769613d6d..f086e96c4 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1828,6 +1828,7 @@ int lxc_attach_run_command(void *payload) ret = execvp(cmd->program, cmd->argv); if (ret < 0) { switch (errno) { + case EACCES: case ENOEXEC: ret = 126; break;