Ejemplo n.º 1
0
    def copySessionStart(self):
        profile_tmp_dir = os.path.join(Profile.TEMPORARY_PROFILE_PATH,
                                       self.session.user.name)
        if os.path.exists(profile_tmp_dir):
            System.rchown(profile_tmp_dir, self.session.user.name)

        if self.homeDir is None or not os.path.isdir(self.homeDir):
            return

        d = os.path.join(self.profile_mount_point, "conf.Linux")
        if not System.mount_point_exist(d):
            return

        if self.profile['profile_mode'] == 'advanced':
            return

        # Copy conf files
        d = self.transformToLocaleEncoding(d)
        cmd = self.getRsyncMethod(d, self.homeDir,
                                  Config.profile_filters_filename, True)
        Logger.debug("rsync cmd '%s'" % (cmd))

        p = System.execute(cmd)
        if p.returncode is not 0:
            Logger.error("Unable to copy conf from profile")
            Logger.debug(
                "Unable to copy conf from profile, cmd '%s' return %d: %s" %
                (cmd, p.returncode, p.stdout.read()))
Ejemplo n.º 2
0
    def copySessionStart(self):
        profile_tmp_dir = os.path.join(Profile.TEMPORARY_PROFILE_PATH, self.session.user.name)
        if os.path.exists(profile_tmp_dir):
            System.rchown(profile_tmp_dir, self.session.user.name)

        if self.homeDir is None or not os.path.isdir(self.homeDir):
            return

        d = os.path.join(self.profile_mount_point, "conf.Linux")
        if not System.mount_point_exist(d):
            return

        if self.profile["profile_mode"] == "advanced":
            return

            # Copy conf files
        d = self.transformToLocaleEncoding(d)
        cmd = self.getRsyncMethod(d, self.homeDir, Config.profile_filters_filename, True)
        Logger.debug("rsync cmd '%s'" % (cmd))

        p = System.execute(cmd)
        if p.returncode is not 0:
            Logger.error("Unable to copy conf from profile")
            Logger.debug(
                "Unable to copy conf from profile, cmd '%s' return %d: %s" % (cmd, p.returncode, p.stdout.read())
            )
Ejemplo n.º 3
0
    def copySessionStart(self):
        d = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
        profile_tmp_dir = os.path.join(d, "ulteo", "profile",
                                       self.session.user.name)
        profile_tmp_dir = System.local_encode(profile_tmp_dir)
        profile_filter = System.local_encode(Config.profile_filters_filename)

        for f in [self.DesktopDir, self.DocumentsDir]:
            d = os.path.join(self.mountPoint, "Data", f)

            trial = 5
            while not os.path.exists(d):
                try:
                    os.makedirs(d)
                except OSError:
                    trial -= 1
                    if trial == 0:
                        Logger.exception("Failed to create directory %s" % d)
                        return False

                    time.sleep(random.randint(1, 10) / 100.0)
                    Logger.debug2(
                        "Profile mkdir failed (concurrent access because of more than one ApS)"
                    )
                    continue

        d = os.path.join(self.mountPoint,
                         "conf.Windows.%s" % System.getWindowsVersionName())
        if os.path.exists(d):

            # clean temporary file used by windows to load registry
            dirs = None
            try:
                dirs = os.listdir(d)
            except Exception:
                Logger.exception("Unable to list content of the directory %s" %
                                 d)
                return

            for content in dirs:
                if content.startswith(r"NTUSER.DAT.LOG") or content.startswith(
                        r"NTUSER.DAT{"):
                    try:
                        path = os.path.join(d, content)
                        os.remove(path)
                    except Exception:
                        Logger.exception("Unable to delete %s" % path)

            # Copy user registry

            src = os.path.join(d, "NTUSER.DAT")
            if os.path.exists(src):
                dst = os.path.join(self.session.windowsProfileDir,
                                   "NTUSER.DAT")

                rand = random.randrange(10000, 50000)

                hiveName_src = "OVD_%s_%d" % (str(self.session.id), rand)
                win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_src, src)

                hiveName_dst = "OVD_%s_%d" % (str(self.session.id), rand + 1)
                win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_dst, dst)

                hkey_src = win32api.RegOpenKey(win32con.HKEY_USERS,
                                               r"%s" % (hiveName_src), 0,
                                               win32con.KEY_ALL_ACCESS)
                hkey_dst = win32api.RegOpenKey(win32con.HKEY_USERS,
                                               r"%s" % (hiveName_dst), 0,
                                               win32con.KEY_ALL_ACCESS)

                Reg.CopyTree(hkey_src, "Software", hkey_dst,
                             self.registry_copy_blacklist)

                win32api.RegCloseKey(hkey_src)
                win32api.RegCloseKey(hkey_dst)

                win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_src)
                win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_dst)

            # Copy configuration File
            if self.profile['profile_mode'] == 'standard':
                cmd = self.getRsyncMethod(Profile.toCygPath(d),
                                          Profile.toCygPath(profile_tmp_dir),
                                          Profile.toCygPath(profile_filter))
                Logger.debug("rsync cmd '%s'" % (cmd))

                p = System.execute(cmd)
                if p.returncode is not 0:
                    Logger.error("Unable to copy conf from profile")
                    Logger.debug(
                        "Unable to copy conf from profile, cmd '%s' return %d: %s"
                        % (cmd, p.returncode, p.stdout.read()))

        if os.path.exists(profile_tmp_dir):
            System.rchown(profile_tmp_dir, self.session.user.name)
Ejemplo n.º 4
0
	def copySessionStart(self):
		d = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
		profile_tmp_dir = os.path.join(d, "ulteo", "profile", self.session.user.name)
		profile_tmp_dir = System.local_encode(profile_tmp_dir)
		profile_filter = System.local_encode(Config.profile_filters_filename)
		
		for f in [self.DesktopDir, self.DocumentsDir]:
			d = os.path.join(self.mountPoint, "Data", f)
			
			trial = 5
			while not os.path.exists(d):
				try:
					os.makedirs(d)
				except OSError:
					trial -= 1
					if trial == 0:
						Logger.exception("Failed to create directory %s"%d)
						return False
					
					time.sleep(random.randint(1,10)/100.0)
					Logger.debug2("Profile mkdir failed (concurrent access because of more than one ApS)")
					continue
		
		
		d = os.path.join(self.mountPoint, "conf.Windows.%s"%System.getWindowsVersionName())
		if os.path.exists(d):
			
			# clean temporary file used by windows to load registry
			dirs = None
			try:
				dirs = os.listdir(d)
			except Exception:
				Logger.exception("Unable to list content of the directory %s"%d)
				return
			
			for content in dirs:
				if content.startswith(r"NTUSER.DAT.LOG") or content.startswith(r"NTUSER.DAT{"):
					try :
						path = os.path.join(d, content)
						os.remove(path)
					except Exception:
						Logger.exception("Unable to delete %s"%path)
			
			# Copy user registry
			
			src = os.path.join(d, "NTUSER.DAT")
			if os.path.exists(src):
				dst = os.path.join(self.session.windowsProfileDir, "NTUSER.DAT")
				
				rand = random.randrange(10000, 50000)
				
				hiveName_src = "OVD_%s_%d"%(str(self.session.id), rand)
				win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_src, src)
				
				hiveName_dst = "OVD_%s_%d"%(str(self.session.id), rand+1)
				win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_dst, dst)
				
				hkey_src = win32api.RegOpenKey(win32con.HKEY_USERS, r"%s"%(hiveName_src), 0, win32con.KEY_ALL_ACCESS)
				hkey_dst = win32api.RegOpenKey(win32con.HKEY_USERS, r"%s"%(hiveName_dst), 0, win32con.KEY_ALL_ACCESS)
				
				Reg.CopyTree(hkey_src, "Software", hkey_dst, self.registry_copy_blacklist)
				
				win32api.RegCloseKey(hkey_src)
				win32api.RegCloseKey(hkey_dst)
				
				win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_src)
				win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_dst)
			
			# Copy configuration File
			if self.profile['profile_mode'] == 'standard':
				cmd = self.getRsyncMethod(Profile.toCygPath(d), Profile.toCygPath(profile_tmp_dir), Profile.toCygPath(profile_filter))
        	        	Logger.debug("rsync cmd '%s'"%(cmd))
				
		                p = System.execute(cmd)
        		        if p.returncode is not 0:
                		        Logger.error("Unable to copy conf from profile")
                        		Logger.debug("Unable to copy conf from profile, cmd '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read()))
			
		if os.path.exists(profile_tmp_dir):
			System.rchown(profile_tmp_dir, self.session.user.name)