Skip to contentSkip to conversation

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

PATCH New Chu Li 1 participant 1 message 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 code about "basename" in auditd-config.c and audispd-pconfig.c
is unnecessary. In these part codes "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.
Do you agree with me?

---

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