[PATCH 6/8] busybox -- libselinux utilities applets

Peter Kjellerstedt peter.kjellerstedt at axis.com
Mon Jan 29 01:11:15 PST 2007


> -----Original Message-----
> From: busybox-bounces at busybox.net 
> [mailto:busybox-bounces at busybox.net] On Behalf Of Denis Vlasenko
> Sent: Saturday, January 27, 2007 00:45
> To: busybox at busybox.net
> Cc: russell at coker.com.au; rob at landley.net; 
> selinux at tycho.nsa.gov; busybox at kaigai.gr.jp
> Subject: Re: [PATCH 6/8] busybox -- libselinux utilities applets
> 
> On Thursday 25 January 2007 15:44, KaiGai Kohei wrote:
> > [6/8] busybox-libselinux-06-togglesebool.patch
> >   togglesebool - flip the current value of a SELinux
> >   boolean variable.
> > 
> > Signed-off-by: Hiroshi Shinji <shiroshi at my.email.ne.jp>
> > Signed-off-by: KaiGai Kohei <kaigai at kaigai.gr.jp>
> > 
> > --
> > KaiGai Kohei <kaigai at kaigai.gr.jp>
> 
>  
> Index: selinux/togglesebool.c
> ===================================================================
> --- selinux/togglesebool.c      (revision 0)
> +++ selinux/togglesebool.c      (revision 0)
> @@ -0,0 +1,106 @@

[snip]

> +       for (i = 1; i < argc; i++) {
> +               printf("%s: ", argv[i]);
> +               rc = security_get_boolean_active(argv[i]);
> +               switch (rc) {
> +               case 1:
> +                       if (security_set_boolean(argv[i], 0) >= 0) {
> +                               printf("inactive\n");
> +                               commit++;
> +                       } else {
> +                               printf("%s - rolling back all changes\n",
> +                                      strerror(errno));
> +                               rollback(i, argv);
> +                       }
> 
> By reversing the if() [i.e.: security_set_boolean(argv[i], 0) < 0]
> and swapping then/else blocks, and noticing that rollback()
> never returns, you don't need else block:
>                        if (security_set_boolean(argv[i], 0) < 0) {
>                                printf("%s - rolling back all changes\n",
>                                       strerror(errno));
>                                rollback(i, argv);

But please make sure to add a comment stating the fact that
rollback() will never return.

//Peter


More information about the busybox mailing list