[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/05: More robust setuid, setgid, etc detection
From: |
Andy Wingo |
Subject: |
[Guile-commits] 01/05: More robust setuid, setgid, etc detection |
Date: |
Mon, 11 Jul 2016 20:55:11 +0000 (UTC) |
wingo pushed a commit to branch stable-2.0
in repository guile.
commit 509c4205baeabb499dba55b9b3df8303f56609fe
Author: Andy Wingo <address@hidden>
Date: Mon Jul 11 22:14:38 2016 +0200
More robust setuid, setgid, etc detection
* configure.ac: Check for getuid, getgid, setuid, and setgid.
* libguile/posix.c (scm_getuid, scm_getgid, scm_setuid, scm_setgid):
Only provide Scheme functions if the OS provides these facilities.
(scm_geteuid, scm_getegid, scm_seteuid, scm_setegid): Provide if the
host has getuid, getgid, etc, instead of being in a MinGW guard.
---
configure.ac | 4 ++--
libguile/posix.c | 30 ++++++++++++++++--------------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index 565fff5..cb61b09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -759,9 +759,9 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
#
AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid
\
fesetround ftime ftruncate fchown fchmod getcwd geteuid getsid \
- gettimeofday gmtime_r ioctl lstat mkdir mknod nice \
+ gettimeofday getuid getgid gmtime_r ioctl lstat mkdir mknod nice \
readdir_r readdir64_r readlink rename rmdir setegid seteuid \
- setlocale setpgid setsid sigaction siginterrupt stat64 \
+ setlocale setuid setgid setpgid setsid sigaction siginterrupt stat64 \
strptime symlink sync sysconf tcgetpgrp tcsetpgrp uname waitpid \
strdup system usleep atexit on_exit chown link fcntl ttyname getpwent
\
getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp \
diff --git a/libguile/posix.c b/libguile/posix.c
index 2654716..f37de83 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -800,8 +800,7 @@ SCM_DEFINE (scm_getppid, "getppid", 0, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_GETPPID */
-
-#ifndef __MINGW32__
+#ifdef HAVE_GETUID
SCM_DEFINE (scm_getuid, "getuid", 0, 0, 0,
(),
"Return an integer representing the current real user ID.")
@@ -810,9 +809,9 @@ SCM_DEFINE (scm_getuid, "getuid", 0, 0, 0,
return scm_from_int (getuid ());
}
#undef FUNC_NAME
+#endif /* HAVE_GETUID */
-
-
+#ifdef HAVE_GETGID
SCM_DEFINE (scm_getgid, "getgid", 0, 0, 0,
(),
"Return an integer representing the current real group ID.")
@@ -821,9 +820,9 @@ SCM_DEFINE (scm_getgid, "getgid", 0, 0, 0,
return scm_from_int (getgid ());
}
#undef FUNC_NAME
+#endif /* HAVE_GETGID */
-
-
+#ifdef HAVE_GETUID
SCM_DEFINE (scm_geteuid, "geteuid", 0, 0, 0,
(),
"Return an integer representing the current effective user ID.\n"
@@ -839,8 +838,9 @@ SCM_DEFINE (scm_geteuid, "geteuid", 0, 0, 0,
#endif
}
#undef FUNC_NAME
+#endif /* HAVE_GETUID */
-
+#ifdef HAVE_GETGID
SCM_DEFINE (scm_getegid, "getegid", 0, 0, 0,
(),
"Return an integer representing the current effective group ID.\n"
@@ -856,8 +856,9 @@ SCM_DEFINE (scm_getegid, "getegid", 0, 0, 0,
#endif
}
#undef FUNC_NAME
+#endif /* HAVE_GETGID */
-
+#ifdef HAVE_SETUID
SCM_DEFINE (scm_setuid, "setuid", 1, 0, 0,
(SCM id),
"Sets both the real and effective user IDs to the integer @var{id},
provided\n"
@@ -870,7 +871,9 @@ SCM_DEFINE (scm_setuid, "setuid", 1, 0, 0,
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
+#endif /* HAVE_SETUID */
+#ifdef HAVE_SETGID
SCM_DEFINE (scm_setgid, "setgid", 1, 0, 0,
(SCM id),
"Sets both the real and effective group IDs to the integer
@var{id}, provided\n"
@@ -883,7 +886,9 @@ SCM_DEFINE (scm_setgid, "setgid", 1, 0, 0,
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
+#endif /* HAVE_SETGID */
+#ifdef HAVE_SETUID
SCM_DEFINE (scm_seteuid, "seteuid", 1, 0, 0,
(SCM id),
"Sets the effective user ID to the integer @var{id}, provided the
process\n"
@@ -905,10 +910,9 @@ SCM_DEFINE (scm_seteuid, "seteuid", 1, 0, 0,
return SCM_UNSPECIFIED;
}
#undef FUNC_NAME
-#endif /* __MINGW32__ */
+#endif /* HAVE_SETUID */
-
-#ifdef HAVE_SETEGID
+#ifdef HAVE_SETGID
SCM_DEFINE (scm_setegid, "setegid", 1, 0, 0,
(SCM id),
"Sets the effective group ID to the integer @var{id}, provided the
process\n"
@@ -931,8 +935,7 @@ SCM_DEFINE (scm_setegid, "setegid", 1, 0, 0,
}
#undef FUNC_NAME
-#endif
-
+#endif /* HAVE_SETGID */
#ifdef HAVE_GETPGRP
SCM_DEFINE (scm_getpgrp, "getpgrp", 0, 0, 0,
@@ -948,7 +951,6 @@ SCM_DEFINE (scm_getpgrp, "getpgrp", 0, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_GETPGRP */
-
#ifdef HAVE_SETPGID
SCM_DEFINE (scm_setpgid, "setpgid", 2, 0, 0,
(SCM pid, SCM pgid),
- [Guile-commits] branch stable-2.0 updated (e2c1659 -> f6dd212), Andy Wingo, 2016/07/11
- [Guile-commits] 04/05: More specific status:exit-val et al compilation guards, Andy Wingo, 2016/07/11
- [Guile-commits] 02/05: Provide `kill' only if supported by the host, Andy Wingo, 2016/07/11
- [Guile-commits] 01/05: More robust setuid, setgid, etc detection,
Andy Wingo <=
- [Guile-commits] 05/05: Factor start_child out of open_process, Andy Wingo, 2016/07/11
- [Guile-commits] 03/05: getaffinity, setaffinity docstring cleanup, Andy Wingo, 2016/07/11