opendoas

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

commit 5dd49ecf1ae77ffad2e4d0aa2a052d97356fad89
parent 70cfef526620e14cb9fc33327fadaa18d7e994e6
Author: Nathan Holstein <nathan.holstein@gmail.com>
Date:   Sun,  2 Aug 2015 12:11:40 -0400

Makefile for gmake on MacOSX.

Diffstat:
Makefile | 29++++++++++++++++++++++++++---
libopenbsd/openbsd.h | 36++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,9 +6,32 @@ PROG= doas 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 diff --git a/libopenbsd/openbsd.h b/libopenbsd/openbsd.h @@ -0,0 +1,36 @@ +#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