MAN= doas.1 doas.conf.5
BINOWN= root
+BINGRP= wheel
BINMODE=4555
-CFLAGS+= -I${.CURDIR}
-COPTS+= -Wall
+COPTS+= -Wall -Wextra -Werror -pedantic -std=c11
+CFLAGS+= -I${CURDIR} -I${CURDIR}/libopenbsd ${COPTS}
-.include <bsd.prog.mk>
+BINDIR?=/usr/bin
+MANDIR?=/usr/share/man
+
+default: ${PROG}
+
+OBJS:=${SRCS:.y=.c}
+OBJS:=${OBJS:.c=.o}
+
+${PROG}: ${OBJS}
+ ${CC} ${COPTS} ${LDOPTS} $^ -o $@
+
+${BINDIR}/${PROG}: ${PROG}
+ cp $< $@
+ chown ${BINOWN}:${BINGRP} $@
+ chmod ${BINMODE} $@
+
+install: ${BINDIR}/${PROG}
+
+clean:
+ rm -f ${OBJS}
+ rm -f ${PROG}
+
+.PHONY: default clean install
--- /dev/null
+#ifndef _LIB_OPENBSD_H_
+#define _LIB_OPENBSD_H_
+
+/* API definitions lifted from OpenBSD src/include */
+
+/* bsd_auth.h */
+int auth_userokay(char *, char *, char *, char *);
+
+/* login_cap.h */
+#define LOGIN_SETGROUP 0x0001 /* Set group */
+#define LOGIN_SETLOGIN 0x0002 /* Set login */
+#define LOGIN_SETPATH 0x0004 /* Set path */
+#define LOGIN_SETPRIORITY 0x0008 /* Set priority */
+#define LOGIN_SETRESOURCES 0x0010 /* Set resource limits */
+#define LOGIN_SETUMASK 0x0020 /* Set umask */
+#define LOGIN_SETUSER 0x0040 /* Set user */
+#define LOGIN_SETENV 0x0080 /* Set environment */
+#define LOGIN_SETALL 0x00ff /* Set all. */
+
+typedef struct login_cap login_cap_t;
+struct passwd;
+int setusercontext(login_cap_t *, struct passwd *, uid_t, unsigned int);
+
+/* pwd.h */
+#define _PW_NAME_LEN 63
+
+/* stdlib.h */
+void * reallocarray(void *optr, size_t nmemb, size_t size);
+long long strtonum(const char *numstr, long long minval,
+ long long maxval, const char **errstrp);
+
+/* unistd.h */
+int execvpe(const char *, char *const *, char *const *);
+int setresuid(uid_t, uid_t, uid_t);
+
+#endif