Changeset e7125f4ec9d298e514b56f721ebac2a7be14b24a
- Timestamp:
- 05/05/08 22:34:21
(4 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1210019661 +0300
- git-parent:
[04a4af73ffcb9602a697e5b2bd8df21c9e9b3c6d]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1210016118 +0300
- Message:
Use getpwuid_r - thread safety
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra88db78 |
re7125f4 |
|
| 465 | 465 | |
|---|
| 466 | 466 | dnl Check for usual libc functions |
|---|
| 467 | | AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv posix_fadvise posix_madvise]) |
|---|
| | 467 | AC_CHECK_FUNCS([gettimeofday strtod strtol strtof strtoll strtoull strsep isatty vasprintf asprintf swab sigrelse getpwuid_r memalign posix_memalign if_nametoindex atoll getenv putenv setenv gmtime_r ctime_r localtime_r lrintf daemon scandir fork bsearch lstat strlcpy strdup strndup strnlen atof lldiv posix_fadvise posix_madvise]) |
|---|
| 468 | 468 | AC_CHECK_FUNCS(strcasecmp,,[AC_CHECK_FUNCS(stricmp)]) |
|---|
| 469 | 469 | AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)]) |
|---|
| r99fec92 |
re7125f4 |
|
| 40 | 40 | #endif |
|---|
| 41 | 41 | |
|---|
| 42 | | #if defined(HAVE_GETPWUID) |
|---|
| 43 | | # include <pwd.h> /* getpwuid() */ |
|---|
| | 42 | #if defined(HAVE_GETPWUID_R) |
|---|
| | 43 | # include <pwd.h> |
|---|
| 44 | 44 | #endif |
|---|
| 45 | 45 | |
|---|
| … | … | |
| 618 | 618 | } |
|---|
| 619 | 619 | |
|---|
| 620 | | /***************************************************************************** |
|---|
| 621 | | * config_GetHomeDir, config_GetUserDir: find the user's home directory. |
|---|
| 622 | | ***************************************************************************** |
|---|
| 623 | | * This function will try by different ways to find the user's home path. |
|---|
| 624 | | * Note that this function is not reentrant, it should be called only once |
|---|
| 625 | | * at the beginning of main where the result will be stored for later use. |
|---|
| 626 | | *****************************************************************************/ |
|---|
| 627 | 620 | static char *GetDir( bool b_appdata ) |
|---|
| 628 | 621 | { |
|---|
| … | … | |
| 672 | 665 | |
|---|
| 673 | 666 | #elif defined(UNDER_CE) |
|---|
| 674 | | |
|---|
| | 667 | (void)b_appdata; |
|---|
| 675 | 668 | #ifndef CSIDL_APPDATA |
|---|
| 676 | 669 | # define CSIDL_APPDATA 0x1A |
|---|
| … | … | |
| 682 | 675 | if( SHGetSpecialFolderPath( NULL, whomedir, CSIDL_APPDATA, 1 ) ) |
|---|
| 683 | 676 | return FromWide( whomedir ); |
|---|
| | 677 | #else |
|---|
| | 678 | (void)b_appdata; |
|---|
| 684 | 679 | #endif |
|---|
| 685 | 680 | |
|---|
| 686 | 681 | psz_localhome = getenv( "HOME" ); |
|---|
| | 682 | #if defined(HAVE_GETPWUID_R) |
|---|
| | 683 | char buf[sysconf (_SC_GETPW_R_SIZE_MAX)]; |
|---|
| 687 | 684 | if( psz_localhome == NULL ) |
|---|
| 688 | 685 | { |
|---|
| 689 | | #if defined(HAVE_GETPWUID) |
|---|
| 690 | | struct passwd *p_pw; |
|---|
| 691 | | (void)b_appdata; |
|---|
| 692 | | |
|---|
| 693 | | if( ( p_pw = getpwuid( getuid() ) ) != NULL ) |
|---|
| 694 | | psz_localhome = p_pw->pw_dir; |
|---|
| 695 | | else |
|---|
| 696 | | #endif |
|---|
| 697 | | { |
|---|
| 698 | | psz_localhome = getenv( "TMP" ); |
|---|
| 699 | | if( psz_localhome == NULL ) |
|---|
| 700 | | psz_localhome = "/tmp"; |
|---|
| 701 | | } |
|---|
| 702 | | } |
|---|
| | 686 | struct passwd pw, *res; |
|---|
| | 687 | |
|---|
| | 688 | if (!getpwuid_r (getuid (), &pw, buf, sizeof (buf), &res) && res) |
|---|
| | 689 | psz_localhome = pw.pw_dir; |
|---|
| | 690 | } |
|---|
| | 691 | #endif |
|---|
| | 692 | if (psz_localhome == NULL) |
|---|
| | 693 | psz_localhome = getenv( "TMP" ); |
|---|
| | 694 | if (psz_localhome == NULL) |
|---|
| | 695 | psz_localhome = "/tmp"; |
|---|
| 703 | 696 | |
|---|
| 704 | 697 | return FromLocaleDup( psz_localhome ); |
|---|