diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-12-10 11:53:45 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-12-10 17:05:22 +0200 |
commit | 177deafe2f7a638759575bac6e22add177b08b3a (patch) | |
tree | 4c0b166ccf3df83f034076c823adceb2ae9918f5 | |
parent | a31c501ecdf86f4c33036bbd841dcacd9c837733 (diff) | |
download | rpm-177deafe2f7a638759575bac6e22add177b08b3a.tar.gz rpm-177deafe2f7a638759575bac6e22add177b08b3a.tar.bz2 rpm-177deafe2f7a638759575bac6e22add177b08b3a.zip |
Support excluding by path or magic in file classification
- %__foo_exclude_pattern and %__foo_exclude_magic regex'es now allow
excluding attributes that would otherwise match.
(cherry picked from commit f5a657112a8f9a107314dcd02767146e64953abe)
-rw-r--r-- | build/rpmfc.c | 18 | ||||
-rw-r--r-- | macros.in | 4 |
2 files changed, 21 insertions, 1 deletions
diff --git a/build/rpmfc.c b/build/rpmfc.c index bddb86529..455a37351 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -23,6 +23,8 @@ typedef struct rpmfcAttr_s { char *name; regex_t *pattern; regex_t *magic; + regex_t *pattern_excl; + regex_t *magic_excl; ARGV_t flags; } * rpmfcAttr; @@ -91,6 +93,8 @@ static rpmfcAttr rpmfcAttrNew(const char *name) attr->name = xstrdup(name); attr->pattern = rpmfcAttrReg(name, "pattern"); attr->magic = rpmfcAttrReg(name, "magic"); + attr->pattern_excl = rpmfcAttrReg(name, "exclude_pattern"); + attr->magic_excl = rpmfcAttrReg(name, "exclude_magic"); return attr; } @@ -106,6 +110,14 @@ static rpmfcAttr rpmfcAttrFree(rpmfcAttr attr) regfree(attr->magic); rfree(attr->magic); } + if (attr->pattern_excl) { + regfree(attr->pattern_excl); + rfree(attr->pattern_excl); + } + if (attr->magic_excl) { + regfree(attr->magic_excl); + rfree(attr->magic_excl); + } argvFree(attr->flags); rfree(attr->name); rfree(attr); @@ -582,6 +594,12 @@ static void rpmfcAttributes(rpmfc fc, const char *ftype, const char *fullpath) if (hasAttr((*attr)->flags, "exeonly") && !is_executable) continue; + /* Filter out path and magic exclude-matches */ + if (regMatch((*attr)->magic_excl, ftype)) + continue; + if (regMatch((*attr)->pattern_excl, path)) + continue; + /* Add attributes on libmagic type & path pattern matches */ if (regMatch((*attr)->magic, ftype)) argvAddTokens(&fc->fattrs[fc->ix], (*attr)->name); @@ -489,7 +489,9 @@ print (t)\ # %__myattr_provides path + args to provides finder script for <myattr> # %__myattr_magic libmagic classification match regex # %__myattr_pattern path based classification match regex -# %__myattr_exeonly require file to be executable to classify +# %__myattr_flags flags to control behavior (just "exeonly" for now) +# %__myattr_exclude_magic exclude by magic regex +# %__myattr_exclude_pattern exclude by path regex # %_fileattrsdir %{_rpmconfigdir}/fileattrs |