From c3ff6611b640e11ab0d4986b64015355b516fa88 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Wed, 24 Jul 2013 20:26:53 -0400 Subject: POSIX: Ignore permissions error on auto-created dirs If the POSIX client tool is run as a non-root user, it is very likely that the _set_perms() call in _makedirs() will fail because it cannot set the owner of the newly-created directories. This causes _makedirs() to return False, which in turn causes POSIXFile.install() to bail out early. Applying the reasoning in the freebie directories created by _makedirs should have mode and ownership done on a best-effort basis. If a user needs parent directories to have a specific ownership and mode, then they should specify that directory in their configuration. --- src/lib/Bcfg2/Client/Tools/POSIX/base.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/base.py b/src/lib/Bcfg2/Client/Tools/POSIX/base.py index 3778569a6..fb5d06e54 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIX/base.py +++ b/src/lib/Bcfg2/Client/Tools/POSIX/base.py @@ -686,7 +686,7 @@ class POSIXTool(Bcfg2.Client.Tools.Tool): """ os.makedirs helpfully creates all parent directories for us, but it sets permissions according to umask, which is probably wrong. we need to find out which directories were - created and set permissions on those + created and try to set permissions on those (http://trac.mcs.anl.gov/projects/bcfg2/ticket/1125 and http://trac.mcs.anl.gov/projects/bcfg2/ticket/1134) """ created = [] @@ -706,8 +706,9 @@ class POSIXTool(Bcfg2.Client.Tools.Tool): (path, err)) rv = False - # set auto-created directories to mode 755, if you need - # something else, you should specify it in your config + # set auto-created directories to mode 755 and use best effort for + # permissions. If you need something else, you should specify it in + # your config. tmpentry = copy.deepcopy(entry) tmpentry.set('mode', '0755') for acl in tmpentry.findall('ACL'): @@ -715,7 +716,7 @@ class POSIXTool(Bcfg2.Client.Tools.Tool): oct_mode(self._norm_acl_perms(acl.get('perms')) | ACL_MAP['x'])) for cpath in created: - rv &= self._set_perms(tmpentry, path=cpath) + self._set_perms(tmpentry, path=cpath) return rv -- cgit v1.2.3-1-g7c22 From b95a5c40d3d145e6a27ea4efcbc483e31f6aa635 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Fri, 2 Aug 2013 17:59:10 -0500 Subject: POSIXUsers: Handle unicode gecos attributes Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Client/Tools/POSIXUsers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/POSIXUsers.py b/src/lib/Bcfg2/Client/Tools/POSIXUsers.py index bb684899d..49fc704e4 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIXUsers.py +++ b/src/lib/Bcfg2/Client/Tools/POSIXUsers.py @@ -196,7 +196,10 @@ class POSIXUsers(Bcfg2.Client.Tools.Tool): # automatically determine one -- i.e., it always # verifies continue - if val != entry.get(attr): + entval = entry.get(attr) + if not isinstance(entval, str): + entval = entval.encode('utf-8') + if val != entval: errors.append("%s for %s %s is incorrect. Current %s is " "%s, but should be %s" % (attr.title(), entry.tag, entry.get("name"), -- cgit v1.2.3-1-g7c22