summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-17 10:15:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-17 10:15:55 +0000
commit55988fddc233c6c012735abf3f1f836f89c7989c (patch)
tree0831c7ee4eef0f490d9d9cafe8efcdcc9630f059
parent486a98479694b428e7790d0554aada2c296d93a5 (diff)
* file.c (rb_stat_[rRwWxX]): check for super user.
fixed: [ruby-core:08616] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--file.c28
2 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b7769324d..92fa8925ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]
diff --git a/file.c b/file.c
index cd787e57fd..790b0d3a2a 100644
--- a/file.c
+++ b/file.c
@@ -849,13 +849,17 @@ group_member(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(path, mode)
const char *path;
int mode;
{
-#if defined(S_IXGRP) && !defined(_WIN32) && !defined(__CYGWIN__)
+#ifdef USE_GETEUID
struct stat st;
int euid;
@@ -3744,6 +3748,9 @@ rb_stat_r(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;
@@ -3777,6 +3784,9 @@ rb_stat_R(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;
@@ -3808,6 +3818,9 @@ rb_stat_w(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;
@@ -3839,6 +3852,9 @@ rb_stat_W(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;
@@ -3872,6 +3888,11 @@ rb_stat_x(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;
@@ -3901,6 +3922,11 @@ rb_stat_X(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;