diff --git a/src/lxc/lxc_attach.c b/src/lxc/lxc_attach.c index fdf8a0664..69ebfacca 100644 --- a/src/lxc/lxc_attach.c +++ b/src/lxc/lxc_attach.c @@ -452,18 +452,24 @@ int main(int argc, char *argv[]) else user_shell = passwd->pw_shell; - if (!user_shell) { - SYSERROR("failed to get passwd " \ - "entry for uid '%d'", uid); - return -1; - } - - { + if (user_shell) { char *const args[] = { user_shell, NULL, }; + (void) execvp(args[0], args); + } + + /* executed if either no passwd entry or execvp fails, + * we will fall back on /bin/sh as a default shell + */ + { + char *const args[] = { + "/bin/sh", + NULL, + }; + execvp(args[0], args); SYSERROR("failed to exec '%s'", args[0]); return -1;