openbsd-ports/comms/minicom/patches/patch-ak
form bb05206d57 Do not use setreuid()/setregid() under OpenBSD,
use seteuid()/setegid() to set eff uid/gid,
use setuid()/setgid() to drop privs instead.
1998-12-20 12:09:47 +00:00

44 lines
1.1 KiB
Plaintext

--- util.c.orig Sat May 16 14:13:12 1998
+++ util.c Mon Dec 21 00:20:31 1998
@@ -165,7 +165,7 @@
/* Drop all priviliges (irreversable). */
void drop_all_privs()
{
-#ifdef HAS_REUID
+#if defined(HAS_REUID) && !defined(__OpenBSD__)
/* Regain privs needed to drop privs :) */
setregid(real_gid, eff_gid);
setreuid(real_uid, eff_uid);
@@ -183,9 +183,15 @@
void drop_privs()
{
#ifdef HAS_REUID
+# ifndef __OpenBSD__
setregid(eff_gid, real_gid);
if (setreuid(eff_uid, real_uid) < 0)
fprintf(stderr, "minicom: cannot setreuid(%d, %d)\n", eff_uid, real_uid);
+# else
+ setegid(real_gid);
+ if (seteuid(real_uid) < 0)
+ fprintf(stderr, "minicom: cannot seteuid(%d)\n", real_uid);
+# endif
not_suid = 1;
#endif
}
@@ -194,9 +200,15 @@
void set_privs()
{
#ifdef HAS_REUID
+# ifndef __OpenBSD__
setregid(real_gid, eff_gid);
if (setreuid(real_uid, eff_uid) < 0)
fprintf(stderr, "minicom: cannot setreuid(%d, %d)\n", real_uid, eff_uid);
+# else
+ setegid(eff_gid);
+ if (seteuid(eff_uid) < 0)
+ fprintf(stderr, "minicom: cannot setreuid(%d)\n", eff_uid);
+# endif
not_suid = 0;
#endif
}