summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-23 06:02:15 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-23 06:02:15 +0000
commit1289a7a11fe55a4e37d923fc6b0af2c228e83175 (patch)
treefe8a90542f77c78ecdaef684d155c6ea66a7dcef /file.c
parente15efe7733f5e6e9377ae1bd2fc5f6029c919f1d (diff)
* eval.c (is_defined): should not dump core for "defined?(())".
* eval.c (umethod_bind): recv can be an instance of descender of oklass if oklass is a Module. * hash.c (rb_hash_equal): check identiry equality first. * file.c (group_member): should check real gid only. * file.c (eaccess): do not cache euid, since effective euid may be changed via Process.euid=(). * file.c (eaccess): return -1 unless every specified access mode is permitted. * eval.c (rb_eval): while/until returns the value which is given to break. * parse.y (value_expr): using while/until/class/def as an expression is now gives a warning, not an error. * range.c (range_eqq): should compare strings based on magical increment (using String#upto), not dictionary order. * enum.c (enum_sort_by): new method for Schewartzian transformed stable sort. * variable.c (mod_av_set): detect constant overriding for built-in classes/modules. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/file.c b/file.c
index 5357163..58eebe5 100644
--- a/file.c
+++ b/file.c
@@ -390,7 +390,7 @@ group_member(gid)
GETGROUPS_T gid;
{
#if !defined(NT)
- if (getgid() == gid || getegid() == gid)
+ if (getgid() == gid)
return Qtrue;
# ifdef HAVE_GETGROUPS
@@ -421,36 +421,36 @@ eaccess(path, mode)
int mode;
{
#ifdef S_IXGRP
- struct stat st;
- static int euid = -1;
+ struct stat st;
+ int euid;
- if (stat(path, &st) < 0) return (-1);
+ if (stat(path, &st) < 0) return -1;
- if (euid == -1)
- euid = geteuid ();
+ euid = geteuid();
- if (euid == 0)
- {
- /* Root can read or write any file. */
- if (mode != X_OK)
- return 0;
+ if (euid == 0) {
+ /* Root can read or write any file. */
+ if (!(mode & X_OK))
+ return 0;
- /* Root can execute any file that has any one of the execute
- bits set. */
- if (st.st_mode & S_IXUGO)
- return 0;
+ /* Root can execute any file that has any one of the execute
+ bits set. */
+ if (st.st_mode & S_IXUGO)
+ return 0;
+
+ return -1;
}
- if (st.st_uid == euid) /* owner */
- mode <<= 6;
- else if (group_member (st.st_gid))
- mode <<= 3;
+ if (st.st_uid == euid) /* owner */
+ mode <<= 6;
+ else if (getegid() == st.st_gid || group_member(st.st_gid))
+ mode <<= 3;
- if (st.st_mode & mode) return 0;
+ if ((st.st_mode & mode) == mode) return 0;
- return -1;
+ return -1;
#else
- return access(path, mode);
+ return access(path, mode);
#endif
}