bug-coreutils
[Top][All Lists]
Advanced

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

better port of euidaccess.c to Solaris


From: Paul Eggert
Subject: better port of euidaccess.c to Solaris
Date: Tue, 27 Jul 2004 22:31:34 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I installed this to improve the port of euidaccess.c to Solaris.  This
lets setuid coreutils apps run without using setreuid to flip their
uids back and forth.

2004-07-27  Paul Eggert  <address@hidden>

        * lib/euidaccess.c [HAVE_LIBGEN_H]: Include <libgen.h>, for
        eaccess on Solaris and SVR4-like systems.
        (euidaccess): Use HAVE_EACCESS, not HAVE_DECL_EACCESS.
        * m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Don't bother checking for
        unistd.h, as autoconf does this for us.  Check for libgen.h.
        Also look for eaccess within -lgen, which is where it is in
        Solaris.  Set LIB_EACCESS accordingly.
        * src/Makefile.am (cp_LDADD, ginstall_LDADD, mv_LDADD,
        pathchk_LDADD, rm_LDADD, test_LDADD): New vars, for eaccess.

Index: lib/euidaccess.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/euidaccess.c,v
retrieving revision 1.17
diff -p -u -r1.17 euidaccess.c
--- lib/euidaccess.c    25 Jul 2004 07:37:22 -0000      1.17
+++ lib/euidaccess.c    28 Jul 2004 03:14:11 -0000
@@ -37,6 +37,10 @@
 # include <unistd.h>
 #endif
 
+#if HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
+
 #ifndef _POSIX_VERSION
 uid_t getuid ();
 gid_t getgid ();
@@ -93,7 +97,7 @@ euidaccess (const char *path, int mode)
   return access (path, mode | EFF_ONLY_OK);
 #elif defined ACC_SELF
   return accessx (path, mode, ACC_SELF);
-#elif HAVE_DECL_EACCESS
+#elif HAVE_EACCESS
   return eaccess (path, mode);
 #else
 
Index: m4/euidaccess.m4
===================================================================
RCS file: /home/eggert/coreutils/cu/m4/euidaccess.m4,v
retrieving revision 1.2
diff -p -u -r1.2 euidaccess.m4
--- m4/euidaccess.m4    25 Jul 2004 07:37:55 -0000      1.2
+++ m4/euidaccess.m4    28 Jul 2004 03:14:42 -0000
@@ -1,4 +1,4 @@
-# euidaccess.m4 serial 3
+# euidaccess.m4 serial 4
 dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -31,9 +31,21 @@ AC_DEFUN([gl_FUNC_EUIDACCESS],
 
 # Prerequisites of lib/euidaccess.c.
 AC_DEFUN([gl_PREREQ_EUIDACCESS], [
-  AC_CHECK_HEADERS_ONCE(unistd.h)
-  AC_CHECK_DECLS_ONCE(eaccess setregid)
+  AC_CHECK_HEADERS_ONCE(libgen.h)
+  AC_CHECK_DECLS_ONCE(setregid)
   AC_REQUIRE([AC_FUNC_GETGROUPS])
   AC_REQUIRE([AC_HEADER_STAT])
+
+  # Solaris 9 needs -lgen to get the eaccess function.
+  # Save and restore LIBS so -lgen isn't added to it.  Otherwise, *all*
+  # programs in the package would end up linked with that potentially-shared
+  # library, inducing unnecessary run-time overhead.
+  gl_saved_libs=$LIBS
+    AC_SEARCH_LIBS(eaccess, [gen],
+                   [test "$ac_cv_search_eaccess" = "none required" ||
+                    LIB_EACCESS=$ac_cv_search_eaccess])
+    AC_SUBST(LIB_EACCESS)
+    AC_CHECK_FUNCS(eaccess)
+  LIBS=$gl_saved_libs
 ])
 
Index: src/Makefile.am
===================================================================
RCS file: /home/eggert/coreutils/cu/src/Makefile.am,v
retrieving revision 1.39
diff -p -u -r1.39 Makefile.am
--- src/Makefile.am     13 May 2004 07:03:00 -0000      1.39
+++ src/Makefile.am     28 Jul 2004 04:28:15 -0000
@@ -32,6 +32,14 @@ AM_CPPFLAGS = -I.. -I$(srcdir) -I$(top_s
 # replacement functions defined in libfetish.a.
 LDADD = ../lib/libfetish.a $(LIBINTL) ../lib/libfetish.a
 
+# for eaccess in lib/euidaccess.c.
+cp_LDADD = $(LDADD) $(LIB_EACCESS)
+ginstall_LDADD = $(LDADD) $(LIB_EACCESS)
+mv_LDADD = $(LDADD) $(LIB_EACCESS)
+pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
+rm_LDADD = $(LDADD) $(LIB_EACCESS)
+test_LDADD = $(LDADD) $(LIB_EACCESS)
+
 # for clock_gettime and fdatasync
 dd_LDADD = $(LDADD) $(LIB_FDATASYNC)
 dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)




reply via email to

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