Guest User

Untitled

a guest
Nov 14th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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))
Add Comment
Please, Sign In to add comment