Smack: don't show empty rules when /smack/load or /smack/load2 is read
authorRafal Krypa <r.krypa@samsung.com>
Mon, 9 Jul 2012 17:36:34 +0000 (19:36 +0200)
committerCasey Schaufler <casey@schaufler-ca.com>
Fri, 13 Jul 2012 22:49:24 +0000 (15:49 -0700)
This patch removes empty rules (i.e. with access set to '-') from the
rule list presented to user space.

Smack by design never removes labels nor rules from its lists. Access
for a rule may be set to '-' to effectively disable it. Such rules would
show up in the listing generated when /smack/load or /smack/load2 is
read. This may cause clutter if many rules were disabled.

As a rule with access set to '-' is equivalent to no rule at all, they
may be safely hidden from the listing.

Targeted for git://git.gitorious.org/smack-next/kernel.git

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smackfs.c

index 29b760d6b746ed99d45eeee5ced2b77ae2883030..d31e6d957c21a47733ca1d73e8a43ef7d3fae22c 100644 (file)
@@ -518,6 +518,9 @@ static void smk_rule_show(struct seq_file *s, struct smack_rule *srp, int max)
        if (strlen(srp->smk_subject) >= max || strlen(srp->smk_object) >= max)
                return;
 
+       if (srp->smk_access == 0)
+               return;
+
        seq_printf(s, "%s %s", srp->smk_subject, srp->smk_object);
 
        seq_putc(s, ' ');
@@ -532,8 +535,6 @@ static void smk_rule_show(struct seq_file *s, struct smack_rule *srp, int max)
                seq_putc(s, 'a');
        if (srp->smk_access & MAY_TRANSMUTE)
                seq_putc(s, 't');
-       if (srp->smk_access == 0)
-               seq_putc(s, '-');
 
        seq_putc(s, '\n');
 }
This page took 0.027293 seconds and 5 git commands to generate.