10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2264Sjacobs * Common Development and Distribution License (the "License"). 6*2264Sjacobs * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2264Sjacobs * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <stdio.h> 290Sstevel@tonic-gate #include <stdlib.h> 300Sstevel@tonic-gate #include <sys/types.h> 310Sstevel@tonic-gate #include <stdarg.h> 320Sstevel@tonic-gate #include <unistd.h> 330Sstevel@tonic-gate #include <limits.h> 340Sstevel@tonic-gate #include <string.h> 350Sstevel@tonic-gate #include <syslog.h> 360Sstevel@tonic-gate #include <errno.h> 370Sstevel@tonic-gate #include <locale.h> 380Sstevel@tonic-gate #ifndef SUNOS_4 390Sstevel@tonic-gate #include <libintl.h> 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate #include <pwd.h> 420Sstevel@tonic-gate 43*2264Sjacobs #include <ns.h> 44*2264Sjacobs #include <misc.h> 45*2264Sjacobs #include <list.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate extern char *optarg; 480Sstevel@tonic-gate extern int optind, opterr, optopt; 490Sstevel@tonic-gate extern char *getenv(const char *); 500Sstevel@tonic-gate 510Sstevel@tonic-gate static void _decode_ldapResult(int result, char *printerName); 520Sstevel@tonic-gate 530Sstevel@tonic-gate static void 540Sstevel@tonic-gate Usage(char *name) 550Sstevel@tonic-gate { 560Sstevel@tonic-gate (void) fprintf(stderr, 570Sstevel@tonic-gate gettext("Usage: %s [-n files | nisplus | ldap] [-x] " 580Sstevel@tonic-gate "[-h ldaphost] [-D binddn] [-w passwd] " 590Sstevel@tonic-gate "[-a key=value] [-d key] (printer)\n"), 600Sstevel@tonic-gate name); 610Sstevel@tonic-gate exit(1); 620Sstevel@tonic-gate } 630Sstevel@tonic-gate 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * main() calls the appropriate routine to parse the command line arguments 670Sstevel@tonic-gate * and then calls the local remove routine, followed by the remote remove 680Sstevel@tonic-gate * routine to remove jobs. 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate int 710Sstevel@tonic-gate main(int ac, char *av[]) 720Sstevel@tonic-gate { 730Sstevel@tonic-gate int result = 0; 740Sstevel@tonic-gate int delete_printer = 0; 750Sstevel@tonic-gate int c; 760Sstevel@tonic-gate char *program = NULL, 770Sstevel@tonic-gate *printer = NULL, 780Sstevel@tonic-gate *host = NULL, 790Sstevel@tonic-gate *binddn = NULL, 800Sstevel@tonic-gate *passwd = NULL, 810Sstevel@tonic-gate *ins = NULL, 820Sstevel@tonic-gate *ons = "files"; 830Sstevel@tonic-gate char **changes = NULL; 840Sstevel@tonic-gate ns_cred_t *cred = NULL; 850Sstevel@tonic-gate ns_printer_t *printer_obj = NULL; 860Sstevel@tonic-gate 870Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 880Sstevel@tonic-gate 890Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 900Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 910Sstevel@tonic-gate #endif 920Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 930Sstevel@tonic-gate 940Sstevel@tonic-gate if ((program = strrchr(av[0], '/')) == NULL) 950Sstevel@tonic-gate program = av[0]; 960Sstevel@tonic-gate else 970Sstevel@tonic-gate program++; 980Sstevel@tonic-gate 990Sstevel@tonic-gate openlog(program, LOG_PID, LOG_LPR); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate if (ac < 2) 1020Sstevel@tonic-gate Usage(program); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate while ((c = getopt(ac, av, "a:d:D:h:n:r:w:x")) != EOF) 1050Sstevel@tonic-gate switch (c) { 1060Sstevel@tonic-gate case 'd': 1070Sstevel@tonic-gate if (strchr(optarg, '=') != NULL) 1080Sstevel@tonic-gate Usage(program); 1090Sstevel@tonic-gate /* FALLTHRU */ 1100Sstevel@tonic-gate case 'a': 1110Sstevel@tonic-gate changes = (char **)list_append((void**)changes, 1120Sstevel@tonic-gate (void *)strdup(optarg)); 1130Sstevel@tonic-gate break; 1140Sstevel@tonic-gate case 'D': 1150Sstevel@tonic-gate binddn = optarg; 1160Sstevel@tonic-gate break; 1170Sstevel@tonic-gate case 'h': 1180Sstevel@tonic-gate host = optarg; 1190Sstevel@tonic-gate break; 1200Sstevel@tonic-gate case 'n': 1210Sstevel@tonic-gate ons = optarg; 1220Sstevel@tonic-gate break; 1230Sstevel@tonic-gate case 'r': 1240Sstevel@tonic-gate ins = optarg; 1250Sstevel@tonic-gate break; 1260Sstevel@tonic-gate case 'w': 1270Sstevel@tonic-gate passwd = optarg; 1280Sstevel@tonic-gate break; 1290Sstevel@tonic-gate case 'x': 1300Sstevel@tonic-gate delete_printer++; 1310Sstevel@tonic-gate break; 1320Sstevel@tonic-gate default: 1330Sstevel@tonic-gate Usage(program); 1340Sstevel@tonic-gate } 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate if (optind != ac-1) 1370Sstevel@tonic-gate Usage(program); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate /* 1400Sstevel@tonic-gate * Check required options have been given: [ -x | [ -a | -d ]] 1410Sstevel@tonic-gate */ 1420Sstevel@tonic-gate if ((changes == NULL) && (delete_printer == 0)) { 1430Sstevel@tonic-gate Usage(program); 1440Sstevel@tonic-gate } 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate printer = av[optind]; 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate if (strchr(printer, ':') != NULL) { 1490Sstevel@tonic-gate (void) fprintf(stderr, gettext( 1500Sstevel@tonic-gate "POSIX-Style names are not valid destinations (%s)\n"), 1510Sstevel@tonic-gate printer); 1520Sstevel@tonic-gate return (1); 1530Sstevel@tonic-gate } 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate ins = normalize_ns_name(ins); 1560Sstevel@tonic-gate ons = normalize_ns_name(ons); 1570Sstevel@tonic-gate if (ins == NULL) 1580Sstevel@tonic-gate ins = ons; 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate /* check / set the name service for writing */ 1610Sstevel@tonic-gate if (strcasecmp("user", ons) == 0) { 1620Sstevel@tonic-gate (void) setuid(getuid()); 1630Sstevel@tonic-gate ons = "user"; 1640Sstevel@tonic-gate } else if (strcasecmp("files", ons) == 0) { 1650Sstevel@tonic-gate struct passwd *pw = getpwnam("lp"); 1660Sstevel@tonic-gate uid_t uid, lpuid = 0; 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate if (pw != NULL) 1690Sstevel@tonic-gate lpuid = pw->pw_uid; 1700Sstevel@tonic-gate uid = getuid(); 1710Sstevel@tonic-gate if ((uid != 0) && (uid != lpuid)) { 1720Sstevel@tonic-gate int len; 1730Sstevel@tonic-gate gid_t list[NGROUPS_MAX]; 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate len = getgroups(sizeof (list), list); 1760Sstevel@tonic-gate if (len == -1) { 1770Sstevel@tonic-gate (void) fprintf(stderr, gettext( 1780Sstevel@tonic-gate "Call to getgroups failed with " 1790Sstevel@tonic-gate "errno %d\n"), errno); 1800Sstevel@tonic-gate return (1); 1810Sstevel@tonic-gate } 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate for (; len >= 0; len--) 1840Sstevel@tonic-gate if (list[len] == 14) 1850Sstevel@tonic-gate break; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate if (len == -1) { 1880Sstevel@tonic-gate (void) fprintf(stderr, gettext( 1890Sstevel@tonic-gate "Permission denied: not in group 14\n")); 1900Sstevel@tonic-gate return (1); 1910Sstevel@tonic-gate } 1920Sstevel@tonic-gate } 1930Sstevel@tonic-gate ons = "files"; 1940Sstevel@tonic-gate } else if (strcasecmp("nisplus", ons) == 0) { 1950Sstevel@tonic-gate ons = "nisplus"; 1960Sstevel@tonic-gate } else if (strcasecmp("ldap", ons) == 0) { 1970Sstevel@tonic-gate if ((cred = calloc(1, sizeof (*cred))) == NULL) { 1980Sstevel@tonic-gate (void) fprintf(stderr, 1990Sstevel@tonic-gate gettext("could not initialize credential\n")); 2000Sstevel@tonic-gate return (1); 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate if (binddn == NULL) { 2040Sstevel@tonic-gate (void) fprintf(stderr, 2050Sstevel@tonic-gate gettext("Distinguished Name is required.\n")); 2060Sstevel@tonic-gate return (1); 2070Sstevel@tonic-gate } 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate if (passwd == NULL) { 2100Sstevel@tonic-gate passwd = getpassphrase(gettext("Bind Password:")); 2110Sstevel@tonic-gate } 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate /* 2140Sstevel@tonic-gate * Setup LDAP bind credentials, so that it uses 2150Sstevel@tonic-gate * the default ldap port, and the NS domain for this 2160Sstevel@tonic-gate * ldapclient box. Note: passwdType is currently not 2170Sstevel@tonic-gate * used but once the ldap native function can select 2180Sstevel@tonic-gate * secure or insure password it will pass the user selected 2190Sstevel@tonic-gate * security type. 2200Sstevel@tonic-gate */ 2210Sstevel@tonic-gate cred->passwd = passwd; 2220Sstevel@tonic-gate cred->passwdType = NS_PW_INSECURE; /* use default */ 2230Sstevel@tonic-gate cred->binddn = binddn; 2240Sstevel@tonic-gate cred->host = host; 2250Sstevel@tonic-gate cred->port = 0; /* use default */ 2260Sstevel@tonic-gate cred->domainDN = NULL; /* use default */ 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate ons = "ldap"; 2290Sstevel@tonic-gate (void) setuid(getuid()); 2300Sstevel@tonic-gate } else { 2310Sstevel@tonic-gate (void) fprintf(stderr, 2320Sstevel@tonic-gate gettext("%s is not a supported name service.\n"), 2330Sstevel@tonic-gate ons); 2340Sstevel@tonic-gate return (1); 2350Sstevel@tonic-gate } 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate if (strcasecmp(NS_SVC_LDAP, ons) != 0) { 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /* Naming Service is not LDAP */ 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate /* get the printer object */ 2420Sstevel@tonic-gate if ((printer_obj = ns_printer_get_name(printer, ins)) == NULL) { 2430Sstevel@tonic-gate if (delete_printer != 0) { 2440Sstevel@tonic-gate (void) fprintf(stderr, gettext("%s: unknown printer\n"), 2450Sstevel@tonic-gate printer); 2460Sstevel@tonic-gate return (1); 2470Sstevel@tonic-gate } 2480Sstevel@tonic-gate if ((printer_obj = calloc(1, sizeof (*printer_obj))) == NULL) { 2490Sstevel@tonic-gate (void) fprintf(stderr, gettext( 2500Sstevel@tonic-gate "could not initialize printer object\n")); 2510Sstevel@tonic-gate return (1); 2520Sstevel@tonic-gate } 2530Sstevel@tonic-gate printer_obj->name = strdup(printer); 2540Sstevel@tonic-gate } 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate printer_obj->source = ons; 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate if (cred != NULL) { 2590Sstevel@tonic-gate printer_obj->cred = cred; 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate /* make the changes to it */ 2630Sstevel@tonic-gate while (changes != NULL && *changes != NULL) { 2640Sstevel@tonic-gate int has_equals = (strchr(*changes, '=') != NULL); 2650Sstevel@tonic-gate char *p, *key = NULL, *value = NULL; 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate key = *(changes++); 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate for (p = key; ((p != NULL) && (*p != NULL)); p++) 2700Sstevel@tonic-gate if (*p == '=') { 2710Sstevel@tonic-gate *p = NULL; 2720Sstevel@tonic-gate value = ++p; 2730Sstevel@tonic-gate break; 2740Sstevel@tonic-gate } else if (*p == '\\') 2750Sstevel@tonic-gate p++; 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate if ((value != NULL) && (*value == NULL)) 2780Sstevel@tonic-gate value = NULL; 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate if ((key != NULL) && (key[0] != NULL)) { 2810Sstevel@tonic-gate if ((value == NULL) && 2820Sstevel@tonic-gate (ns_get_value(key, printer_obj) == NULL) && 2830Sstevel@tonic-gate (has_equals == 0)) { 2840Sstevel@tonic-gate fprintf(stderr, 2850Sstevel@tonic-gate gettext("%s: unknown attribute\n"), 2860Sstevel@tonic-gate key); 2870Sstevel@tonic-gate result = 1; 2880Sstevel@tonic-gate } else 2890Sstevel@tonic-gate (void) ns_set_value_from_string(key, value, 2900Sstevel@tonic-gate printer_obj); 2910Sstevel@tonic-gate } 2920Sstevel@tonic-gate } 2930Sstevel@tonic-gate if (delete_printer != 0) 2940Sstevel@tonic-gate printer_obj->attributes = NULL; 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate /* write it back */ 2970Sstevel@tonic-gate if (ns_printer_put(printer_obj) != 0) { 2980Sstevel@tonic-gate (void) fprintf(stderr, 2990Sstevel@tonic-gate gettext("Failed to write into %s database\n"), 3000Sstevel@tonic-gate ons); 3010Sstevel@tonic-gate result = 1; 3020Sstevel@tonic-gate } 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate 3050Sstevel@tonic-gate else { 3060Sstevel@tonic-gate /* 3070Sstevel@tonic-gate * Naming Service is LDAP 3080Sstevel@tonic-gate * 3090Sstevel@tonic-gate * Action the request by calling ns ldap functions to 3100Sstevel@tonic-gate * add, modify or delete the printer object. 3110Sstevel@tonic-gate */ 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate if ((printer_obj = calloc(1, sizeof (*printer_obj))) == NULL) { 3140Sstevel@tonic-gate (void) fprintf(stderr, gettext( 3150Sstevel@tonic-gate "could not initialize printer object\n")); 3160Sstevel@tonic-gate return (1); 3170Sstevel@tonic-gate } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate if ((cred != NULL) && (printer_obj != NULL)) { 3200Sstevel@tonic-gate printer_obj->name = strdup(printer); 3210Sstevel@tonic-gate printer_obj->cred = cred; 3220Sstevel@tonic-gate printer_obj->cred->domainDN = NULL; /* use default */ 3230Sstevel@tonic-gate printer_obj->source = ons; 3240Sstevel@tonic-gate printer_obj->nsdata = malloc(sizeof (NS_LDAPDATA)); 3250Sstevel@tonic-gate 3260Sstevel@tonic-gate if (printer_obj->nsdata != NULL) { 3270Sstevel@tonic-gate /* 3280Sstevel@tonic-gate * Update the LDAP directory for this printer 3290Sstevel@tonic-gate */ 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate if (delete_printer != 0) { 3320Sstevel@tonic-gate /* Delete the printer object */ 3330Sstevel@tonic-gate ((NS_LDAPDATA *) 3340Sstevel@tonic-gate (printer_obj->nsdata))->attrList = NULL; 3350Sstevel@tonic-gate } else { 3360Sstevel@tonic-gate /* Add or modify the printer object */ 3370Sstevel@tonic-gate ((NS_LDAPDATA *) 3380Sstevel@tonic-gate (printer_obj->nsdata))->attrList = 3390Sstevel@tonic-gate changes; 3400Sstevel@tonic-gate } 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate result = ns_printer_put(printer_obj); 3430Sstevel@tonic-gate if (result != 0) { 3440Sstevel@tonic-gate /* display LDAP specific message */ 3450Sstevel@tonic-gate _decode_ldapResult(result, printer); 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate (void) fprintf(stderr, gettext( 3480Sstevel@tonic-gate "Failed to update %s database\n"), ons); 3490Sstevel@tonic-gate result = 1; 3500Sstevel@tonic-gate } 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate free(printer_obj->nsdata); 3530Sstevel@tonic-gate } 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate else { 3560Sstevel@tonic-gate _decode_ldapResult(NSL_ERR_MEMORY, NULL); 3570Sstevel@tonic-gate result = 1; 3580Sstevel@tonic-gate } 3590Sstevel@tonic-gate } 3600Sstevel@tonic-gate 3610Sstevel@tonic-gate else { 3620Sstevel@tonic-gate result = 1; 3630Sstevel@tonic-gate (void) fprintf(stderr, 3640Sstevel@tonic-gate gettext("Error - no LDAP credentials\n")); 3650Sstevel@tonic-gate } 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate if (printer_obj != NULL) { 3680Sstevel@tonic-gate if (printer_obj->name != NULL) { 3690Sstevel@tonic-gate free(printer_obj->name); 3700Sstevel@tonic-gate } 3710Sstevel@tonic-gate free(printer_obj); 3720Sstevel@tonic-gate } 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate } 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate return (result); 3770Sstevel@tonic-gate } /* main */ 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate /* 3830Sstevel@tonic-gate * ***************************************************************************** 3840Sstevel@tonic-gate * 3850Sstevel@tonic-gate * Function: _decode_ldapResult() 3860Sstevel@tonic-gate * 3870Sstevel@tonic-gate * Description: Decode the ldap_put_printer specific error codes and display 3880Sstevel@tonic-gate * the appropriate error message. 3890Sstevel@tonic-gate * 3900Sstevel@tonic-gate * Parameters: 3910Sstevel@tonic-gate * Input: int result - contains the NSL_RESULT codes 3920Sstevel@tonic-gate * char *printerName - name of printer 3930Sstevel@tonic-gate * Output: None 3940Sstevel@tonic-gate * 3950Sstevel@tonic-gate * Returns: void 3960Sstevel@tonic-gate * 3970Sstevel@tonic-gate * ***************************************************************************** 3980Sstevel@tonic-gate */ 3990Sstevel@tonic-gate 4000Sstevel@tonic-gate static void 4010Sstevel@tonic-gate _decode_ldapResult(int result, char *printerName) 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate { 4040Sstevel@tonic-gate NSL_RESULT lresult = (NSL_RESULT)result; 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate /* ------------- */ 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate switch (lresult) 4090Sstevel@tonic-gate { 4100Sstevel@tonic-gate case NSL_OK: 4110Sstevel@tonic-gate { 4120Sstevel@tonic-gate break; 4130Sstevel@tonic-gate } 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate case NSL_ERR_INTERNAL: 4160Sstevel@tonic-gate { 4170Sstevel@tonic-gate (void) fprintf(stderr, 4180Sstevel@tonic-gate gettext("Unexpected software error\n")); 4190Sstevel@tonic-gate break; 4200Sstevel@tonic-gate } 4210Sstevel@tonic-gate 4220Sstevel@tonic-gate case NSL_ERR_ADD_FAILED: 4230Sstevel@tonic-gate { 4240Sstevel@tonic-gate (void) fprintf(stderr, "%s %s\n", 4250Sstevel@tonic-gate gettext("Failed to add printer:"), printerName); 4260Sstevel@tonic-gate break; 4270Sstevel@tonic-gate } 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate case NSL_ERR_MOD_FAILED: 4300Sstevel@tonic-gate { 4310Sstevel@tonic-gate (void) fprintf(stderr, "%s %s\n", 4320Sstevel@tonic-gate gettext("Failed to modify printer:"), 4330Sstevel@tonic-gate printerName); 4340Sstevel@tonic-gate break; 4350Sstevel@tonic-gate } 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate case NSL_ERR_DEL_FAILED: 4380Sstevel@tonic-gate { 4390Sstevel@tonic-gate (void) fprintf(stderr, "%s %s\n", 4400Sstevel@tonic-gate gettext("Failed to delete printer:"), 4410Sstevel@tonic-gate printerName); 4420Sstevel@tonic-gate break; 4430Sstevel@tonic-gate } 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate case NSL_ERR_UNKNOWN_PRINTER: 4470Sstevel@tonic-gate { 4480Sstevel@tonic-gate (void) fprintf(stderr, "%s %s\n", 4490Sstevel@tonic-gate gettext("Unknown printer:"), printerName); 4500Sstevel@tonic-gate break; 4510Sstevel@tonic-gate } 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate case NSL_ERR_CREDENTIALS: 4540Sstevel@tonic-gate { 4550Sstevel@tonic-gate (void) fprintf(stderr, "%s\n", 4560Sstevel@tonic-gate gettext("Missing LDAP credential information for printer:")); 4570Sstevel@tonic-gate break; 4580Sstevel@tonic-gate } 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate case NSL_ERR_CONNECT: 4610Sstevel@tonic-gate { 4620Sstevel@tonic-gate (void) fprintf(stderr, "%s\n", 4630Sstevel@tonic-gate gettext("Failed to connect to LDAP server")); 4640Sstevel@tonic-gate break; 4650Sstevel@tonic-gate } 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate case NSL_ERR_BIND: 4680Sstevel@tonic-gate { 4690Sstevel@tonic-gate (void) fprintf(stderr, gettext("LDAP bind failed\n")); 4700Sstevel@tonic-gate break; 4710Sstevel@tonic-gate } 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate case NSL_ERR_RENAME: 4740Sstevel@tonic-gate { 4750Sstevel@tonic-gate (void) fprintf(stderr, "%s %s\n", 4760Sstevel@tonic-gate gettext("Object rename not allowed for printer:"), 4770Sstevel@tonic-gate printerName); 4780Sstevel@tonic-gate break; 4790Sstevel@tonic-gate } 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate case NSL_ERR_KVP: 4820Sstevel@tonic-gate { 4830Sstevel@tonic-gate (void) fprintf(stderr, "%s", 4840Sstevel@tonic-gate gettext("Setting sun-printer-kvp attribute is " 4850Sstevel@tonic-gate "not supported through this command.\n")); 4860Sstevel@tonic-gate break; 4870Sstevel@tonic-gate } 4880Sstevel@tonic-gate 4890Sstevel@tonic-gate case NSL_ERR_BSDADDR: 4900Sstevel@tonic-gate { 4910Sstevel@tonic-gate (void) fprintf(stderr, "%s", 4920Sstevel@tonic-gate gettext("Setting sun-printer-bsdaddr attribute is " 4930Sstevel@tonic-gate "not supported through this command.\n" 4940Sstevel@tonic-gate "Use the bsaddr attribute instead.\n")); 4950Sstevel@tonic-gate break; 4960Sstevel@tonic-gate } 4970Sstevel@tonic-gate 4980Sstevel@tonic-gate case NSL_ERR_PNAME: 4990Sstevel@tonic-gate { 5000Sstevel@tonic-gate (void) fprintf(stderr, "%s", 5010Sstevel@tonic-gate gettext("Setting printer-name attribute is " 5020Sstevel@tonic-gate "not supported through this command.\n")); 5030Sstevel@tonic-gate break; 5040Sstevel@tonic-gate } 5050Sstevel@tonic-gate 5060Sstevel@tonic-gate case NSL_ERR_MEMORY: 5070Sstevel@tonic-gate { 5080Sstevel@tonic-gate (void) fprintf(stderr, 5090Sstevel@tonic-gate gettext("Memory allocation error\n")); 5100Sstevel@tonic-gate break; 5110Sstevel@tonic-gate } 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate case NSL_ERR_MULTIOP: 5140Sstevel@tonic-gate { 5150Sstevel@tonic-gate (void) fprintf(stderr, 5160Sstevel@tonic-gate gettext("Delete and add operation on the " 5170Sstevel@tonic-gate "same key attribute is not allowed\n")); 5180Sstevel@tonic-gate break; 5190Sstevel@tonic-gate } 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate case NSL_ERR_NOTALLOWED: 5220Sstevel@tonic-gate { 5230Sstevel@tonic-gate (void) fprintf(stderr, 5240Sstevel@tonic-gate gettext("KVP attribute is not allowed\n")); 5250Sstevel@tonic-gate break; 5260Sstevel@tonic-gate } 5270Sstevel@tonic-gate 5280Sstevel@tonic-gate default: 5290Sstevel@tonic-gate { 5300Sstevel@tonic-gate (void) fprintf(stderr, 5310Sstevel@tonic-gate gettext("Error code = %d\n"), result); 5320Sstevel@tonic-gate break; 5330Sstevel@tonic-gate } 5340Sstevel@tonic-gate } 5350Sstevel@tonic-gate 5360Sstevel@tonic-gate } /* _decode_ldapResult */ 537