From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 11241385DC0F for ; Tue, 21 Jul 2020 03:28:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 11241385DC0F Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-BjEMSU_8OC6XBgKOGBpm4Q-1; Mon, 20 Jul 2020 23:28:19 -0400 X-MC-Unique: BjEMSU_8OC6XBgKOGBpm4Q-1 Received: by mail-qv1-f69.google.com with SMTP id l12so11477816qvu.21 for ; Mon, 20 Jul 2020 20:28:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=yUKhUBOgL1XRNIfveN2ySxGvFw5XSp8W7JBr96cNg7I=; b=jr9CPSEBU51h9g9Fk6jUtpF9UOJzk/vfx8gc56Gpbr22yhgj3hTCp/Il3I2OvkJYYv 3s2Ul5XalcjRbGBLDKlizyAi0t/6K+2oZx3xRBvaJUEcnOzoxV4VMOTZfjrXPehODgDO 5RZvSn937RkgM5R3fwrYG6kMXSlCmcWg2+DJJ15jGQuld39QQTw8tJW0GW3e0eAHqJNz I7iL3y8cO5PwwWqjEeCV1nL58l+1ZFgdbtRzF4YztZ2DJ7dZ2wpAFrMRkdVa0247CcjG zWKAOe9SJo3uYAHPpTm9OypjHS4A47vDIyG9QcX7IRvvNyt/FDpwB/UHXRnR9cHFT2ql YJPQ== X-Gm-Message-State: AOAM532b6FRp2o/aIHCxXtypX23C2jr1xsvtSrQ4Ibgwu/JzElBQJENd 1RXqOVIZ6HLZUNewj3b0ckC4yWzQFj1RMaWfMcxdvNkM4A400gQv/8uULwYlUvo7y33/GYVJc2z aNDz8C7/ZSwJGwGcaVVdb X-Received: by 2002:ac8:1c2d:: with SMTP id a42mr27301820qtk.301.1595302099310; Mon, 20 Jul 2020 20:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaXyvesW1tDskDT72A9slzRTk2NMCiPzbMxCZmql7dMgtILHBQ0K3qoTWQPG9QjWjVz9CRTg== X-Received: by 2002:ac8:1c2d:: with SMTP id a42mr27301807qtk.301.1595302099088; Mon, 20 Jul 2020 20:28:19 -0700 (PDT) Received: from [192.168.1.4] (198-84-170-103.cpe.teksavvy.com. [198.84.170.103]) by smtp.gmail.com with ESMTPSA id 84sm1407930qkf.136.2020.07.20.20.28.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Jul 2020 20:28:18 -0700 (PDT) Subject: Re: [PATCH 10/11] shadow: Implement fgetspent_r using __nss_fgetent_r To: Florian Weimer , libc-alpha@sourceware.org References: <418bb5d8b04310cdb91a966af870031188dd36dd.1594974444.git.fweimer@redhat.com> From: Carlos O'Donell Organization: Red Hat Message-ID: <6e40894a-0b71-3dd9-97cc-f7f93f570f66@redhat.com> Date: Mon, 20 Jul 2020 23:28:17 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <418bb5d8b04310cdb91a966af870031188dd36dd.1594974444.git.fweimer@redhat.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2020 03:28:23 -0000 On 7/17/20 4:30 AM, Florian Weimer via Libc-alpha wrote: OK for 2.32. Tested-by: Carlos O'Donell Reviewed-by: Carlos O'Donell > --- > gshadow/tst-fgetsgent_r.c | 1 + > shadow/fgetspent_r.c | 43 ++++++--------------------------------- > 2 files changed, 7 insertions(+), 37 deletions(-) > > diff --git a/gshadow/tst-fgetsgent_r.c b/gshadow/tst-fgetsgent_r.c > index 780409afa9..f81e09b362 100644 > --- a/gshadow/tst-fgetsgent_r.c > +++ b/gshadow/tst-fgetsgent_r.c > @@ -168,6 +168,7 @@ run_test (const char *path, size_t buffer_size) > free (result_storage); > } > > + xfclose (fp); > return resized; > } > > diff --git a/shadow/fgetspent_r.c b/shadow/fgetspent_r.c > index da35846df0..d4d4e52f6a 100644 > --- a/shadow/fgetspent_r.c > +++ b/shadow/fgetspent_r.c > @@ -20,9 +20,6 @@ > #include > #include > > -#define flockfile(s) _IO_flockfile (s) > -#define funlockfile(s) _IO_funlockfile (s) > - > /* Define a line parsing function using the common code > used in the nss_files module. */ > > @@ -39,39 +36,11 @@ int > __fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen, > struct spwd **result) > { > - char *p; > - > - flockfile (stream); > - do > - { > - buffer[buflen - 1] = '\xff'; > - p = fgets_unlocked (buffer, buflen, stream); > - if (p == NULL && feof_unlocked (stream)) > - { > - funlockfile (stream); > - *result = NULL; > - __set_errno (ENOENT); > - return errno; > - } > - if (p == NULL || buffer[buflen - 1] != '\xff') > - { > - funlockfile (stream); > - *result = NULL; > - __set_errno (ERANGE); > - return errno; > - } > - > - /* Skip leading blanks. */ > - while (isspace (*p)) > - ++p; > - } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */ > - /* Parse the line. If it is invalid, loop to > - get the next line of the file to parse. */ > - || ! parse_line (buffer, (void *) resbuf, NULL, 0, &errno)); > - > - funlockfile (stream); > - > - *result = resbuf; > - return 0; > + int ret = __nss_fgetent_r (stream, resbuf, buffer, buflen, parse_line); > + if (ret == 0) > + *result = resbuf; > + else > + *result = NULL; > + return ret; > } > weak_alias (__fgetspent_r, fgetspent_r) > -- Cheers, Carlos.