1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* file.c (rb_stat_[rRwWxX]): check for super user.

fixed: [ruby-core:08616]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2006-08-17 10:15:55 +00:00
parent 5d863ccbac
commit 79b82a8749
2 changed files with 32 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Aug 17 19:15:16 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_stat_[rRwWxX]): check for super user.
fixed: [ruby-core:08616]
Thu Aug 17 14:47:06 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb: added rdoc by Daniel Berger. [ruby-core:08177]

28
file.c
View file

@ -818,11 +818,15 @@ group_member(GETGROUPS_T gid)
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#endif
#if defined(S_IXGRP) && !defined(_WIN32) && !defined(__CYGWIN__)
#define USE_GETEUID 1
#endif
#ifndef HAVE_EACCESS
int
eaccess(const char *path, int mode)
{
#if defined(S_IXGRP) && !defined(_WIN32) && !defined(__CYGWIN__)
#ifdef USE_GETEUID
struct stat st;
int euid;
@ -3655,6 +3659,9 @@ rb_stat_r(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
if (rb_stat_owned(obj))
return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
@ -3687,6 +3694,9 @@ rb_stat_R(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IRUSR
if (rb_stat_rowned(obj))
return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
@ -3743,6 +3753,9 @@ rb_stat_w(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
if (rb_stat_owned(obj))
return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
@ -3773,6 +3786,9 @@ rb_stat_W(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) return Qtrue;
#endif
#ifdef S_IWUSR
if (rb_stat_rowned(obj))
return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
@ -3831,6 +3847,11 @@ rb_stat_x(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (geteuid() == 0) {
return st->st_mode & S_IXUGO ? Qtrue : Qfalse;
}
#endif
#ifdef S_IXUSR
if (rb_stat_owned(obj))
return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
@ -3859,6 +3880,11 @@ rb_stat_X(VALUE obj)
{
struct stat *st = get_stat(obj);
#ifdef USE_GETEUID
if (getuid() == 0) {
return st->st_mode & S_IXUGO ? Qtrue : Qfalse;
}
#endif
#ifdef S_IXUSR
if (rb_stat_rowned(obj))
return st->st_mode & S_IXUSR ? Qtrue : Qfalse;