Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite757cdd

Browse files
committed
Remove dead getpwuid_r replacement code.
getpwuid_r is in SUSv2 and all targeted Unix systems have it. We don'tuse it for Windows.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Greg Stark <stark@mit.edu>Reviewed-by: Robert Haas <robertmhaas@gmail.com>Discussion:https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
1 parentfb12bec commite757cdd

File tree

5 files changed

+6
-60
lines changed

5 files changed

+6
-60
lines changed

‎configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11751,7 +11751,7 @@ fi
1175111751

1175211752

1175311753

11754-
for ac_func in strerror_rgetpwuid_rgethostbyname_r
11754+
for ac_func in strerror_r gethostbyname_r
1175511755
do :
1175611756
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1175711757
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

‎configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ LIBS="$LIBS $PTHREAD_LIBS"
12141214
AC_CHECK_HEADER(pthread.h,[],[AC_MSG_ERROR([
12151215
pthread.h not found; use --disable-thread-safety to disable thread safety])])
12161216
1217-
AC_CHECK_FUNCS([strerror_rgetpwuid_rgethostbyname_r])
1217+
AC_CHECK_FUNCS([strerror_r gethostbyname_r])
12181218
12191219
# Do test here with the proper thread flags
12201220
PGAC_FUNC_STRERROR_R_INT

‎src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@
240240
/* Define to 1 if you have the `getpeerucred' function. */
241241
#undef HAVE_GETPEERUCRED
242242

243-
/* Define to 1 if you have the `getpwuid_r' function. */
244-
#undef HAVE_GETPWUID_R
245-
246243
/* Define to 1 if you have the `getrlimit' function. */
247244
#undef HAVE_GETRLIMIT
248245

‎src/port/thread.c

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,12 @@
1818

1919

2020
/*
21-
*Threading sometimes requires specially-named versions of functions
22-
*that return data in static buffers, like strerror_r() instead of
23-
*strerror(). Other operating systems use pthread_setspecific()
24-
*and pthread_getspecific() internally to allow standard library
25-
*functions to return static data to threaded applications. And some
26-
*operating systems have neither.
27-
*
28-
*Additional confusion exists because many operating systems that
29-
*use pthread_setspecific/pthread_getspecific() also have *_r versions
30-
*of standard library functions for compatibility with operating systems
31-
*that require them. However, internally, these *_r functions merely
32-
*call the thread-safe standard library functions.
33-
*
34-
*For example, BSD/OS 4.3 uses Bind 8.2.3 for getpwuid(). Internally,
35-
*getpwuid() calls pthread_setspecific/pthread_getspecific() to return
36-
*static data to the caller in a thread-safe manner. However, BSD/OS
37-
*also has getpwuid_r(), which merely calls getpwuid() and shifts
38-
*around the arguments to match the getpwuid_r() function declaration.
39-
*Therefore, while BSD/OS has getpwuid_r(), it isn't required. It also
40-
*doesn't have strerror_r(), so we can't fall back to only using *_r
41-
*functions for threaded programs.
42-
*
43-
*The current setup is to try threading in this order:
44-
*
45-
*use *_r function names if they exit
46-
*(*_THREADSAFE=yes)
47-
*use non-*_r functions if they are thread-safe
21+
* Historically, the code in this module had to deal with operating systems
22+
* that lacked getpwuid_r().
4823
*/
4924

5025
#ifndefWIN32
5126

52-
/*
53-
* Wrapper around getpwuid() or getpwuid_r() to mimic POSIX getpwuid_r()
54-
* behaviour, if that function is not available or required.
55-
*
56-
* Per POSIX, the possible cases are:
57-
* success: returns zero, *result is non-NULL
58-
* uid not found: returns zero, *result is NULL
59-
* error during lookup: returns an errno code, *result is NULL
60-
* (caller should *not* assume that the errno variable is set)
61-
*/
62-
staticint
63-
pqGetpwuid(uid_tuid,structpasswd*resultbuf,char*buffer,
64-
size_tbuflen,structpasswd**result)
65-
{
66-
#if defined(FRONTEND)&& defined(ENABLE_THREAD_SAFETY)&& defined(HAVE_GETPWUID_R)
67-
returngetpwuid_r(uid,resultbuf,buffer,buflen,result);
68-
#else
69-
/* no getpwuid_r() available, just use getpwuid() */
70-
errno=0;
71-
*result=getpwuid(uid);
72-
/* paranoia: ensure we return zero on success */
73-
return (*result==NULL) ?errno :0;
74-
#endif
75-
}
76-
7727
/*
7828
* pg_get_user_name - get the name of the user with the given ID
7929
*
@@ -89,7 +39,7 @@ pg_get_user_name(uid_t user_id, char *buffer, size_t buflen)
8939
structpasswd*pw=NULL;
9040
intpwerr;
9141

92-
pwerr=pqGetpwuid(user_id,&pwdstr,pwdbuf,sizeof(pwdbuf),&pw);
42+
pwerr=getpwuid_r(user_id,&pwdstr,pwdbuf,sizeof(pwdbuf),&pw);
9343
if (pw!=NULL)
9444
{
9545
strlcpy(buffer,pw->pw_name,buflen);
@@ -125,7 +75,7 @@ pg_get_user_home_dir(uid_t user_id, char *buffer, size_t buflen)
12575
structpasswd*pw=NULL;
12676
intpwerr;
12777

128-
pwerr=pqGetpwuid(user_id,&pwdstr,pwdbuf,sizeof(pwdbuf),&pw);
78+
pwerr=getpwuid_r(user_id,&pwdstr,pwdbuf,sizeof(pwdbuf),&pw);
12979
if (pw!=NULL)
13080
{
13181
strlcpy(buffer,pw->pw_dir,buflen);

‎src/tools/msvc/Solution.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ sub GenerateFiles
274274
HAVE_GETOPT_LONG=>undef,
275275
HAVE_GETPEEREID=>undef,
276276
HAVE_GETPEERUCRED=>undef,
277-
HAVE_GETPWUID_R=>undef,
278277
HAVE_GETRLIMIT=>undef,
279278
HAVE_GETTIMEOFDAY=>undef,
280279
HAVE_GSSAPI_GSSAPI_H=>undef,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp