From patchwork Tue Aug 29 19:04:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 22402 Received: (qmail 113777 invoked by alias); 29 Aug 2017 19:04:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113765 invoked by uid 89); 29 Aug 2017 19:04:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=8648, UD:config.h X-HELO: NAM02-SN1-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Steve.Ellcey@cavium.com; Message-ID: <1504033460.5204.8.camel@cavium.com> Subject: Re: [PATCH] Remove compat from DEFAULT_CONFIG lookup strings From: Steve Ellcey Reply-To: sellcey@cavium.com To: Joseph Myers Cc: DJ Delorie , libc-alpha@sourceware.org Date: Tue, 29 Aug 2017 12:04:20 -0700 In-Reply-To: References: <1503951778.28672.139.camel@cavium.com> <1503957036.28672.144.camel@cavium.com> Mime-Version: 1.0 X-ClientProxiedBy: MWHPR10CA0052.namprd10.prod.outlook.com (10.169.238.14) To DM5PR07MB3548.namprd07.prod.outlook.com (10.164.153.146) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53f1265d-b743-4b18-e273-08d4ef10c333 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(49563074)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3548; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3548; 3:YHHnYLzuNDbeRwcLLByUxha7nY2EDEbEskL7piw97F5Ab26AMAuhTgg9nnULBC88liI775dvnZcQuIRt0WYEEFH0iVlbEe/t/LtknWjNu/hCQOsh5hqleLe/1OO44jkHsB9SI1Tk/E3HJ3AJD94VhBGYZjF9t9teDprn6kl0HrFiLm5BT6kFA+ICJrQ0CvD74WzomHJl9bG1i8bAVeUNeRWXucaN6vZZHdxwLuwp6mF30Cqbh+OhR64VMDIEKY5/; 25:jqJa9jrHIuLF+dIAOI5lRO5cwiQYXWtauIcv+VG9QNkq3kCXH6t0p+7OFJqyvphmcLSsLhsiAf3rbNnCI80EEbaCGIpRalm6XwYpHNRlAgiG6Fgi4Zp6iyr90kEzfhol+sakLMpfx4WdU2M+ICyR1w9tY06o0hb14lYwF5XQDmKiLI5lYU3GXIXlwXi2zH9l8tBz2OpFI0ZlxFg7kXFfsrqkOqPDERsfcK1VLa8IWokewmbKIPChgvUnUX3s+zPMVpwATla0i2MiED4kC1h5Kwd+beNWqqzvrwT41nmP6E8s1J2FbMVr8UOkfSxHYZiCd35e63u3pU6I00RBt5pFXg==; 31:kAPVcs69Bp3AYL5Qk/XsussZ1NIS8hpsdLOiRPNqyvV8JxbzqfZ5fQhzF1a1u0d5bkolOSI8KkOnIuDPaPo3IETypr8EBmNnUwRGbLmKT+iAkASo8DhagnOCMlSaSxMN8gZp8R+dtrTGKOut+kOnVl1NcdIrsOWrD8a1hRN0elYdvBmCu6D4q2DmSLPzNmFgXHsjfPA4oRjBPqKcK0bOEvZq15rZ2abDB0b7NPdz1rI= X-MS-TrafficTypeDiagnostic: DM5PR07MB3548: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3548; 20:kPEHF+0kjyy1cflhdNxkx1h0i6x+nJfayvhr7UEZMMdsg8gfklqEN8wfkEP1h/TircIBSFsDKeCRDcoDKO5UaUBUP6ERvHTVeJJEvzfYo9x5Phqt7DfYlD4ng6BBGGOBQgpySnhO3OI5W5AvKYMQKFnl2Qag4hTyXI631IISrxiPvXBz465FwnCGiR1+G2+Y7YP0pws8lJ4Rfwg+uTmvhvCnyzX9IOfYguqxJ3gZkLZSTgEYWyEg1kPHE8MnO0QDaZJoV+lRwvg9D2lDnIpIk0jZILUAq9/em14ocvN6bJNIZuNwjWG7jak3luW70MngiW/YCQ5tQN/yr48FcyEaRX1sJ5CCn28kM4Pn/HCyobiLz6E5Oowld3cbPyaK989qOi6Kb247e1IPcLELuOtNLZf6DPN1v9ept/WIsdL/XDNcXYpw2TpEh3HWUTXzEUF0Cu+YfLBFJGLPkyXY8RdFFYMr7kHG4ziCnMNnL2G80WSVPX6lmIFZP4WNaTutBKyh; 4:1861xmzaL0l1WXGDoeAJ/8cnoLQXIbXHQoqbzEZqsZnyOqQFug76vbZmtOPYNhbgbiMDFuc0O7bO9OQSA3Iv03BX6jRxoT4/Q+efnQ9Uk/Pl21bl72ew9BlTaY+n7rsYV2YpgOVgAUJSfkIy3gRWc2hU1aTn+gU7l+mqj8JiSHHl+OUALUo8gM3qY8qlVEdHyaxMSKBnIjpa54Yqz9XUepiSpJFA8f+l+u/J5C4tgIBxHpgmGrDIcUGqjVboMpyT X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(102415395)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3548; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3548; X-Forefront-PRVS: 0414DF926F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(189002)(199003)(24454002)(377424004)(50226002)(110136004)(6246003)(66066001)(4326008)(84326002)(568964002)(5890100001)(53416004)(97736004)(6506006)(189998001)(42186005)(6116002)(2476003)(6486002)(3846002)(68736007)(106356001)(105586002)(50986999)(53936002)(76176999)(4610100001)(43066003)(25786009)(478600001)(6512007)(103116003)(36756003)(81156014)(7350300001)(8676002)(81166006)(72206003)(229853002)(33646002)(69596002)(5660300001)(305945005)(512874002)(7736002)(93886005)(6916009)(2950100002)(2906002)(101416001)(3450700001)(99106002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3548; H:sellcey-dt.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3548; 23:L+Gzt3dBawpSM5MiI/xfrEWQkZH4C1lBWGgsfwbww?= =?us-ascii?Q?waRdnfqS+KpzBAvx/k8kPRM7kLYjN5UphE0b9C7ZnQhkJx3h6hKnkGpDCawa?= =?us-ascii?Q?YuQuZ4i4qc6kjdnvHpBvhEPWlMbYfhSKjPXEskUkhHtsoy7C2nmfbynx7jO1?= =?us-ascii?Q?GxnPFTzTPOTdYDgM6N0lSqirXYrwedaB13SgtDWMPdQrTbr8TxN7IgzJbUtJ?= =?us-ascii?Q?Ljr4sCxQfYr6qpZzltU36iaawNFd/zoQCZTR50qByhV+ryf+aDENfwJ8Z/bT?= =?us-ascii?Q?Gy/Jqa1+yrss06A/HRd2W4oFzrd7NtEjmg+ue/jOec2IeyaU6T80a2l8VwKd?= =?us-ascii?Q?frWzr5jg4jks5dFmEmWnJplrWpT7xPVd/wIC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utput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 19:04:23.5961 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3548 On Mon, 2017-08-28 at 22:57 +0000, Joseph Myers wrote: > On Mon, 28 Aug 2017, Steve Ellcey wrote: > > > > > > > > > Does the "nis [NOTFOUND=return] files" default in  > > > nsswitch.c:__nss_database_lookup need to change as well? > > I think this default is still OK.  The other changes I made were to > > remove 'compat' entries from the list of databases to be searched > > if the compat library is not built.  I am not sure why we would > > want to > > change this one.  Am I missing something? > Well, libnss_nis isn't built by default either.  Is there some reason for  > searching nis by default without the relevant library, but not doing so  > for compat without the relevant library? No reason, I just didn't realise libnss_nis wasn't built by default. Here is an updated patch for setting the default lookup methods in nss. I updated nss/nsswitch.c to not use nis lookups when RPC is not configured and I updated DEFAULT_CONFIG in grp/initgroups.c to be "compat [NOTFOUND=return] files" when using NSL instead of just "compat files".  DJ noticed that and I think the missing NOTFOUND is just an oversight and it conflicted with the documentation in manual/nss.texi. Fixing the code seemed more reasonable than documenting the existing setting.  I did update the documentation to reflect the behavour of this patch. I tested once with "--enable-obsolete-nsl --enable-obsolete-rpc" and once without and had no regressions from the unmodified glibc on aarch64. OK to checkin? Steve Ellcey sellcey@cavium.com 2017-08-29  Steve Ellcey   * grp/initgroups.c: Include config.h. (DEFAULT_CONFIG): New macro. (internal_getgrouplist): Use DEFAULT_CONFIG. * nscd/initgrcache.c (addinitgroupsX): Likewise. * nss/nsswitch.c (__nss_disable_nscd): Likewise. (DEFAULT_DEFCONFIG): New macro. (__nss_database_lookup): Use DEFAULT_DEFCONFIG. * nss/grp-lookup.c: Include config.h (DEFAULT_CONFIG): Set definition based on LINK_OBSOLETE_NSL. * nss/pwd-lookup.c (DEFAULT_CONFIG): Likewise. * nss/spwd-lookup.c (DEFAULT_CONFIG): Likewise. * manual/nss.texi: Update default values section. diff --git a/grp/initgroups.c b/grp/initgroups.c index 3e4a3de..45dd391 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -26,10 +26,16 @@ #include #include #include +#include #include "../nscd/nscd-client.h" #include "../nscd/nscd_proto.h" +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif /* Type of the lookup function. */ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t, @@ -77,7 +83,7 @@ internal_getgrouplist (const char *user, gid_t group, long int *size, &__nss_initgroups_database) < 0) { if (__nss_group_database == NULL) - no_more = __nss_database_lookup ("group", NULL, "compat files", + no_more = __nss_database_lookup ("group", NULL, DEFAULT_CONFIG, &__nss_group_database); __nss_initgroups_database = __nss_group_database; diff --git a/manual/nss.texi b/manual/nss.texi index ee70ad3..d534c26 100644 --- a/manual/nss.texi +++ b/manual/nss.texi @@ -318,13 +318,17 @@ The @code{passwd}, @code{group}, and @code{shadow} databases are traditionally handled in a special way. The appropriate files in the @file{/etc} directory are read but if an entry with a name starting with a @code{+} character is found NIS is used. This kind of lookup -remains possible by using the special lookup service @code{compat} -and the default value for the three databases above is -@code{compat [NOTFOUND=return] files}. - -For all other databases the default value is -@code{nis [NOTFOUND=return] files}. This solution gives the best -chance to be correct since NIS and file based lookups are used. +remains possible if @theglibc{} was configured with the +@code{--enable-obsolete-nsl} option and the special lookup service +@code{compat} is used. If @theglibc{} was configured with the +@code{--enable-obsolete-nsl} option the default value for the three +databases above is @code{compat [NOTFOUND=return] files}. If the +@code{--enable-obsolete-nsl} option was not used the default value +for the services is @code{files}. + +For all other databases the default value is @code{files} unless +@theglibc{} was configured with @code{--enable-obsolete-rpc} option, in +which case it the default value is @code{nis [NOTFOUND=return] files}. @cindex optimizing NSS A second point is that the user should try to optimize the lookup diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c index 4deb483..4114fbe 100644 --- a/nscd/initgrcache.c +++ b/nscd/initgrcache.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "dbg_log.h" #include "nscd.h" @@ -34,6 +35,11 @@ #include "../nss/nsswitch.h" +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif /* Type of the lookup function. */ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t, @@ -85,8 +91,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req, int no_more; if (group_database == NULL) - no_more = __nss_database_lookup ("group", NULL, - "compat [NOTFOUND=return] files", + no_more = __nss_database_lookup ("group", NULL, DEFAULT_CONFIG, &group_database); else no_more = 0; diff --git a/nss/grp-lookup.c b/nss/grp-lookup.c index 8cb00aa..7c019f8 100644 --- a/nss/grp-lookup.c +++ b/nss/grp-lookup.c @@ -16,7 +16,13 @@ License along with the GNU C Library; if not, see . */ +#include + #define DATABASE_NAME group -#define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif #include "XXX-lookup.c" diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 834bef6..3de085e 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -40,6 +40,19 @@ #include "nsswitch.h" #include "../nscd/nscd_proto.h" #include +#include + +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif + +#ifdef LINK_OBSOLETE_RPC +# define DEFAULT_DEFCONFIG "nis [NOTFOUND=return] files" +#else +# define DEFAULT_DEFCONFIG "files" +#endif /* Prototypes for the local functions. */ static name_database *nss_parse_file (const char *fname) internal_function; @@ -153,8 +166,7 @@ __nss_database_lookup (const char *database, const char *alternate_name, or null to use the most common default. */ if (*ni == NULL) { - *ni = nss_parse_service_list (defconfig - ?: "nis [NOTFOUND=return] files"); + *ni = nss_parse_service_list (defconfig ?: DEFAULT_DEFCONFIG); if (*ni != NULL) { /* Record the memory we've just allocated in defconfig_entries list, @@ -852,8 +864,8 @@ __nss_disable_nscd (void (*cb) (size_t, struct traced_file *)) is_nscd = true; /* Find all the relevant modules so that the init functions are called. */ - nss_load_all_libraries ("passwd", "compat [NOTFOUND=return] files"); - nss_load_all_libraries ("group", "compat [NOTFOUND=return] files"); + nss_load_all_libraries ("passwd", DEFAULT_CONFIG); + nss_load_all_libraries ("group", DEFAULT_CONFIG); nss_load_all_libraries ("hosts", "dns [!UNAVAIL=return] files"); nss_load_all_libraries ("services", NULL); diff --git a/nss/pwd-lookup.c b/nss/pwd-lookup.c index 00040d4..180ac7c 100644 --- a/nss/pwd-lookup.c +++ b/nss/pwd-lookup.c @@ -16,7 +16,13 @@ License along with the GNU C Library; if not, see . */ +#include + #define DATABASE_NAME passwd -#define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif #include "XXX-lookup.c" diff --git a/nss/spwd-lookup.c b/nss/spwd-lookup.c index 319a7bb..f12156d 100644 --- a/nss/spwd-lookup.c +++ b/nss/spwd-lookup.c @@ -16,8 +16,14 @@ License along with the GNU C Library; if not, see . */ +#include + #define DATABASE_NAME shadow #define ALTERNATE_NAME passwd -#define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#ifdef LINK_OBSOLETE_NSL +# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" +#else +# define DEFAULT_CONFIG "files" +#endif #include "XXX-lookup.c"