Skip to content

Commit

Permalink
lib/, po/: Remove fgetsx() and fputsx()
Browse files Browse the repository at this point in the history
It seems they never worked correctly.  Let's keep it simple and remove
support for escaped newlines.

Closes: <shadow-maint#1055>
Reported-by: Chris Hofstaedtler <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Oct 15, 2024
1 parent 8929e11 commit fee111c
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 107 deletions.
1 change: 0 additions & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ libshadow_la_SOURCES = \
find_new_uid.c \
find_new_sub_gids.c \
find_new_sub_uids.c \
fputsx.c \
get_pid.c \
getdate.h \
getdate.y \
Expand Down
9 changes: 4 additions & 5 deletions lib/commonio.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ int commonio_open (struct commonio_db *db, int mode)
if (NULL == buf)
goto cleanup_errno;

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

while ( (strrchr (buf, '\n') == NULL)
Expand All @@ -655,9 +655,8 @@ int commonio_open (struct commonio_db *db, int mode)
goto cleanup_errno;

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

Expand Down Expand Up @@ -877,9 +876,9 @@ static int write_all (const struct commonio_db *db)
return -1;
}
} else if (NULL != p->line) {
if (db->ops->fputs (p->line, db->fp) == EOF) {
if (fputs(p->line, db->fp) == EOF)
return -1;
}

if (putc ('\n', db->fp) == EOF) {
return -1;
}
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 (*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 *(*fgets)(/*@returned@*/char *restrict s, int n,
FILE *restrict stream);
int (*fputs) (const char *, FILE *);

/*
* open_hook and close_hook.
* If non NULL, these functions will be called after the database
Expand Down
69 changes: 0 additions & 69 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 @@ -98,8 +98,6 @@ static struct commonio_ops group_ops = {
group_getname,
group_parse,
group_put,
fgetsx,
fputsx,
group_open_hook,
group_close_hook
};
Expand Down
10 changes: 3 additions & 7 deletions lib/gshadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void endsgent (void)
return NULL;
}

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

while ( (strrchr(buf, '\n') == NULL)
Expand All @@ -170,7 +170,7 @@ void endsgent (void)
buflen *= 2;

len = strlen (buf);
if (fgetsx(&buf[len], buflen - len, fp) == NULL)
if (fgets(&buf[len], buflen - len, fp) == NULL)
return NULL;
}
stpsep(buf, "\n");
Expand Down Expand Up @@ -269,11 +269,7 @@ int 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
5 changes: 0 additions & 5 deletions lib/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,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 @@ -73,8 +73,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 @@ -197,8 +197,6 @@ static struct commonio_ops gshadow_ops = {
gshadow_getname,
gshadow_parse,
gshadow_put,
fgetsx,
fputsx,
NULL, /* open_hook */
NULL /* close_hook */
};
Expand Down
2 changes: 0 additions & 2 deletions lib/shadowio.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,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 @@ -148,8 +148,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

0 comments on commit fee111c

Please sign in to comment.