openbsd-ports/comms/minicom/patches/patch-src_util_c
ckuethe 20bc216713 As I seem to be the only minicom user, take maintainership.
Update from 2.00.0 to 2.2.
Minicom 2.2 includes improved logging
2007-05-23 16:40:55 +00:00

58 lines
1.4 KiB
Plaintext

$OpenBSD: patch-src_util_c,v 1.2 2007/05/23 16:40:56 ckuethe Exp $
--- src/util.c.orig Thu May 17 12:48:49 2007
+++ src/util.c Thu May 17 12:48:54 2007
@@ -178,11 +178,16 @@ int fastsystem(char *cmd, char *in, char *out, char *e
/* Drop all priviliges (irreversable). */
void drop_all_privs(void)
{
+#ifdef HAS_EUID
+ setegid(real_gid);
+ seteuid(real_uid);
+#else
#ifdef HAS_REUID
/* Regain privs needed to drop privs :) */
setregid(real_gid, eff_gid);
setreuid(real_uid, eff_uid);
#endif
+#endif
/* Drop it. */
setgid(real_gid);
@@ -195,22 +200,36 @@ void drop_all_privs(void)
/* Drop priviliges (swap uid's) */
void drop_privs(void)
{
+#ifdef HAS_EUID
+ setegid(real_gid);
+ if (seteuid(real_uid) < 0)
+ fprintf(stderr, _("minicom: cannot seteuid(%d)\n"), real_uid);
+ not_suid = 1;
+#else
#ifdef HAS_REUID
setregid(eff_gid, real_gid);
if (setreuid(eff_uid, real_uid) < 0)
fprintf(stderr, _("minicom: cannot setreuid(%d, %d)\n"), eff_uid, real_uid);
not_suid = 1;
#endif
+#endif
}
/* Set priviliges (swap uid's) */
void set_privs(void)
{
+#ifdef HAS_EUID
+ setegid(eff_gid);
+ if (seteuid(eff_uid) < 0)
+ fprintf(stderr, _("minicom: cannot seteuid(%d, %d)\n"), eff_uid);
+ not_suid = 0;
+#else
#ifdef HAS_REUID
setregid(real_gid, eff_gid);
if (setreuid(real_uid, eff_uid) < 0)
fprintf(stderr, _("minicom: cannot setreuid(%d, %d)\n"), real_uid, eff_uid);
not_suid = 0;
+#endif
#endif
}