nss.c revision e059026e2da8f12ef0ebea9d686d67f32660cfc0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* Id: nss.c 180 2006-07-20 17:33:02Z njacobs $ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <syslog.h>
#include <papi.h>
#include <uri.h>
#include <papi_impl.h>
#ifdef NSS_EMULATION
#include <nss-emulation.h>
#include <nss_dbdefs.h>
#endif
#include <config-site.h>
#include <sys/systeminfo.h>
#endif
static char *
{
char buf[512];
}
return (result);
}
/*
* This is an awful HACK to force the dynamic PAPI library to use the
* lpsched support when the destination apears to be a local lpsched
* queue on Solaris.
*/
static void
{
/* setting this in the calling env can be useful for debugging */
return;
"printer-uri-supported", &printer);
/* if there is no printer-uri-supported, there is nothing to do */
return;
}
return;
}
/* already an lpsched URI ? */
return;
}
printer = "";
} else {
else
printer++;
}
return;
}
/* is this the "local" host */
return;
}
"printer-uri-supported", buf);
}
#endif
static void
{
/* do we have a printer-uri-supported */
return;
/* do we have a printer-uri (in URI form) to rename */
/* rename it in place and return */
return;
}
/* do we have a printers.conf(4) "bsdaddr" to convert */
"printer-uri-supported", uri);
return;
}
}
/* do we have a printers.conf(4) "rm" (and "rp") to convert */
/* default to "printer-name", but use "rp" if we have it */
return;
}
}
/* if were are here, we don't have a printer-uri-supported */
}
static void
{
return;
/* do we have a printer-uri */
return;
/*
* this is sufficient to fool libgnomeprintpapi, but not promote it's
* use in the future.
*/
"broken printer-uri semantic");
}
#endif /* NEED_BROKEN_PRINTER_URI_SEMANTIC */
static void
{
return;
"member-names", value);
}
}
static papi_attribute_t **
_cvt_nss_entry_to_printer(char *entry)
{
*cp,
return (NULL);
switch (*cp) {
case ':': /* end of kvp */
if (in_namelist != 0) {
in_namelist = 0;
}
buf_pos = 0;
break;
case '=': /* kvp seperator */
buf_pos = 0;
} else
break;
case '|': /* namelist seperator */
if (in_namelist != 0) {
buf_pos = 0;
} else /* add it to the buffer */
break;
case '\\': /* escape char */
break;
default:
}
}
}
/* resolve any "use" references in the configuration DB */
}
return (list);
}
#if defined(NSS_SOLARIS) && !defined(NSS_EMULATION)
#ifndef NSS_DBNAM__PRINTERS /* not in nss_dbdefs.h because it's private */
#define NSS_DBNAM__PRINTERS "_printers"
#endif
static DEFINE_NSS_DB_ROOT(db_root);
static DEFINE_NSS_GETENT(context);
static char *private_ns = NULL;
static void
nss_db_params_t *p;
{
if (private_ns != NULL) {
/*
* because we need to support a legacy interface that allows
* us to select a specific name service, we need to dummy up
* the parameters to use a private nsswitch database and set
* the * default_config entry to the name service we are
* looking into.
*/
p->default_config = private_ns;
} else {
/* regular behaviour */
}
}
/*
* Return values: 0 = success, 1 = parse error, 2 = erange ...
* The structure pointer passed in is a structure in the caller's space
* wherein the field pointers would be set to areas in the buffer if
* need be. instring and buffer should be separate areas.
*/
/* ARGSUSED */
static int
{
return (NSS_STR_PARSE_ERANGE);
/* skip entries that begin with '#' */
if (instr[0] == '#')
return (NSS_STR_PARSE_PARSE);
/*
* We copy the input string into the output buffer
*/
return (NSS_STR_PARSE_SUCCESS);
}
#endif /* NSS_SOLARIS */
int
{
#ifdef NSS_EMULATION
private_ns = ns;
private_ns = NULL;
#endif
return (0);
}
int
endprinterentry(int i)
{
#ifdef NSS_EMULATION
private_ns = NULL;
#endif
return (0);
}
/* ARGSUSED2 */
getprinterentry(char *ns)
{
#if defined(NSS_EMULATION) || defined(NSS_SOLARIS)
char buf[10240];
#ifdef NSS_EMULATION
private_ns = ns;
(void) NSS_XbyY_FINI(&arg);
private_ns = NULL;
#endif
if (res != NSS_SUCCESS)
buf[0] = '\0';
#endif
#endif /* NEED_BROKEN_PRINTER_URI_SEMANTIC */
#endif
#ifdef DEBUG
char buf[4096];
}
#endif /* DEBUG */
return (result);
}
{
"printer-name", name);
"printer-uri-supported", name);
"printer-name", name);
"printer-uri-supported", uri);
}
} else { /* anything else */
#if defined(NSS_EMULATION) || defined(NSS_SOLARIS)
char buf[10240];
#ifdef NSS_EMULATION
private_ns = ns;
(void) NSS_XbyY_FINI(&arg);
private_ns = NULL;
if (res != NSS_SUCCESS)
buf[0] = '\0';
#endif
#endif
}
#endif
#ifdef DEBUG
char buf[4096];
}
#endif /* DEBUG */
return (result);
}