From 25ff7725cc934fff9bca44add76b5557c71e4a4a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 5 Apr 2012 15:16:50 -0700 Subject: [PATCH] e2fsck: add portability fallback in case getpwuid_r is not present Signed-off-by: "Theodore Ts'o" --- configure | 2 +- configure.in | 1 + e2fsck/logfile.c | 4 ++++ lib/config.h.in | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 8cb332cd..aae5e602 100755 --- a/configure +++ b/configure @@ -10893,7 +10893,7 @@ if test "$ac_res" != no; then : fi fi -for ac_func in __secure_getenv backtrace blkid_probe_get_topology chflags fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 getdtablesize getmntinfo getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mmap msync nanosleep open64 pathconf posix_fadvise posix_memalign prctl quotactl setresgid setresuid srandom strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc +for ac_func in __secure_getenv backtrace blkid_probe_get_topology chflags fallocate fallocate64 fchown fdatasync fstat64 ftruncate64 getdtablesize getmntinfo getpwuid_r getrlimit getrusage jrand48 llseek lseek64 mallinfo mbstowcs memalign mmap msync nanosleep open64 pathconf posix_fadvise posix_memalign prctl quotactl setresgid setresuid srandom strcasecmp strdup strnlen strptime strtoull sync_file_range sysconf usleep utime valloc do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 32d57684..e458a7d6 100644 --- a/configure.in +++ b/configure.in @@ -968,6 +968,7 @@ AC_CHECK_FUNCS(m4_flatten([ ftruncate64 getdtablesize getmntinfo + getpwuid_r getrlimit getrusage jrand48 diff --git a/e2fsck/logfile.c b/e2fsck/logfile.c index 76ae52d1..3bb15cd3 100644 --- a/e2fsck/logfile.c +++ b/e2fsck/logfile.c @@ -126,7 +126,11 @@ static void expand_percent_expression(e2fsck_t ctx, char ch, strcpy(buf, "tytso"); break; #else +#ifdef HAVE_GETPWUID_R getpwuid_r(getuid(), &pw_struct, buf, sizeof(buf), &pw); +#else + pw = getpwuid(getuid()); +#endif if (pw) append_string(s, pw->pw_name, 0); return; diff --git a/lib/config.h.in b/lib/config.h.in index f69eebe7..bd57a471 100644 --- a/lib/config.h.in +++ b/lib/config.h.in @@ -145,6 +145,9 @@ /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE +/* Define to 1 if you have the `getpwuid_r' function. */ +#undef HAVE_GETPWUID_R + /* Define to 1 if you have the `getrlimit' function. */ #undef HAVE_GETRLIMIT -- 2.11.0