mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
7c465090fd
commit
ba37db0453
2 changed files with 11 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Feb 21 13:04:59 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* file.c (eaccess): use access() when not using setuid nor setgid.
|
||||||
|
This is minor optimization.
|
||||||
|
|
||||||
Thu Feb 21 12:56:19 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Thu Feb 21 12:56:19 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* file.c (rb_group_member): get rid of NGROUPS dependency.
|
* file.c (rb_group_member): get rid of NGROUPS dependency.
|
||||||
|
|
8
file.c
8
file.c
|
@ -1077,11 +1077,15 @@ eaccess(const char *path, int mode)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
rb_uid_t euid;
|
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)
|
if (STAT(path, &st) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
euid = geteuid();
|
|
||||||
|
|
||||||
if (euid == 0) {
|
if (euid == 0) {
|
||||||
/* Root can read or write any file. */
|
/* Root can read or write any file. */
|
||||||
if (!(mode & X_OK))
|
if (!(mode & X_OK))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue