From 5e7dab5420e5fb7378ec27643cf6d10cfe889057 Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Mon, 13 Sep 2021 15:56:17 -0400 Subject: [PATCH] Add MidnightBSD support. --- Makefile | 4 ++++ README.md | 9 ++++++--- compat/closefrom.c | 2 +- doas.c | 6 +++--- env.c | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f163826..cfa5cf0 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,10 @@ ifeq ($(UNAME_S),FreeBSD) CFLAGS+=-DHAVE_LOGIN_CAP_H LDFLAGS+=-lutil endif +ifeq ($(UNAME_S),MidnightBSD) + CFLAGS+=-DHAVE_LOGIN_CAP_H + LDFLAGS+=-lutil +endif ifeq ($(UNAME_S),NetBSD) CFLAGS+=-DHAVE_LOGIN_CAP_H -D_OPENBSD_SOURCE OBJECTS=doas.o env.o y.tab.o diff --git a/README.md b/README.md index 3815912..d09b446 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # doas -A port of OpenBSD's doas which runs on FreeBSD, Linux, NetBSD, illumos and macOS. +A port of OpenBSD's doas which runs on FreeBSD, Linux, NetBSD, illumos, macOS and MidnightBSD. The doas utility is a program originally written for OpenBSD which allows a user to run a command as though they were another user. Typically doas is used to allow non-privileged users to run commands as though they were the root user. The doas program acts as an alternative to sudo, which is a popular method in the Linux community for granting admin access to specific users. @@ -27,6 +27,9 @@ The doas command is in FreeBSD's ports collection and may be installed by simply pkg install doas +The doas command may be installed from MidnightBSD's mports collection with: + + mport install doas ## Installing build tools @@ -64,7 +67,7 @@ The doas command is in FreeBSD's ports collection and may be installed by simply make -#### FreeBSD, NetBSD and macOS +#### FreeBSD, MidnightBSD, NetBSD and macOS gmake @@ -98,7 +101,7 @@ following lines: After you save this file you may need to reboot in order for the change to take effect. -#### FreeBSD and NetBSD +#### FreeBSD, MidnightBSD and NetBSD gmake install diff --git a/compat/closefrom.c b/compat/closefrom.c index 2b8b7b2..f1cdb65 100644 --- a/compat/closefrom.c +++ b/compat/closefrom.c @@ -46,7 +46,7 @@ closefrom(int lowfd) int i; /* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */ -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__MidnightBSD__) path = "/dev/fd"; # else path = "/proc/self/fd"; diff --git a/doas.c b/doas.c index 6f9e7e6..94da173 100644 --- a/doas.c +++ b/doas.c @@ -199,7 +199,7 @@ checkconfig(const char *confpath, int argc, char **argv, struct rule *rule; int status; - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__MidnightBSD__) status = setresuid(uid, uid, uid); #else status = setreuid(uid, uid); @@ -526,7 +526,7 @@ main(int argc, char **argv) LOGIN_SETUSER) != 0) errx(1, "failed to set user context for target"); #else - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__MidnightBSD__) if (setresgid(target_pw->pw_gid, target_pw->pw_gid, target_pw->pw_gid) == -1) err(1, "setresgid"); #else @@ -535,7 +535,7 @@ main(int argc, char **argv) #endif if (initgroups(target_pw->pw_name, target_pw->pw_gid) == -1) err(1, "initgroups"); - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__MidnightBSD__) if (setresuid(target, target, target) == -1) err(1, "setresuid"); #else diff --git a/env.c b/env.c index 57c91b7..1bce15e 100644 --- a/env.c +++ b/env.c @@ -102,7 +102,7 @@ copyenvpw(struct passwd *my_static) new_pw->pw_passwd = strdup(my_static->pw_passwd); new_pw->pw_uid = my_static->pw_uid; new_pw->pw_gid = my_static->pw_gid; - #if defined(__FreeBSD__) + #if defined(__FreeBSD__) || defined(__MidnightBSD__) new_pw->pw_class = strdup(my_static->pw_class); #endif new_pw->pw_gecos = strdup(my_static->pw_gecos);