From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chu Li" Subject: [PATCH]Delete unnecessary codes in auditd-config.c and audispd-pconfig.c Date: Thu, 7 Aug 2008 12:23:16 +0800 Message-ID: <005901c8f845$509c1fa0$958da70a@truly> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: 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: 'linux-audit' List-Id: linux-audit@redhat.com Hi Steve, I think such code about "basename" in auditd-config.c and audispd-pconf= ig.c is unnecessary. In these part codes "nv->value" can't be null and "basena= me()" will=20 never return an empty string. And the variable "base" is not used in the = following=20 codes. So such codes are better to be deleted. Do you agree with me? Signed-off-by: Chu Li --- 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 =3D NULL, *tdir, *base; + char *dir =3D NULL, *tdir; DIR *d; int fd, mode; struct stat buf; =20 audit_msg(LOG_DEBUG, "log_file_parser called with: %s", nv->value); =20 - /* split name into dir and basename. */ + /* get dir from name. */ tdir =3D strdup(nv->value); if (tdir) dir =3D dirname(tdir); @@ -453,14 +453,6 @@ static int log_file_parser(struct nv_pair *nv, int l= ine, return 1; } =20 - base =3D basename((char *)nv->value); - if (base =3D=3D 0 || strlen(base) =3D=3D 0) { - audit_msg(LOG_ERR, "The file name: %s is too short - line %d",=20 - base, line); - free((void *)tdir); - return 1; - } -=09 /* verify the directory path exists */ d =3D opendir(dir); if (d =3D=3D 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 =3D NULL, *tdir, *base; + char *dir =3D NULL, *tdir; int fd; struct stat buf; =20 @@ -587,7 +579,7 @@ static int dispatch_parser(struct nv_pair *nv, int li= ne, return 0; } =20 - /* split name into dir and basename. */ + /* get dir from name. */ tdir =3D strdup(nv->value); if (tdir) dir =3D dirname(tdir); @@ -600,12 +592,6 @@ static int dispatch_parser(struct nv_pair *nv, int l= ine, } =20 free((void *)tdir); - base =3D basename((char *)nv->value); - if (base =3D=3D 0 || strlen(base) =3D=3D 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 =3D 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 l= ine, static int path_parser(struct nv_pair *nv, int line, plugin_conf_t *config) { - char *dir =3D NULL, *tdir, *base; + char *dir =3D NULL, *tdir; struct stat buf; =20 if (nv->value =3D=3D NULL) { @@ -374,7 +374,7 @@ static int path_parser(struct nv_pair *nv, int line, return 0; } =20 - /* split name into dir and basename. */ + /* get dir form name. */ tdir =3D strdup(nv->value); if (tdir) dir =3D dirname(tdir); @@ -387,12 +387,6 @@ static int path_parser(struct nv_pair *nv, int line, } =20 free((void *)tdir); - base =3D basename((char *)nv->value); - if (base =3D=3D 0 || strlen(base) =3D=3D 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