17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*07925104Sgww * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * ldapaddrbac.c 277c478bd9Sstevel@tonic-gate * 287c478bd9Sstevel@tonic-gate * Routines to add RBAC /etc files into LDAP. 297c478bd9Sstevel@tonic-gate * Can also be used to dump entries from a ldap container in /etc format. 307c478bd9Sstevel@tonic-gate */ 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <stdio.h> 337c478bd9Sstevel@tonic-gate #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #include <libintl.h> 357c478bd9Sstevel@tonic-gate #include <strings.h> 367c478bd9Sstevel@tonic-gate #include <sys/param.h> 377c478bd9Sstevel@tonic-gate #include <ctype.h> 387c478bd9Sstevel@tonic-gate #include <sys/types.h> 397c478bd9Sstevel@tonic-gate #include <sys/socket.h> 407c478bd9Sstevel@tonic-gate #include <netinet/in.h> 417c478bd9Sstevel@tonic-gate #include <arpa/inet.h> 427c478bd9Sstevel@tonic-gate #include <locale.h> 437c478bd9Sstevel@tonic-gate #include <syslog.h> 447c478bd9Sstevel@tonic-gate #include "ldapaddent.h" 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #undef opaque 477c478bd9Sstevel@tonic-gate #undef GROUP 487c478bd9Sstevel@tonic-gate #include <bsm/libbsm.h> 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate extern char *_strtok_escape(char *, char *, char **); /* from libnsl */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #include <user_attr.h> 537c478bd9Sstevel@tonic-gate #include <prof_attr.h> 547c478bd9Sstevel@tonic-gate #include <exec_attr.h> 557c478bd9Sstevel@tonic-gate #include <auth_attr.h> 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 58*07925104Sgww * The parsing routines for RBAC databases 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * genent_attr: 637c478bd9Sstevel@tonic-gate * Generic function for generating entries for all of the *_attr databases. 647c478bd9Sstevel@tonic-gate */ 6545916cd2Sjpk int 667c478bd9Sstevel@tonic-gate genent_attr( 677c478bd9Sstevel@tonic-gate char *line, /* entry to parse */ 687c478bd9Sstevel@tonic-gate int ncol, /* number of columns in the database */ 697c478bd9Sstevel@tonic-gate entry_col **ecolret) /* return entry array */ 707c478bd9Sstevel@tonic-gate { 717c478bd9Sstevel@tonic-gate int i; 727c478bd9Sstevel@tonic-gate char (*buf)[BUFSIZ + 1]; 737c478bd9Sstevel@tonic-gate char *s; 747c478bd9Sstevel@tonic-gate char *sep = KV_TOKEN_DELIMIT; 757c478bd9Sstevel@tonic-gate char *lasts; 767c478bd9Sstevel@tonic-gate entry_col *ecol; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * check input length 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate if (strlen(line) >= sizeof (*buf)) { 827c478bd9Sstevel@tonic-gate (void) strcpy(parse_err_msg, "line too long"); 837c478bd9Sstevel@tonic-gate return (GENENT_PARSEERR); 847c478bd9Sstevel@tonic-gate } 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * setup and clear column data 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate if ((ecol = (entry_col *)malloc(ncol * sizeof (entry_col) + 907c478bd9Sstevel@tonic-gate sizeof (*buf))) == NULL) 917c478bd9Sstevel@tonic-gate return (GENENT_ERR); 927c478bd9Sstevel@tonic-gate (void) memset((char *)ecol, 0, ncol * sizeof (ecol)); 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* don't scribble over input */ 957c478bd9Sstevel@tonic-gate buf = (char (*)[sizeof (*buf)]) (ecol + ncol); 967c478bd9Sstevel@tonic-gate (void) strncpy((char *)buf, line, sizeof (*buf)); 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* Split up columns */ 997c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++, buf = NULL) { 1007c478bd9Sstevel@tonic-gate s = _strtok_escape((char *)buf, sep, &lasts); 1017c478bd9Sstevel@tonic-gate if (s == NULL) { 1027c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_val = ""; 1037c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_len = 0; 1047c478bd9Sstevel@tonic-gate } else { 1057c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_val = s; 1067c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_len = strlen(s)+1; 1077c478bd9Sstevel@tonic-gate } 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate *ecolret = ecol; 1117c478bd9Sstevel@tonic-gate return (GENENT_OK); 1127c478bd9Sstevel@tonic-gate } 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate int 1157c478bd9Sstevel@tonic-gate genent_user_attr(char *line, int (*cback)()) 1167c478bd9Sstevel@tonic-gate { 1177c478bd9Sstevel@tonic-gate entry_col *ecol; 1187c478bd9Sstevel@tonic-gate userstr_t data; 1197c478bd9Sstevel@tonic-gate int res, retval; 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * parse entry into columns 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate res = genent_attr(line, USERATTR_DB_NCOL, &ecol); 1257c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 1267c478bd9Sstevel@tonic-gate return (res); 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 1297c478bd9Sstevel@tonic-gate data.qualifier = ecol[1].ec_value.ec_value_val; 1307c478bd9Sstevel@tonic-gate data.res1 = NULL; 1317c478bd9Sstevel@tonic-gate data.res2 = NULL; 1327c478bd9Sstevel@tonic-gate data.attr = ecol[4].ec_value.ec_value_val; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 1357c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 1367c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 1); 13912fbe00aSjs198686 if (retval != NS_LDAP_SUCCESS) { 14012fbe00aSjs198686 if (retval == LDAP_NO_SUCH_OBJECT) 14112fbe00aSjs198686 (void) fprintf(stdout, 14212fbe00aSjs198686 gettext("Cannot add user_attr entry (%s), " 14312fbe00aSjs198686 "add passwd entry first\n"), data.name); 14412fbe00aSjs198686 if (continue_onerror == 0) res = GENENT_CBERR; 14512fbe00aSjs198686 } 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate free(ecol); 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate return (res); 1507c478bd9Sstevel@tonic-gate } 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate void 1537c478bd9Sstevel@tonic-gate dump_user_attr(ns_ldap_result_t *res) 1547c478bd9Sstevel@tonic-gate { 1557c478bd9Sstevel@tonic-gate char **value = NULL; 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "uid"); 1587c478bd9Sstevel@tonic-gate if (value && value[0]) 1597c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 1607c478bd9Sstevel@tonic-gate else 1617c478bd9Sstevel@tonic-gate return; 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "::::"); 1647c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 1657c478bd9Sstevel@tonic-gate if (value && value[0]) 1667c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 1677c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate int 1717c478bd9Sstevel@tonic-gate genent_prof_attr(char *line, int (*cback)()) 1727c478bd9Sstevel@tonic-gate { 1737c478bd9Sstevel@tonic-gate entry_col *ecol; 1747c478bd9Sstevel@tonic-gate profstr_t data; 1757c478bd9Sstevel@tonic-gate int res, retval; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * parse entry into columns 1797c478bd9Sstevel@tonic-gate */ 1807c478bd9Sstevel@tonic-gate res = genent_attr(line, PROFATTR_DB_NCOL, &ecol); 1817c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 1827c478bd9Sstevel@tonic-gate return (res); 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 1857c478bd9Sstevel@tonic-gate data.res1 = NULL; 1867c478bd9Sstevel@tonic-gate data.res2 = NULL; 1877c478bd9Sstevel@tonic-gate data.desc = ecol[3].ec_value.ec_value_val; 1887c478bd9Sstevel@tonic-gate data.attr = ecol[4].ec_value.ec_value_val; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 1917c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 1927c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 1957c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 1967c478bd9Sstevel@tonic-gate if (continue_onerror) 1977c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 1987c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists," 1997c478bd9Sstevel@tonic-gate " skipping it.\n"), 2007c478bd9Sstevel@tonic-gate data.name); 2017c478bd9Sstevel@tonic-gate else { 2027c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2037c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2047c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists\n"), 2057c478bd9Sstevel@tonic-gate data.name); 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate } else if (retval) 2087c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate free(ecol); 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate return (res); 2137c478bd9Sstevel@tonic-gate } 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate void 2167c478bd9Sstevel@tonic-gate dump_prof_attr(ns_ldap_result_t *res) 2177c478bd9Sstevel@tonic-gate { 2187c478bd9Sstevel@tonic-gate char **value = NULL; 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "cn"); 2217c478bd9Sstevel@tonic-gate if (value && value[0]) 2227c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2237c478bd9Sstevel@tonic-gate else 2247c478bd9Sstevel@tonic-gate return; 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 2277c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrLongDesc"); 2287c478bd9Sstevel@tonic-gate if (value && value[0]) 2297c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2307c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 2317c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 2327c478bd9Sstevel@tonic-gate if (value && value[0]) 2337c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2347c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 2357c478bd9Sstevel@tonic-gate } 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate int 2387c478bd9Sstevel@tonic-gate genent_exec_attr(char *line, int (*cback)()) 2397c478bd9Sstevel@tonic-gate { 2407c478bd9Sstevel@tonic-gate entry_col *ecol; 2417c478bd9Sstevel@tonic-gate execstr_t data; 2427c478bd9Sstevel@tonic-gate int res, retval; 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate /* 2457c478bd9Sstevel@tonic-gate * parse entry into columns 2467c478bd9Sstevel@tonic-gate */ 2477c478bd9Sstevel@tonic-gate res = genent_attr(line, EXECATTR_DB_NCOL, &ecol); 2487c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 2497c478bd9Sstevel@tonic-gate return (res); 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 2527c478bd9Sstevel@tonic-gate data.policy = ecol[1].ec_value.ec_value_val; 2537c478bd9Sstevel@tonic-gate data.type = ecol[2].ec_value.ec_value_val; 2547c478bd9Sstevel@tonic-gate data.res1 = NULL; 2557c478bd9Sstevel@tonic-gate data.res2 = NULL; 2567c478bd9Sstevel@tonic-gate data.id = ecol[5].ec_value.ec_value_val; 2577c478bd9Sstevel@tonic-gate data.attr = ecol[6].ec_value.ec_value_val; 2587c478bd9Sstevel@tonic-gate data.next = NULL; 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 2617c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 2627c478bd9Sstevel@tonic-gate gettext("Adding entry : %s+%s+%s+%s\n"), 2637c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 2667c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 2677c478bd9Sstevel@tonic-gate if (continue_onerror) 2687c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2697c478bd9Sstevel@tonic-gate gettext("Entry: %s+%s+%s+%s - already Exists," 2707c478bd9Sstevel@tonic-gate " skipping it.\n"), 2717c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2727c478bd9Sstevel@tonic-gate else { 2737c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2747c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2757c478bd9Sstevel@tonic-gate gettext("Entry: %s+%s+%s+%s - already Exists\n"), 2767c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate } else if (retval) 2797c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate free(ecol); 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate return (res); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate void 2877c478bd9Sstevel@tonic-gate dump_exec_attr(ns_ldap_result_t *res) 2887c478bd9Sstevel@tonic-gate { 2897c478bd9Sstevel@tonic-gate char **profile; 2907c478bd9Sstevel@tonic-gate char **policy; 2917c478bd9Sstevel@tonic-gate char **type; 2927c478bd9Sstevel@tonic-gate char **id; 2937c478bd9Sstevel@tonic-gate char **value; 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate profile = __ns_ldap_getAttr(res->entry, "cn"); 2967c478bd9Sstevel@tonic-gate policy = __ns_ldap_getAttr(res->entry, "SolarisKernelSecurityPolicy"); 2977c478bd9Sstevel@tonic-gate type = __ns_ldap_getAttr(res->entry, "SolarisProfileType"); 2987c478bd9Sstevel@tonic-gate id = __ns_ldap_getAttr(res->entry, "SolarisProfileId"); 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate if (profile == NULL || profile[0] == NULL || 3017c478bd9Sstevel@tonic-gate policy == NULL || policy[0] == NULL || 3027c478bd9Sstevel@tonic-gate type == NULL || type[0] == NULL || 3037c478bd9Sstevel@tonic-gate id == NULL || id[0] == NULL) 3047c478bd9Sstevel@tonic-gate return; 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", profile[0]); 3077c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3087c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", policy[0]); 3097c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3107c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", type[0]); 3117c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 3127c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", id[0]); 3137c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3147c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 3157c478bd9Sstevel@tonic-gate if (value && value[0]) 3167c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3177c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 3187c478bd9Sstevel@tonic-gate } 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate int 3217c478bd9Sstevel@tonic-gate genent_auth_attr(char *line, int (*cback)()) 3227c478bd9Sstevel@tonic-gate { 3237c478bd9Sstevel@tonic-gate entry_col *ecol; 3247c478bd9Sstevel@tonic-gate authstr_t data; 3257c478bd9Sstevel@tonic-gate int res, retval; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate /* 3287c478bd9Sstevel@tonic-gate * parse entry into columns 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate res = genent_attr(line, AUTHATTR_DB_NCOL, &ecol); 3317c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 3327c478bd9Sstevel@tonic-gate return (res); 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 3357c478bd9Sstevel@tonic-gate data.res1 = NULL; 3367c478bd9Sstevel@tonic-gate data.res2 = NULL; 3377c478bd9Sstevel@tonic-gate data.short_desc = ecol[3].ec_value.ec_value_val; 3387c478bd9Sstevel@tonic-gate data.long_desc = ecol[4].ec_value.ec_value_val; 3397c478bd9Sstevel@tonic-gate data.attr = ecol[5].ec_value.ec_value_val; 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 3427c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 3437c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 3467c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 3477c478bd9Sstevel@tonic-gate if (continue_onerror) 3487c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 3497c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists," 3507c478bd9Sstevel@tonic-gate " skipping it.\n"), data.name); 3517c478bd9Sstevel@tonic-gate else { 3527c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 3537c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 3547c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists\n"), 3557c478bd9Sstevel@tonic-gate data.name); 3567c478bd9Sstevel@tonic-gate } 3577c478bd9Sstevel@tonic-gate } else if (retval) 3587c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate free(ecol); 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate return (res); 3637c478bd9Sstevel@tonic-gate } 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate void 3667c478bd9Sstevel@tonic-gate dump_auth_attr(ns_ldap_result_t *res) 3677c478bd9Sstevel@tonic-gate { 3687c478bd9Sstevel@tonic-gate char **value = NULL; 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "cn"); 3717c478bd9Sstevel@tonic-gate if (value && value[0]) 3727c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3737c478bd9Sstevel@tonic-gate else 3747c478bd9Sstevel@tonic-gate return; 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 3777c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrShortDesc"); 3787c478bd9Sstevel@tonic-gate if (value && value[0]) 3797c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3807c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3817c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrLongDesc"); 3827c478bd9Sstevel@tonic-gate if (value && value[0]) 3837c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3847c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3857c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 3867c478bd9Sstevel@tonic-gate if (value && value[0]) 3877c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3887c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 3897c478bd9Sstevel@tonic-gate } 390