diff --git a/ChangeLog b/ChangeLog index be4e91b850..86a3f2bfcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Feb 21 13:04:59 2013 KOSAKI Motohiro + + * file.c (eaccess): use access() when not using setuid nor setgid. + This is minor optimization. + Thu Feb 21 12:56:19 2013 KOSAKI Motohiro * file.c (rb_group_member): get rid of NGROUPS dependency. 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))