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

[Cluster-devel] conga/luci/utils luci_admin



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-06-18 03:26:29

Modified files:
	luci/utils     : luci_admin 

Log message:
	silence useless zope/plone warnings, make sure luci_backup.xml is not world-readable.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- conga/luci/utils/luci_admin	2006/06/16 23:19:58	1.12
+++ conga/luci/utils/luci_admin	2006/06/18 03:26:29	1.13
@@ -18,20 +18,22 @@
 from xml.dom import minidom
 import types
 
-import Zope2
 import OFS
-import App
-import App.Extensions
-import OFS.Application
-from App.Extensions import *
 from OFS.Application import AppInitializer
 import OFS.Folder
 import AccessControl
 import AccessControl.User
 from AccessControl.SecurityManagement import newSecurityManager
+import transaction
+
+null = file('/dev/null', 'rwb+', 0)
+orig_stderr = sys.stderr
+
+sys.stderr = null
 import Products.CMFCore
+sys.stderr = orig_stderr
+
 import Products.CMFCore.MemberDataTool
-import transaction
 
 LUCI_INIT_DEBUG = 0
 
@@ -52,13 +54,11 @@
 	'Products.CMFCore.MemberDataTool.MemberData'
 ]
 
-null = file('/dev/null', 'rwb+', 0)
 
 if LUCI_INIT_DEBUG:
 	verbose = sys.stderr
 else:
 	verbose = null
-orig_stderr = sys.stderr
 
 def luci_restore(argv):
 	if len(argv) > 0:
@@ -130,7 +130,7 @@
 	if not userList or len(userList) < 1:
 		sys.stderr.write('Your backup file contains no users. At the very least, the admin user must exist. Please check that your backup file is not corrupt.\n')
 		return -1
-	
+
 	for u in userList:
 		id = u.getAttribute('id')
 		if not id:
@@ -468,9 +468,8 @@
 				try:
 					cur_user = users[dict['id']]
 				except:
-					users[dict['name']] = {}
+					users[dict['name']] = { 'id': dict['name'] }
 					cur_user = users[dict['name']]
-					cur_user['id'] = dict['name']
 			cur_user['name'] = dict['name']
 			cur_user['passwd'] = dict['__']
 		elif obj_class == 'Products.CMFCore.MemberDataTool.MemberData':
@@ -484,9 +483,8 @@
 				try:
 					cur_user = users[dict['name']]
 				except:
-					users[dict['id']] = {}
+					users[dict['id']] = { 'name': dict['id'] }
 					cur_user = users[dict['id']]
-					cur_user['name'] = dict['id']
 			for i in dict:
 				cur_user[i] = dict[i]
 		if next_oid is None:
@@ -783,32 +781,39 @@
 
 
 def backup(argv):
-    if not luci_initialized():
-        print 'Luci site has not yet been initialized'
-        print 'To initialize it, execute'
-        print argv[0] + ' init'
-        sys.exit(1)
-        pass
-    
-    print 'Backing up the Luci server...'
-
-    if luci_backup(argv[2:]):
-        sys.write.stderr('The Luci backup failed.\n')
-        sys.exit(1)
-    print 'Backup was successful. The backup file is',LUCI_BACKUP_PATH
-    return
+	if not luci_initialized():
+		print 'Luci site has not yet been initialized'
+		print 'To initialize it, execute'
+		print argv[0] + ' init'
+		sys.exit(1)
+   
+	print 'Backing up the Luci server...'
+
+	try: os.umask(077)
+	except: pass
+
+	if luci_backup(argv[2:]):
+		sys.write.stderr('The Luci backup failed.\n')
+		sys.exit(1)
+
+	print 'Backup was successful. The backup file is',LUCI_BACKUP_PATH
+
+	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."
 
 
 def restore(argv):
-    print 'Restoring the Luci server...'
+	print 'Restoring the Luci server...'
     
-    if luci_restore(argv[2:]):
-        print 'The Luci restore failed. Try reinstalling Luci, then restoring again.'
-        sys.exit(1)
+	if luci_restore(argv[2:]):
+		print 'The Luci restore failed. Try reinstalling Luci, then restoring again.'
+		sys.exit(1)
 
-    restart_message()
-    
-    return
+	restart_message()
+	return True
 
 
 def luci_help(argv):


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