SHARE
TWEET

Untitled

a guest Nov 14th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def modify_permiss(self, path, name,R=True):
  2.         '''
  3.         change file or directory permission
  4.         :param name: linux user name\
  5.         :param R: Recursive modify permission
  6.         :return:
  7.         '''
  8.         idshell = 'id %s'%(name)
  9.         code, output = self.execshell(idshell)
  10.         if 'No such' not in output:
  11.             uid = re.findall('uid=(.*?)\(', output)[0]
  12.             gid = re.findall('gid=(.*?)\(', output)[0]
  13.             gname = re.findall('\((.*?)\)', output)[1]
  14.             if R:
  15.                 chownshell = 'chown -R %s:%s %s'%(name, gname, path)
  16.                 code, output = self.execshell(chownshell)
  17.             else:
  18.                 os.chown(path, int(uid), int(gid))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top