* [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c
@ 2008-08-07 4:23 Chu Li
0 siblings, 0 replies; 3+ messages in thread
From: Chu Li @ 2008-08-07 4:23 UTC (permalink / raw)
To: 'Steve Grubb'; +Cc: 'linux-audit'
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?
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c
@ 2008-08-07 4:26 Chu Li
2008-08-07 20:47 ` Steve Grubb
0 siblings, 1 reply; 3+ messages in thread
From: Chu Li @ 2008-08-07 4:26 UTC (permalink / raw)
To: 'Steve Grubb'; +Cc: 'linux-audit'
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c
2008-08-07 4:26 Chu Li
@ 2008-08-07 20:47 ` Steve Grubb
0 siblings, 0 replies; 3+ messages in thread
From: Steve Grubb @ 2008-08-07 20:47 UTC (permalink / raw)
To: Chu Li; +Cc: 'linux-audit'
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-07 20:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-07 4:23 [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c Chu Li
-- strict thread matches above, loose matches on Subject: below --
2008-08-07 4:26 Chu Li
2008-08-07 20:47 ` Steve Grubb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox