* lib/shadowmem.c: Added spw_free().

* lib/shadowio.c: Use spw_free() for shadow_free().
	* lib/groupmem.c: Added gr_free().
	* lib/groupio.c: Use gr_free() for group_free().
	* lib/pwmem.c: Include define.h before prototypes.h
	* lib/pwmem.c: Added pw_free().
	* lib/pwio.c: Use pw_free() for passwd_free().
	* lib/sgroupio.c: Added sgr_free().
	* lib/sgroupio.c: Use sgr_free() for gshadow_free().
	* lib/prototypes.h: Added gr_free(), pw_free(), sgr_free(),
	spw_free().
This commit is contained in:
nekral-guest 2009-04-21 22:14:10 +00:00
parent 408a30f0ba
commit 5bdf239a66
9 changed files with 68 additions and 30 deletions

View File

@ -1,3 +1,17 @@
2009-04-21 Nicolas François <nicolas.francois@centraliens.net>
* lib/shadowmem.c: Added spw_free().
* lib/shadowio.c: Use spw_free() for shadow_free().
* lib/groupmem.c: Added gr_free().
* lib/groupio.c: Use gr_free() for group_free().
* lib/pwmem.c: Include define.h before prototypes.h
* lib/pwmem.c: Added pw_free().
* lib/pwio.c: Use pw_free() for passwd_free().
* lib/sgroupio.c: Added sgr_free().
* lib/sgroupio.c: Use sgr_free() for gshadow_free().
* lib/prototypes.h: Added gr_free(), pw_free(), sgr_free(),
spw_free().
2009-04-21 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/shell.c: Add brackets and parenthesis.

View File

@ -59,14 +59,7 @@ static void group_free (void *ent)
{
struct group *gr = ent;
free (gr->gr_name);
memzero (gr->gr_passwd, strlen (gr->gr_passwd));
free (gr->gr_passwd);
while (*(gr->gr_mem)) {
free (*(gr->gr_mem));
gr->gr_mem++;
}
free (gr);
gr_free (gr);
}
static const char *group_getname (const void *ent)

View File

@ -75,3 +75,15 @@ struct group *__gr_dup (const struct group *grent)
return gr;
}
void gr_free (struct group *grent)
{
free (grent->gr_name);
memzero (grent->gr_passwd, strlen (grent->gr_passwd));
free (grent->gr_passwd);
while (*(grent->gr_mem)) {
free (*(grent->gr_mem));
grent->gr_mem++;
}
free (grent);
}

View File

@ -173,6 +173,7 @@ extern void __gr_set_changed (void);
/* groupmem.c */
extern struct group *__gr_dup (const struct group *grent);
extern void gr_free (struct group *grent);
/* hushed.c */
extern bool hushed (const char *username);
@ -258,6 +259,7 @@ extern struct commonio_entry *__pw_get_head (void);
/* pwmem.c */
extern struct passwd *__pw_dup (const struct passwd *pwent);
extern void pw_free (struct passwd *pwent);
/* rlogin.c */
extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
@ -295,6 +297,7 @@ extern struct spwd *sgetspent (const char *string)
/* sgroupio.c */
extern void __sgr_del_entry (const struct commonio_entry *ent);
extern struct sgrp *__sgr_dup (const struct sgrp *sgent);
extern void sgr_free (struct sgrp *sgent);
extern struct commonio_entry *__sgr_get_head (void);
extern void __sgr_set_changed (void);
@ -304,6 +307,7 @@ extern void __spw_del_entry (const struct commonio_entry *ent);
/* shadowmem.c */
extern struct spwd *__spw_dup (const struct spwd *spent);
extern void spw_free (struct spwd *spent);
/* shell.c */
extern int shell (const char *, const char *, char *const *);

View File

@ -53,13 +53,7 @@ static void passwd_free (void *ent)
{
struct passwd *pw = ent;
free (pw->pw_name);
memzero (pw->pw_passwd, strlen (pw->pw_passwd));
free (pw->pw_passwd);
free (pw->pw_gecos);
free (pw->pw_dir);
free (pw->pw_shell);
free (pw);
pw_free (pw);
}
static const char *passwd_getname (const void *ent)

View File

@ -36,8 +36,8 @@
#ident "$Id$"
#include <stdio.h>
#include "prototypes.h"
#include "defines.h"
#include "prototypes.h"
#include "pwio.h"
struct passwd *__pw_dup (const struct passwd *pwent)
@ -73,3 +73,14 @@ struct passwd *__pw_dup (const struct passwd *pwent)
return pw;
}
void pw_free (struct passwd *pwent)
{
free (pwent->pw_name);
memzero (pwent->pw_passwd, strlen (pwent->pw_passwd));
free (pwent->pw_passwd);
free (pwent->pw_gecos);
free (pwent->pw_dir);
free (pwent->pw_shell);
free (pwent);
}

View File

@ -101,18 +101,23 @@ static void gshadow_free (void *ent)
{
struct sgrp *sg = ent;
free (sg->sg_name);
memzero (sg->sg_passwd, strlen (sg->sg_passwd));
free (sg->sg_passwd);
while (NULL != *(sg->sg_adm)) {
free (*(sg->sg_adm));
sg->sg_adm++;
sgr_free (sg);
}
void sgr_free (struct sgrp *sgent)
{
free (sgent->sg_name);
memzero (sgent->sg_passwd, strlen (sgent->sg_passwd));
free (sgent->sg_passwd);
while (NULL != *(sgent->sg_adm)) {
free (*(sgent->sg_adm));
sgent->sg_adm++;
}
while (NULL != *(sg->sg_mem)) {
free (*(sg->sg_mem));
sg->sg_mem++;
while (NULL != *(sgent->sg_mem)) {
free (*(sgent->sg_mem));
sgent->sg_mem++;
}
free (sg);
free (sgent);
}
static const char *gshadow_getname (const void *ent)

View File

@ -53,10 +53,7 @@ static void shadow_free (void *ent)
{
struct spwd *sp = ent;
free (sp->sp_namp);
memzero (sp->sp_pwdp, strlen (sp->sp_pwdp));
free (sp->sp_pwdp);
free (sp);
spw_free (sp);
}
static const char *shadow_getname (const void *ent)

View File

@ -62,3 +62,11 @@ struct spwd *__spw_dup (const struct spwd *spent)
return sp;
}
void spw_free (struct spwd *spent)
{
free (spent->sp_namp);
memzero (spent->sp_pwdp, strlen (spent->sp_pwdp));
free (spent->sp_pwdp);
free (spent);
}