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 5*cb5caa98Sdjl * Common Development and Distribution License (the "License"). 6*cb5caa98Sdjl * 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*cb5caa98Sdjl * 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 #include <sys/types.h> 297c478bd9Sstevel@tonic-gate #include <stdio.h> 307c478bd9Sstevel@tonic-gate #include <string.h> 317c478bd9Sstevel@tonic-gate #include <stdlib.h> 327c478bd9Sstevel@tonic-gate #include <nss_dbdefs.h> 337c478bd9Sstevel@tonic-gate #include <deflt.h> 347c478bd9Sstevel@tonic-gate #include <exec_attr.h> 357c478bd9Sstevel@tonic-gate #include <user_attr.h> 367c478bd9Sstevel@tonic-gate #include <auth_attr.h> 377c478bd9Sstevel@tonic-gate #include <prof_attr.h> 387c478bd9Sstevel@tonic-gate #include <getxby_door.h> 397c478bd9Sstevel@tonic-gate #include <sys/mman.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* Externs from libnsl */ 437c478bd9Sstevel@tonic-gate extern execstr_t *_getexecattr(execstr_t *, char *, int, int *); 447c478bd9Sstevel@tonic-gate extern void _setexecattr(void); 457c478bd9Sstevel@tonic-gate extern void _endexecattr(void); 467c478bd9Sstevel@tonic-gate extern execstr_t *_getexecprof(const char *, const char *, const char *, int, 477c478bd9Sstevel@tonic-gate execstr_t *, char *, int, int *); 487c478bd9Sstevel@tonic-gate extern userstr_t *_getusernam(const char *, userstr_t *, char *, int, int *); 497c478bd9Sstevel@tonic-gate extern userstr_t *_getuserattr(userstr_t *, char *, int, int *); 507c478bd9Sstevel@tonic-gate extern char *_strtok_escape(char *, char *, char **); 517c478bd9Sstevel@tonic-gate extern char *_strdup_null(char *); 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate static execattr_t *userprof(const char *, const char *, const char *, int); 547c478bd9Sstevel@tonic-gate static execattr_t *get_tail(execattr_t *); 557c478bd9Sstevel@tonic-gate static execattr_t *execstr2attr(execstr_t *); 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate execattr_t * 587c478bd9Sstevel@tonic-gate getexecattr() 597c478bd9Sstevel@tonic-gate { 607c478bd9Sstevel@tonic-gate int err = 0; 617c478bd9Sstevel@tonic-gate char buf[NSS_BUFLEN_EXECATTR]; 627c478bd9Sstevel@tonic-gate execstr_t exec; 637c478bd9Sstevel@tonic-gate execstr_t *tmp; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate tmp = _getexecattr(&exec, buf, NSS_BUFLEN_EXECATTR, &err); 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate return (execstr2attr(tmp)); 687c478bd9Sstevel@tonic-gate } 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate execattr_t * 727c478bd9Sstevel@tonic-gate getexecprof(const char *name, const char *type, const char *id, int search_flag) 737c478bd9Sstevel@tonic-gate { 747c478bd9Sstevel@tonic-gate int err = 0; 757c478bd9Sstevel@tonic-gate char unique[NSS_BUFLEN_EXECATTR]; 767c478bd9Sstevel@tonic-gate char buf[NSS_BUFLEN_EXECATTR]; 777c478bd9Sstevel@tonic-gate execattr_t *head = (execattr_t *)NULL; 787c478bd9Sstevel@tonic-gate execattr_t *prev = (execattr_t *)NULL; 797c478bd9Sstevel@tonic-gate execstr_t exec; 807c478bd9Sstevel@tonic-gate execstr_t *tmp; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate (void) memset(unique, 0, NSS_BUFLEN_EXECATTR); 837c478bd9Sstevel@tonic-gate (void) memset(&exec, 0, sizeof (execstr_t)); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate if ((search_flag != GET_ONE) && (search_flag != GET_ALL)) { 867c478bd9Sstevel@tonic-gate return ((execattr_t *)NULL); 877c478bd9Sstevel@tonic-gate } 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate if ((name == NULL) && (type == NULL) && (id == NULL)) { 907c478bd9Sstevel@tonic-gate setexecattr(); 917c478bd9Sstevel@tonic-gate switch (search_flag) { 927c478bd9Sstevel@tonic-gate case GET_ONE: 937c478bd9Sstevel@tonic-gate head = getexecattr(); 947c478bd9Sstevel@tonic-gate break; 957c478bd9Sstevel@tonic-gate case GET_ALL: 967c478bd9Sstevel@tonic-gate head = getexecattr(); 977c478bd9Sstevel@tonic-gate prev = head; 987c478bd9Sstevel@tonic-gate while (prev != NULL) { 997c478bd9Sstevel@tonic-gate prev->next = getexecattr(); 1007c478bd9Sstevel@tonic-gate prev = prev->next; 1017c478bd9Sstevel@tonic-gate }; 1027c478bd9Sstevel@tonic-gate break; 1037c478bd9Sstevel@tonic-gate default: 1047c478bd9Sstevel@tonic-gate head = (execattr_t *)NULL; 1057c478bd9Sstevel@tonic-gate break; 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate endexecattr(); 1087c478bd9Sstevel@tonic-gate return (head); 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate tmp = _getexecprof(name, 1127c478bd9Sstevel@tonic-gate type, 1137c478bd9Sstevel@tonic-gate id, 1147c478bd9Sstevel@tonic-gate search_flag, 1157c478bd9Sstevel@tonic-gate &exec, 1167c478bd9Sstevel@tonic-gate buf, 1177c478bd9Sstevel@tonic-gate NSS_BUFLEN_EXECATTR, 1187c478bd9Sstevel@tonic-gate &err); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate return (execstr2attr(tmp)); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate execattr_t * 1257c478bd9Sstevel@tonic-gate getexecuser(const char *username, const char *type, const char *id, 1267c478bd9Sstevel@tonic-gate int search_flag) 1277c478bd9Sstevel@tonic-gate { 1287c478bd9Sstevel@tonic-gate int err = 0; 1297c478bd9Sstevel@tonic-gate char buf[NSS_BUFLEN_USERATTR]; 1307c478bd9Sstevel@tonic-gate userstr_t user; 1317c478bd9Sstevel@tonic-gate userstr_t *utmp; 1327c478bd9Sstevel@tonic-gate execattr_t *head = (execattr_t *)NULL; 1337c478bd9Sstevel@tonic-gate execattr_t *prev = (execattr_t *)NULL; 1347c478bd9Sstevel@tonic-gate execattr_t *new = (execattr_t *)NULL; 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate if ((search_flag != GET_ONE) && (search_flag != GET_ALL)) { 1377c478bd9Sstevel@tonic-gate return ((execattr_t *)NULL); 1387c478bd9Sstevel@tonic-gate } 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate if (username == NULL) { 1417c478bd9Sstevel@tonic-gate setuserattr(); 1427c478bd9Sstevel@tonic-gate /* avoid userstr2attr mallocs by calling libnsl directly */ 1437c478bd9Sstevel@tonic-gate utmp = _getuserattr(&user, buf, NSS_BUFLEN_USERATTR, &err); 1447c478bd9Sstevel@tonic-gate if (utmp == NULL) { 1457c478bd9Sstevel@tonic-gate return (head); 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate switch (search_flag) { 1487c478bd9Sstevel@tonic-gate case GET_ONE: 1497c478bd9Sstevel@tonic-gate head = userprof((const char *)(utmp->name), type, id, 1507c478bd9Sstevel@tonic-gate search_flag); 1517c478bd9Sstevel@tonic-gate break; 1527c478bd9Sstevel@tonic-gate case GET_ALL: 1537c478bd9Sstevel@tonic-gate head = userprof((const char *)(utmp->name), type, id, 1547c478bd9Sstevel@tonic-gate search_flag); 1557c478bd9Sstevel@tonic-gate if (head != NULL) { 1567c478bd9Sstevel@tonic-gate prev = get_tail(head); 1577c478bd9Sstevel@tonic-gate } 1587c478bd9Sstevel@tonic-gate while ((utmp = _getuserattr(&user, 1597c478bd9Sstevel@tonic-gate buf, NSS_BUFLEN_USERATTR, &err)) != NULL) { 1607c478bd9Sstevel@tonic-gate if ((new = 1617c478bd9Sstevel@tonic-gate userprof((const char *)(utmp->name), 1627c478bd9Sstevel@tonic-gate type, id, search_flag)) != NULL) { 1637c478bd9Sstevel@tonic-gate if (prev != NULL) { 1647c478bd9Sstevel@tonic-gate prev->next = new; 1657c478bd9Sstevel@tonic-gate prev = get_tail(prev->next); 1667c478bd9Sstevel@tonic-gate } else { 1677c478bd9Sstevel@tonic-gate head = new; 1687c478bd9Sstevel@tonic-gate prev = get_tail(head); 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate } 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate break; 1737c478bd9Sstevel@tonic-gate default: 1747c478bd9Sstevel@tonic-gate head = (execattr_t *)NULL; 1757c478bd9Sstevel@tonic-gate break; 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate enduserattr(); 1787c478bd9Sstevel@tonic-gate } else { 1797c478bd9Sstevel@tonic-gate head = userprof(username, type, id, search_flag); 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate return (head); 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate execattr_t * 1877c478bd9Sstevel@tonic-gate match_execattr(execattr_t *exec, const char *profname, const char *type, 1887c478bd9Sstevel@tonic-gate const char *id) 1897c478bd9Sstevel@tonic-gate { 1907c478bd9Sstevel@tonic-gate execattr_t *execp = (execattr_t *)NULL; 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate for (execp = exec; execp != NULL; execp = execp->next) { 1937c478bd9Sstevel@tonic-gate if ((profname && execp->name && 1947c478bd9Sstevel@tonic-gate (strcmp(profname, execp->name) != 0)) || 1957c478bd9Sstevel@tonic-gate (type && execp->type && (strcmp(type, execp->type) != 0)) || 1967c478bd9Sstevel@tonic-gate (id && execp->id && (strcmp(id, execp->id) != 0))) 1977c478bd9Sstevel@tonic-gate continue; 1987c478bd9Sstevel@tonic-gate } 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate return (execp); 2017c478bd9Sstevel@tonic-gate } 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate void 2057c478bd9Sstevel@tonic-gate setexecattr() 2067c478bd9Sstevel@tonic-gate { 2077c478bd9Sstevel@tonic-gate _setexecattr(); 2087c478bd9Sstevel@tonic-gate } 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate void 2127c478bd9Sstevel@tonic-gate endexecattr() 2137c478bd9Sstevel@tonic-gate { 2147c478bd9Sstevel@tonic-gate _endexecattr(); 2157c478bd9Sstevel@tonic-gate } 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate void 2197c478bd9Sstevel@tonic-gate free_execattr(execattr_t *exec) 2207c478bd9Sstevel@tonic-gate { 2217c478bd9Sstevel@tonic-gate if (exec != (execattr_t *)NULL) { 2227c478bd9Sstevel@tonic-gate free(exec->name); 2237c478bd9Sstevel@tonic-gate free(exec->type); 2247c478bd9Sstevel@tonic-gate free(exec->policy); 2257c478bd9Sstevel@tonic-gate free(exec->res1); 2267c478bd9Sstevel@tonic-gate free(exec->res2); 2277c478bd9Sstevel@tonic-gate free(exec->id); 2287c478bd9Sstevel@tonic-gate _kva_free(exec->attr); 2297c478bd9Sstevel@tonic-gate free_execattr(exec->next); 2307c478bd9Sstevel@tonic-gate free(exec); 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate static execattr_t * 2367c478bd9Sstevel@tonic-gate userprof(const char *username, const char *type, const char *id, 2377c478bd9Sstevel@tonic-gate int search_flag) 2387c478bd9Sstevel@tonic-gate { 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate int err = 0; 2417c478bd9Sstevel@tonic-gate char *last; 2427c478bd9Sstevel@tonic-gate char *sep = ","; 2437c478bd9Sstevel@tonic-gate char *proflist = (char *)NULL; 2447c478bd9Sstevel@tonic-gate char *profname = (char *)NULL; 2457c478bd9Sstevel@tonic-gate char buf[NSS_BUFLEN_USERATTR]; 2467c478bd9Sstevel@tonic-gate char pwdb[NSS_BUFLEN_PASSWD]; 2477c478bd9Sstevel@tonic-gate kva_t *user_attr; 2487c478bd9Sstevel@tonic-gate userstr_t user; 2497c478bd9Sstevel@tonic-gate userstr_t *utmp; 2507c478bd9Sstevel@tonic-gate execattr_t *exec; 2517c478bd9Sstevel@tonic-gate execattr_t *head = (execattr_t *)NULL; 2527c478bd9Sstevel@tonic-gate execattr_t *prev = (execattr_t *)NULL; 2537c478bd9Sstevel@tonic-gate struct passwd pwd; 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate char *profArray[MAXPROFS]; 2567c478bd9Sstevel@tonic-gate int profcnt = 0; 2577c478bd9Sstevel@tonic-gate int i; 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* 2607c478bd9Sstevel@tonic-gate * Check if specified username is valid user 2617c478bd9Sstevel@tonic-gate */ 2627c478bd9Sstevel@tonic-gate if (getpwnam_r(username, &pwd, pwdb, sizeof (pwdb)) == NULL) { 2637c478bd9Sstevel@tonic-gate return (head); 2647c478bd9Sstevel@tonic-gate } 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate utmp = _getusernam(username, &user, buf, NSS_BUFLEN_USERATTR, &err); 2677c478bd9Sstevel@tonic-gate if (utmp != NULL) { 2687c478bd9Sstevel@tonic-gate proflist = NULL; 2697c478bd9Sstevel@tonic-gate user_attr = _str2kva(user.attr, KV_ASSIGN, KV_DELIMITER); 2707c478bd9Sstevel@tonic-gate if ((proflist = kva_match(user_attr, "profiles")) != NULL) { 2717c478bd9Sstevel@tonic-gate /* Get the list of profiles for this user */ 2727c478bd9Sstevel@tonic-gate for (profname = _strtok_escape(proflist, sep, &last); 2737c478bd9Sstevel@tonic-gate profname != NULL; 2747c478bd9Sstevel@tonic-gate profname = _strtok_escape(NULL, sep, &last)) { 2757c478bd9Sstevel@tonic-gate getproflist(profname, profArray, &profcnt); 2767c478bd9Sstevel@tonic-gate } 2777c478bd9Sstevel@tonic-gate } 2787c478bd9Sstevel@tonic-gate } 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate /* Get the list of default profiles */ 2817c478bd9Sstevel@tonic-gate if (defopen(AUTH_POLICY) == NULL) { 2827c478bd9Sstevel@tonic-gate proflist = defread(DEF_PROF); 2837c478bd9Sstevel@tonic-gate (void) defopen(NULL); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate if (proflist != NULL) { 2867c478bd9Sstevel@tonic-gate for (profname = _strtok_escape(proflist, sep, &last); 2877c478bd9Sstevel@tonic-gate profname != NULL; 2887c478bd9Sstevel@tonic-gate profname = _strtok_escape(NULL, sep, &last)) { 2897c478bd9Sstevel@tonic-gate getproflist(profname, profArray, &profcnt); 2907c478bd9Sstevel@tonic-gate } 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate if (profcnt == 0) { 2947c478bd9Sstevel@tonic-gate return (head); 2957c478bd9Sstevel@tonic-gate } 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* Get execs from the list of profiles */ 2987c478bd9Sstevel@tonic-gate for (i = 0; i < profcnt; i++) { 2997c478bd9Sstevel@tonic-gate profname = profArray[i]; 3007c478bd9Sstevel@tonic-gate if ((exec = getexecprof(profname, type, id, search_flag)) != 3017c478bd9Sstevel@tonic-gate NULL) { 3027c478bd9Sstevel@tonic-gate if (search_flag == GET_ONE) { 3037c478bd9Sstevel@tonic-gate head = exec; 3047c478bd9Sstevel@tonic-gate break; 3057c478bd9Sstevel@tonic-gate } else if (search_flag == GET_ALL) { 3067c478bd9Sstevel@tonic-gate if (head == NULL) { 3077c478bd9Sstevel@tonic-gate head = exec; 3087c478bd9Sstevel@tonic-gate prev = get_tail(head); 3097c478bd9Sstevel@tonic-gate } else { 3107c478bd9Sstevel@tonic-gate prev->next = exec; 3117c478bd9Sstevel@tonic-gate prev = get_tail(exec); 3127c478bd9Sstevel@tonic-gate } 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate } 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate free_proflist(profArray, profcnt); 3177c478bd9Sstevel@tonic-gate return (head); 3187c478bd9Sstevel@tonic-gate } 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate static execattr_t * 3227c478bd9Sstevel@tonic-gate get_tail(execattr_t *exec) 3237c478bd9Sstevel@tonic-gate { 3247c478bd9Sstevel@tonic-gate execattr_t *i_exec = (execattr_t *)NULL; 3257c478bd9Sstevel@tonic-gate execattr_t *j_exec = (execattr_t *)NULL; 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate if (exec != NULL) { 3287c478bd9Sstevel@tonic-gate if (exec->next == NULL) { 3297c478bd9Sstevel@tonic-gate j_exec = exec; 3307c478bd9Sstevel@tonic-gate } else { 3317c478bd9Sstevel@tonic-gate for (i_exec = exec->next; i_exec != NULL; 3327c478bd9Sstevel@tonic-gate i_exec = i_exec->next) { 3337c478bd9Sstevel@tonic-gate j_exec = i_exec; 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate } 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate return (j_exec); 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate static execattr_t * 3437c478bd9Sstevel@tonic-gate execstr2attr(execstr_t *es) 3447c478bd9Sstevel@tonic-gate { 3457c478bd9Sstevel@tonic-gate execattr_t *newexec; 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate if (es == NULL) { 3487c478bd9Sstevel@tonic-gate return ((execattr_t *)NULL); 3497c478bd9Sstevel@tonic-gate } 3507c478bd9Sstevel@tonic-gate if ((newexec = (execattr_t *)malloc(sizeof (execattr_t))) == NULL) { 3517c478bd9Sstevel@tonic-gate return ((execattr_t *)NULL); 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate newexec->name = _do_unescape(es->name); 3557c478bd9Sstevel@tonic-gate newexec->policy = _do_unescape(es->policy); 3567c478bd9Sstevel@tonic-gate newexec->type = _do_unescape(es->type); 3577c478bd9Sstevel@tonic-gate newexec->res1 = _do_unescape(es->res1); 3587c478bd9Sstevel@tonic-gate newexec->res2 = _do_unescape(es->res2); 3597c478bd9Sstevel@tonic-gate newexec->id = _do_unescape(es->id); 3607c478bd9Sstevel@tonic-gate newexec->attr = _str2kva(es->attr, KV_ASSIGN, KV_DELIMITER); 3617c478bd9Sstevel@tonic-gate if (es->next) { 3627c478bd9Sstevel@tonic-gate newexec->next = execstr2attr((execstr_t *)(es->next)); 3637c478bd9Sstevel@tonic-gate } else { 3647c478bd9Sstevel@tonic-gate newexec->next = (execattr_t *)NULL; 3657c478bd9Sstevel@tonic-gate } 3667c478bd9Sstevel@tonic-gate return (newexec); 3677c478bd9Sstevel@tonic-gate } 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate #ifdef DEBUG 3707c478bd9Sstevel@tonic-gate void 3717c478bd9Sstevel@tonic-gate print_execattr(execattr_t *exec) 3727c478bd9Sstevel@tonic-gate { 3737c478bd9Sstevel@tonic-gate extern void print_kva(kva_t *); 3747c478bd9Sstevel@tonic-gate char *empty = "empty"; 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate if (exec != NULL) { 3777c478bd9Sstevel@tonic-gate printf("name=%s\n", exec->name ? exec->name : empty); 3787c478bd9Sstevel@tonic-gate printf("policy=%s\n", exec->policy ? exec->policy : empty); 3797c478bd9Sstevel@tonic-gate printf("type=%s\n", exec->type ? exec->type : empty); 3807c478bd9Sstevel@tonic-gate printf("res1=%s\n", exec->res1 ? exec->res1 : empty); 3817c478bd9Sstevel@tonic-gate printf("res2=%s\n", exec->res2 ? exec->res2 : empty); 3827c478bd9Sstevel@tonic-gate printf("id=%s\n", exec->id ? exec->id : empty); 3837c478bd9Sstevel@tonic-gate printf("attr=\n"); 3847c478bd9Sstevel@tonic-gate print_kva(exec->attr); 3857c478bd9Sstevel@tonic-gate fflush(stdout); 3867c478bd9Sstevel@tonic-gate if (exec->next) { 3877c478bd9Sstevel@tonic-gate print_execattr(exec->next); 3887c478bd9Sstevel@tonic-gate } 3897c478bd9Sstevel@tonic-gate } else { 3907c478bd9Sstevel@tonic-gate printf("NULL\n"); 3917c478bd9Sstevel@tonic-gate } 3927c478bd9Sstevel@tonic-gate } 3937c478bd9Sstevel@tonic-gate #endif /* DEBUG */ 394