diff options
Diffstat (limited to 'anaconda')
-rwxr-xr-x | anaconda | 159 |
1 files changed, 27 insertions, 132 deletions
@@ -381,101 +381,10 @@ def setupGraphicalLinks(): except: pass -def handleSshPw(anaconda): - if not anaconda.ksdata: - return - - from pyanaconda import users - u = users.Users(anaconda) - - userdata = anaconda.ksdata.sshpw.dataList() - for ud in userdata: - if u.checkUserExists(ud.username, root="/"): - u.setUserPassword(username=ud.username, password=ud.password, - isCrypted=ud.isCrypted, lock=ud.lock) - else: - kwargs = ud.__dict__ - kwargs.update({"root": "/", "mkmailspool": False}) - u.createUser(ud.username, **kwargs) - - del u - -def createSshKey(algorithm, keyfile): - path = '/etc/ssh/%s' % (keyfile,) - argv = ['-q','-t',algorithm,'-f',path,'-C','','-N',''] - if os.access(path, os.R_OK): - return - log.info("running \"%s\"" % (" ".join(['ssh-keygen']+argv),)) - - so = "/tmp/ssh-keygen-%s-stdout.log" % (algorithm,) - se = "/tmp/ssh-keygen-%s-stderr.log" % (algorithm,) - iutil.execWithRedirect('ssh-keygen', argv, stdout=so, stderr=se) - -def fork_orphan(): - """Forks an orphan. - - Returns 1 in the parent and 0 in the orphaned child. - """ - intermediate = os.fork() - if not intermediate: - if os.fork(): - # the intermediate child dies - os._exit(0) - return 0; - # the original process waits for the intermediate child - os.waitpid(intermediate, 0) - return 1 - -def startSsh(): - if iutil.isS390(): - return - - if not fork_orphan(): - os.open("/var/log/lastlog", os.O_RDWR | os.O_CREAT, 0644) - ssh_keys = { - 'rsa1':'ssh_host_key', - 'rsa':'ssh_host_rsa_key', - 'dsa':'ssh_host_dsa_key', - } - for (algorithm, keyfile) in ssh_keys.items(): - createSshKey(algorithm, keyfile) - sshd = iutil.find_program_in_path("sshd") - args = [sshd, "-f", "/etc/ssh/sshd_config.anaconda"] - os.execv(sshd, args) - sys.exit(1) - def startDebugger(signum, frame): import epdb epdb.serve(skip=1) -def runRescueMode(anaconda, opts): - anaconda.rescue = True - - from pyanaconda import rescue - - if anaconda.ksdata: - anaconda.instClass.configure(anaconda) - - # We need an interface before running kickstart execute methods for - # storage. - from snack import SnackScreen - screen = SnackScreen() - anaconda.intf = rescue.RescueInterface(screen) - - anaconda.ksdata.execute() - - anaconda.intf = None - screen.finish() - - # command line 'nomount' overrides kickstart /same for vnc/ - anaconda.rescue_mount = not (opts.rescue_nomount or - anaconda.ksdata.rescue.nomount) - - rescue.runRescue(anaconda) - - # shouldn't get back here - sys.exit(1) - def setupDisplay(anaconda, opts): graphical_failed = 0 vncS = vnc.VncServer() # The vnc Server object. @@ -506,7 +415,9 @@ def setupDisplay(anaconda, opts): anaconda.xdriver = opts.xdriver anaconda.writeXdriver(root="/") - if not opts.rescue: + if anaconda.rescue: + anaconda.displayMode = 'r' + else: if anaconda.ksdata: if anaconda.ksdata.vnc.enabled: flags.usevnc = 1 @@ -629,9 +540,9 @@ def setupDisplay(anaconda, opts): runVNC(vncS) doStartupX11Actions() - # with X running we can initialize the UI interface - anaconda.initInterface() - anaconda.instClass.configure(anaconda) + # with X running we can initialize the UI interface + anaconda.initInterface() + anaconda.instClass.configure(anaconda) def runDogtail(opts): import urlgrabber @@ -707,7 +618,6 @@ if __name__ == "__main__": from pyanaconda import iutil from pyanaconda import vnc - from pyanaconda import users from pyanaconda import kickstart import gettext @@ -805,7 +715,7 @@ if __name__ == "__main__": if opts.targetArch: flags.targetarch = opts.targetArch - # set flags + # set flags flags.dmraid = opts.dmraid flags.mpath = opts.mpath flags.selinux = opts.selinux @@ -825,12 +735,31 @@ if __name__ == "__main__": if opts.debug: flags.debug = True + if opts.rescue: + anaconda.rescue = True + log.info("anaconda called with cmdline = %s" %(sys.argv,)) log.info("Default encoding = %s " % sys.getdefaultencoding()) - setupDisplay(anaconda, opts) os.system("udevadm control --env=ANACONDA=1") + # parse (not execute) kickstart now, the ks commands can affect things like + # UI interface type or enabling rescue mode + if opts.ksfile: + kickstart.preScriptPass(anaconda, opts.ksfile) + anaconda.ksdata = kickstart.parseKickstart(anaconda, opts.ksfile) + if anaconda.ksdata.rescue.rescue: + anaconda.rescue = True + # now start the interface + setupDisplay(anaconda, opts) + # setting the install steps requires interface to be running + if opts.ksfile: + kickstart.setSteps(anaconda) + else: + anaconda.instClass.setSteps(anaconda) + if anaconda.rescue: + anaconda.dispatch.skipStep("rescue", skip=0) + image_count = 0 for image in opts.images: image_spec = image.rsplit(":", 1) @@ -851,26 +780,6 @@ if __name__ == "__main__": if image_count: anaconda.storage.setupDiskImages() - # This is the one place we do all kickstart file parsing. - if opts.ksfile: - kickstart.preScriptPass(anaconda, opts.ksfile) - anaconda.ksdata = kickstart.parseKickstart(anaconda, opts.ksfile) - opts.rescue = opts.rescue or anaconda.ksdata.rescue.rescue - - if flags.sshd: - # we need to have a libuser.conf that points to the installer root for - # sshpw, but after that we start sshd, we need one that points to the - # install target. - luserConf = users.createLuserConf(instPath="") - handleSshPw(anaconda) - startSsh() - del(os.environ["LIBUSER_CONF"]) - - users.createLuserConf(anaconda.rootPath) - - if opts.rescue: - runRescueMode(anaconda, opts) - # comment out the next line to make exceptions non-fatal from pyanaconda.exception import initExceptionHandling anaconda.mehConfig = initExceptionHandling(anaconda) @@ -896,24 +805,10 @@ if __name__ == "__main__": anaconda.keyboard.set(opts.keymap) anaconda.keyboard.activate() - if anaconda.ksdata: - from pyanaconda import storage - storage.storageInitialize(anaconda) - - # Now having initialized storage, we can apply all the other kickstart - # commands. This gives us the ability to check that storage commands - # are correctly formed and refer to actual devices. - anaconda.ksdata.execute() - # set up the headless case if anaconda.isHeadless: anaconda.dispatch.skipStep("keyboard", permanent = 1) - if not anaconda.ksdata: - anaconda.instClass.setSteps(anaconda) - else: - kickstart.setSteps(anaconda) - try: anaconda.dispatch.run() except SystemExit, code: |