gathering as much data as we can on the f14 boxes setup
[infrastructure.git] / bbox-f14 / rpm-fedora / rpm-fileperm.patch
1 From: Panu Matilainen <pmatilai@redhat.com>
2 Date: Fri, 13 Apr 2012 10:16:51 +0000 (+0300)
3 Subject: Raise file conflicts on differing permissions (user, group, mode)
4 X-Git-Tag: rpm-4.11.0-alpha~426
5 X-Git-Url: http://rpm.org/gitweb?p=rpm.git;a=commitdiff_plain;h=cf1095648194104a81a58abead05974a5bfa3b9a
6
7 Raise file conflicts on differing permissions (user, group, mode)
8
9 - Two files (or directories) cannot be correctly shared if their
10   permissions differ, even if the content is identical: either
11   file will end up having wrong permissions, depending on installation
12   order. This means a package can among other things silently
13   eg relax permissions of eg security sensitive directory (accidentally
14   or intentionallY).
15 - We now require exact match of user, group and entire file mode
16   (previously only the file type part of mode was tested)
17 ---
18
19 diff --git a/lib/rpmfi.c b/lib/rpmfi.c
20 index 42c07db..e6e1fb3 100644
21 --- a/lib/rpmfi.c
22 +++ b/lib/rpmfi.c
23 @@ -542,13 +542,20 @@ rpmFileTypes rpmfiWhatis(rpm_mode_t mode)
24  
25  int rpmfiCompareIndex(rpmfi afi, int aix, rpmfi bfi, int bix)
26  {
27 -    rpmFileTypes awhat = rpmfiWhatis(rpmfiFModeIndex(afi, aix));
28 -    rpmFileTypes bwhat = rpmfiWhatis(rpmfiFModeIndex(bfi, bix));
29 +    mode_t amode = rpmfiFModeIndex(afi, aix);
30 +    mode_t bmode = rpmfiFModeIndex(bfi, bix);
31 +    rpmFileTypes awhat = rpmfiWhatis(amode);
32 +    rpmFileTypes bwhat = rpmfiWhatis(bmode);
33  
34      if ((rpmfiFFlagsIndex(afi, aix) & RPMFILE_GHOST) ||
35         (rpmfiFFlagsIndex(bfi, bix) & RPMFILE_GHOST)) return 0;
36  
37 -    if (awhat != bwhat) return 1;
38 +    if (amode != bmode) return 1;
39 +
40 +    if (!rstreq(rpmfiFUserIndex(afi, aix), rpmfiFUserIndex(bfi, bix)))
41 +       return 1;
42 +    if (!rstreq(rpmfiFGroupIndex(afi, aix), rpmfiFGroupIndex(bfi, bix)))
43 +       return 1;
44  
45      if (awhat == LINK) {
46         const char * alink = rpmfiFLinkIndex(afi, aix);