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

Re: [Fedora-livecd-list] [Patch] setting root password



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeremy Katz wrote:
> On Sun, 2007-04-15 at 12:28 +0200, Jeroen van Meeuwen wrote:
>> This is an attempt to fix being able to set the root password from
>> kickstart.
> 
> This changes the behavior, though.  A blank password isn't the same as
> setting the passwd to empty with -d.  So you need to check for a lack of
> a root pass and still set it with -d.
> 
> Also, instead of essentially running sed on /etc/shadow for the case of
> a crypted password, you can use usermod -p.  Or it could use libuser
> like anaconda currently does, but that's probably overkill.
> 
> Jeremy
> 

Good point. Improvements attached.

Kind regards,

Jeroen van Meeuwen
- -kanarip
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGI5VrKN6f2pNCvwgRAjExAKCtuSlRrmVHyLjOkodp0k58tkbMiQCcCD6W
wBC8dBcoqCOE73yISXDwJW4=
=5YmH
-----END PGP SIGNATURE-----
--- livecd/creator/livecd-creator.orig  2007-04-10 23:53:59.000000000 +0200
+++ livecd/creator/livecd-creator   2007-04-16 14:21:52.000000000 +0200
@@ -522,9 +522,22 @@
@@ -522,9 +537,17 @@
                 args.append("--selinux=disabled")
             subprocess.call(args, preexec_fn=self.run_in_root)

-        # FIXME: we should allow the setting of the root pass
-        if os.path.exists("%s/usr/bin/passwd" %(instroot,)):
+        # Set the root password
+        if self.ksparser.handler.rootpw.isCrypted:
+            subprocess.call(["/usr/sbin/usermod", "-p", self.ksparser.handler.rootpw.password, "root"], preexec_fn=self.run_in_root)
+        elif self.ksparser.handler.rootpw.password == "":
+            # Root password is not set and not crypted, empty it
             subprocess.call(["/usr/bin/passwd", "-d", "root"], preexec_fn=self.run_in_root)
+        else:
+            # Root password is set and not crypted
+            p1 = subprocess.Popen(["/bin/echo", self.ksparser.handler.rootpw.password], stdout=subprocess.PIPE, preexec_fn=self.run_in_root)
+            p2 = subprocess.Popen(["/usr/bin/passwd", "--stdin", "root"], stdin=p1.stdout, stdout=subprocess.PIPE, preexec_fn=self.run_in_root)
+            output = p2.communicate()[0]

         # enable/disable services appropriately
         if os.path.exists("%s/sbin/chkconfig" %(instroot,)):

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