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) 1989, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2N/A/* All Rights Reserved */ 2N/A * the data structures like nss_XbyY_args_t and the interaction 2N/A * with the packed buffers etc. versus the mechanics of the 2N/A * actual policy component operations such as nss_search sequencing. 2N/A * ALIGN? is there an official definition of this? 2N/A * We use sizeof(long) to cover what we want 2N/A * for both the 32-bit world and 64-bit world. 2N/A#
define ALIGN(x) ((((
long)(x)) +
sizeof (
long) -
1) & ~(
sizeof (
long) -
1))
2N/A /* Use one malloc for dbargs, result struct and buffer */ 2N/A/* === Comment: used by fget{gr,pw,sp}ent */ 2N/A/* ==== Should do ye olde syslog()ing of suspiciously long lines */ 2N/A /* Allocate initial input buffer */ 2N/A /* Loop reading input until newline or end-of-file */ 2N/A /* Break on newline or end-of-file */ 2N/A /* Allocate larger buffer to continue input */ 2N/A /* Check for end-of-file */ 2N/A * The input line parser uses the length of valid characters 2N/A * to copy the buffer, appending a null terminator to the copy. 2N/A * Use this to remove any trailing newlines. 2N/A /* Call the input line parser */ 2N/A /* Release the input buffer */ 2N/A * parse the aliases string into the buffer and if successful return 2N/A * a char ** pointer to the beginning of the aliases. 2N/A * CAUTION: (instr, instr+lenstr) and (buffer, buffer+buflen) are 2N/A * non-intersecting memory areas. Since this is an internal interface, 2N/A * we should be able to live with that. 2N/A /* "instr" is the beginning of the aliases string */ 2N/A /* "buffer" has the return val for success */ 2N/A /* "buflen" is the length of the buffer available for aliases */ 2N/A * Build the alias-list in the start of the buffer, and copy 2N/A * the strings to the end of the buffer. 2N/A /* Has to be room for the pointer to */ 2N/A /* the alias we're about to add, */ 2N/A /* as well as the final NULL ptr. */ 2N/A * pack well known getXbyY keys to packed buffer prior to the door_call 2N/A * to nscd. Some consideration is given to ordering the tests based on 2N/A * usage. Note: buf is nssuint_t aligned. 2N/A const char *
name;
/* NSS_DBNAM_* */ 2N/A const char *
strfn;
/* str2X function name */ 2N/A const char *
cstrfn;
/* cstr2X function name */ 2N/A const char *
tostr;
/* key2str cvt str */ 2N/A * The getXbyY_to_dbop structure is hashed on first call in order to 2N/A * reduce the search time for the well known getXbyY operations. 2N/A * A binary search was not fast enough. There were on average 2N/A * 3-4 tests (strcmps) per getXbyY call. 2N/A * DBOP_PRIME_HASH must be a prime number (reasonably small) but that 2N/A * is sufficient to uniquely map the entries in the following table 2N/A * without collision. 2N/A * The DBOP_PRIME_HASH was selected as the smallest hash value 2N/A * for this table without collisions. Changing this table WILL 2N/A * necessitate re-testing for possible collisions. 2N/A * If the size of getXbyY_to_dbop[] is changed then hash function must be 2N/A * corrected to be without collisions in nss_dbop_search(). 2N/A /* NSS_MK_GETXYDBOP(ALIASES, ?, ?), */ 2N/A /* NSS_MK_GETXYDBOP(AUTOMOUNT, ?, ?), */ 2N/A /* Uses a table size is known to have no collisions */ 2N/A /* hash table collision-see above */ 2N/A * Private key to string packing function for getXbyY routines 2N/A * This routine performs a printf like parse over the argument 2N/A * key, given a string of items to pack and assembles the key in 2N/A * the packed structure. This routine is called (currently) by 2N/A * nss_default_key2str, but will be used by other external 2N/A * APIs in the future. 2N/A * buffer - Start of the key buffer location [in packed buffer] 2N/A * length - Length of key buffer component 2N/A * Key offsets are relative to start of key buffer location. 2N/A /* for search flag */ 2N/A /* for sizeof (_priv_execattr) static buffer */ 2N/A /* Plus lots of slop just in case... */ 2N/A /* head_exec, prev_exec - are client side only... */ 2N/A * Double argv space. Reason: 2N/A * Second 1/2 for client side pointer arrays 2N/A for (; --i >= 0; ) {
2N/A for (; --i >= 0; ) {
2N/A for (; --i >= 0; ) {
2N/A for (; --i >= 0; ) {
2N/A * If this is not one of the well known getXbyYs 2N/A * (IE _printers special processing etc.) use a 2N/A * local (non-nscd) getXbyY lookup. 2N/A /* sidestep odd cases */ 2N/A /* tell nss_unpack() operation is successful */ 2N/A /* process normal cases */ 2N/A * Private string to key unpacking function for getXbyY routines 2N/A * string, to uppack and re-assemble the key in the args structure. 2N/A * buffer - Start of the key buffer location [in packed buffer] 2N/A * length - Length of key buffer component 2N/A * Key offsets are relative to start of key buffer location. 2N/A * Assumes arguments are all valid 2N/A /* keysize is length of the key area */ 2N/A /* use slop space as priv_execattr structure */ 2N/A /* skip over slop ... */ 2N/A /* insert initial group into data area */ 2N/A * Start of argv pointer storage 2N/A * str2packent: Standard format interposed str2X function for normal APIs 2N/A * Return values: 0 = success, 1 = parse error, 2 = erange ... 2N/A * The structure pointer is ignored since this is a nscd side packed request. 2N/A * The client side routine does all the real parsing; we just check limits and 2N/A * store the entry in the buffer we were passed by the caller. 2N/A void *
ent,
/* really (char *) */ 2N/A * Initialize db_root, initf, dbop and arg from a packed buffer 2N/A /* db_root is initialized by nscd's based on door info */ 2N/A /* do nothing here */ 2N/A /* init key information - (and get dbname dbop etc...) */ 2N/A /* possible audituser init */ 2N/A /* sidestep odd arg cases */ 2N/A /* get initf and str2ent functions */ 2N/A /* get initf and str2ent functions */ 2N/A /* init normal arg cases */ 2N/A * Initialize db_root, initf, dbop, contextp and arg from a packed buffer