author | Casper H.S. Dik <Casper.Dik@Sun.COM> |
Wed, 28 Apr 2010 10:01:37 +0200 | |
changeset 12273 | 63678502e95e |
parent 10020 | ff5f2b3729b6 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
2830 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
0 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
22 |
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 23 |
*/ |
24 |
||
25 |
#include <sys/types.h> |
|
26 |
#include <stdio.h> |
|
27 |
#include <string.h> |
|
28 |
#include <stdlib.h> |
|
29 |
#include <nss_dbdefs.h> |
|
30 |
#include <deflt.h> |
|
31 |
#include <exec_attr.h> |
|
32 |
#include <user_attr.h> |
|
33 |
#include <auth_attr.h> |
|
34 |
#include <prof_attr.h> |
|
35 |
#include <getxby_door.h> |
|
36 |
#include <sys/mman.h> |
|
37 |
||
38 |
||
39 |
/* Externs from libnsl */ |
|
40 |
extern execstr_t *_getexecattr(execstr_t *, char *, int, int *); |
|
41 |
extern void _setexecattr(void); |
|
42 |
extern void _endexecattr(void); |
|
43 |
extern execstr_t *_getexecprof(const char *, const char *, const char *, int, |
|
44 |
execstr_t *, char *, int, int *); |
|
45 |
extern userstr_t *_getusernam(const char *, userstr_t *, char *, int, int *); |
|
46 |
extern userstr_t *_getuserattr(userstr_t *, char *, int, int *); |
|
47 |
extern char *_strtok_escape(char *, char *, char **); |
|
48 |
extern char *_strdup_null(char *); |
|
49 |
||
50 |
static execattr_t *userprof(const char *, const char *, const char *, int); |
|
51 |
static execattr_t *get_tail(execattr_t *); |
|
52 |
static execattr_t *execstr2attr(execstr_t *); |
|
53 |
||
54 |
execattr_t * |
|
55 |
getexecattr() |
|
56 |
{ |
|
57 |
int err = 0; |
|
58 |
char buf[NSS_BUFLEN_EXECATTR]; |
|
59 |
execstr_t exec; |
|
60 |
execstr_t *tmp; |
|
61 |
||
62 |
tmp = _getexecattr(&exec, buf, NSS_BUFLEN_EXECATTR, &err); |
|
63 |
||
64 |
return (execstr2attr(tmp)); |
|
65 |
} |
|
66 |
||
67 |
||
68 |
execattr_t * |
|
69 |
getexecprof(const char *name, const char *type, const char *id, int search_flag) |
|
70 |
{ |
|
71 |
int err = 0; |
|
72 |
char unique[NSS_BUFLEN_EXECATTR]; |
|
73 |
char buf[NSS_BUFLEN_EXECATTR]; |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
74 |
execattr_t *head = NULL; |
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
75 |
execattr_t *prev = NULL; |
0 | 76 |
execstr_t exec; |
77 |
execstr_t *tmp; |
|
78 |
||
79 |
(void) memset(unique, 0, NSS_BUFLEN_EXECATTR); |
|
80 |
(void) memset(&exec, 0, sizeof (execstr_t)); |
|
81 |
||
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
82 |
if (!IS_GET_ONE(search_flag) && !IS_GET_ALL(search_flag)) { |
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
83 |
return (NULL); |
0 | 84 |
} |
85 |
||
86 |
if ((name == NULL) && (type == NULL) && (id == NULL)) { |
|
87 |
setexecattr(); |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
88 |
if (IS_GET_ONE(search_flag)) { |
0 | 89 |
head = getexecattr(); |
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
90 |
} else if (IS_GET_ALL(search_flag)) { |
0 | 91 |
head = getexecattr(); |
92 |
prev = head; |
|
93 |
while (prev != NULL) { |
|
94 |
prev->next = getexecattr(); |
|
95 |
prev = prev->next; |
|
96 |
}; |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
97 |
} else { |
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
98 |
head = NULL; |
0 | 99 |
} |
100 |
endexecattr(); |
|
101 |
return (head); |
|
102 |
} |
|
103 |
||
104 |
tmp = _getexecprof(name, |
|
105 |
type, |
|
106 |
id, |
|
107 |
search_flag, |
|
108 |
&exec, |
|
109 |
buf, |
|
110 |
NSS_BUFLEN_EXECATTR, |
|
111 |
&err); |
|
112 |
||
113 |
return (execstr2attr(tmp)); |
|
114 |
} |
|
115 |
||
116 |
execattr_t * |
|
117 |
getexecuser(const char *username, const char *type, const char *id, |
|
118 |
int search_flag) |
|
119 |
{ |
|
120 |
int err = 0; |
|
121 |
char buf[NSS_BUFLEN_USERATTR]; |
|
122 |
userstr_t user; |
|
123 |
userstr_t *utmp; |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
124 |
execattr_t *head = NULL; |
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
125 |
execattr_t *prev = NULL; |
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
126 |
execattr_t *new = NULL; |
0 | 127 |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
128 |
if (!IS_GET_ONE(search_flag) && !IS_GET_ALL(search_flag)) { |
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
129 |
return (NULL); |
0 | 130 |
} |
131 |
||
132 |
if (username == NULL) { |
|
133 |
setuserattr(); |
|
134 |
/* avoid userstr2attr mallocs by calling libnsl directly */ |
|
135 |
utmp = _getuserattr(&user, buf, NSS_BUFLEN_USERATTR, &err); |
|
136 |
if (utmp == NULL) { |
|
137 |
return (head); |
|
138 |
} |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
139 |
if (IS_GET_ONE(search_flag)) { |
0 | 140 |
head = userprof((const char *)(utmp->name), type, id, |
141 |
search_flag); |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
142 |
} else if (IS_GET_ALL(search_flag)) { |
0 | 143 |
head = userprof((const char *)(utmp->name), type, id, |
144 |
search_flag); |
|
145 |
if (head != NULL) { |
|
146 |
prev = get_tail(head); |
|
147 |
} |
|
148 |
while ((utmp = _getuserattr(&user, |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
149 |
buf, NSS_BUFLEN_USERATTR, &err)) != NULL) { |
0 | 150 |
if ((new = |
151 |
userprof((const char *)(utmp->name), |
|
152 |
type, id, search_flag)) != NULL) { |
|
153 |
if (prev != NULL) { |
|
154 |
prev->next = new; |
|
155 |
prev = get_tail(prev->next); |
|
156 |
} else { |
|
157 |
head = new; |
|
158 |
prev = get_tail(head); |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
10020
ff5f2b3729b6
6848927 sulogin accepts empty username
Joep Vesseur <Joep.Vesseur@Sun.COM>
parents:
6059
diff
changeset
|
162 |
} else { |
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
163 |
head = NULL; |
0 | 164 |
} |
165 |
enduserattr(); |
|
166 |
} else { |
|
167 |
head = userprof(username, type, id, search_flag); |
|
168 |
} |
|
169 |
||
170 |
return (head); |
|
171 |
} |
|
172 |
||
173 |
||
174 |
execattr_t * |
|
175 |
match_execattr(execattr_t *exec, const char *profname, const char *type, |
|
176 |
const char *id) |
|
177 |
{ |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
178 |
execattr_t *execp = NULL; |
0 | 179 |
|
180 |
for (execp = exec; execp != NULL; execp = execp->next) { |
|
181 |
if ((profname && execp->name && |
|
182 |
(strcmp(profname, execp->name) != 0)) || |
|
183 |
(type && execp->type && (strcmp(type, execp->type) != 0)) || |
|
184 |
(id && execp->id && (strcmp(id, execp->id) != 0))) |
|
185 |
continue; |
|
186 |
} |
|
187 |
||
188 |
return (execp); |
|
189 |
} |
|
190 |
||
191 |
||
192 |
void |
|
193 |
setexecattr() |
|
194 |
{ |
|
195 |
_setexecattr(); |
|
196 |
} |
|
197 |
||
198 |
||
199 |
void |
|
200 |
endexecattr() |
|
201 |
{ |
|
202 |
_endexecattr(); |
|
203 |
} |
|
204 |
||
205 |
||
206 |
void |
|
207 |
free_execattr(execattr_t *exec) |
|
208 |
{ |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
209 |
if (exec != NULL) { |
0 | 210 |
free(exec->name); |
211 |
free(exec->type); |
|
212 |
free(exec->policy); |
|
213 |
free(exec->res1); |
|
214 |
free(exec->res2); |
|
215 |
free(exec->id); |
|
216 |
_kva_free(exec->attr); |
|
217 |
free_execattr(exec->next); |
|
218 |
free(exec); |
|
219 |
} |
|
220 |
} |
|
221 |
||
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
222 |
typedef struct call { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
223 |
const char *type; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
224 |
const char *id; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
225 |
int sflag; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
226 |
} call; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
227 |
|
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
228 |
typedef struct result { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
229 |
execattr_t *head; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
230 |
execattr_t *prev; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
231 |
} result; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
232 |
|
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
233 |
/*ARGSUSED*/ |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
234 |
static int |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
235 |
findexecattr(const char *prof, kva_t *kva, void *ctxt, void *res) |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
236 |
{ |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
237 |
execattr_t *exec; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
238 |
call *c = ctxt; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
239 |
result *r = res; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
240 |
|
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
241 |
if ((exec = getexecprof(prof, c->type, c->id, c->sflag)) != NULL) { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
242 |
if (IS_GET_ONE(c->sflag)) { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
243 |
r->head = exec; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
244 |
return (1); |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
245 |
} else if (IS_GET_ALL(c->sflag)) { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
246 |
if (r->head == NULL) { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
247 |
r->head = exec; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
248 |
r->prev = get_tail(r->head); |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
249 |
} else { |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
250 |
r->prev->next = exec; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
251 |
r->prev = get_tail(exec); |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
252 |
} |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
253 |
} |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
254 |
} |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
255 |
return (0); |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
256 |
} |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
257 |
|
0 | 258 |
|
259 |
static execattr_t * |
|
260 |
userprof(const char *username, const char *type, const char *id, |
|
261 |
int search_flag) |
|
262 |
{ |
|
263 |
||
264 |
char pwdb[NSS_BUFLEN_PASSWD]; |
|
265 |
struct passwd pwd; |
|
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
266 |
call call; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
267 |
result result; |
0 | 268 |
|
269 |
/* |
|
270 |
* Check if specified username is valid user |
|
271 |
*/ |
|
272 |
if (getpwnam_r(username, &pwd, pwdb, sizeof (pwdb)) == NULL) { |
|
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
273 |
return (NULL); |
0 | 274 |
} |
275 |
||
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
276 |
result.head = result.prev = NULL; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
277 |
call.type = type; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
278 |
call.id = id; |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
279 |
call.sflag = search_flag; |
0 | 280 |
|
12273
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
281 |
(void) _enum_profs(username, findexecattr, &call, &result); |
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
282 |
|
63678502e95e
PSARC 2009/377 In-kernel pfexec implementation.
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents:
10020
diff
changeset
|
283 |
return (result.head); |
0 | 284 |
} |
285 |
||
286 |
||
287 |
static execattr_t * |
|
288 |
get_tail(execattr_t *exec) |
|
289 |
{ |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
290 |
execattr_t *i_exec = NULL; |
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
291 |
execattr_t *j_exec = NULL; |
0 | 292 |
|
293 |
if (exec != NULL) { |
|
294 |
if (exec->next == NULL) { |
|
295 |
j_exec = exec; |
|
296 |
} else { |
|
297 |
for (i_exec = exec->next; i_exec != NULL; |
|
298 |
i_exec = i_exec->next) { |
|
299 |
j_exec = i_exec; |
|
300 |
} |
|
301 |
} |
|
302 |
} |
|
303 |
||
304 |
return (j_exec); |
|
305 |
} |
|
306 |
||
307 |
||
308 |
static execattr_t * |
|
309 |
execstr2attr(execstr_t *es) |
|
310 |
{ |
|
311 |
execattr_t *newexec; |
|
312 |
||
313 |
if (es == NULL) { |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
314 |
return (NULL); |
0 | 315 |
} |
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
316 |
if ((newexec = malloc(sizeof (execattr_t))) == NULL) { |
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
317 |
return (NULL); |
0 | 318 |
} |
319 |
||
320 |
newexec->name = _do_unescape(es->name); |
|
321 |
newexec->policy = _do_unescape(es->policy); |
|
322 |
newexec->type = _do_unescape(es->type); |
|
323 |
newexec->res1 = _do_unescape(es->res1); |
|
324 |
newexec->res2 = _do_unescape(es->res2); |
|
325 |
newexec->id = _do_unescape(es->id); |
|
326 |
newexec->attr = _str2kva(es->attr, KV_ASSIGN, KV_DELIMITER); |
|
327 |
if (es->next) { |
|
328 |
newexec->next = execstr2attr((execstr_t *)(es->next)); |
|
329 |
} else { |
|
6059
6f4d284e50d9
PSARC/2008/034 Defining Workstation Owner Infrastructure
gww
parents:
2830
diff
changeset
|
330 |
newexec->next = NULL; |
0 | 331 |
} |
332 |
return (newexec); |
|
333 |
} |
|
334 |
||
335 |
#ifdef DEBUG |
|
336 |
void |
|
337 |
print_execattr(execattr_t *exec) |
|
338 |
{ |
|
339 |
extern void print_kva(kva_t *); |
|
340 |
char *empty = "empty"; |
|
341 |
||
342 |
if (exec != NULL) { |
|
343 |
printf("name=%s\n", exec->name ? exec->name : empty); |
|
344 |
printf("policy=%s\n", exec->policy ? exec->policy : empty); |
|
345 |
printf("type=%s\n", exec->type ? exec->type : empty); |
|
346 |
printf("res1=%s\n", exec->res1 ? exec->res1 : empty); |
|
347 |
printf("res2=%s\n", exec->res2 ? exec->res2 : empty); |
|
348 |
printf("id=%s\n", exec->id ? exec->id : empty); |
|
349 |
printf("attr=\n"); |
|
350 |
print_kva(exec->attr); |
|
351 |
fflush(stdout); |
|
352 |
if (exec->next) { |
|
353 |
print_execattr(exec->next); |
|
354 |
} |
|
355 |
} else { |
|
356 |
printf("NULL\n"); |
|
357 |
} |
|
358 |
} |
|
359 |
#endif /* DEBUG */ |