summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Wrobel <p@rdus.de>2008-06-02 15:25:32 +0000
committerGunnar Wrobel <p@rdus.de>2008-06-02 15:25:32 +0000
commit71d189c7eb7fd53c0ed006b20fc5ed0e403ed515 (patch)
tree4cf72e0c1ef1d4c755a5b197935e29e3fc37fa1f
parentda7ff6a2f00cdc4c68a909cdea9d642543ac4ef5 (diff)
downloadlayman-71d189c7eb7fd53c0ed006b20fc5ed0e403ed515.tar.gz
layman-71d189c7eb7fd53c0ed006b20fc5ed0e403ed515.tar.bz2
layman-71d189c7eb7fd53c0ed006b20fc5ed0e403ed515.zip
Implement a umask setting (#186819)
-rw-r--r--ChangeLog3
-rw-r--r--etc/layman.cfg12
-rw-r--r--layman/action.py13
-rw-r--r--layman/config.py3
4 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e16658a..240cdf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2008-06-02 Gunnar Wrobel <p@rdus.de>
+ * layman/config.py: Implement a umask setting (#186819)
+ http://bugs.gentoo.org/show_bug.cgi?id=186819
+
* INSTALL: Fix the documentation.
* README: Updated project links.
diff --git a/etc/layman.cfg b/etc/layman.cfg
index b6073e5..12d65ee 100644
--- a/etc/layman.cfg
+++ b/etc/layman.cfg
@@ -3,7 +3,7 @@
#-----------------------------------------------------------
# Defines the directory where overlays should be installed
-storage : /usr/portage/local/layman
+storage : /usr/local/portage/layman
#-----------------------------------------------------------
# Remote overlay lists will be stored here
@@ -46,3 +46,13 @@ overlays : http://www.gentoo.org/proj/en/overlays/layman-global.txt
# description or contact information.
#
nocheck : no
+
+#-----------------------------------------------------------
+# Umask settings
+#
+# layman should usually work with a umask of 0022. You should
+# only change this setting if you are absolutely certain that
+# you know what you are doing.
+#
+#umask : 0022
+
diff --git a/layman/action.py b/layman/action.py
index 32802b7..d5bd032 100644
--- a/layman/action.py
+++ b/layman/action.py
@@ -24,7 +24,7 @@ __version__ = "$Id: action.py 312 2007-04-09 19:45:49Z wrobel $"
#
#-------------------------------------------------------------------------------
-import sys
+import os, sys
from layman.db import DB, RemoteDB
@@ -472,6 +472,15 @@ class Actions:
result = 0
+ # Set the umask
+ umask = config['umask']
+ try:
+ new_umask = int(umask, 8)
+ old_umask = os.umask(new_umask)
+ except Exception, error:
+ OUT.die('Failed setting to umask "' + umask + '"!\nError was: '
+ + str(error))
+
for i in self.actions:
OUT.debug('Checking for action', 7)
@@ -479,6 +488,8 @@ class Actions:
if i[0] in config.keys():
result += i[1](config).run()
+ # Reset umask
+ os.umask(old_umask)
if not result:
sys.exit(0)
diff --git a/layman/config.py b/layman/config.py
index 597cf2d..ff610e8 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -52,7 +52,7 @@ class Config(object):
>>> a['overlays']
'\\nhttp://www.gentoo.org/proj/en/overlays/layman-global.txt'
>>> sorted(a.keys())
- ['cache', 'config', 'local_list', 'make_conf', 'nocheck', 'overlays', 'proxy', 'quietness', 'storage']
+ ['cache', 'config', 'local_list', 'make_conf', 'nocheck', 'overlays', 'proxy', 'quietness', 'storage', 'umask']
'''
self.defaults = {'config' : '/etc/layman/layman.cfg',
@@ -62,6 +62,7 @@ class Config(object):
'make_conf' : '%(storage)s/make.conf',
'nocheck' : 'yes',
'proxy' : '',
+ 'umask' : '0022',
'overlays' :
'http://www.gentoo.org/proj/en/overlays/layman-global.'
'txt',}