From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/utils luci_admin
Date: 3 Aug 2006 03:30:04 -0000 [thread overview]
Message-ID: <20060803033004.24701.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-08-03 03:30:03
Modified files:
luci/utils : luci_admin
Log message:
save misc. member data (other than id and passwd)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.33&r2=1.34
--- conga/luci/utils/luci_admin 2006/08/02 23:29:27 1.33
+++ conga/luci/utils/luci_admin 2006/08/03 03:30:02 1.34
@@ -88,6 +88,27 @@
except:
return -1
+def restore_luci_fsattr():
+ try:
+ luci = pwd.getpwnam(LUCI_USER)[2:4]
+ if not luci or len(luci) != 2:
+ raise
+ except:
+ sys.stderr.write('Cannot find the \"' + LUCI_USER + '\" user.\n')
+ return -1
+
+ try:
+ os.chown(LUCI_DB_PATH, luci[0], luci[1])
+ os.chmod(LUCI_DB_PATH, 0600)
+ for i in [ '.tmp', '.old', '.index', '.lock' ]:
+ try:
+ os.chown(LUCI_DB_PATH + i, luci[0], luci[1])
+ os.chmod(LUCI_DB_PATH + i, 0600)
+ except: pass
+ except:
+ sys.stderr.write('Unable to change ownership of the Luci database back to user \"' + LUCI_USER + '\"\n')
+ return -1
+
def set_zope_passwd(user, passwd):
sys.stderr = null
import ZODB
@@ -155,30 +176,15 @@
raise
except:
sys.stderr.write('Unable to set the password for user \"' + user + '\"\n')
+
conn.close()
db.pack()
db.close()
fs.close()
- try:
- luci = pwd.getpwnam(LUCI_USER)[2:4]
- if not luci or len(luci) != 2:
- raise
- except:
- sys.stderr.write('Cannot find the \"' + LUCI_USER + '\" user.\n')
+ if restore_luci_fsattr():
return -1
- try:
- os.chown(LUCI_DB_PATH, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH, 0600)
- for i in [ '.tmp', '.old', '.index', '.lock' ]:
- try:
- os.chown(LUCI_DB_PATH + i, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH + i, 0600)
- except: pass
- except:
- sys.stderr.write('Unable to change ownership of the Luci database back to user \"' + LUCI_USER + '\"\n')
- return -1
return ret
@@ -254,9 +260,6 @@
import ImageFile
import Products.PluggableAuthService.plugins.ZODBUserManager
import BTrees.OOBTree
- # Zope wants to open a www/ok.gif and images/error.gif
- # when you initialize the application object. This keeps
- # the AppInitializer(app).initialize() call below from failing.
ImageFile.ImageFile.__init__ = lambda x,y,z:None
sys.stderr = orig_stderr
@@ -612,12 +615,10 @@
import transaction
import Products.CMFCore
import Products.CMFCore.MemberDataTool
+ from CMFPlone.utils import getToolByName
import ImageFile
import Products.PluggableAuthService.plugins.ZODBUserManager
import BTrees.OOBTree
- # Zope wants to open a www/ok.gif and images/error.gif
- # when you initialize the application object. This keeps
- # the AppInitializer(app).initialize() call below from failing.
ImageFile.ImageFile.__init__ = lambda x,y,z:None
sys.stderr = orig_stderr
@@ -662,11 +663,12 @@
sys.stderr.write('An error occurred while initializing the Luci installation for restoration from backup\n')
return -1
+ app.luci.portal_memberdata.pruneMemberDataContents()
+ transaction.commit()
+
try:
acl_users = app.acl_users.users
- portal_mem = app.luci.portal_membership
- portal_reg = app.luci.portal_registration
- if not (acl_users and len(acl_users) and portal_mem and portal_reg):
+ if not (acl_users and len(acl_users)):
raise
except:
sys.stderr.write('Your Luci installation appears to be corrupt.\n')
@@ -705,6 +707,23 @@
sys.stderr.write('An error occurred while saving user information.')
return -1
+ save_member_properties = [ 'login_time', 'last_login_time', 'must_change_password', 'email' ]
+ try:
+ membertool = getToolByName(app.luci, 'portal_membership')
+ if not membertool:
+ raise
+ for mem in membertool.listMembers():
+ try:
+ for i in save_member_properties:
+ prop = mem.getProperty(i)
+ if prop != '':
+ users[mem.id][i] = str(prop)
+ except:
+ continue
+ except:
+ pass
+
+
try:
storagedir = app.luci.systems.storage
clusterdir = app.luci.systems.cluster
@@ -714,7 +733,7 @@
if storagedir and len(storagedir):
for i in storagedir.objectItems():
- systems[i[0]] = { 'id': i[0], 'name': i[0] }
+ systems[i[0]] = { 'id': i[0] }
if hasattr(i[1], 'title'):
systems[i[0]]['title'] = getattr(i[1], 'title')
else:
@@ -742,32 +761,19 @@
clusters[cluster_name]['permList'] = {}
for csystem in i[1].objectItems():
- csystem_hash = { 'id': csystem[0] }
+ csystem_hash = { 'id': csystem[0], 'permList': {} }
if hasattr(csystem[1], 'title'):
csystem_hash['title'] = getattr(csystem[1], 'title')
else:
csystem_hash['title'] = '__luci__:csystem:' + cluster_name
-
- if hasattr(csystem[1], '__ac_local_roles__'):
- roles = getattr(csystem[1], '__ac_local_roles__')
- csystem_hash['permList'] = map(lambda x: x[0], filter(lambda x: len(x) > 1 and 'View' in x[1], roles.items()))
- else:
- csystem_hash['permList'] = {}
clusters[cluster_name]['csystemList'][csystem[0]] = csystem_hash
- sys.stderr = orig_stderr
conn.close()
+ db.pack()
db.close()
fs.close()
- junk = list()
- for i in users:
- if not 'passwd' in users[i]:
- junk.append(i)
- for i in junk:
- del users[i]
-
backup = {
'userList': users,
'systemList': systems,
@@ -809,6 +815,7 @@
return doc
+
def _execWithCaptureErrorStatus(command, argv, searchPath = 0, root = '/', stdin = 0, catchfd = 1, catcherrfd = 2, closefd = -1):
if not os.access (root + command, os.X_OK):
raise RuntimeError, command + " can not be run"
@@ -1009,25 +1016,8 @@
try: os.umask(077)
except: pass
- try:
- luci = pwd.getpwnam(LUCI_USER)[2:4]
- except:
- sys.stderr.write('Cannot find the \"' + LUCI_USER + '\" user.\n')
- sys.exit(1)
-
doc = luci_backup(argv[2:])
-
- try:
- os.chown(LUCI_DB_PATH, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH, 0600)
- for i in [ '.tmp', '.old', '.index', '.lock' ]:
- try:
- os.chown(LUCI_DB_PATH + i, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH + i, 0600)
- except: pass
- except:
- sys.stderr.write('Unable to change ownership of the Luci database back to user \"' + LUCI_USER + '\"\n')
-
+ restore_luci_fsattr()
if not doc:
sys.stderr.write('The Luci backup failed.\n')
sys.exit(1)
@@ -1039,6 +1029,7 @@
stat = os.stat(LUCI_BACKUP_PATH)
trynum = 1
basename = '/luci_backup-'
+
while True:
oldbackup = LUCI_BACKUP_DIR + basename + str(trynum) + '.xml'
if not os.path.exists(oldbackup):
@@ -1046,7 +1037,7 @@
os.rename(LUCI_BACKUP_PATH, oldbackup)
except:
sys.stderr.stderr('Unable to rename the existing backup file.\n')
- return -1
+ sys.stderr.write('The Luci backup failed.\n')
break
trynum += 1
except OSError, e:
@@ -1057,13 +1048,14 @@
f = file(LUCI_BACKUP_PATH, 'wb+')
except:
sys.stderr.write('Unable to open \"' + LUCI_BACKUP_PATH + '\" to write backup.\n')
+ sys.stderr.write('The Luci backup failed.\n')
sys.exit(1)
try:
os.chmod(LUCI_BACKUP_PATH, 0600)
except OSError, e:
- print "An error occurred while making",LUCI_BACKUP_PATH,"read-only:",e
- print "Please check that this file is not world-readable."
+ sys.stderr.write('An error occurred while making \"' + LUCI_BACKUP_PATH + '\" read-only: ' + e + '\n')
+ sys.stderr.write('Please check that this file is not world-readable.\n')
try:
f.write(doc.toprettyxml())
@@ -1081,27 +1073,17 @@
except: pass
if luci_restore(argv[2:]):
- retCode = False
+ ret = False
print 'The Luci restore failed. Try reinstalling Luci, then restoring again.'
else:
- retCode = True
+ ret = True
print 'Restore was successful.'
restart_message()
- try:
- luci = pwd.getpwnam(LUCI_USER)[2:4]
- os.chown(LUCI_DB_PATH, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH, 0600)
- for i in [ '.tmp', '.old', '.index', '.lock' ]:
- try:
- os.chown(LUCI_DB_PATH + i, luci[0], luci[1])
- os.chmod(LUCI_DB_PATH + i, 0600)
- except: pass
- except:
- sys.stderr.write('Unable to change ownership of the Luci database back to user \"' + LUCI_USER + '\"\n')
+ if restore_luci_fsattr():
return False
- return retCode
+ return ret
def luci_help(argv):
@@ -1116,7 +1098,6 @@
print
-
def main(argv):
if len(argv) != 2:
luci_help(argv)
next reply other threads:[~2006-08-03 3:30 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-03 3:30 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-03-25 20:14 [Cluster-devel] conga/luci/utils luci_admin rmccabe
2007-09-19 5:17 rmccabe
2007-08-10 18:36 rmccabe
2007-08-10 18:33 rmccabe
2007-08-10 18:32 rmccabe
2007-08-07 20:22 rmccabe
2006-10-13 6:56 kupcevic
2006-08-18 18:03 rmccabe
2006-08-04 19:19 rmccabe
2006-08-04 18:37 rmccabe
2006-08-03 22:58 kupcevic
2006-08-03 21:19 rmccabe
2006-08-03 21:11 rmccabe
2006-08-03 16:32 rmccabe
2006-08-03 15:55 rmccabe
2006-08-03 12:26 rmccabe
2006-08-03 3:58 rmccabe
2006-08-02 23:29 rmccabe
2006-08-02 20:52 rmccabe
2006-08-02 20:45 rmccabe
2006-07-26 1:17 rmccabe
2006-07-25 22:36 rmccabe
2006-07-11 18:46 rmccabe
2006-07-11 14:51 rmccabe
2006-06-29 18:04 rmccabe
2006-06-29 17:51 rmccabe
2006-06-27 19:50 rmccabe
2006-06-27 19:40 rmccabe
2006-06-27 18:19 rmccabe
2006-06-26 22:30 rmccabe
2006-06-26 20:01 rmccabe
2006-06-21 23:06 rmccabe
2006-06-21 17:41 rmccabe
2006-06-21 17:06 rmccabe
2006-06-18 15:02 rmccabe
2006-06-18 12:50 rmccabe
2006-06-18 3:26 rmccabe
2006-06-16 23:19 rmccabe
2006-06-16 19:35 rmccabe
2006-06-16 18:17 rmccabe
2006-06-16 17:44 rmccabe
2006-06-16 5:35 rmccabe
2006-06-13 18:42 rmccabe
2006-06-13 17:36 rmccabe
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=20060803033004.24701.qmail@sourceware.org \
--to=rmccabe@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.