Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 12 Jul 2014 11:55:06 -0600
From: Brent Cook <bcook@...nbsd.org>
To: musl@...ts.openwall.com
Cc: Brent Cook <bcook@...nbsd.org>
Subject: [PATCH] implement issetugid(2)

>From OpenBSD 2.0 and later
http://www.openbsd.org/cgi-bin/man.cgi?query=issetugid&sektion=2
---
 include/unistd.h       | 1 +
 src/unistd/issetugid.c | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 src/unistd/issetugid.c

diff --git a/include/unistd.h b/include/unistd.h
index bb19cd8..30290c3 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -109,6 +109,7 @@ uid_t geteuid(void);
 gid_t getgid(void);
 gid_t getegid(void);
 int getgroups(int, gid_t []);
+int issetugid(void);
 int setuid(uid_t);
 int setreuid(uid_t, uid_t);
 int seteuid(uid_t);
diff --git a/src/unistd/issetugid.c b/src/unistd/issetugid.c
new file mode 100644
index 0000000..8c81336
--- /dev/null
+++ b/src/unistd/issetugid.c
@@ -0,0 +1,9 @@
+#include <errno.h>
+#include <unistd.h>
+#include <sys/auxv.h>
+
+int issetugid(void)
+{
+	errno = 0;
+	return !(getauxval(AT_SECURE) == 0 && errno != ENOENT);
+}
--
1.9.1

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ