Permalink
Browse files

Implement the safedir option

  • Loading branch information...
1 parent 135e153 commit de906a60dc3db1c0d50a338fc562ad50caea3dc4 @tom111 tom111 committed Mar 22, 2012
Showing with 16 additions and 1 deletion.
  1. +5 −0 manual.org
  2. +10 −1 scripts/tatt
  3. +1 −0 tatt/dot-tatt-spec
View
@@ -85,3 +85,8 @@ The specification of the configuration file can be found in dot-tatt-spec which
# Url where the pre-generated rindex is to be found
# tinderbox-url="http://qa-reports.gentoo.org/output/genrdeps/rindex/"
+
+# If this is set, then tatt will refuse to run in a directory that does not
+# match this string. Use it as a safety measure against creating tatt-scripts
+# in random places of you filesystem
+# safedir=string(default="")
View
@@ -92,11 +92,20 @@ try:
int(options.bugnum)
except ValueError:
print ("The bugnumber you gave with -b should be an integer.")
- exit(1);
+ exit(1)
except TypeError:
# This occurs if bugnum is None, that is, -b was not given
pass
+## If safedir is set, check for the current directory
+if config['safedir'] != "":
+ if os.getcwd().find(config['safedir']) == -1:
+ # Safedir not found
+ print ("Your safedir variable is set to '" + config['safedir'] + "',")
+ print ("but you are in " + os.getcwd())
+ print ("Exiting.")
+ exit (1)
+
## Checking for root, tatt should be run as a user, I guess.
## Remove on occasion.
if (Popen(['whoami'], stdout=PIPE).communicate()[0].rstrip() == 'root'):
View
@@ -9,3 +9,4 @@ rdeps=integer(0,50,default=10)
usecombis=integer(0,64,default=12)
repodir=string(default="")
tinderbox-url=string(default="http://qa-reports.gentoo.org/output/genrdeps/rindex/")
+safedir=string(default="")

0 comments on commit de906a6

Please sign in to comment.