2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * POSIX.1c Draft-6 version of the function getgrnam_r. 2N/A * It was implemented by Solaris 2.3. 2N/A * POSIX.1c Draft-6 version of the function getgrgid_r. 2N/A * It was implemented by Solaris 2.3. 2N/A * POSIX.1c standard version of the function getgrgid_r. 2N/A * User gets it via static getgrgid_r from the header file. 2N/A * POSIX.1c standard version of the function getgrnam_r. 2N/A * User gets it via static getgrnam_r from the header file. 2N/A /* In getXXent_r(), protect the unsuspecting caller from +/- entries */ 2N/A /* No key to fill in */ 2N/A /* ... but in fgetXXent_r, the caller deserves any +/- entry he gets */ 2N/A /* No key to fill in */ 2N/A * _getgroupsbymember(uname, gid_array, maxgids, numgids): 2N/A * Private interface for initgroups(). It returns the group ids of 2N/A * groups of which the specified user is a member. 2N/A * username Username of the putative member 2N/A * gid_array Space in which to return the gids. The first [numgids] 2N/A * elements are assumed to already contain valid gids. 2N/A * maxgids Maximum number of elements in gid_array. 2N/A * numgids Number of elements (normally 0 or 1) that already contain 2N/A * number of valid gids in gid_array (may be zero) 2N/A * -1 (and errno set appropriately) on errors (none currently defined) 2N/A * NSS2 Consistency enhancements: 2N/A * The "files normal" format between an application and nscd for the 2N/A * NSS_DBOP_GROUP_BYMEMBER nss_search operation is defined to be a 2N/A * processed array of numgids [up to maxgids] gid_t values. gid_t 2N/A * values in the array are unique. 2N/A * In backwards compatibility mode, use the old str2group & 2N/A * process_cstr interfaces. Ditto within nscd processing. 2N/A * The old value being provided here was 0, ie do the quick 2N/A * way. Given that this was never actually used under NIS 2N/A * we need to change the default to be 1 (TRUE) as we now 2N/A * need the admin to decided to use netid, setting 2N/A * a value of 0 for force_slow_way - don't you just love 2N/A * double negatives ;-) 2N/A * We need to do this to preserve the behaviour seen when the 2N/A * admin makes no changes. 2N/A while ((c = *q) !=
'\0' && c !=
sep)
2N/A * Return values: 0 = success, 1 = parse error, 2 = erange ... 2N/A * The structure pointer passed in is a structure in the caller's space 2N/A * wherein the field pointers would be set to areas in the buffer if 2N/A * need be. instring and buffer should be separate areas. 2N/A * We copy the input string into the output buffer and 2N/A * operate on it in place. 2N/A /* Overlapping buffer copies are OK */ 2N/A /* quick exit do not entry fill if not needed */ 2N/A * Parsers for passwd and group have always been pretty rigid; 2N/A * we wouldn't want to buck a Unix tradition 2N/A /* Empty group-name; not allowed */ 2N/A /* Always return at least an empty gr_mem list */ 2N/A /* Then the rest of the group entry is optional */ 2N/A if (p == 0 || *p ==
'\0') {
2N/A /* gid field should be nonempty */ 2N/A /* also check errno from strtoul */ 2N/A /* Parse error, even for a '+' entry (which should have */ 2N/A /* an empty gid field, since it's always overridden) */ 2N/A /* === Could check and complain if there are any extra colons */ 2N/A if (p == 0 || *p ==
'\0') {
2N/A /* Successfully parsed and stored */ 2N/A /* Out of space; error even for black_magic */ 2N/A * It's possible to do a much less inefficient version of this by 2N/A * selectively duplicating code from str2group(). For now, 2N/A * however, we'll take the easy way out and implement this on 2N/A * top of str2group(). 2N/A /* Filled the array; stop searching */