# may come here if pop substepStack, e.g., exit() self.setSubstepEnv({'next': self.start}) return else: raise try: if trial1 != trial2: raise ValueError(errNotMatch) users.sanityCheckPassword(trial1) except ValueError, ex: msg = "%s\n" % str(ex) self.errorPushPop(title, msg + TransMenu.Back) return userchoices.setRootPassword(users.cryptPassword(trial1), userchoices.ROOTPASSWORD_TYPE_MD5) self.setSubstepEnv( {'next': self.stepForward} ) def help(self): ui = { 'title': title, 'body': helpText, 'menu': { '<': self.start, '*': self.start, } } self.setSubstepEnv(ui)
def writeKS(self, filename): f = open(filename, "w") f.write("# Kickstart file automatically generated by anaconda.\n\n") f.write("#version=%s\n" % versionToString(RHEL6)) if self.upgrade: f.write("upgrade\n") else: f.write("install\n") m = None if self.anaconda.methodstr: m = self.anaconda.methodstr elif self.anaconda.stage2: m = self.anaconda.stage2 if m: if m.startswith("cdrom:"): f.write("cdrom\n") elif m.startswith("hd:"): if m.count(":") == 3: (part, fs, dir) = string.split(m[3:], ":") else: (part, dir) = string.split(m[3:], ":") f.write("harddrive --partition=%s --dir=%s\n" % (part, dir)) elif m.startswith("nfs:") or m.startswith("nfsiso:"): if m.count(":") == 3: (method, opts, server, dir) = m.split(":") f.write("nfs --server=%s --opts=%s --dir=%s\n" % (server, opts, dir)) else: (method, server, dir) = m.split(":") f.write("nfs --server=%s --dir=%s\n" % (server, dir)) elif m.startswith("ftp://") or m.startswith("http"): ssl = "" if flags.noverifyssl: ssl = " --noverifyssl" f.write("url --url=%s%s\n" % (urllib.unquote(m), ssl)) self.instLanguage.writeKS(f) if not self.isHeadless: self.keyboard.writeKS(f) self.network.writeKS(f) if self.rootPassword["isCrypted"]: args = " --iscrypted %s" % self.rootPassword["password"] else: args = " --iscrypted %s" % users.cryptPassword( self.rootPassword["password"], algo=self.getPassAlgo()) if self.rootPassword["lock"]: args += " --lock" f.write("rootpw %s\n" % args) # Some kickstart commands do not correspond to any anaconda UI # component. If this is a kickstart install, we need to make sure # the information from the input file ends up in the output file. if self.anaconda.isKickstart: f.write(self.ksdata.user.__str__()) f.write(self.ksdata.services.__str__()) f.write(self.ksdata.reboot.__str__()) self.firewall.writeKS(f) if self.auth.strip() != "": f.write("authconfig %s\n" % self.auth) self.security.writeKS(f) self.timezone.writeKS(f) self.bootloader.writeKS(f) self.storage.writeKS(f) if self.backend is not None: self.backend.writeKS(f) self.backend.writePackagesKS(f, self.anaconda) # Also write out any scripts from the input ksfile. if self.anaconda.isKickstart: for s in self.ksdata.scripts: f.write(s.__str__()) # make it so only root can read, could have password os.chmod(filename, 0600)
def writeKS(self, filename): f = open(filename, "w") f.write("# Kickstart file automatically generated by anaconda.\n\n") f.write("#version=%s\n" % versionToString(RHEL6)) if self.upgrade: f.write("upgrade\n") else: f.write("install\n") m = None if self.anaconda.methodstr: m = self.anaconda.methodstr elif self.anaconda.stage2: m = self.anaconda.stage2 if m: if m.startswith("cdrom:"): f.write("cdrom\n") elif m.startswith("hd:"): if m.count(":") == 3: (part, fs, dir) = string.split(m[3:], ":") else: (part, dir) = string.split(m[3:], ":") f.write("harddrive --partition=%s --dir=%s\n" % (part, dir)) elif m.startswith("nfs:") or m.startswith("nfsiso:"): if m.count(":") == 3: (method, opts, server, dir) = m.split(":") f.write("nfs --server=%s --opts=%s --dir=%s\n" % (server, opts, dir)) else: (method, server, dir) = m.split(":") f.write("nfs --server=%s --dir=%s\n" % (server, dir)) elif m.startswith("ftp://") or m.startswith("http"): ssl = "" if flags.noverifyssl: ssl = " --noverifyssl" f.write("url --url=%s%s\n" % (urllib.unquote(m), ssl)) self.instLanguage.writeKS(f) if not self.isHeadless: self.keyboard.writeKS(f) self.network.writeKS(f) if self.rootPassword["isCrypted"]: args = " --iscrypted %s" % self.rootPassword["password"] else: args = " --iscrypted %s" % users.cryptPassword(self.rootPassword["password"], algo=self.getPassAlgo()) if self.rootPassword["lock"]: args += " --lock" f.write("rootpw %s\n" % args) # Some kickstart commands do not correspond to any anaconda UI # component. If this is a kickstart install, we need to make sure # the information from the input file ends up in the output file. if self.anaconda.isKickstart: f.write(self.ksdata.user.__str__()) f.write(self.ksdata.services.__str__()) f.write(self.ksdata.reboot.__str__()) self.firewall.writeKS(f) if self.auth.strip() != "": f.write("authconfig %s\n" % self.auth) self.security.writeKS(f) self.timezone.writeKS(f) self.bootloader.writeKS(f) self.storage.writeKS(f) if self.backend is not None: self.backend.writeKS(f) self.backend.writePackagesKS(f, self.anaconda) # abiquo kickstarts self.abiquo.writeKS(f) self.abiquo_rs.writeKS(f) # Also write out any scripts from the input ksfile. if self.anaconda.isKickstart: for s in self.ksdata.scripts: f.write(s.__str__()) # make it so only root can read, could have password os.chmod(filename, 0600)
def writeKS(self, filename): f = open(filename, "w") f.write("# Kickstart file automatically generated by anaconda.\n\n") if self.upgrade: f.write("upgrade\n") else: f.write("install\n") # figure out the install method and write out a line if self.methodstr.startswith('ftp://') or self.methodstr.startswith( 'http://'): f.write("url --url %s\n" % urllib.unquote(self.methodstr)) elif self.methodstr.startswith('cdrom://'): f.write("cdrom\n") elif self.methodstr.startswith('hd://'): pidx = string.find(self.methodstr, '//') + 2 didx = string.find(self.methodstr[pidx:], '/') partition = string.split(self.methodstr[pidx:pidx + didx], ':')[0] dir = self.methodstr[pidx + didx + 1:] f.write("harddrive --partition=%s --dir=%s\n" % (partition, dir)) elif self.methodstr.startswith('nfs:/') or self.methodstr.startswith( 'nfsiso:'): (method, tmpmntpt) = string.split(self.methodstr, ':') # clean up extra '/' at front if tmpmntpt[1] == '/': rawmntpt = tmpmntpt[1:] else: rawmntpt = tmpmntpt mntpt = os.path.normpath(rawmntpt) # find mntpt in /proc/mounts so we can get NFS server info fproc = open("/proc/mounts", "r") lines = fproc.readlines() fproc.close() for l in lines: minfo = string.split(l) if len(minfo) > 1 and minfo[1] == mntpt and minfo[0].find( ":") != -1: (srv, dir) = minfo[0].split(':') f.write("nfs --server=%s --dir=%s\n" % (srv, dir)) break if self.instClass.skipkey: f.write("key --skip\n") elif self.instClass.installkey: f.write("key %s\n" % (self.instClass.installkey, )) self.instLanguage.writeKS(f) if not self.isHeadless: self.keyboard.writeKS(f) self.xsetup.writeKS(f, self.desktop, self.ksdata) self.network.writeKS(f) self.zfcp.writeKS(f) self.iscsi.writeKS(f) if self.rootPassword["isCrypted"]: f.write("rootpw --iscrypted %s\n" % self.rootPassword["password"]) else: f.write("rootpw --iscrypted %s\n" % users.cryptPassword( self.rootPassword["password"], salt=self.getSalt())) self.firewall.writeKS(f) if self.auth.strip() != "": f.write("authconfig %s\n" % self.auth) self.security.writeKS(f) self.timezone.writeKS(f) self.bootloader.writeKS(f) self.partitions.writeKS(f) if self.backend is not None: self.backend.writeKS(f) self.backend.writePackagesKS(f, self.anaconda) # make it so only root can read, could have password os.chmod(filename, 0600)
def writeKS(self, filename): f = open(filename, "w") f.write("# Kickstart file automatically generated by anaconda.\n\n") if self.upgrade: f.write("upgrade\n"); else: f.write("install\n"); # figure out the install method and write out a line if self.methodstr.startswith('ftp://') or self.methodstr.startswith('http://'): f.write("url --url %s\n" % urllib.unquote(self.methodstr)) elif self.methodstr.startswith('cdrom://'): f.write("cdrom\n") elif self.methodstr.startswith('hd://'): pidx = string.find(self.methodstr, '//') + 2 didx = string.find(self.methodstr[pidx:], '/') partition = string.split(self.methodstr[pidx:pidx+didx], ':')[0] dir = self.methodstr[pidx+didx+1:] f.write("harddrive --partition=%s --dir=%s\n" % (partition, dir)) elif self.methodstr.startswith('nfs:/') or self.methodstr.startswith('nfsiso:'): (method, tmpmntpt) = string.split(self.methodstr, ':') # clean up extra '/' at front if tmpmntpt[1] == '/': rawmntpt = tmpmntpt[1:] else: rawmntpt = tmpmntpt mntpt = os.path.normpath(rawmntpt) # find mntpt in /proc/mounts so we can get NFS server info fproc = open("/proc/mounts", "r") lines = fproc.readlines() fproc.close() for l in lines: minfo = string.split(l) if len(minfo) > 1 and minfo[1] == mntpt and minfo[0].find(":") != -1: (srv, dir) = minfo[0].split(':') f.write("nfs --server=%s --dir=%s\n" % (srv, dir)) break if self.instClass.skipkey: f.write("key --skip\n") elif self.instClass.installkey: f.write("key %s\n" %(self.instClass.installkey,)) self.instLanguage.writeKS(f) if not self.isHeadless: self.keyboard.writeKS(f) self.xsetup.writeKS(f, self.desktop, self.ksdata) self.network.writeKS(f) self.zfcp.writeKS(f) self.iscsi.writeKS(f) if self.rootPassword["isCrypted"]: f.write("rootpw --iscrypted %s\n" % self.rootPassword["password"]) else: f.write("rootpw --iscrypted %s\n" % users.cryptPassword(self.rootPassword["password"], salt=self.getSalt())) self.firewall.writeKS(f) if self.auth.strip() != "": f.write("authconfig %s\n" % self.auth) self.security.writeKS(f) self.timezone.writeKS(f) self.bootloader.writeKS(f) self.partitions.writeKS(f) if self.backend is not None: self.backend.writeKS(f) self.backend.writePackagesKS(f, self.anaconda) self.abiquo.writeKS(f) self.abiquo_rs.writeKS(f) # make it so only root can read, could have password os.chmod(filename, 0600)
class PasswordWindow: SCREEN_NAME = 'rootpassword' def __init__(self, controlState, xml): controlState.displayHeaderBar = True controlState.windowIcon = 'adminpassword.png' controlState.windowTitle = "Set Administrator Password" controlState.windowText = \ "Enter the administrator (root) password for ESX" self.controlState = controlState self.xml = xml self.accounts = [] self.passwdEntry1 = self.xml.get_widget("RootpasswordPassword1Entry") self.passwdEntry2 = self.xml.get_widget("RootpasswordPassword2Entry") self.view = self.xml.get_widget("AdduserTreeView") self.scrolled = self.xml.get_widget("AdduserScrolledWindow") self.removeButton = self.xml.get_widget("RemoveuserButton") self.addUserWindow = AddUserWindow(self.xml, self) setupUserAccountsView(self.view, self.scrolled) connectSignalHandlerByDict( self, PasswordWindow, self.xml, { ('AdduserButton', 'clicked'): 'addUser', ('RemoveuserButton', 'clicked'): 'removeUser', }) self.restoreUsers() controlState.initialFocus = self.passwdEntry1 def restoreUsers(self): '''Retrieve any previous users from userchoices and populate.''' for account in userchoices.getUsers(): self.accounts.append((account['username'], account['password'])) self.updateAccounts() def commitUsers(self): '''Save the user accounts in userchoices.''' userchoices.clearUsers() for username, password in self.accounts: userchoices.addUser(username, password, userchoices.ROOTPASSWORD_TYPE_MD5) def setRemoveButton(self): if self.accounts and len(self.accounts) > 0: self.removeButton.set_sensitive(True) else: self.removeButton.set_sensitive(False) def addUser(self, *args): self.addUserWindow.show() def removeUser(self, widget, *args): store, selected = self.view.get_selection().get_selected_rows() if not selected: MessageWindow(None, 'User Account Error', 'You must select an account to remove.') return window = MessageWindow( None, "Delete User Account", "Are you sure you want to remove this user account?", type='yesno') if window.affirmativeResponse: for entry in selected: # remove the entry at the storeIndex storeIndex = entry[0] self.accounts.pop(storeIndex) self.updateAccounts() def updateAccounts(self): _populateUserAccountsModel(self.view, self.scrolled, self.accounts) self.setRemoveButton() def getBack(self): self.commitUsers() def getNext(self): passwd1 = self.passwdEntry1.get_text() passwd2 = self.passwdEntry2.get_text() if passwd1 != passwd2: MessageWindow(self.controlState.gui.getWindow(), "Administrator Password Error", "The two passwords entered did not match.") raise exception.StayOnScreen try: users.sanityCheckPassword(passwd1) except ValueError, msg: MessageWindow(self.controlState.gui.getWindow(), "Administrator Password Error", msg[0]) raise exception.StayOnScreen userchoices.setRootPassword(users.cryptPassword(passwd1), userchoices.ROOTPASSWORD_TYPE_MD5) self.commitUsers()
if len(self.userinput) == 1: # may come here if pop substepStack, e.g., exit() self.setSubstepEnv({'next': self.start}) return else: raise try: if trial1 != trial2: raise ValueError(errNotMatch) users.sanityCheckPassword(trial1) except ValueError, ex: msg = "%s\n" % str(ex) self.errorPushPop(title, msg + TransMenu.Back) return userchoices.setRootPassword(users.cryptPassword(trial1), userchoices.ROOTPASSWORD_TYPE_MD5) self.setSubstepEnv({'next': self.stepForward}) def help(self): ui = { 'title': title, 'body': helpText, 'menu': { '<': self.start, '*': self.start, } } self.setSubstepEnv(ui)