Fix work with symlinks

master3.3
parent 4758208c1e
commit 813a1a6e72

@ -525,7 +525,7 @@ class Client(commandServer, encrypt):
return True
def syncUser(self, userName, userHome, sync, homeTemplate, \
host="default"):
host="default",skipList=[]):
"""
Sync user profile from server or to server
"""
@ -541,7 +541,7 @@ class Client(commandServer, encrypt):
deletePaths = []
excludePaths = " ".join(map(lambda x: '--exclude="/%s"'\
%x.replace('"',"").replace("'",""),
skipPaths + deletePaths))
skipPaths + deletePaths + skipList))
if sync == "login":
if os.path.exists(userHome) and\
os.path.exists(homeTemplate):
@ -1279,14 +1279,15 @@ class Client(commandServer, encrypt):
def tarSymLinks(self,userHome,uid,gid):
"""Create tar archive of symlinks"""
linkArch = pathJoin(userHome,".calculate/links.tar.bz2")
symList = []
try:
for filename in tarLinks(userHome,linkArch,
symList = list(tarLinks(userHome,linkArch,
skip=self.clVars.Get("cl_sync_del_path")+
self.clVars.Get("cl_sync_skip_path")):
try:
os.unlink(filename)
except OSError:
self.printWARNING(_("Failed to remove %s")%filename)
self.clVars.Get("cl_sync_skip_path")))
#try:
# os.unlink(filename)
#except OSError:
# self.printWARNING(_("Failed to remove %s")%filename)
except:
self.printWARNING(_("Failed to make a links archive"))
try:
@ -1294,6 +1295,7 @@ class Client(commandServer, encrypt):
os.chown(linkArch,uid,gid)
except:
self.printWARNING(_("Failed to make a links archive"))
return symList
def unpackLinks(self,userHome):
"""Unpack archive of symlinks"""
@ -1600,10 +1602,13 @@ class Client(commandServer, encrypt):
configFileName = os.path.join(self.homeDir, self.configFileDesktop)
self.setVarToConfig("main", {"date_logout":currentDateStr},
configFileName)
skipList = []
if os.path.exists(self.homeDir):
self.moveHomeDir(self.homeDir)
if self.sync:
self.tarSymLinks(self.homeDir,self.uid,self.gid)
skipList = self.tarSymLinks(self.homeDir,self.uid,self.gid)
lHomeDir = len(self.homeDir)+1
skipList = map(lambda x:x[lHomeDir:],skipList)
else:
raise ClientError(_("Directory %s not found") % self.homeDir)
# get status sync
@ -1628,7 +1633,8 @@ class Client(commandServer, encrypt):
if self.sync:
# sync profiles local to domain
if not self.syncUser(self.userName, self.homeDir, "logout",
homeProfile,host=self.domain):
homeProfile,host=self.domain,
skipList=skipList):
return False
finally:
# remove files, which hinder correct dm work

Loading…
Cancel
Save