commit: 444f2af6280e2c0ce7e820033017a770201c3ee0
parent: eea25b61ce962faa514f402668ebdf295118ce87
author: Brian Callahan <dodonpachi-github@mailinator.com>
date: Thu, 9 Apr 2015 19:30:13 -0400
NetBSD does not have setresgid and setresuid so provide compatability calls in misc.c
Now that oksh supports NetBSD, release version oksh-3.
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
@@ -1,12 +1,13 @@
oksh
====
-ksh(1) from OpenBSD ported to FreeBSD.
+ksh(1) from OpenBSD ported to FreeBSD, DragonFly BSD, and NetBSD.
Might work on other operating systems too but not tested.
Why?
----
Sometimes I have to use FreeBSD. I don't like tcsh.
-OpenBSD's ksh is much better. Now FreeBSD users can use it too.
+ksh from OpenBSD is much better. Now FreeBSD users can use it too.
+Later ported to NetBSD. Hopefully a Linux port will come soon.
Designed to be as minimally invasive as possible.
Changes
@@ -15,6 +16,7 @@ Changes
* Added #include <sys/param.h> and changed _PW_NAME_LEN to MAXLOGNAME in main.c
* Added #define srand_deterministic block in var.c
* Added charclass.h from OpenBSD libc
+* NetBSD does not have setresgid and setresuid so provide compatability calls in misc.c
* Added LDFLAGS+=-static line in Makefile
* Renamed README to README.pdksh
* Added README.md (this file)
@@ -26,4 +28,4 @@ A couple are BSD licensed (alloc.c and mknod.c).
Get a tarball
-------------
-http://homepages.rpi.edu/~callab3/oksh-2.tar.gz
+http://homepages.rpi.edu/~callab3/oksh-3.tar.gz
diff --git a/misc.c b/misc.c
@@ -295,9 +295,19 @@ change_flag(enum sh_flag f,
if (f == FPRIVILEGED && oldval && !newval) {
gid_t gid = getgid();
+#ifdef __NetBSD__
+ setgid(gid);
+ setegid(gid);
+#else
setresgid(gid, gid, gid);
+#endif
setgroups(1, &gid);
+#ifdef __NetBSD__
+ setuid(ksheuid);
+ seteuid(ksheuid);
+#else
setresuid(ksheuid, ksheuid, ksheuid);
+#endif
} else if (f == FPOSIX && newval) {
#ifdef BRACE_EXPAND
Flag(FBRACEEXPAND) = 0