]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: search shell from path, when necessary
authorSami Kerola <kerolasa@iki.fi>
Fri, 28 Dec 2012 21:23:40 +0000 (21:23 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Jan 2013 12:37:01 +0000 (13:37 +0100)
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
term-utils/script.c

index 94a20da6c3161d9d11170433335c4bdf7863b052..983930f5cd2e006669c674eba85e25f009286916 100644 (file)
@@ -445,11 +445,17 @@ doshell(void) {
         */
        signal(SIGTERM, SIG_DFL);
 
-       if (cflg)
-               execl(shell, shname, "-c", cflg, NULL);
-       else
-               execl(shell, shname, "-i", NULL);
-
+       if (access(shell, X_OK) == 0) {
+               if (cflg)
+                       execl(shell, shname, "-c", cflg, NULL);
+               else
+                       execl(shell, shname, "-i", NULL);
+       } else {
+               if (cflg)
+                       execlp(shname, "-c", cflg, NULL);
+               else
+                       execlp(shname, "-i", NULL);
+       }
        warn(_("failed to execute %s"), shell);
        fail();
 }