]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fall back to getgrgid and getpwuid if the reentrant versions are missing.
authorJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Sat, 19 Jun 2010 17:25:58 +0000 (13:25 -0400)
committerJoerg Sonnenberger <joerg.sonnenberger@gmail.com>
Sat, 19 Jun 2010 17:25:58 +0000 (13:25 -0400)
SVN-Revision: 2490

CMakeLists.txt
build/cmake/config.h.in
configure.ac
libarchive/archive_read_disk_set_standard_lookup.c

index 716a70d9deebe0d6b1d8f36282a50da6a4333921..69107bea3bc34248ea3745c793e4efc8ec7d8537 100644 (file)
@@ -492,8 +492,10 @@ CHECK_FUNCTION_EXISTS_GLIBC(ftruncate HAVE_FTRUNCATE)
 CHECK_FUNCTION_EXISTS_GLIBC(futimens HAVE_FUTIMENS)
 CHECK_FUNCTION_EXISTS_GLIBC(futimes HAVE_FUTIMES)
 CHECK_FUNCTION_EXISTS_GLIBC(geteuid HAVE_GETEUID)
+CHECK_FUNCTION_EXISTS_GLIBC(getgrgid_r HAVE_GETGRGID_R)
 CHECK_FUNCTION_EXISTS_GLIBC(getgrnam_r HAVE_GETGRNAM_R)
 CHECK_FUNCTION_EXISTS_GLIBC(getpwnam_r HAVE_GETPWNAM_R)
+CHECK_FUNCTION_EXISTS_GLIBC(getpwuid_r HAVE_GETPWUID_R)
 CHECK_FUNCTION_EXISTS_GLIBC(getpid HAVE_GETPID)
 CHECK_FUNCTION_EXISTS_GLIBC(gmtime_r HAVE_GMTIME_R)
 CHECK_FUNCTION_EXISTS_GLIBC(lchflags HAVE_LCHFLAGS)
index 736591898437560ea1b5f0b5928425ec87aa6420..ba871812ea075f360b1d04bccf8327fc80e2d1b9 100644 (file)
 /* Define to 1 if you have the `geteuid' function. */
 #cmakedefine HAVE_GETEUID 1
 
+/* Define to 1 if you have the `getgrgid_r' function. */
+#cmakedefine HAVE_GETGRGID_R
+
 /* Define to 1 if you have the `getgrnam_r' function. */
 #cmakedefine HAVE_GETGRNAM_R 1
 
 /* Define to 1 if you have the `getpwnam_r' function. */
 #cmakedefine HAVE_GETPWNAM_R 1
 
+/* Define to 1 if you have the `getpwuid_r' function. */
+#cmakedefine HAVE_GETPWUID_R
+
 /* Define to 1 if you have the `getpid' function. */
 #cmakedefine HAVE_GETPID 1
 
index 3b2fbca5905edc2f86bc124b805442d81b468902..a0c19505fbb44041f60f5a0619b1596d6031306c 100644 (file)
@@ -415,7 +415,7 @@ AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *])
 AC_CHECK_FUNCS([chflags chown chroot ctime_r])
 AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork])
 AC_CHECK_FUNCS([fstat ftruncate futimens futimes geteuid getpid])
-AC_CHECK_FUNCS([getgrnam_r getpwnam_r gmtime_r])
+AC_CHECK_FUNCS([getgrgid_r getgrnam_r getpwnam_r getpwuid_r gmtime_r])
 AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat])
 AC_CHECK_FUNCS([lutimes mbrtowc memmove memset mkdir mkfifo mknod mkstemp])
 AC_CHECK_FUNCS([nl_langinfo pipe poll readlink])
index ceaf0cf2d9b25892571f1b1ef5412ab8ccf7a4d9..c302b98dfb4166afb97a5646d53e50444dc07a96 100644 (file)
@@ -192,6 +192,7 @@ lookup_uname(void *data, int64_t uid)
                    &lookup_uname_helper, (id_t)uid));
 }
 
+#if HAVE_GETPWUID_R
 static const char *
 lookup_uname_helper(struct name_cache *cache, id_t id)
 {
@@ -232,6 +233,20 @@ lookup_uname_helper(struct name_cache *cache, id_t id)
 
        return strdup(result->pw_name);
 }
+#else
+static const char *
+lookup_uname_helper(struct name_cache *cache, id_t id)
+{
+       struct passwd   *result;
+
+       result = getpwuid((uid_t)id);
+
+       if (result == NULL)
+               return (NULL);
+
+       return strdup(result->pw_name);
+}
+#endif
 
 #if ARCHIVE_VERSION_NUMBER < 3000000
 static const char *
@@ -246,6 +261,7 @@ lookup_gname(void *data, int64_t gid)
                    &lookup_gname_helper, (id_t)gid));
 }
 
+#if HAVE_GETGRGID_R
 static const char *
 lookup_gname_helper(struct name_cache *cache, id_t id)
 {
@@ -284,4 +300,19 @@ lookup_gname_helper(struct name_cache *cache, id_t id)
 
        return strdup(result->gr_name);
 }
+#else
+static const char *
+lookup_gname_helper(struct name_cache *cache, id_t id)
+{
+       struct group    *result;
+
+       result = getgrgid((gid_t)id);
+
+       if (result == NULL)
+               return (NULL);
+
+       return strdup(result->gr_name);
+}
+#endif
+
 #endif /* ! (_WIN32 && !__CYGWIN__) */