[前][次][番号順一覧][スレッド一覧]

ruby-changes:27298

From: kosaki <ko1@a...>
Date: Thu, 21 Feb 2013 13:41:23 +0900 (JST)
Subject: [ruby-changes:27298] kosaki:r39350 (trunk): * file.c (eaccess): use access() when not using setuid nor setgid.

kosaki	2013-02-21 13:41:11 +0900 (Thu, 21 Feb 2013)

  New Revision: 39350

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39350

  Log:
    * file.c (eaccess): use access() when not using setuid nor setgid.
      This is minor optimization.

  Modified files:
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39349)
+++ ChangeLog	(revision 39350)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Feb 21 13:04:59 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* 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@g...>
 
 	* file.c (rb_group_member): get rid of NGROUPS dependency.
Index: file.c
===================================================================
--- file.c	(revision 39349)
+++ file.c	(revision 39350)
@@ -1077,11 +1077,15 @@ eaccess(const char *path, int mode) https://github.com/ruby/ruby/blob/trunk/file.c#L1077
     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))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]