aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Holstein <nathan.holstein@gmail.com>2015-08-02 12:11:40 -0400
committerNathan Holstein <nathan.holstein@gmail.com>2015-08-05 08:49:07 -0400
commit5dd49ecf1ae77ffad2e4d0aa2a052d97356fad89 (patch)
treec9e3880614566656ad404b0f1db9f10197bcb9a9
parent70cfef526620e14cb9fc33327fadaa18d7e994e6 (diff)
downloadopendoas-5dd49ecf1ae77ffad2e4d0aa2a052d97356fad89.tar.gz
Makefile for gmake on MacOSX.
-rw-r--r--Makefile29
-rw-r--r--libopenbsd/openbsd.h36
2 files changed, 62 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 191d00f..7bb667e 100644
--- 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
new file mode 100644
index 0000000..bcf0e3b
--- /dev/null
+++ 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