Skip to content

Commit

Permalink
Merge pull request #1 from barkingiguana/random-tmp-filename
Browse files Browse the repository at this point in the history
Use a random filename to reduce name collisions
  • Loading branch information
craigw authored Apr 10, 2017
2 parents 35f065b + 5cfccbb commit 0c48488
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/chage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import shlex
import os
import json
import random
import string

args_file = sys.argv[1]
args_data = file(args_file).read()
Expand Down Expand Up @@ -86,8 +88,9 @@
sys.exit(1)

def chage_check(user):
os.system('chage -l "%s" > tmp' % user)
return open('tmp', 'r').read()
filename = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(32))
os.system('chage -l "%s" > %s' % (user, filename))
return open(filename, 'r').read()

before = chage_check(user)

Expand Down

0 comments on commit 0c48488

Please sign in to comment.