[Dev OpenGP] [82] Message of the day: the end :) (still to be tested with a network)

[ Thread Index | Date Index | More opengp.tuxfamily.org/development Archives ]


Revision: 82
Author:   alband85
Date:     2009-03-24 14:51:47 +0100 (Tue, 24 Mar 2009)

Log Message:
-----------
Message of the day: the end :) (still to be tested with a network)

Modified Paths:
--------------
    trunk/src/lib/ogp/plugins/motd/motd.py
    trunk/src/lib/ogp/plugins/plugin.py


Modified: trunk/src/lib/ogp/plugins/motd/motd.py
===================================================================
--- trunk/src/lib/ogp/plugins/motd/motd.py	2009-03-24 13:36:02 UTC (rev 81)
+++ trunk/src/lib/ogp/plugins/motd/motd.py	2009-03-24 13:51:47 UTC (rev 82)
@@ -63,18 +63,22 @@
 	def installConf(self):
 		motd = str(self.pullFile('motd', True))
 		dist_e = self.currentConf.xpath(self.__motd_xpath)
+		prefix = '/home/alban/tmp/ogp/etc/'
 		if len(dist_e) != 0:
 			distro = dist_e[0].text
 		else:
 			distro = None
 
 		if distro == 'debian':
-			f = open('/home/alban/tmp/ogp/etc/motd.tail','w')
+			f = open(prefix + 'motd.tail','w')
 			f.write(motd)
 			f.close()
-			spawnl(P_WAIT, '/home/alban/tmp/ogp/etc/init.d/bootmisc.sh', 'start')
+			spawnl(P_WAIT, prefix + 'init.d/bootmisc.sh', 'start')
+			self.setSecurityAttributes('motd', prefix + 'motd.tail')
 		else:
-			f = open('/home/alban/tmp/ogp/etc/motd', 'w')
+			f = open(prefix + 'motd', 'w')
 			f.write(motd)
 			f.close()
 
+		self.setSecurityAttributes('motd', prefix + 'motd')
+

Modified: trunk/src/lib/ogp/plugins/plugin.py
===================================================================
--- trunk/src/lib/ogp/plugins/plugin.py	2009-03-24 13:36:02 UTC (rev 81)
+++ trunk/src/lib/ogp/plugins/plugin.py	2009-03-24 13:51:47 UTC (rev 82)
@@ -176,7 +176,8 @@
 		"""
 		# Default file stats (644)
 		mask = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH 
-		
+		# Default owner
+		own = {'uid':0, 'gid':0}
 		# Security attributes for fileName
 		xpath_sec_attr = OgpXmlConsts.TAG_FILES + '/' + OgpXmlConsts.TAG_FILE + "[@" + OgpXmlConsts.ATTR_FILE_NAME + "='" + fileName + "']" + \
 				'/' + OgpXmlConsts.TAG_SECURITY
@@ -199,24 +200,16 @@
 					'gs':S_ISGID,
 					't': S_ISVTX
 				}
-		print oct(mask)
 		for attr in sec_e:
 			if attr.tag in OgpXmlConsts.TAGS_OWN:
-				if attr.tag == 'uid':
-					os.chown(filePath, int(attr.text), -1)
-				elif attr.tag == 'gid':
-					os.chown(filePath, -1, int(attr.text))
-				else:
-					pass
+				own[attr.tag] = int(attr.text)
 			elif attr.tag in OgpXmlConsts.TAGS_MOD:
-				print attr.tag + ": " + attr.text
 				if smart_bool(attr.text):
-					#print str(oct(mask)) + ' | ' + str(oct(mod_attr[attr.tag]))
 					mask = mask | mod_attr[attr.tag]
 				else:
-					#print str(oct(mask)) + ' & ~' + str(oct(mod_attr[attr.tag]))
 					mask = mask & ~(mod_attr[attr.tag])
-				print oct(mask)
+		os.chmod(filePath, mask)
+		os.chown(filePath, own['uid'], own['gid'])
 
 	# Abstract methods
 	def installConf(self):


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/