[Buildbot-commits] buildbot/buildbot/scripts runner.py,1.13,1.14

Brian Warner warner at users.sourceforge.net
Tue Apr 26 20:10:12 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10452/buildbot/scripts

Modified Files:
	runner.py 
Log Message:
* buildbot/scripts/runner.py (loadOptions): do something sane for
windows, I think. We use %APPDATA%/buildbot instead of
~/.buildbot, but we still search everywhere from the current
directory up to the root for a .buildbot/ subdir. The "is it under
$HOME" security test was replaced with "is it owned by the current
user", which is only performed under posix.

* buildbot/test/test_runner.py (Options.testFindOptions): update
tests to match. The "is it owned by the current user" check is
untested. The test has been re-enabled for windows.


Index: runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/runner.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- runner.py	26 Apr 2005 09:14:10 -0000	1.13
+++ runner.py	26 Apr 2005 20:10:10 -0000	1.14
@@ -2,8 +2,8 @@
 
 # N.B.: don't import anything that might pull in a reactor yet. Some of our
 # subcommands want to load modules that need the gtk reactor.
-import os, os.path, sys, shutil
-from twisted.python import usage, util
+import os, os.path, sys, shutil, stat
+from twisted.python import usage, util, runtime
 
 # this is mostly just a front-end for mktap, twistd, and kill(1), but in the
 # future it will also provide an interface to some developer tools that talk
@@ -141,11 +141,12 @@
     # TODO: poll once per second until twistd.pid goes away
     sys.exit(0)
 
-def loadOptions(here=None, filename="options"):
-    """Find the .buildbot/FILENAME file. If we're somewhere under the user's
-    home directory, look in all directories between here and $HOME. If we're
-    elsewhere, only look in $HOME. exec() the first 'options' file we find.
-
+def loadOptions(filename="options", here=None, home=None):
+    """Find the .buildbot/FILENAME file. Crawl from the current directory up
+    towards the root, and also look in ~/.buildbot . The first directory
+    that's owned by the user and has the file we're looking for wins. Windows
+    skips the owned-by-user test.
+    
     @rtype : dict
     @return: a dictionary of names defined in the options file. If no options
     file was found, return an empty dict."""
@@ -153,30 +154,36 @@
     if here is None:
         here = os.getcwd()
     here = os.path.abspath(here)
-    home = os.path.expanduser("~")
+
+    if home is None:
+        if runtime.platformType == 'win32':
+            home = os.path.join(os.environ['APPDATA'], "buildbot")
+        else:
+            home = os.path.expanduser("~/.buildbot")
+
     searchpath = []
     toomany = 20
     while True:
-        searchpath.append(here)
-        if here == home:
-            break
+        searchpath.append(os.path.join(here, ".buildbot"))
         next = os.path.dirname(here)
         if next == here:
-            # we've hit the root, without seeing $HOME, so ignore everything
-            # except the user's home directory
-            searchpath = [home]
             break # we've hit the root
         here = next
         toomany -= 1 # just in case
         if toomany == 0:
             raise ValueError("Hey, I seem to have wandered up into the "
                              "infinite glories of the heavens. Oops.")
+    searchpath.append(home)
 
     localDict = {}
 
     for d in searchpath:
-        if os.path.isdir(os.path.join(d, ".buildbot")):
-            optfile = os.path.join(d, ".buildbot", filename)
+        if os.path.isdir(d):
+            if runtime.platformType != 'win32':
+                if os.stat(d)[stat.ST_UID] != os.getuid():
+                    print "skipping %s because you don't own it" % d
+                    continue # security, skip other people's directories
+            optfile = os.path.join(d, filename)
             if os.path.exists(optfile):
                 try:
                     f = open(optfile, "r")





More information about the Commits mailing list