All of lore.kernel.org
 help / color / mirror / Atom feed
From: kupcevic@sourceware.org <kupcevic@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga ./conga.spec.in.in luci/utils/luci_admin
Date: 3 Aug 2006 23:39:01 -0000	[thread overview]
Message-ID: <20060803233901.6936.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-08-03 23:39:01

Modified files:
	.              : conga.spec.in.in 
	luci/utils     : luci_admin 

Log message:
	Add '--random' argument to `luci_admin password`, update specfile to use it

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.41&r2=1.42

--- conga/conga.spec.in.in	2006/08/03 20:54:04	1.22
+++ conga/conga.spec.in.in	2006/08/03 23:39:00	1.23
@@ -153,42 +153,35 @@
 
 %post -n luci
 /sbin/chkconfig --add luci
+/sbin/service luci status >/dev/null 2>&1
+LUCI_RUNNING=$?
+if [ "$LUCI_RUNNING" = "0" ]; then
+   /sbin/service luci stop >/dev/null 2>&1
+fi
 if [ -e /var/lib/luci/var/luci_backup.xml ]; then
-   /sbin/service luci status >/dev/null 2>$1
-   LUCI_RUNNING=$?
-   if [ "$LUCI_RUNNING" = "0" ]; then
-      /sbin/service luci stop >/dev/null 2>$1
-   fi
-   /usr/sbin/luci_admin restore >/dev/null 2>$1
-   if [ "$LUCI_RUNNING" = "0" ]; then
-      /sbin/service luci start >/dev/null 2>$1
-   fi
+   /usr/sbin/luci_admin restore >/dev/null 2>&1
 fi
 if [ ! -e /var/lib/luci/var/certs/privkey.pem ]; then
    # no privkey.pem -> luci not initialized
-   # set initial random admin password
-   T_PASS=`dd if=/dev/urandom bs=5M count=1 2> /dev/null | sha1sum`
-   for i in $T_PASS; do
-      if [ "-" != $i ] ; then
-	echo -n "admin:{SHA}$i" > /var/lib/luci/inituser
-      fi
-   done
-   /bin/chmod 600 /var/lib/luci/inituser
-   /bin/chown luci /var/lib/luci/inituser
+   /usr/sbin/luci_admin password --random >/dev/null 2>&1
+fi
+if [ "$LUCI_RUNNING" = "0" ]; then
+   /sbin/service luci start >/dev/null 2>&1
 fi
 
+
 %preun -n luci
-/sbin/service luci status >/dev/null 2>$1
+/sbin/service luci status >/dev/null 2>&1
 LUCI_RUNNING=$?
 if [ "$LUCI_RUNNING" = "0" ]; then
-   /sbin/service luci stop >/dev/null 2>$1
+   /sbin/service luci stop >/dev/null 2>&1
 fi
-/usr/sbin/luci_admin backup >/dev/null 2>$1
+/usr/sbin/luci_admin backup >/dev/null 2>&1
 if [ "$LUCI_RUNNING" = "0" ]; then
-   /sbin/service luci start >/dev/null 2>$1
+   /sbin/service luci start >/dev/null 2>&1
 fi
 if [ "$1" = "0" ]; then
-   /sbin/service luci stop >/dev/null 2>$1
+   /sbin/service luci stop >/dev/null 2>&1
    /sbin/chkconfig --del luci
 fi
 
--- conga/luci/utils/luci_admin	2006/08/03 22:58:26	1.41
+++ conga/luci/utils/luci_admin	2006/08/03 23:39:00	1.42
@@ -996,14 +996,26 @@
 
 
 def password(argv):
-	if not luci_initialized():
-		sys.stderr.write('The Luci site has not been initialized.\n')
-		sys.stderr.write('To initialize it, execute\n')
-		sys.stderr.write('\t' + argv[0] + ' init\n')
-		sys.exit(1)
-
-	print 'Resetting the admin user\'s password\n'
-	password = read_passwd('Enter new password: ', 'Confirm password: ')
+	password = None
+	if '--random' in argv:
+		print 'Resetting the admin user\'s password to some random value\n'
+		try:
+			rand = file('/dev/urandom', 'r')
+			password = rand.read(16)
+			rand.close()
+		except:
+			sys.stderr.write('Unable to read from /dev/urandom\n')
+			sys.exit(1)
+	else:
+		if not luci_initialized():
+			sys.stderr.write('The Luci site has not been initialized.\n')
+			sys.stderr.write('To initialize it, execute\n')
+			sys.stderr.write('\t' + argv[0] + ' init\n')
+			sys.exit(1)
+		
+		print 'Resetting the admin user\'s password\n'
+		password = read_passwd('Enter new password: ', 'Confirm password: ')
+		
 	print '\nPlease wait...'
 	if not set_zope_passwd('admin', password):
 		print 'The admin password has been successfully reset.'
@@ -1112,7 +1124,7 @@
 
 
 def main(argv):
-    if len(argv) != 2:
+    if len(argv) < 2:
         luci_help(argv)
         sys.exit(1)
 
@@ -1123,7 +1135,6 @@
         sys.stderr.write('Try again with root privileges.\n')
         sys.exit(2)
 
-
     if 'init' in argv:
         init(argv)
     elif 'backup' in argv:



                 reply	other threads:[~2006-08-03 23:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060803233901.6936.qmail@sourceware.org \
    --to=kupcevic@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.