Skip to contentSkip to conversation

Delete unnecessary codes in auditd-config.c and audispd-pconfig.c

PATCH Applied Chu Li 2 participants 2 messages Aug 7, 2008

lore
Share & tools
lore

Chu Li

author
#0 lore raw

PATCH 1/1 Delete unnecessary codes in auditd-config.c and audispd-pconfig.c

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.

---

src/auditd-config.c +4 -18
index 8977502..ca3d3a3 100644
@@ -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);
audisp/audispd-pconfig.c +2 -8
index 63b3307..c630a00 100644
@@ -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

Applied
#1 lore raw
Quoted 4 lines · On Thursday 07 August 2008 00:26:46 Chu Li wrote:

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.

Applied. Thanks for the patch !

-Steve