summaryrefslogtreecommitdiff
path: root/libguile/posix.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-07-11 22:14:38 +0200
committerAndy Wingo <wingo@pobox.com>2016-07-25 11:24:26 +0200
commita9e726eda73b8f08ce64b201471b46789a105a7a (patch)
treef64363b939e898181f62c194022598823f18d80c /libguile/posix.c
parentb505ad9ad335de453e0ebcbd4e63e866e09092b0 (diff)
downloadguile-a9e726eda73b8f08ce64b201471b46789a105a7a.tar.gz
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.
Diffstat (limited to 'libguile/posix.c')
-rw-r--r--libguile/posix.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libguile/posix.c b/libguile/posix.c
index 494df1e0c..dfb5bf9c9 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),