Last active
January 22, 2016 01:18
-
-
Save qbit/5682069 to your computer and use it in GitHub Desktop.
Diff to make OpenBSD's pdksh work on OSX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index c3a880c..c07ae39 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -17,6 +17,9 @@ OBJS+= openbsd/strlcat.o openbsd/strlcpy.o openbsd/setmode.o \ | |
DEFS= -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ | |
-DSYSTYPE=\"${OSTYPE}\" | |
CFLAGS+= ${DEFS} -I. -I${.CURDIR} | |
+.if ${OSTYPE} == "Darwin" | |
+LDFLAGS+= -arch x86_64 | |
+.endif | |
MAN= ksh.1 sh.1 | |
NOGCCERROR= 1 | |
diff --git a/main.c b/main.c | |
index 3bd46bd..f2ef692 100644 | |
--- a/main.c | |
+++ b/main.c | |
@@ -10,6 +10,10 @@ | |
#include <sys/stat.h> | |
#include <pwd.h> | |
+#ifdef __APPLE__ | |
+#include <sys/param.h> | |
+#endif | |
+ | |
extern char **environ; | |
/* | |
@@ -65,6 +69,8 @@ static const char *initcoms [] = { | |
#ifdef __FreeBSD__ | |
char username[_SC_LOGIN_NAME_MAX + 1]; | |
+#elif defined __APPLE__ | |
+ char username[MAXLOGNAME +1]; | |
#else | |
char username[LOGIN_NAME_MAX + 1]; | |
#endif | |
diff --git a/misc.c b/misc.c | |
index e41bef5..217130e 100644 | |
--- a/misc.c | |
+++ b/misc.c | |
@@ -296,9 +296,9 @@ change_flag(enum sh_flag f, | |
if (f == FPRIVILEGED && oldval && !newval) { | |
gid_t gid = getgid(); | |
- setresgid(gid, gid, gid); | |
+ setgid(gid); | |
setgroups(1, &gid); | |
- setresuid(ksheuid, ksheuid, ksheuid); | |
+ setuid(ksheuid); | |
} else if (f == FPOSIX && newval) { | |
#ifdef BRACE_EXPAND | |
Flag(FBRACEEXPAND) = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment