So I ended up in doas again, this time with the CFLAGS I use for most of my other projects. This popped up a few new not very exciting warnings. Diff below compiles clean with both clang and gcc on amd64.
Worth doing? martijn@ Index: Makefile =================================================================== RCS file: /cvs/src/usr.bin/doas/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile 3 Jul 2017 22:21:47 -0000 1.3 +++ Makefile 18 Dec 2020 21:18:51 -0000 @@ -9,7 +9,11 @@ BINOWN= root BINMODE=4555 CFLAGS+= -I${.CURDIR} -COPTS+= -Wall +CFLAGS+= -Wall +CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes +CFLAGS+= -Wmissing-declarations +CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual +CFLAGS+= -Wsign-compare YFLAGS= .include <bsd.prog.mk> Index: doas.c =================================================================== RCS file: /cvs/src/usr.bin/doas/doas.c,v retrieving revision 1.84 diff -u -p -r1.84 doas.c --- doas.c 9 Oct 2020 07:43:38 -0000 1.84 +++ doas.c 18 Dec 2020 21:18:51 -0000 @@ -94,7 +94,7 @@ parsegid(const char *s, gid_t *gid) static int match(uid_t uid, gid_t *groups, int ngroups, uid_t target, const char *cmd, - const char **cmdargs, struct rule *r) + const char * const*cmdargs, struct rule *r) { int i; @@ -134,7 +134,7 @@ match(uid_t uid, gid_t *groups, int ngro static int permit(uid_t uid, gid_t *groups, int ngroups, const struct rule **lastr, - uid_t target, const char *cmd, const char **cmdargs) + uid_t target, const char *cmd, const char * const*cmdargs) { int i; @@ -188,7 +188,7 @@ checkconfig(const char *confpath, int ar exit(0); if (permit(uid, groups, ngroups, &rule, target, argv[0], - (const char **)argv + 1)) { + (const char * const*)argv + 1)) { printf("permit%s\n", (rule->options & NOPASS) ? " nopass" : ""); exit(0); } else { @@ -244,7 +244,7 @@ good: } } -int +static int unveilcommands(const char *ipath, const char *cmd) { char *path = NULL, *p; @@ -271,7 +271,7 @@ unveilcommands(const char *ipath, const if (cp) { int r = snprintf(buf, sizeof buf, "%s/%s", cp, cmd); - if (r >= 0 && r < sizeof buf) { + if (r >= 0 && (size_t)r < sizeof buf) { if (unveil(buf, "x") != -1) unveils++; } @@ -394,7 +394,7 @@ main(int argc, char **argv) cmd = argv[0]; if (!permit(uid, groups, ngroups, &rule, target, cmd, - (const char **)argv + 1)) { + (const char * const*)argv + 1)) { syslog(LOG_AUTHPRIV | LOG_NOTICE, "command not permitted for %s: %s", mypw->pw_name, cmdline); errc(1, EPERM, NULL); Index: env.c =================================================================== RCS file: /cvs/src/usr.bin/doas/env.c,v retrieving revision 1.10 diff -u -p -r1.10 env.c --- env.c 7 Jul 2019 19:21:28 -0000 1.10 +++ env.c 18 Dec 2020 21:18:51 -0000 @@ -32,8 +32,8 @@ const char *formerpath; struct envnode { RB_ENTRY(envnode) node; - const char *key; - const char *value; + char *key; + char *value; }; struct env { Index: parse.y =================================================================== RCS file: /cvs/src/usr.bin/doas/parse.y,v retrieving revision 1.28 diff -u -p -r1.28 parse.y --- parse.y 9 Oct 2020 07:43:38 -0000 1.28 +++ parse.y 18 Dec 2020 21:18:51 -0000 @@ -56,7 +56,7 @@ static void yyerror(const char *, ...); static int yylex(void); static size_t -arraylen(const char **arr) +arraylen(const char * const*arr) { size_t cnt = 0; @@ -222,7 +222,8 @@ int yylex(void) { char buf[1024], *ebuf, *p, *str; - int i, c, quotes = 0, escape = 0, qpos = -1, nonkw = 0; + int c, quotes = 0, escape = 0, qpos = -1, nonkw = 0; + size_t i; p = buf; ebuf = buf + sizeof(buf);