[PATCH 3/3] Add handling for sshpw command.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This lets you set passwords to ssh into the anaconda environment.
---
 anaconda     |   30 ++++++++++++++++++++++++++----
 kickstart.py |    3 ++-
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/anaconda b/anaconda
index ef891de..21b4d4b 100755
--- a/anaconda
+++ b/anaconda
@@ -396,6 +396,22 @@ def setupGraphicalLinks():
         except:
             pass
 
+def handleSshPw(ks):
+    import users
+    u = users.Users()
+
+    userdata = ks.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:
+            u.createUser(name=ud.username, password=ud.password,
+                         isCrypted=ud.isCrypted, lock=ud.lock,
+                         root="/")
+
+    del u
+
 def createSshKey(algorithm, keyfile):
     path = '/etc/ssh/%s' % (keyfile,)
     argv = ['-q','-t',algorithm,'-f',path,'-C','','-N','']
@@ -602,8 +618,6 @@ if __name__ == "__main__":
 
     warnings.showwarning = AnacondaShowWarning
 
-    startSsh()
-
     setupTranslations()
 
     # reset python's default SIGINT handler
@@ -727,8 +741,6 @@ if __name__ == "__main__":
     if not flags.test and not flags.rootpath and not flags.livecdInstall:
             isys.auditDaemon()
 
-    users.createLuserConf(anaconda.rootPath)
-
     # setup links required for all install types
     for i in ( "services", "protocols", "nsswitch.conf", "joe", "selinux",
                "mke2fs.conf" ):
@@ -753,6 +765,16 @@ if __name__ == "__main__":
     if earlyKS and not opts.rescue:
         opts.rescue = earlyKS.rescue.rescue
 
+    # 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(earlyKS)
+    startSsh()
+    del(os.environ["LIBUSER_CONF"])
+
+    users.createLuserConf(anaconda.rootPath)
+
     if opts.rescue:
         anaconda.rescue = True
 
diff --git a/kickstart.py b/kickstart.py
index a961a99..147431b 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -1086,6 +1086,7 @@ commandMap = {
         "services": commands.services.FC6_Services,
         "shutdown": Reboot,
         "skipx": SkipX,
+        "sshpw": commands.sshpw.F13_SshPw,
         "text": commands.displaymode.FC3_DisplayMode,
         "timezone": Timezone,
         "updates": commands.updates.F7_Updates,
@@ -1128,7 +1129,7 @@ class EarlyKSHandler(superclass):
 
         self.maskAllExcept(["vnc", "displaymode", "text", "cmdline",
                             "graphical", "rescue", "ignoredisk", "clearpart",
-                            "zerombr"])
+                            "zerombr", "sshpw"])
 
 class AnacondaPreParser(KickstartParser):
     # A subclass of KickstartParser that only looks for %pre scripts and
-- 
1.6.5.rc2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux