public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Yu Zhiguo <yuzg@cn.fujitsu.com>
To: Steve Grubb <sgrubb@redhat.com>
Cc: audit-list <linux-audit@redhat.com>
Subject: Re: [PATCH] fix a bug that option '-i' cannot be used
Date: Wed, 23 Jul 2008 08:53:49 +0800	[thread overview]
Message-ID: <4886811D.5080908@cn.fujitsu.com> (raw)
In-Reply-To: <48816289.4060500@cn.fujitsu.com>

Hello Mr. Steve,

   What's you opinion about this patch.
   I think option '-i' should can be used with option '-R file',
This is its function.

   If I'm wrong, please correct me, thanks.

------------------

Yu Zhiguo wrote:
> Hello Steve,
> CC Miloslav,
> 
>  Option '-i' cannot be used, because the check about option '-R'
> in main() is wrong.
>  When check option '-R', we should consider whether option '-i'
> is specified.
> 
>  Using option '-i' with '-R' should ignore errors when reading
> rules from file rather than reporting error message
> "Error - nested rule files not supported".
> 
>  This is a patch to fix the bug of audit-1.7.4.
> 
> Signed-off-by: Yu Zhiguo<yuzg@cn.fujitsu.com>
> ---
>  src/auditctl.c |   45 +++++++++++++++++++++++++--------------------
>  1 files changed, 25 insertions(+), 20 deletions(-)
> 
> diff --git a/src/auditctl.c b/src/auditctl.c
> index 2c136ea..ac20fdc 100644
> --- a/src/auditctl.c
> +++ b/src/auditctl.c
> @@ -1089,39 +1089,44 @@ int main(int argc, char *argv[])
> 
>      set_aumessage_mode(MSG_STDERR, DBG_NO);
> 
> -    /* Check where the rules are coming from: commandline or file */
> -    if ((argc == 3) && (strcmp(argv[1], "-R") == 0)) {
> +    if (argc == 1) {
> +        usage();
> +        return 1;
> +    }
>  #ifndef DEBUG
> -        /* Make sure we are root */
> -        if (getuid() != 0) {
> -            fprintf(stderr,
> -                "You must be root to run this program.\n");
> -            return 4;
> -        }
> +    /* Make sure we are root */
> +    if (getuid()) {
> +        fprintf(stderr,
> +            "You must be root to run this program.\n");
> +        return 4;
> +    }
>  #endif
> +
> +    /* Check where the rules are coming from: commandline or file */
> +    if ((argc == 3) && (!strcmp(argv[1], "-R"))) {
>          if (fileopt(argv[2]))
>              return 1;
>          else
>              return 0;
> -    } else {
> -        if (argc == 1) {
> -            usage();
> +    } else if ((argc == 4) &&
> +        ((!strcmp(argv[1], "-R") && !strcmp(argv[3], "-i")) ||
> +        (!strcmp(argv[2], "-R") && !strcmp(argv[1], "-i")))) {
> +        ignore = 1;
> +        if (!strcmp(argv[1], "-R"))
> +            retval = fileopt(argv[2]);
> +        else retval = fileopt(argv[3]);
> +        if (retval)
>              return 1;
> -        }
> -#ifndef DEBUG
> -        /* Make sure we are root */
> -        if (getuid() != 0) {
> -            fprintf(stderr,
> -                "You must be root to run this program.\n");
> -            return 4;
> -        }
> -#endif
> +        else
> +            return 0;
> +    } else {
>          if (reset_vars())
>              return 1;
>          retval = setopt(argc, argv);
>          if (retval == -3)
>              return 0;
>      }
> +
>      return handle_request(retval);
>  }
> 
> 
> 
> -- 
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit
> 
> 
> 

  reply	other threads:[~2008-07-23  0:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19  3:42 [PATCH] fix a bug that option '-i' cannot be used Yu Zhiguo
2008-07-23  0:53 ` Yu Zhiguo [this message]
2008-07-25 18:22 ` Steve Grubb
2008-07-26  2:48   ` Yu Zhiguo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4886811D.5080908@cn.fujitsu.com \
    --to=yuzg@cn.fujitsu.com \
    --cc=linux-audit@redhat.com \
    --cc=sgrubb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox