]> git.armaanb.net Git - opendoas.git/commitdiff
sudo emulation: if execvpe fails with ENOENT, print "command not found"
authorTed Unangst <tedu@openbsd.org>
Sun, 19 Jul 2015 01:19:22 +0000 (01:19 +0000)
committerTed Unangst <tedu@openbsd.org>
Sun, 19 Jul 2015 01:19:22 +0000 (01:19 +0000)
requested by krw

doas.c

diff --git a/doas.c b/doas.c
index ac15f50955d1a79ff03a2fa7846cf1c762c6ee13..8db988ea242885ab834c4f9b3575b4de6dfc0ff4 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: doas.c,v 1.8 2015/07/18 06:33:23 nicm Exp $ */
+/* $OpenBSD: doas.c,v 1.9 2015/07/18 18:44:26 tedu Exp $ */
 /*
  * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
  *
@@ -29,6 +29,7 @@
 #include <pwd.h>
 #include <grp.h>
 #include <syslog.h>
+#include <errno.h>
 
 #include "doas.h"
 
@@ -343,5 +344,7 @@ main(int argc, char **argv, char **envp)
        if (setenv("PATH", safepath, 1) == -1)
                err(1, "failed to set PATH '%s'", safepath);
        execvpe(cmd, argv, envp);
+       if (errno == ENOENT)
+               errx(1, "%s: command not found", cmd);
        err(1, "%s", cmd);
 }