Skip to content
Snippets Groups Projects
Commit 661d57cc authored by Philip Chan's avatar Philip Chan
Browse files

subprocess.call instead of os.system

parent c2adcb2b
No related branches found
No related tags found
1 merge request!73copy skel files into user home
......@@ -3,7 +3,8 @@ import ldap
import traceback
import os
import stat
import shutil
#import shutil
import subprocess
class ldapSearchConfig:
def __init__(self):
......@@ -62,10 +63,10 @@ def recursive_chown(path,uidNumber,gidNumber):
if si.st_uid != uidNumber or si.st_gid != gidNumber:
raise Exception("user home %s uid %d != %d, gid %d != %d mismatch" % (path,si.st_uid,uidNumber,si.st_gid,gidNumber))
for root, dirs, files in os.walk(path):
for momo in dirs:
os.chown(os.path.join(root, momo), uidNumber, gidNumber)
for momo in files:
os.chown(os.path.join(root, momo), uidNumber, gidNumber)
for dname in dirs:
os.chown(os.path.join(root, dname), uidNumber, gidNumber)
for fname in files:
os.chown(os.path.join(root, fname), uidNumber, gidNumber)
def cp_skel(skelroot, path, uidNumber, gidNumber):
if skelroot is None:
......@@ -75,8 +76,10 @@ def cp_skel(skelroot, path, uidNumber, gidNumber):
skelpath = os.path.join(skelroot, 'common', 'skel')
if os.path.isdir(skelpath):
# copy the skel into the user $HOME
os.system("/bin/cp -r %s/* %s" % (skelpath, path))
os.system("/bin/cp %s/\.* %s" % (skelpath, path))
# os.system("/bin/cp -r %s/* %s" % (skelpath, path))
subprocess.call(['/bin/cp', '-r', "%s/*" % skelpath, path])
# os.system("/bin/cp %s/\.* %s" % (skelpath, path))
subprocess.call(['/bin/cp', "%s/.*" % skelpath, path])
# ideally use this, but it assumes 'path' does not exist
# shutil.copytree(skelpath, path)
# chown to user ownership
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment