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 /* 2245916cd2Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * ldapaddrbac.c 307c478bd9Sstevel@tonic-gate * 317c478bd9Sstevel@tonic-gate * Routines to add RBAC /etc files into LDAP. 327c478bd9Sstevel@tonic-gate * Can also be used to dump entries from a ldap container in /etc format. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <stdio.h> 367c478bd9Sstevel@tonic-gate #include <stdlib.h> 377c478bd9Sstevel@tonic-gate #include <libintl.h> 387c478bd9Sstevel@tonic-gate #include <strings.h> 397c478bd9Sstevel@tonic-gate #include <sys/param.h> 407c478bd9Sstevel@tonic-gate #include <ctype.h> 417c478bd9Sstevel@tonic-gate #include <sys/types.h> 427c478bd9Sstevel@tonic-gate #include <sys/socket.h> 437c478bd9Sstevel@tonic-gate #include <netinet/in.h> 447c478bd9Sstevel@tonic-gate #include <arpa/inet.h> 457c478bd9Sstevel@tonic-gate #include <locale.h> 467c478bd9Sstevel@tonic-gate #include <syslog.h> 477c478bd9Sstevel@tonic-gate #include "ldapaddent.h" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #undef opaque 507c478bd9Sstevel@tonic-gate #undef GROUP 517c478bd9Sstevel@tonic-gate #include <bsm/libbsm.h> 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate extern char *_strtok_escape(char *, char *, char **); /* from libnsl */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #include <user_attr.h> 567c478bd9Sstevel@tonic-gate #include <prof_attr.h> 577c478bd9Sstevel@tonic-gate #include <exec_attr.h> 587c478bd9Sstevel@tonic-gate #include <auth_attr.h> 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * The parsing routines for RBAC and audit_user databases 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * genent_attr: 667c478bd9Sstevel@tonic-gate * Generic function for generating entries for all of the *_attr databases. 677c478bd9Sstevel@tonic-gate */ 6845916cd2Sjpk int 697c478bd9Sstevel@tonic-gate genent_attr( 707c478bd9Sstevel@tonic-gate char *line, /* entry to parse */ 717c478bd9Sstevel@tonic-gate int ncol, /* number of columns in the database */ 727c478bd9Sstevel@tonic-gate entry_col **ecolret) /* return entry array */ 737c478bd9Sstevel@tonic-gate { 747c478bd9Sstevel@tonic-gate int i; 757c478bd9Sstevel@tonic-gate char (*buf)[BUFSIZ + 1]; 767c478bd9Sstevel@tonic-gate char *s; 777c478bd9Sstevel@tonic-gate char *sep = KV_TOKEN_DELIMIT; 787c478bd9Sstevel@tonic-gate char *lasts; 797c478bd9Sstevel@tonic-gate entry_col *ecol; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * check input length 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate if (strlen(line) >= sizeof (*buf)) { 857c478bd9Sstevel@tonic-gate (void) strcpy(parse_err_msg, "line too long"); 867c478bd9Sstevel@tonic-gate return (GENENT_PARSEERR); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * setup and clear column data 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate if ((ecol = (entry_col *)malloc(ncol * sizeof (entry_col) + 937c478bd9Sstevel@tonic-gate sizeof (*buf))) == NULL) 947c478bd9Sstevel@tonic-gate return (GENENT_ERR); 957c478bd9Sstevel@tonic-gate (void) memset((char *)ecol, 0, ncol * sizeof (ecol)); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* don't scribble over input */ 987c478bd9Sstevel@tonic-gate buf = (char (*)[sizeof (*buf)]) (ecol + ncol); 997c478bd9Sstevel@tonic-gate (void) strncpy((char *)buf, line, sizeof (*buf)); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* Split up columns */ 1027c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++, buf = NULL) { 1037c478bd9Sstevel@tonic-gate s = _strtok_escape((char *)buf, sep, &lasts); 1047c478bd9Sstevel@tonic-gate if (s == NULL) { 1057c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_val = ""; 1067c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_len = 0; 1077c478bd9Sstevel@tonic-gate } else { 1087c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_val = s; 1097c478bd9Sstevel@tonic-gate ecol[i].ec_value.ec_value_len = strlen(s)+1; 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate *ecolret = ecol; 1147c478bd9Sstevel@tonic-gate return (GENENT_OK); 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate int 1187c478bd9Sstevel@tonic-gate genent_user_attr(char *line, int (*cback)()) 1197c478bd9Sstevel@tonic-gate { 1207c478bd9Sstevel@tonic-gate entry_col *ecol; 1217c478bd9Sstevel@tonic-gate userstr_t data; 1227c478bd9Sstevel@tonic-gate int res, retval; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * parse entry into columns 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate res = genent_attr(line, USERATTR_DB_NCOL, &ecol); 1287c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 1297c478bd9Sstevel@tonic-gate return (res); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 1327c478bd9Sstevel@tonic-gate data.qualifier = ecol[1].ec_value.ec_value_val; 1337c478bd9Sstevel@tonic-gate data.res1 = NULL; 1347c478bd9Sstevel@tonic-gate data.res2 = NULL; 1357c478bd9Sstevel@tonic-gate data.attr = ecol[4].ec_value.ec_value_val; 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 1387c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 1397c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 1); 142*12fbe00aSjs if (retval != NS_LDAP_SUCCESS) { 143*12fbe00aSjs if (retval == LDAP_NO_SUCH_OBJECT) 144*12fbe00aSjs (void) fprintf(stdout, 145*12fbe00aSjs gettext("Cannot add user_attr entry (%s), " 146*12fbe00aSjs "add passwd entry first\n"), data.name); 147*12fbe00aSjs if (continue_onerror == 0) res = GENENT_CBERR; 148*12fbe00aSjs } 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate free(ecol); 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate return (res); 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate void 1567c478bd9Sstevel@tonic-gate dump_user_attr(ns_ldap_result_t *res) 1577c478bd9Sstevel@tonic-gate { 1587c478bd9Sstevel@tonic-gate char **value = NULL; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "uid"); 1617c478bd9Sstevel@tonic-gate if (value && value[0]) 1627c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 1637c478bd9Sstevel@tonic-gate else 1647c478bd9Sstevel@tonic-gate return; 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "::::"); 1677c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 1687c478bd9Sstevel@tonic-gate if (value && value[0]) 1697c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 1707c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate int 1747c478bd9Sstevel@tonic-gate genent_prof_attr(char *line, int (*cback)()) 1757c478bd9Sstevel@tonic-gate { 1767c478bd9Sstevel@tonic-gate entry_col *ecol; 1777c478bd9Sstevel@tonic-gate profstr_t data; 1787c478bd9Sstevel@tonic-gate int res, retval; 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate /* 1817c478bd9Sstevel@tonic-gate * parse entry into columns 1827c478bd9Sstevel@tonic-gate */ 1837c478bd9Sstevel@tonic-gate res = genent_attr(line, PROFATTR_DB_NCOL, &ecol); 1847c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 1857c478bd9Sstevel@tonic-gate return (res); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 1887c478bd9Sstevel@tonic-gate data.res1 = NULL; 1897c478bd9Sstevel@tonic-gate data.res2 = NULL; 1907c478bd9Sstevel@tonic-gate data.desc = ecol[3].ec_value.ec_value_val; 1917c478bd9Sstevel@tonic-gate data.attr = ecol[4].ec_value.ec_value_val; 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 1947c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 1957c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 1987c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 1997c478bd9Sstevel@tonic-gate if (continue_onerror) 2007c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2017c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists," 2027c478bd9Sstevel@tonic-gate " skipping it.\n"), 2037c478bd9Sstevel@tonic-gate data.name); 2047c478bd9Sstevel@tonic-gate else { 2057c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2067c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2077c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists\n"), 2087c478bd9Sstevel@tonic-gate data.name); 2097c478bd9Sstevel@tonic-gate } 2107c478bd9Sstevel@tonic-gate } else if (retval) 2117c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate free(ecol); 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate return (res); 2167c478bd9Sstevel@tonic-gate } 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate void 2197c478bd9Sstevel@tonic-gate dump_prof_attr(ns_ldap_result_t *res) 2207c478bd9Sstevel@tonic-gate { 2217c478bd9Sstevel@tonic-gate char **value = NULL; 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "cn"); 2247c478bd9Sstevel@tonic-gate if (value && value[0]) 2257c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2267c478bd9Sstevel@tonic-gate else 2277c478bd9Sstevel@tonic-gate return; 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 2307c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrLongDesc"); 2317c478bd9Sstevel@tonic-gate if (value && value[0]) 2327c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2337c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 2347c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 2357c478bd9Sstevel@tonic-gate if (value && value[0]) 2367c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 2377c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate int 2417c478bd9Sstevel@tonic-gate genent_exec_attr(char *line, int (*cback)()) 2427c478bd9Sstevel@tonic-gate { 2437c478bd9Sstevel@tonic-gate entry_col *ecol; 2447c478bd9Sstevel@tonic-gate execstr_t data; 2457c478bd9Sstevel@tonic-gate int res, retval; 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * parse entry into columns 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate res = genent_attr(line, EXECATTR_DB_NCOL, &ecol); 2517c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 2527c478bd9Sstevel@tonic-gate return (res); 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 2557c478bd9Sstevel@tonic-gate data.policy = ecol[1].ec_value.ec_value_val; 2567c478bd9Sstevel@tonic-gate data.type = ecol[2].ec_value.ec_value_val; 2577c478bd9Sstevel@tonic-gate data.res1 = NULL; 2587c478bd9Sstevel@tonic-gate data.res2 = NULL; 2597c478bd9Sstevel@tonic-gate data.id = ecol[5].ec_value.ec_value_val; 2607c478bd9Sstevel@tonic-gate data.attr = ecol[6].ec_value.ec_value_val; 2617c478bd9Sstevel@tonic-gate data.next = NULL; 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 2647c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 2657c478bd9Sstevel@tonic-gate gettext("Adding entry : %s+%s+%s+%s\n"), 2667c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 2697c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 2707c478bd9Sstevel@tonic-gate if (continue_onerror) 2717c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2727c478bd9Sstevel@tonic-gate gettext("Entry: %s+%s+%s+%s - already Exists," 2737c478bd9Sstevel@tonic-gate " skipping it.\n"), 2747c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2757c478bd9Sstevel@tonic-gate else { 2767c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2777c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 2787c478bd9Sstevel@tonic-gate gettext("Entry: %s+%s+%s+%s - already Exists\n"), 2797c478bd9Sstevel@tonic-gate data.name, data.policy, data.type, data.id); 2807c478bd9Sstevel@tonic-gate } 2817c478bd9Sstevel@tonic-gate } else if (retval) 2827c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate free(ecol); 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate return (res); 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate void 2907c478bd9Sstevel@tonic-gate dump_exec_attr(ns_ldap_result_t *res) 2917c478bd9Sstevel@tonic-gate { 2927c478bd9Sstevel@tonic-gate char **profile; 2937c478bd9Sstevel@tonic-gate char **policy; 2947c478bd9Sstevel@tonic-gate char **type; 2957c478bd9Sstevel@tonic-gate char **id; 2967c478bd9Sstevel@tonic-gate char **value; 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate profile = __ns_ldap_getAttr(res->entry, "cn"); 2997c478bd9Sstevel@tonic-gate policy = __ns_ldap_getAttr(res->entry, "SolarisKernelSecurityPolicy"); 3007c478bd9Sstevel@tonic-gate type = __ns_ldap_getAttr(res->entry, "SolarisProfileType"); 3017c478bd9Sstevel@tonic-gate id = __ns_ldap_getAttr(res->entry, "SolarisProfileId"); 3027c478bd9Sstevel@tonic-gate 3037c478bd9Sstevel@tonic-gate if (profile == NULL || profile[0] == NULL || 3047c478bd9Sstevel@tonic-gate policy == NULL || policy[0] == NULL || 3057c478bd9Sstevel@tonic-gate type == NULL || type[0] == NULL || 3067c478bd9Sstevel@tonic-gate id == NULL || id[0] == NULL) 3077c478bd9Sstevel@tonic-gate return; 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", profile[0]); 3107c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3117c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", policy[0]); 3127c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3137c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", type[0]); 3147c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 3157c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", id[0]); 3167c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3177c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 3187c478bd9Sstevel@tonic-gate if (value && value[0]) 3197c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3207c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate int 3247c478bd9Sstevel@tonic-gate genent_auth_attr(char *line, int (*cback)()) 3257c478bd9Sstevel@tonic-gate { 3267c478bd9Sstevel@tonic-gate entry_col *ecol; 3277c478bd9Sstevel@tonic-gate authstr_t data; 3287c478bd9Sstevel@tonic-gate int res, retval; 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate /* 3317c478bd9Sstevel@tonic-gate * parse entry into columns 3327c478bd9Sstevel@tonic-gate */ 3337c478bd9Sstevel@tonic-gate res = genent_attr(line, AUTHATTR_DB_NCOL, &ecol); 3347c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 3357c478bd9Sstevel@tonic-gate return (res); 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate data.name = ecol[0].ec_value.ec_value_val; 3387c478bd9Sstevel@tonic-gate data.res1 = NULL; 3397c478bd9Sstevel@tonic-gate data.res2 = NULL; 3407c478bd9Sstevel@tonic-gate data.short_desc = ecol[3].ec_value.ec_value_val; 3417c478bd9Sstevel@tonic-gate data.long_desc = ecol[4].ec_value.ec_value_val; 3427c478bd9Sstevel@tonic-gate data.attr = ecol[5].ec_value.ec_value_val; 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 3457c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 3467c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.name); 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 0); 3497c478bd9Sstevel@tonic-gate if (retval == LDAP_ALREADY_EXISTS) { 3507c478bd9Sstevel@tonic-gate if (continue_onerror) 3517c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 3527c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists," 3537c478bd9Sstevel@tonic-gate " skipping it.\n"), data.name); 3547c478bd9Sstevel@tonic-gate else { 3557c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 3567c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 3577c478bd9Sstevel@tonic-gate gettext("Entry: %s - already Exists\n"), 3587c478bd9Sstevel@tonic-gate data.name); 3597c478bd9Sstevel@tonic-gate } 3607c478bd9Sstevel@tonic-gate } else if (retval) 3617c478bd9Sstevel@tonic-gate res = GENENT_CBERR; 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate free(ecol); 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate return (res); 3667c478bd9Sstevel@tonic-gate } 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate void 3697c478bd9Sstevel@tonic-gate dump_auth_attr(ns_ldap_result_t *res) 3707c478bd9Sstevel@tonic-gate { 3717c478bd9Sstevel@tonic-gate char **value = NULL; 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "cn"); 3747c478bd9Sstevel@tonic-gate if (value && value[0]) 3757c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3767c478bd9Sstevel@tonic-gate else 3777c478bd9Sstevel@tonic-gate return; 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":::"); 3807c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrShortDesc"); 3817c478bd9Sstevel@tonic-gate if (value && value[0]) 3827c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3837c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3847c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrLongDesc"); 3857c478bd9Sstevel@tonic-gate if (value && value[0]) 3867c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3877c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 3887c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAttrKeyValue"); 3897c478bd9Sstevel@tonic-gate if (value && value[0]) 3907c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 3917c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 3927c478bd9Sstevel@tonic-gate } 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate int 3957c478bd9Sstevel@tonic-gate genent_audit_user(char *line, int (*cback)()) 3967c478bd9Sstevel@tonic-gate { 3977c478bd9Sstevel@tonic-gate entry_col *ecol; 3987c478bd9Sstevel@tonic-gate au_user_str_t data; 3997c478bd9Sstevel@tonic-gate int res, retval; 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * parse entry into columns 4037c478bd9Sstevel@tonic-gate */ 4047c478bd9Sstevel@tonic-gate res = genent_attr(line, AUDITUSER_DB_NCOL, &ecol); 4057c478bd9Sstevel@tonic-gate if (res != GENENT_OK) 4067c478bd9Sstevel@tonic-gate return (res); 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate data.au_name = strdup(ecol[0].ec_value.ec_value_val); 4097c478bd9Sstevel@tonic-gate data.au_always = strdup(ecol[1].ec_value.ec_value_val); 4107c478bd9Sstevel@tonic-gate data.au_never = strdup(ecol[2].ec_value.ec_value_val); 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate if (flags & F_VERBOSE) 4137c478bd9Sstevel@tonic-gate (void) fprintf(stdout, 4147c478bd9Sstevel@tonic-gate gettext("Adding entry : %s\n"), data.au_name); 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate retval = (*cback)(&data, 1); 417*12fbe00aSjs if (retval != NS_LDAP_SUCCESS) { 418*12fbe00aSjs if (retval == LDAP_NO_SUCH_OBJECT) 419*12fbe00aSjs (void) fprintf(stdout, 420*12fbe00aSjs gettext("Cannot add audit_user entry (%s), " 421*12fbe00aSjs "add passwd entry first\n"), data.au_name); 422*12fbe00aSjs if (continue_onerror == 0) res = GENENT_CBERR; 423*12fbe00aSjs } 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate free(ecol); 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate return (res); 4287c478bd9Sstevel@tonic-gate } 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate void 4317c478bd9Sstevel@tonic-gate dump_audit_user(ns_ldap_result_t *res) 4327c478bd9Sstevel@tonic-gate { 4337c478bd9Sstevel@tonic-gate char **value = NULL; 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "uid"); 4367c478bd9Sstevel@tonic-gate if (value && value[0]) 4377c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 4387c478bd9Sstevel@tonic-gate else 4397c478bd9Sstevel@tonic-gate return; 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 4427c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAuditAlways"); 4437c478bd9Sstevel@tonic-gate if (value && value[0]) 4447c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 4457c478bd9Sstevel@tonic-gate (void) fprintf(stdout, ":"); 4467c478bd9Sstevel@tonic-gate value = __ns_ldap_getAttr(res->entry, "SolarisAuditNever"); 4477c478bd9Sstevel@tonic-gate if (value && value[0]) 4487c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%s", value[0]); 4497c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 4507c478bd9Sstevel@tonic-gate } 451