From 71d189c7eb7fd53c0ed006b20fc5ed0e403ed515 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Mon, 2 Jun 2008 15:25:32 +0000 Subject: Implement a umask setting (#186819) --- ChangeLog | 3 +++ etc/layman.cfg | 12 +++++++++++- layman/action.py | 13 ++++++++++++- layman/config.py | 3 ++- 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 + * 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',} -- cgit v1.2.3-1-g7c22