Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def modify_permiss(self, path, name,R=True):
- '''
- change file or directory permission
- :param name: linux user name\
- :param R: Recursive modify permission
- :return:
- '''
- idshell = 'id %s'%(name)
- code, output = self.execshell(idshell)
- if 'No such' not in output:
- uid = re.findall('uid=(.*?)\(', output)[0]
- gid = re.findall('gid=(.*?)\(', output)[0]
- gname = re.findall('\((.*?)\)', output)[1]
- if R:
- chownshell = 'chown -R %s:%s %s'%(name, gname, path)
- code, output = self.execshell(chownshell)
- else:
- os.chown(path, int(uid), int(gid))
Add Comment
Please, Sign In to add comment