summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-05 03:43:28 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-05 03:43:28 +0000
commit82d85fe441210bf847ef7f5b803a787bb15429d0 (patch)
treebcd67e358775e5388f853a27021c1f5f45e90d3f
parent2cf2d7ee20d614ff9aa1689dcf093fe6ddde6d2b (diff)
* configure.in: Check sys/id.h, getuidx and getgidx for AIX.
* process.c (getresuid): Defined for AIX. (getresgid): Ditto AIX don't have getresuid/getresgid but getuidx/getgidx. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--configure.in5
-rw-r--r--process.c39
3 files changed, 51 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 28c9024..d7006de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Sep 5 12:40:55 2014 Tanaka Akira <akr@fsij.org>
+
+ * configure.in: Check sys/id.h, getuidx and getgidx for AIX.
+
+ * process.c (getresuid): Defined for AIX.
+ (getresgid): Ditto
+ AIX don't have getresuid/getresgid but getuidx/getgidx.
+
Fri Sep 5 12:28:21 2014 Tanaka Akira <akr@fsij.org>
* process.c (has_privilege): Fix assignements.
diff --git a/configure.in b/configure.in
index 7934df7..97fff7c 100644
--- a/configure.in
+++ b/configure.in
@@ -1143,7 +1143,8 @@ AC_CHECK_HEADERS( \
malloc.h \
malloc_np.h \
malloc/malloc.h \
- setjmpex.h
+ setjmpex.h \
+ sys/id.h
)
AC_ARG_WITH([gmp],
@@ -1991,6 +1992,7 @@ AC_CHECK_FUNCS(fsync)
AC_CHECK_FUNCS(ftruncate)
AC_CHECK_FUNCS(ftruncate64) # used for Win32 platform
AC_CHECK_FUNCS(getcwd)
+AC_CHECK_FUNCS(getgidx)
AC_CHECK_FUNCS(getgrnam_r)
AC_CHECK_FUNCS(getgroups)
AC_CHECK_FUNCS(getpgid)
@@ -2002,6 +2004,7 @@ AC_CHECK_FUNCS(getresuid)
AC_CHECK_FUNCS(getrlimit)
AC_CHECK_FUNCS(getsid)
AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday
+AC_CHECK_FUNCS(getuidx)
AC_CHECK_FUNCS(gmtime_r)
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS(ioctl)
diff --git a/process.c b/process.c
index 22783b7..cfa466b 100644
--- a/process.c
+++ b/process.c
@@ -84,6 +84,9 @@
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
+#ifdef HAVE_SYS_ID_H
+#include <sys/id.h>
+#endif
#ifdef __APPLE__
# include <mach/mach_time.h>
@@ -3277,6 +3280,42 @@ recv_child_error(int fd, int *errp, char *errmsg, size_t errmsg_buflen)
return size != 0;
}
+#if !defined(HAVE_GETRESUID) && defined(HAVE_GETUIDX)
+/* AIX 7.1 */
+static int
+getresuid(rb_uid_t *ruid, rb_uid_t *euid, rb_uid_t *suid)
+{
+ rb_uid_t ret;
+
+ *ruid = getuid();
+ *euid = geteuid();
+ ret = getuidx(ID_SAVED);
+ if (ret == (rb_uid_t)-1)
+ return -1;
+ *suid = ret;
+ return 0;
+}
+#define HAVE_GETRESUID
+#endif
+
+#if !defined(HAVE_GETRESGID) && defined(HAVE_GETGIDX)
+/* AIX 7.1 */
+static int
+getresgid(rb_gid_t *rgid, rb_gid_t *egid, rb_gid_t *sgid)
+{
+ rb_gid_t ret;
+
+ *rgid = getgid();
+ *egid = getegid();
+ ret = getgidx(ID_SAVED);
+ if (ret == (rb_gid_t)-1)
+ return -1;
+ *sgid = ret;
+ return 0;
+}
+#define HAVE_GETRESGID
+#endif
+
static int
has_privilege(void)
{