From 67c3eb93fa85e506a1665e8a12f45b366824c3eb Mon Sep 17 00:00:00 2001 From: brent s Date: Thu, 19 Apr 2018 13:41:48 -0400 Subject: [PATCH] add option to skip symlinks in RPMs (apache, etc.) --- centos/find_changed_confs.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/centos/find_changed_confs.py b/centos/find_changed_confs.py index f32f504..c040f69 100755 --- a/centos/find_changed_confs.py +++ b/centos/find_changed_confs.py @@ -9,6 +9,7 @@ import copy import datetime import hashlib import os +import re from sys import version_info as py_ver try: import rpm @@ -19,9 +20,10 @@ except ImportError: # https://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html class PkgChk(object): - def __init__(self, dirpath, pkgs = None): + def __init__(self, dirpath, symlinks = True, pkgs = None): self.path = dirpath self.pkgs = pkgs + self.symlinks = symlinks self.orig_pkgs = copy.deepcopy(pkgs) self.pkgfilemap = {} self.flatfiles = [] @@ -89,6 +91,10 @@ class PkgChk(object): if (f in self.flst.keys() and (self.flst[f]['hash'] != self.pkgfilemap[p][f]['hash'])): + if not self.symlinks: + if re.search('^0+$', + self.pkgfilemap[p][f]['hash']): + continue r_time = datetime.datetime.fromtimestamp( self.pkgfilemap[p][f]['date']) r_hash = self.pkgfilemap[p][f]['hash'] @@ -130,6 +136,11 @@ def parseArgs(): 'files that have changed ' + 'from the package\'s ' + 'defaults')) + args.add_argument('-l', '--ignore-symlinks', + dest = 'symlinks', + action = 'store_false', + help = ('If specified, don\'t track files that are ' + + 'symlinks in the RPM')) args.add_argument('-p', '--package', dest = 'pkgs', #nargs = 1,