diff --git a/jumpserver/api.py b/jumpserver/api.py index a4840f206..b9732f49c 100644 --- a/jumpserver/api.py +++ b/jumpserver/api.py @@ -463,9 +463,8 @@ def mkdir(dir_name, username='', mode=0755): insure the dir exist and mode ok 目录存在,如果不存在就建立,并且权限正确 """ - if not os.path.isdir(dir_name): - os.makedirs(dir_name) - os.chmod(dir_name, mode) + cmd = 'mkdir -p %s && chmod %s %s' % (dir_name, mode, dir_name) + bash(cmd) if username: chown(dir_name, username)