summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-21 04:41:11 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-21 04:41:11 +0000
commitba37db04533cec102212605488989c5d02bea67f (patch)
treebfb7f2503116497af27bbe5f1c5ce64ff0ccd414 /file.c
parent7c465090fd976fe6892a8ec64b036fa0696e3723 (diff)
* file.c (eaccess): use access() when not using setuid nor setgid.
This is minor optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/file.c b/file.c
index 1cc6066e99..19a99379ec 100644
--- a/file.c
+++ b/file.c
@@ -1077,11 +1077,15 @@ eaccess(const char *path, int mode)
struct stat st;
rb_uid_t euid;
+ euid = geteuid();
+
+ /* no setuid nor setgid. run shortcut. */
+ if (getuid() == euid && getgid() == getegid())
+ return access(path, mode);
+
if (STAT(path, &st) < 0)
return -1;
- euid = geteuid();
-
if (euid == 0) {
/* Root can read or write any file. */
if (!(mode & X_OK))