opendoas

A portable version of the OpenBSD `doas` command
git clone https://pi.duncano.de/git/opendoas.git
Log | Files | Refs | README | LICENSE

commit 86e95de1a44a7d041c7a1ba07c08b6eba770c13a
parent 4d4f6fa0c5427100849b2bbfe95aa93d7fbf8b87
Author: Ted Unangst <tedu@openbsd.org>
Date:   Sun, 19 Jul 2015 01:19:22 +0000

sudo emulation: if execvpe fails with ENOENT, print "command not found"
requested by krw

Diffstat:
doas.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 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); }