From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Zhiguo Subject: Re: [PATCH] fix a bug that option '-i' cannot be used Date: Wed, 23 Jul 2008 08:53:49 +0800 Message-ID: <4886811D.5080908@cn.fujitsu.com> References: <48816289.4060500@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <48816289.4060500@cn.fujitsu.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: Steve Grubb Cc: audit-list List-Id: linux-audit@redhat.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 > --- > 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 > > >