Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ libshadow_la_SOURCES = \
find_new_uid.c \
find_new_sub_gids.c \
find_new_sub_uids.c \
fputsx.c \
fs/mkstemp/fmkomstemp.c \
fs/mkstemp/fmkomstemp.h \
fs/mkstemp/mkomstemp.c \
Expand Down
34 changes: 8 additions & 26 deletions lib/commonio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <utime.h>

#include "alloc/malloc.h"
#include "alloc/reallocf.h"
#include "atoi/getnum.h"
#include "commonio.h"
#include "defines.h"
Expand Down Expand Up @@ -568,11 +567,9 @@ static void add_one_entry_nis (struct commonio_db *db,
}
#endif /* KEEP_NIS_AT_END */

/* Initial buffer size, as well as increment if not sufficient
(for reading very long lines in group files). */
#define BUFLEN 4096

int commonio_open (struct commonio_db *db, int mode)
int
commonio_open(struct commonio_db *db, int mode)
{
char *buf;
char *line;
Expand Down Expand Up @@ -634,28 +631,12 @@ int commonio_open (struct commonio_db *db, int mode)
return 0;
}

buflen = BUFLEN;
buf = MALLOC(buflen, char);
if (NULL == buf)
goto cleanup_errno;

while (db->ops->cio_fgets(buf, buflen, db->fp) != NULL) {
buf = NULL;
while (getline(&buf, &buflen, db->fp) != -1) {
struct commonio_entry *p;

while ( (strrchr (buf, '\n') == NULL)
&& (feof (db->fp) == 0)) {
size_t len;

buflen += BUFLEN;
buf = REALLOCF(buf, buflen, char);
if (NULL == buf)
goto cleanup_errno;

len = strlen (buf);
if (db->ops->cio_fgets(buf + len, buflen - len, db->fp) == NULL)
goto cleanup_buf;
}
stpsep(buf, "\n");
if (stpsep(buf, "\n") == NULL)
goto cleanup_buf;

line = strdup (buf);
if (NULL == line) {
Expand Down Expand Up @@ -716,6 +697,7 @@ int commonio_open (struct commonio_db *db, int mode)
return 0;
}


/*
* Sort given db according to cmp function (usually compares uids)
*/
Expand Down Expand Up @@ -870,7 +852,7 @@ static int write_all (const struct commonio_db *db)
return -1;
}
} else if (NULL != p->line) {
if (db->ops->cio_fputs(p->line, db->fp) == EOF)
if (fputs(p->line, db->fp) == EOF)
return -1;

if (putc ('\n', db->fp) == EOF) {
Expand Down
9 changes: 0 additions & 9 deletions lib/commonio.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ struct commonio_ops {
*/
int (*cio_put)(const void *, FILE *);

/*
* fgets and fputs (can be replaced by versions that
* understand line continuation conventions).
*/
ATTR_ACCESS(write_only, 1, 2)
/*@null@*/char *(*cio_fgets)(/*@returned@*/char *restrict s, int n,
FILE *restrict stream);
int (*cio_fputs)(const char *, FILE *);

/*
* open_hook and close_hook.
* If non NULL, these functions will be called after the database
Expand Down
68 changes: 0 additions & 68 deletions lib/fputsx.c

This file was deleted.

2 changes: 0 additions & 2 deletions lib/groupio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ static struct commonio_ops group_ops = {
group_getname,
group_parse,
group_put,
fgetsx,
fputsx,
group_open_hook,
group_close_hook
};
Expand Down
5 changes: 0 additions & 5 deletions lib/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ extern int getrange (const char *range,
/* gettime.c */
extern time_t gettime (void);

/* fputsx.c */
ATTR_ACCESS(write_only, 1, 2)
extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict);
extern int fputsx (const char *, FILE *);

/* groupio.c */
extern void __gr_del_entry (const struct commonio_entry *ent);
extern /*@observer@*/const struct commonio_db *__gr_get_db (void);
Expand Down
2 changes: 0 additions & 2 deletions lib/pwio.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ static struct commonio_ops passwd_ops = {
passwd_getname,
passwd_parse,
passwd_put,
fgets,
fputs,
NULL, /* open_hook */
NULL /* close_hook */
};
Expand Down
2 changes: 0 additions & 2 deletions lib/sgroupio.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ static struct commonio_ops gshadow_ops = {
gshadow_getname,
gshadow_parse,
gshadow_put,
fgetsx,
fputsx,
NULL, /* open_hook */
NULL /* close_hook */
};
Expand Down
45 changes: 15 additions & 30 deletions lib/shadow/gshadow/fgetsgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,27 @@
struct sgrp *
fgetsgent(FILE *fp)
{
static size_t buflen = 0;
static char *buf = NULL;

char *cp;

if (0 == buflen) {
buf = MALLOC(BUFSIZ, char);
if (NULL == buf) {
return NULL;
}
buflen = BUFSIZ;
}
char *buf;
size_t buflen;
struct sgrp *sg;

if (NULL == fp) {
return NULL;
}

if (fgetsx(buf, buflen, fp) == NULL)
return NULL;

while ( (strrchr(buf, '\n') == NULL)
&& (feof (fp) == 0)) {
size_t len;
buf = NULL;
buflen = 0;
if (getline(&buf, &buflen, fp) == -1)
goto fail;
if (stpsep(buf, "\n") == NULL)
goto fail;

cp = REALLOC(buf, buflen * 2, char);
if (NULL == cp) {
return NULL;
}
buf = cp;
buflen *= 2;
sg = sgetsgent(buf);

len = strlen (buf);
if (fgetsx(&buf[len], buflen - len, fp) == NULL)
return NULL;
}
stpsep(buf, "\n");
return sgetsgent(buf);
free(buf);
return sg;
fail:
free(buf);
return NULL;
}
#endif
6 changes: 1 addition & 5 deletions lib/shadow/gshadow/putsgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ putsgent(const struct sgrp *sgrp, FILE *fp)
}
stpcpy(cp, "\n");

/*
* Output using the function which understands the line
* continuation conventions.
*/
if (fputsx (buf, fp) == EOF) {
if (fputs(buf, fp) == EOF) {
free (buf);
return -1;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/shadowio.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ static struct commonio_ops shadow_ops = {
shadow_getname,
shadow_parse,
shadow_put,
fgets,
fputs,
NULL, /* open_hook */
NULL /* close_hook */
};
Expand Down
2 changes: 0 additions & 2 deletions lib/subordinateio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ static struct commonio_ops subordinate_ops = {
NULL, /* getname */
subordinate_parse, /* parse */
subordinate_put, /* put */
fgets, /* fgets */
fputs, /* fputs */
NULL, /* open_hook */
NULL, /* close_hook */
};
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ lib/find_new_gid.c
lib/find_new_sub_gids.c
lib/find_new_sub_uids.c
lib/find_new_uid.c
lib/fputsx.c
lib/getdef.c
lib/getgr_nam_gid.c
lib/getrange.c
Expand Down
Loading