From ab62481b597edcc099811039f7fd60743353d979 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Fri, 28 Jun 2013 23:56:30 -0400 Subject: Info: make builddir add owner write permissions to all files Since bcfg2-info isn't normally run as root, it can remove write permissions from itself in certain situations. This patch ensures that owner write is added to the mode for all files written by builddir. For example, suppose a bundle specifies a file /etc/foo/private with mode 0444. The POSIX tool will create /etc/foo with mode 0555. Any subsequent files that are specified to exist in /etc/foo will not be created because bcfg2-info will hit a permission denied error. --- src/sbin/bcfg2-info | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 133e1ccb3..a8aad3730 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -10,6 +10,7 @@ import fnmatch import logging import lxml.etree import traceback +import stat from code import InteractiveConsole import Bcfg2.Logger import Bcfg2.Options @@ -280,6 +281,9 @@ Bcfg2 client itself.""") for entry in struct: if entry.tag == 'Path': entry.set('name', odir + '/' + entry.get('name')) + if entry.get('mode') != None: + entry.set('mode', \ + oct(int(entry.get('mode'), 8)|stat.S_IWUSR)) posix = Bcfg2.Client.Tools.POSIX.POSIX(MockLog(), self.setup, -- cgit v1.2.3-1-g7c22