aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@openbsd.org>2015-07-19 01:19:22 +0000
committerTed Unangst <tedu@openbsd.org>2015-07-19 01:19:22 +0000
commit86e95de1a44a7d041c7a1ba07c08b6eba770c13a (patch)
tree64f9ab736309b03c951d14b2378d2ec440491f66
parent4d4f6fa0c5427100849b2bbfe95aa93d7fbf8b87 (diff)
downloadopendoas-86e95de1a44a7d041c7a1ba07c08b6eba770c13a.tar.gz
sudo emulation: if execvpe fails with ENOENT, print "command not found"
requested by krw
-rw-r--r--doas.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/doas.c b/doas.c
index ac15f50..8db988e 100644
--- 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);
}