def sudo(cmd, remote=False, user=None): if remote: return fabric_sudo(cmd, user=user) else: if user: result = commands.getstatusoutput('sudo -u %s %s' % (user, cmd)) else: result = commands.getstatusoutput('sudo %s' % cmd) if result[0] == 0: return result else: print result[1] sys.exit(1)
def sudo(cmd): '''Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=639391''' username = os.environ['USER'] refcount_file = '/dev/shm/ecryptfs-%s-Private' % username if os.path.exists(refcount_file): fp = open(refcount_file,'r') count = int(fp.readlines()[0].strip()) fp.close() count += 1 fp = open(refcount_file,'w') fp.write('%d\n'%count) fp.close() print ('Incremented ecryptfs ref count to %d to protect against Debian bug 639391.' % count) return fabric_sudo(cmd)