diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2005-06-29 15:44:42 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2005-06-29 15:44:42 +0000 |
commit | 7bcbed06eb1894cf968be7e624d82e97b08b73d4 (patch) | |
tree | a334bf2239b1f389eacfc1e19df2a31cfdcf2178 /src | |
parent | be1709356f2adc456480b18f07456d0a83ae4032 (diff) | |
download | bcfg2-7bcbed06eb1894cf968be7e624d82e97b08b73d4.tar.gz bcfg2-7bcbed06eb1894cf968be7e624d82e97b08b73d4.tar.bz2 bcfg2-7bcbed06eb1894cf968be7e624d82e97b08b73d4.zip |
implement permissions
2005/06/29 10:20:27-05:00 anl.gov!desai
fix up perms on "wonderful" gpfs filesystems (and perhaps mount points
in general)
(Logical change 1.242)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1009 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Toolset.py | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py index 98ab93493..3cc163dd8 100644 --- a/src/lib/Client/Toolset.py +++ b/src/lib/Client/Toolset.py @@ -225,6 +225,8 @@ class Toolset(object): def VerifyDirectory(self, entry): '''Verify Directory Entry''' + while len(entry.get('perms', '')) < 4: + entry.set('perms', '0' + entry.get('perms', '')) try: ondisk = stat(entry.get('name')) except OSError: @@ -237,18 +239,19 @@ class Toolset(object): self.CondPrint('debug', 'User resolution failing') owner = 'root' group = 'root' - perms = stat(entry.get('name'))[ST_MODE] + perms = oct(stat(entry.get('name'))[ST_MODE])[-4:] if ((owner == entry.get('owner')) and (group == entry.get('group')) and - (perms == calc_perms(S_IFDIR, entry.get('perms')))): + (perms == entry.get('perms'))): return True else: if owner != entry.get('owner'): self.CondPrint("debug", "Directory %s ownership wrong" % (entry.get('name'))) if group != entry.get('group'): self.CondPrint("debug", "Directory %s group wrong" % (entry.get('name'))) - if perms != calc_perms(S_IFDIR, entry.get('perms')): - self.CondPrint("debug", "Directory %s permissions wrong" % (entry.get('name'))) + if perms != entry.get('perms'): + self.CondPrint("debug", "Directory %s permissions wrong: are %s should be %s" % + (entry.get('name'), perms, entry.get('perms'))) return False def InstallDirectory(self, entry): @@ -257,7 +260,7 @@ class Toolset(object): self.CondPrint('verbose', "Installing Directory %s" % (entry.get('name'))) try: fmode = lstat(entry.get('name')) - if not S_ISDIR(fmode[0]): + if not S_ISDIR(fmode[ST_MODE]): self.CondPrint("debug", "Found a non-directory entry at %s" % (entry.get('name'))) try: unlink(entry.get('name')) @@ -369,6 +372,36 @@ class Toolset(object): '''Dummy package verification method. Cannot succeed''' return False + def VerifyPermission(self, entry): + '''Verify method for abstract permission''' + try: + sinfo = stat(entry.get('name')) + except OSError: + self.CondPrint('debug', "Entry %s doesn't exist" % entry.get('name')) + return False + # pad out perms if needed + while len(entry.get('perms', '')) < 4: + entry.set('perms', '0' + entry.get('perms', '')) + perms = oct(sinfo[ST_MODE])[-4:] + if perms == entry.get('perms'): + return True + else: + self.CondPrint('debug', "Entry %s permissions incorrect" % entry.get('name')) + + def InstallPermissions(self, entry): + '''Install method for abstract permission''' + try: + sinfo = stat(entry.get('name')) + except OSError: + self.CondPrint('debug', "Entry %s doesn't exist" % entry.get('name')) + return False + for ftype in [S_ISDIR, S_ISREG]: + if ftype(sinfo[ST_MODE]): + chmod(entry.get('name'), calc_perms(ftype, entry.get('perms'))) + return True + self.CondPrint('verbose', "Entry %s has unknown file type" % entry.get('name')) + return False + def HandleBundleDeps(self): '''Handle bundles depending on what has been modified''' for entry in [child for child in self.structures if child.tag == 'Bundle']: |