Merge pull request #87 from laffer1/master

Add MidnightBSD support.
This commit is contained in:
Jesse Smith 2021-09-13 17:02:51 -03:00 committed by GitHub
commit 66519077d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View file

@ -26,6 +26,10 @@ ifeq ($(UNAME_S),FreeBSD)
CFLAGS+=-DHAVE_LOGIN_CAP_H CFLAGS+=-DHAVE_LOGIN_CAP_H
LDFLAGS+=-lutil LDFLAGS+=-lutil
endif endif
ifeq ($(UNAME_S),MidnightBSD)
CFLAGS+=-DHAVE_LOGIN_CAP_H
LDFLAGS+=-lutil
endif
ifeq ($(UNAME_S),NetBSD) ifeq ($(UNAME_S),NetBSD)
CFLAGS+=-DHAVE_LOGIN_CAP_H -D_OPENBSD_SOURCE CFLAGS+=-DHAVE_LOGIN_CAP_H -D_OPENBSD_SOURCE
OBJECTS=doas.o env.o y.tab.o OBJECTS=doas.o env.o y.tab.o

View file

@ -1,5 +1,5 @@
# doas # 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. 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 pkg install doas
The doas command may be installed from MidnightBSD's mports collection with:
mport install doas
## Installing build tools ## Installing build tools
@ -64,7 +67,7 @@ The doas command is in FreeBSD's ports collection and may be installed by simply
make make
#### FreeBSD, NetBSD and macOS #### FreeBSD, MidnightBSD, NetBSD and macOS
gmake 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. 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 gmake install

View file

@ -46,7 +46,7 @@ closefrom(int lowfd)
int i; int i;
/* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */ /* 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"; path = "/dev/fd";
# else # else
path = "/proc/self/fd"; path = "/proc/self/fd";

6
doas.c
View file

@ -199,7 +199,7 @@ checkconfig(const char *confpath, int argc, char **argv,
struct rule *rule; struct rule *rule;
int status; int status;
#if defined(__linux__) || defined(__FreeBSD__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__MidnightBSD__)
status = setresuid(uid, uid, uid); status = setresuid(uid, uid, uid);
#else #else
status = setreuid(uid, uid); status = setreuid(uid, uid);
@ -526,7 +526,7 @@ main(int argc, char **argv)
LOGIN_SETUSER) != 0) LOGIN_SETUSER) != 0)
errx(1, "failed to set user context for target"); errx(1, "failed to set user context for target");
#else #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) if (setresgid(target_pw->pw_gid, target_pw->pw_gid, target_pw->pw_gid) == -1)
err(1, "setresgid"); err(1, "setresgid");
#else #else
@ -535,7 +535,7 @@ main(int argc, char **argv)
#endif #endif
if (initgroups(target_pw->pw_name, target_pw->pw_gid) == -1) if (initgroups(target_pw->pw_name, target_pw->pw_gid) == -1)
err(1, "initgroups"); err(1, "initgroups");
#if defined(__linux__) || defined(__FreeBSD__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__MidnightBSD__)
if (setresuid(target, target, target) == -1) if (setresuid(target, target, target) == -1)
err(1, "setresuid"); err(1, "setresuid");
#else #else

2
env.c
View file

@ -102,7 +102,7 @@ copyenvpw(struct passwd *my_static)
new_pw->pw_passwd = strdup(my_static->pw_passwd); new_pw->pw_passwd = strdup(my_static->pw_passwd);
new_pw->pw_uid = my_static->pw_uid; new_pw->pw_uid = my_static->pw_uid;
new_pw->pw_gid = my_static->pw_gid; 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); new_pw->pw_class = strdup(my_static->pw_class);
#endif #endif
new_pw->pw_gecos = strdup(my_static->pw_gecos); new_pw->pw_gecos = strdup(my_static->pw_gecos);