[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

secure_getenv: Fix warning on Android

From: Bruno Haible
Subject: secure_getenv: Fix warning on Android
Date: Tue, 10 Jan 2023 14:27:36 +0100

Building a testdir on Android, I see this warning:

../../gllib/secure_getenv.c:34:7: warning: call to undeclared function 
'issetugid'; ISO C99 and later do not support implicit function declarations 

The reason is that the function issetugid is not declared; therefore we should
not use it.

This patch fixes it.

2023-01-10  Bruno Haible  <bruno@clisp.org>

        secure_getenv: Fix warning on Android.
        * m4/secure_getenv.m4 (gl_FUNC_SECURE_GETENV): Test for issetugid using
        * lib/secure_getenv.c: Fix comment regarding issetugid.

diff --git a/lib/secure_getenv.c b/lib/secure_getenv.c
index 8b2dd5ec17..a0bc0cf817 100644
--- a/lib/secure_getenv.c
+++ b/lib/secure_getenv.c
@@ -30,7 +30,7 @@ secure_getenv (char const *name)
 #if HAVE___SECURE_GETENV /* glibc */
   return __secure_getenv (name);
-#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */
+#elif HAVE_ISSETUGID /* musl, OS X, FreeBSD, NetBSD, OpenBSD, Solaris, Minix */
   if (issetugid ())
     return NULL;
   return getenv (name);
diff --git a/m4/secure_getenv.m4 b/m4/secure_getenv.m4
index 85104e3488..acb06507cc 100644
--- a/m4/secure_getenv.m4
+++ b/m4/secure_getenv.m4
@@ -1,4 +1,4 @@
-# Look up an environment variable more securely.
+# secure_getenv.m4 serial 2
 dnl Copyright 2013-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ AC_DEFUN([gl_FUNC_SECURE_GETENV],
   if test $ac_cv_func___secure_getenv = no; then
-    AC_CHECK_FUNCS([issetugid])
+    gl_CHECK_FUNCS_ANDROID([issetugid], [[#include <unistd.h>]])
   AC_CHECK_FUNCS_ONCE([getuid geteuid getgid getegid])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]