]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, po/: Remove fgetsx() and fputsx()
authorAlejandro Colomar <alx@kernel.org>
Sun, 21 Jul 2024 16:40:25 +0000 (18:40 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 6 Dec 2025 01:23:18 +0000 (19:23 -0600)
It seems they never worked correctly.  Let's keep it simple and remove
support for escaped newlines.

Closes: <https://github.com/shadow-maint/shadow/issues/1055>
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
13 files changed:
lib/Makefile.am
lib/commonio.c
lib/commonio.h
lib/fputsx.c [deleted file]
lib/groupio.c
lib/prototypes.h
lib/pwio.c
lib/sgroupio.c
lib/shadow/gshadow/fgetsgent.c
lib/shadow/gshadow/putsgent.c
lib/shadowio.c
lib/subordinateio.c
po/POTFILES.in

index 798262500531690f03eb0bfc5c63bcdd144aac93..c402ff02a338403a46edc6727cfe4954c2b3fd0d 100644 (file)
@@ -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 \
index 7cb2f420a5c2c841b589815fea0017589874a174..cd18560f69bc32a4944e9dcbaf954e077e157c55 100644 (file)
@@ -639,7 +639,7 @@ int commonio_open (struct commonio_db *db, int mode)
        if (NULL == buf)
                goto cleanup_errno;
 
-       while (db->ops->cio_fgets(buf, buflen, db->fp) != NULL) {
+       while (fgets(buf, buflen, db->fp) != NULL) {
                struct commonio_entry  *p;
 
                while (   (strrchr (buf, '\n') == NULL)
@@ -652,7 +652,7 @@ int commonio_open (struct commonio_db *db, int mode)
                                goto cleanup_errno;
 
                        len = strlen (buf);
-                       if (db->ops->cio_fgets(buf + len, buflen - len, db->fp) == NULL)
+                       if (fgets(buf + len, buflen - len, db->fp) == NULL)
                                goto cleanup_buf;
                }
                stpsep(buf, "\n");
@@ -870,7 +870,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) {
index 1f32facea24c0dea87ff8a442fe2b3a33277b2e7..2e86d561d4e723243f369cd480c98c08e42562d7 100644 (file)
@@ -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
diff --git a/lib/fputsx.c b/lib/fputsx.c
deleted file mode 100644 (file)
index 0f86da4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2005       , Tomasz Kłoczko
- * SPDX-FileCopyrightText: 2008       , Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "config.h"
-
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "defines.h"
-#include "prototypes.h"
-#include "string/strcmp/streq.h"
-
-
-/*@null@*/char *
-fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f)
-{
-       char *cp = buf;
-       char *ep;
-
-       while (cnt > 0) {
-               if (fgets(cp, cnt, f) == NULL) {
-                       if (cp == buf) {
-                               return NULL;
-                       } else {
-                               break;
-                       }
-               }
-               ep = strrchr (cp, '\\');
-               if ((NULL != ep) && (*(ep + 1) == '\n')) {
-                       cnt -= ep - cp;
-                       if (cnt > 0)
-                               cp = stpcpy(ep, "");
-               } else {
-                       break;
-               }
-       }
-       return buf;
-}
-
-int fputsx (const char *s, FILE * stream)
-{
-       int i;
-
-       for (i = 0; !streq(s, ""); i++, s++) {
-               if (putc (*s, stream) == EOF) {
-                       return EOF;
-               }
-
-#if 0                          /* The standard getgr*() can't handle that.  --marekm */
-               if (i > (BUFSIZ / 2)) {
-                       if (putc ('\\', stream) == EOF ||
-                           putc ('\n', stream) == EOF)
-                               return EOF;
-
-                       i = 0;
-               }
-#endif
-       }
-       return 0;
-}
-
index b9ef5285417498216b746b0513845a5356d58071..a28e96c599181162f8d16e81073b720c79accae9 100644 (file)
@@ -102,8 +102,6 @@ static struct commonio_ops group_ops = {
        group_getname,
        group_parse,
        group_put,
-       fgetsx,
-       fputsx,
        group_open_hook,
        group_close_hook
 };
index 0a951f8804f652af52dd3d61069ad85410569e75..d1fb9b8789149540ab21c505649b52099ec682ad 100644 (file)
@@ -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);
index f4044c9b173b7fd453e8e7ad9228fdcbea7b3721..57ed4a45274930e8314facda1ad3788b7a0a2d5b 100644 (file)
@@ -75,8 +75,6 @@ static struct commonio_ops passwd_ops = {
        passwd_getname,
        passwd_parse,
        passwd_put,
-       fgets,
-       fputs,
        NULL,                   /* open_hook */
        NULL                    /* close_hook */
 };
index ef6fb4d5941b68f229b27f104c6b0b63c5c0400b..5df3ffc71be8b60e15deec774fe63189c597510d 100644 (file)
@@ -202,8 +202,6 @@ static struct commonio_ops gshadow_ops = {
        gshadow_getname,
        gshadow_parse,
        gshadow_put,
-       fgetsx,
-       fputsx,
        NULL,                   /* open_hook */
        NULL                    /* close_hook */
 };
index 64e7d4541c29d59cf221b6b8f97dfbe789a008a7..91cc520004fa65ddaccb7e328286a578cd940a00 100644 (file)
@@ -51,7 +51,7 @@ fgetsgent(FILE *fp)
                return NULL;
        }
 
-       if (fgetsx(buf, buflen, fp) == NULL)
+       if (fgets(buf, buflen, fp) == NULL)
                return NULL;
 
        while (   (strrchr(buf, '\n') == NULL)
@@ -66,7 +66,7 @@ fgetsgent(FILE *fp)
                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");
index cd8dc024b4a636327bede42192572cb953aa2aeb..488f4a0e4b6a7509eae10516c74ac6947e6bdb65 100644 (file)
@@ -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;
        }
index 4d2bf3b7fb86fa67bccd8e9c2aee06ffd90da61b..bf875036ed53b62b114e1311ba5cee43fdd24e9c 100644 (file)
@@ -76,8 +76,6 @@ static struct commonio_ops shadow_ops = {
        shadow_getname,
        shadow_parse,
        shadow_put,
-       fgets,
-       fputs,
        NULL,                   /* open_hook */
        NULL                    /* close_hook */
 };
index 7aa912d00a260cc65faa9ffd464cd3f73fa4e9d1..f9a845ddfec97e19c16a15a67cb721e0567cafcb 100644 (file)
@@ -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 */
 };
index 376dec4e185e916b43ac3da32de8b7a48f9eba47..8d8ae28a48ef65c689a5e6c82ce3f424dcb1812b 100644 (file)
@@ -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