Skip to content

Commit 1ffd502

Browse files
Restore the behaviour before r1915214.
* subversion/libsvn_subr/io.c (svn_io__is_finfo_read_only): As above (svn_io__is_finfo_executable): As above (svn_io_is_file_executable): As above git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1930473 13f79535-47bb-0310-9956-ffa450edef68
1 parent a629444 commit 1ffd502

File tree

1 file changed

+54
-10
lines changed
  • subversion/libsvn_subr

1 file changed

+54
-10
lines changed

subversion/libsvn_subr/io.c

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,14 +2531,27 @@ svn_io__is_finfo_read_only(svn_boolean_t *read_only,
25312531
apr_pool_t *pool)
25322532
{
25332533
#if defined(APR_HAS_USER) && !defined(WIN32) &&!defined(__OS2__)
2534-
*read_only = (access(file_info->fname, W_OK) != 0);
2535-
/* svn_io__is_finfo_read_only can be called with a dangling
2536-
* symlink. access() will check the permission on the missing
2537-
* target and return -1 and errno = ENOENT. Check for ENOENT
2538-
* and pretend the file is writeable, otherwise we will get
2539-
* spurious Reverted messages on the symlink.
2540-
*/
2541-
if (*read_only && errno == ENOENT) *read_only = FALSE;
2534+
apr_status_t apr_err;
2535+
apr_uid_t uid;
2536+
apr_gid_t gid;
2537+
2538+
*read_only = FALSE;
2539+
2540+
apr_err = apr_uid_current(&uid, &gid, pool);
2541+
2542+
if (apr_err)
2543+
return svn_error_wrap_apr(apr_err, _("Error getting UID of process"));
2544+
2545+
/* Check write bit for current user. */
2546+
if (apr_uid_compare(uid, file_info->user) == APR_SUCCESS)
2547+
*read_only = !(file_info->protection & APR_UWRITE);
2548+
2549+
else if (apr_gid_compare(gid, file_info->group) == APR_SUCCESS)
2550+
*read_only = !(file_info->protection & APR_GWRITE);
2551+
2552+
else
2553+
*read_only = !(file_info->protection & APR_WWRITE);
2554+
25422555
#else /* WIN32 || __OS2__ || !APR_HAS_USER */
25432556
*read_only = (file_info->protection & APR_FREADONLY);
25442557
#endif
@@ -2551,7 +2564,33 @@ svn_io__is_finfo_executable(svn_boolean_t *executable,
25512564
apr_finfo_t *file_info,
25522565
apr_pool_t *pool)
25532566
{
2554-
return svn_io_is_file_executable(executable, file_info->fname, pool);
2567+
#if defined(APR_HAS_USER) && !defined(WIN32) &&!defined(__OS2__)
2568+
apr_status_t apr_err;
2569+
apr_uid_t uid;
2570+
apr_gid_t gid;
2571+
2572+
*executable = FALSE;
2573+
2574+
apr_err = apr_uid_current(&uid, &gid, pool);
2575+
2576+
if (apr_err)
2577+
return svn_error_wrap_apr(apr_err, _("Error getting UID of process"));
2578+
2579+
/* Check executable bit for current user. */
2580+
if (apr_uid_compare(uid, file_info->user) == APR_SUCCESS)
2581+
*executable = (file_info->protection & APR_UEXECUTE);
2582+
2583+
else if (apr_gid_compare(gid, file_info->group) == APR_SUCCESS)
2584+
*executable = (file_info->protection & APR_GEXECUTE);
2585+
2586+
else
2587+
*executable = (file_info->protection & APR_WEXECUTE);
2588+
2589+
#else /* WIN32 || __OS2__ || !APR_HAS_USER */
2590+
*executable = FALSE;
2591+
#endif
2592+
2593+
return SVN_NO_ERROR;
25552594
}
25562595

25572596
svn_error_t *
@@ -2560,7 +2599,12 @@ svn_io_is_file_executable(svn_boolean_t *executable,
25602599
apr_pool_t *pool)
25612600
{
25622601
#if defined(APR_HAS_USER) && !defined(WIN32) &&!defined(__OS2__)
2563-
*executable = (access(path, X_OK) == 0);
2602+
apr_finfo_t file_info;
2603+
2604+
SVN_ERR(svn_io_stat(&file_info, path, APR_FINFO_PROT | APR_FINFO_OWNER,
2605+
pool));
2606+
SVN_ERR(svn_io__is_finfo_executable(executable, &file_info, pool));
2607+
25642608
#else /* WIN32 || __OS2__ || !APR_HAS_USER */
25652609
*executable = FALSE;
25662610
#endif

0 commit comments

Comments
 (0)