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 [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 8B7743851C20 for ; Tue, 21 Jul 2020 03:28:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8B7743851C20 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-g5CU3H5qPbKps4X1ov5NtQ-1; Mon, 20 Jul 2020 23:28:14 -0400 X-MC-Unique: g5CU3H5qPbKps4X1ov5NtQ-1 Received: by mail-qk1-f200.google.com with SMTP id v188so2408455qkb.17 for ; Mon, 20 Jul 2020 20:28:14 -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=gDwdRPiHLwH4Lf+QtkEY4XVCZbZpQ1xtgJCPCdeNF0g=; b=ft/lBOkuvEAEzuo4chHWR+ck12FEW6UjY5TEGTCYfgnUXLm7BuEw2J+4zbg+cbJ6+3 VYX4+BjGO3K0Heob4su0q36Z9FJNU0FOQ7UwA67wgWseSsV6O8ml+fxOdAO9BxccyAou KfhTqnIQthExe7pnRCGBtzbUInXjmgMCdx9I+s4lfZ5+2ErMSqahthRjkomtFNdnTyI6 F/dJO62ZUtpHglzNGQUwIA7jDTFihdarbiFFxcu80zUEh5crAe9hlNT0LKyJixwij1GS g2XSjL8D60lc65ppSbth/p2JV6xvVvWqVLaAT2AlFr9HjC+MWdsQQjW8wQ7KAaWfy4BH xHyQ== X-Gm-Message-State: AOAM532r0WsIYk6o0Cy2bMf6vp3mLTJsoxh+ENDSkp+HXD0nCpB1X83g qFuLO0G8WFuDvc8Vjv709D7zDwFCu3/yoBXeaYQ3gtuNnGc4yW1ccW2aN14a5lC8Qb9cZhw6SkR 9W2fnIAQ+GpXVClrsY5oJ X-Received: by 2002:ad4:4bb2:: with SMTP id i18mr24968214qvw.8.1595302093856; Mon, 20 Jul 2020 20:28:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtqlMRbsIeMxTRK0U3xI7LVXih/qq+YTS2KsWIa7J8NgVhvVPOTOxpLNbLBDwyaUOlxL/qtg== X-Received: by 2002:ad4:4bb2:: with SMTP id i18mr24968204qvw.8.1595302093641; Mon, 20 Jul 2020 20:28:13 -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 e23sm1398927qkl.55.2020.07.20.20.28.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Jul 2020 20:28:13 -0700 (PDT) Subject: Re: [PATCH 09/11] pwd: Implement fgetpwent_r using __nss_fgetent_r To: Florian Weimer , libc-alpha@sourceware.org References: From: Carlos O'Donell Organization: Red Hat Message-ID: <87b78d52-a597-29f7-16d1-d9ba808bac6b@redhat.com> Date: Mon, 20 Jul 2020 23:28:12 -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: 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_H2, 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:17 -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 > --- > pwd/fgetpwent_r.c | 43 ++++++------------------------------------- > 1 file changed, 6 insertions(+), 37 deletions(-) > > diff --git a/pwd/fgetpwent_r.c b/pwd/fgetpwent_r.c > index 26b0ee52aa..0a2e4a55e2 100644 > --- a/pwd/fgetpwent_r.c > +++ b/pwd/fgetpwent_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. */ > > @@ -72,39 +69,11 @@ int > __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer, > size_t buflen, struct passwd **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 (p, resbuf, (void *) buffer, buflen, &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 (__fgetpwent_r, fgetpwent_r) > -- Cheers, Carlos.