[apparmor] [patch] apparmor-utils: setprofileflags() drops leading whitespace

Steve Beattie steve at nxnw.org
Tue Aug 9 09:31:06 UTC 2011


On Mon, Aug 08, 2011 at 11:46:13PM +0200, Christian Boltz wrote:
> Hello,
> 
> the first openSUSE patch not related to profiles: genprof killed the 
> spaces at the start of a subprofile. Guess who found this bug ;-)
> 
> 
> From: Jeff Mahoney <jeffm at suse.com>                                                                                                                                             
> Subject: apparmor-utils: setprofileflags() drops leading whitespace
> References: bnc#480795
> 
>  setprofileflags() drops leading whitespace for subprofiles. writeheader()
>  properly indents subprofiles 2 spaces per nesting level but when
>  genprof sets the profile to enforce mode at completion, the whitespace
>  is removed.
> 
>  This patch adds the whitespace globbing to the regexp and uses it to
>  prefix the sub-profile with the correct spacing.
> 
>  Reported at: https://bugzilla.novell.com/show_bug.cgi?id=480795
> 
> Signed-off-by: Jeff Mahoney <jeffm at suse.com>

Acked-By: Steve Beattie <sbeattie at ubuntu.com>

Thanks!

> From: Jeff Mahoney <jeffm at suse.com>
> Subject: apparmor-utils: setprofileflags() drops leading whitespace
> 
>  setprofileflags() drops leading whitespace for subprofiles. writeheader()
>  properly indents subprofiles 2 spaces per nesting level but when
>  genprof sets the profile to enforce mode at completion, the whitespace
>  is removed.
> 
>  This patch adds the whitespace globbing to the regexp and uses it to
>  prefix the sub-profile with the correct spacing.
> 
>  Reported at: https://bugzilla.novell.com/show_bug.cgi?id=480795
> 
> Signed-off-by: Jeff Mahoney <jeffm at suse.com>
> ---
>  utils/Immunix/AppArmor.pm |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> --- a/utils/Immunix/AppArmor.pm
> +++ b/utils/Immunix/AppArmor.pm
> @@ -1033,13 +1033,13 @@ sub setprofileflags ($$) {
>      if (open(PROFILE, "$filename")) {
>          if (open(NEWPROFILE, ">$filename.new")) {
>              while (<PROFILE>) {
> -                if (m/^\s*(("??\/.+?"??)|(profile\s+("??.+?"??)))\s+(flags=\(.+\)\s+)*\{\s*$/) {
> -                    my ($binary, $flags) = ($1, $5);
> +                if (m/^(\s*)(("??\/.+?"??)|(profile\s+("??.+?"??)))\s+(flags=\(.+\)\s+)*\{\s*$/) {
> +                    my ($space, $binary, $flags) = ($1, $2, $6);
>  
>                      if ($newflags) {
> -                        $_ = "$binary flags=($newflags) {\n";
> +                        $_ = "$space$binary flags=($newflags) {\n";
>                      } else {
> -                        $_ = "$binary {\n";
> +                        $_ = "$space$binary {\n";
>                      }
>                  } elsif (m/^(\s*\^\S+)\s+(flags=\(.+\)\s+)*\{\s*$/) {
>                      my ($hat, $flags) = ($1, $2);

> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor


-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20110809/4559568a/attachment.pgp>


More information about the AppArmor mailing list