public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: "Chu Li" <chul@cn.fujitsu.com>
To: 'Steve Grubb' <sgrubb@redhat.com>
Cc: 'linux-audit' <linux-audit@redhat.com>
Subject: [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c
Date: Thu, 7 Aug 2008 12:26:46 +0800	[thread overview]
Message-ID: <005a01c8f845$cda16f00$958da70a@truly> (raw)

Hi Steve,
  I think such codes about "basename" in auditd-config.c and audispd-pconfig.c
is unnecessary. In these part "nv->value" can't be null and "basename()" will
never return an empty string. And the variable "base" is not used in the following
codes. So such codes are better to be deleted.

Signed-off-by: Chu Li <chul@cn.fujitsu.com>
---
diff --git a/src/auditd-config.c b/src/auditd-config.c
index 8977502..ca3d3a3 100644
--- a/src/auditd-config.c
+++ b/src/auditd-config.c
@@ -434,14 +434,14 @@ static const struct kw_pair *kw_lookup(const char *val)
 static int log_file_parser(struct nv_pair *nv, int line,
 	struct daemon_conf *config)
 {
-	char *dir = NULL, *tdir, *base;
+	char *dir = NULL, *tdir;
 	DIR *d;
 	int fd, mode;
 	struct stat buf;

 	audit_msg(LOG_DEBUG, "log_file_parser called with: %s", nv->value);

-	/* split name into dir and basename. */
+	/* get dir from name. */
 	tdir = strdup(nv->value);
 	if (tdir)
 		dir = dirname(tdir);
@@ -453,14 +453,6 @@ static int log_file_parser(struct nv_pair *nv, int line,
 		return 1;
 	}

-	base = basename((char *)nv->value);
-	if (base == 0 || strlen(base) == 0) {
-		audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-			base, line);
-		free((void *)tdir);
-		return 1;
-	}
-
 	/* verify the directory path exists */
 	d = opendir(dir);
 	if (d == NULL) {
@@ -577,7 +569,7 @@ static int qos_parser(struct nv_pair *nv, int line,
 static int dispatch_parser(struct nv_pair *nv, int line,
 	struct daemon_conf *config)
 {
-	char *dir = NULL, *tdir, *base;
+	char *dir = NULL, *tdir;
 	int fd;
 	struct stat buf;

@@ -587,7 +579,7 @@ static int dispatch_parser(struct nv_pair *nv, int line,
 		return 0;
 	}

-	/* split name into dir and basename. */
+	/* get dir from name. */
 	tdir = strdup(nv->value);
 	if (tdir)
 		dir = dirname(tdir);
@@ -600,12 +592,6 @@ static int dispatch_parser(struct nv_pair *nv, int line,
 	}

 	free((void *)tdir);
-	base = basename((char *)nv->value);
-	if (base == 0 || strlen(base) == 0) {
-		audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-			base, line);
-		return 1;
-	}
 	/* if the file exists, see that its regular, owned by root,
 	 * and not world anything */
 	fd = open(nv->value, O_RDONLY);

diff --git a/audisp/audispd-pconfig.c b/audisp/audispd-pconfig.c
index 63b3307..c630a00 100644
--- a/audisp/audispd-pconfig.c
+++ b/audisp/audispd-pconfig.c
@@ -361,7 +361,7 @@ static int direction_parser(struct nv_pair *nv, int line,
 static int path_parser(struct nv_pair *nv, int line,
 	plugin_conf_t *config)
 {
-	char *dir = NULL, *tdir, *base;
+	char *dir = NULL, *tdir;
 	struct stat buf;

 	if (nv->value == NULL) {
@@ -374,7 +374,7 @@ static int path_parser(struct nv_pair *nv, int line,
 		return 0;
 	}

-	/* split name into dir and basename. */
+	/* get dir form name. */
 	tdir = strdup(nv->value);
 	if (tdir)
 		dir = dirname(tdir);
@@ -387,12 +387,6 @@ static int path_parser(struct nv_pair *nv, int line,
 	}

 	free((void *)tdir);
-	base = basename((char *)nv->value);
-	if (base == 0 || strlen(base) == 0) {
-		audit_msg(LOG_ERR, "The file name: %s is too short - line %d",
-			base, line);
-		return 1;
-	}
 	/* If the file exists, see that its regular, owned by root,
 	 * and not world anything */
 	if (stat(nv->value, &buf) < 0) {

Regards
Chu Li


Regards
Chu Li

             reply	other threads:[~2008-08-07  4:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-07  4:26 Chu Li [this message]
2008-08-07 20:47 ` [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c Steve Grubb
  -- strict thread matches above, loose matches on Subject: below --
2008-08-07  4:23 Chu Li

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='005a01c8f845$cda16f00$958da70a@truly' \
    --to=chul@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