def createHome(self, datavars=None): """ Creating user profile and userdir """ self.initVars(datavars) self.verbose = self.clVars.Get('cl_verbose_set') == 'on' #uid = os.getuid() #try: # realUserName = pwd.getpwuid(uid).pw_name #except: # realUserName = "" userName = self.clVars.Get("ur_login") uidGid = False if self.clVars.isModuleInstalled("client"): # domain host domain = self.clVars.Get("client.cl_remote_host") # authorized in domain or local hostAuth = self.clVars.Get("client.os_remote_auth") else: domain = "" hostAuth = "" uid = self.clVars.Get('ur_uid') gid = self.clVars.Get('ur_gid') if not uid or not gid: raise DesktopError(_("Failed to determine the user UID")) uid,gid = int(uid),int(gid) self.homeDir = self.clVars.Get('ur_home_path') rootPath = self.clVars.Get('cl_root_path') # real path to home dir self.homeDir = path.join(rootPath, self.homeDir[1:]) if not path.exists(self.homeDir): self.startTask(_("Creating the home directory for %s")%self.homeDir) self.createUserDir(userName,uid,gid,self.homeDir) self.endTask() if (self.clVars.Get('ur_home_crypt_set') == 'on' and self.clVars.Get('install.cl_autologin') != userName): self.createCryptDir(userName,uid,gid,self.homeDir) domainUser = self.clVars.Get('ur_domain_set') == 'on' lastTimestamp = templateFunction.getLastElog() iniEnv = path.join(self.homeDir,'.calculate/ini.env') userIni = iniParser(iniEnv) userTimestamp = userIni.getVar('main','elog').encode('utf-8') if (domainUser or not path.exists(iniEnv) or userTimestamp != lastTimestamp): # action - "user profile configuration" self.clVars.Set("cl_action", "desktop", True) # apply user profiles self.startTask(_("Setting up the user profile"),progress=True) dirsAndFiles = self.applyTemplatesFromUser() self.endTask() if not dirsAndFiles: raise DesktopError(_("Failed to apply user profile templates")) self.printSUCCESS(_("User account %s is configured")%userName + " ...") return True
def get(self): lastTimestamp = templateFunction.getLastElog() iniEnv = path.join(self.Get('ur_home_path'),'.calculate/ini.env') userIni = iniParser(iniEnv) userTimestamp = userIni.getVar('main','elog').encode('utf-8') if self.Get('ur_domain_set') == 'on' or \ not path.exists(iniEnv) or userTimestamp != lastTimestamp: return 'on' else: return 'off'