xref: /titanic_41/usr/src/head/libzonecfg.h (revision 989f28072d20c73ae0955d6a1e3e2fc74831cb39)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
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 
22 /*
23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _LIBZONECFG_H
27 #define	_LIBZONECFG_H
28 
29 /*
30  * Zone configuration header file.
31  */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /* sys/socket.h is required by net/if.h, which has a constant needed here */
38 #include <sys/param.h>
39 #include <sys/fstyp.h>
40 #include <sys/mount.h>
41 #include <priv.h>
42 #include <netinet/in.h>
43 #include <sys/socket.h>
44 #include <net/if.h>
45 #include <stdio.h>
46 #include <rctl.h>
47 #include <zone.h>
48 #include <libbrand.h>
49 #include <sys/uuid.h>
50 #include <libuutil.h>
51 #include <sys/mnttab.h>
52 #include <limits.h>
53 #include <utmpx.h>
54 
55 #define	ZONE_ID_UNDEFINED	-1
56 
57 #define	Z_OK			0
58 #define	Z_EMPTY_DOCUMENT	1	/* XML doc root element is null */
59 #define	Z_WRONG_DOC_TYPE	2	/* top-level XML doc element != zone */
60 #define	Z_BAD_PROPERTY		3	/* libxml-level property problem */
61 #define	Z_TEMP_FILE		4	/* problem creating temporary file */
62 #define	Z_SAVING_FILE		5	/* libxml error saving or validating */
63 #define	Z_NO_ENTRY		6	/* no such entry */
64 #define	Z_BOGUS_ZONE_NAME	7	/* illegal zone name */
65 #define	Z_REQD_RESOURCE_MISSING	8	/* required resource missing */
66 #define	Z_REQD_PROPERTY_MISSING	9	/* required property missing */
67 #define	Z_BAD_HANDLE		10	/* bad document handle */
68 #define	Z_NOMEM			11	/* out of memory (like ENOMEM) */
69 #define	Z_INVAL			12	/* invalid argument (like EINVAL) */
70 #define	Z_ACCES			13	/* permission denied (like EACCES) */
71 #define	Z_TOO_BIG		14	/* string won't fit in char array */
72 #define	Z_MISC_FS		15	/* miscellaneous file-system error */
73 #define	Z_NO_ZONE		16	/* no such zone */
74 #define	Z_NO_RESOURCE_TYPE	17	/* no/wrong resource type */
75 #define	Z_NO_RESOURCE_ID	18	/* no/wrong resource id */
76 #define	Z_NO_PROPERTY_TYPE	19	/* no/wrong property type */
77 #define	Z_NO_PROPERTY_ID	20	/* no/wrong property id */
78 #define	Z_BAD_ZONE_STATE	21	/* zone state invalid for given task */
79 #define	Z_INVALID_DOCUMENT	22	/* libxml can't validate against DTD */
80 #define	Z_NAME_IN_USE		23	/* zone name already in use (rename) */
81 #define	Z_NO_SUCH_ID		24	/* delete_index: no old ID */
82 #define	Z_UPDATING_INDEX	25	/* add/modify/delete_index problem */
83 #define	Z_LOCKING_FILE		26	/* problem locking index file */
84 #define	Z_UNLOCKING_FILE	27	/* problem unlocking index file */
85 #define	Z_SYSTEM		28	/* consult errno instead */
86 #define	Z_INSUFFICIENT_SPEC	29	/* resource insufficiently specified */
87 #define	Z_RESOLVED_PATH		34	/* resolved path mismatch */
88 #define	Z_IPV6_ADDR_PREFIX_LEN	35	/* IPv6 address prefix length needed */
89 #define	Z_BOGUS_ADDRESS		36	/* not IPv[4|6] address or host name */
90 #define	Z_PRIV_PROHIBITED	37	/* specified privilege is prohibited */
91 #define	Z_PRIV_REQUIRED		38	/* required privilege is missing */
92 #define	Z_PRIV_UNKNOWN		39	/* specified privilege is unknown */
93 #define	Z_BRAND_ERROR		40	/* brand-specific error */
94 #define	Z_INCOMPATIBLE		41	/* incompatible settings */
95 #define	Z_ALIAS_DISALLOW	42	/* rctl alias disallowed */
96 #define	Z_CLEAR_DISALLOW	43	/* clear property disallowed */
97 #define	Z_POOL			44	/* generic libpool error */
98 #define	Z_POOLS_NOT_ACTIVE	45	/* pool service not enabled */
99 #define	Z_POOL_ENABLE		46	/* pools enable failed */
100 #define	Z_NO_POOL		47	/* no such pool configured */
101 #define	Z_POOL_CREATE		48	/* pool create failed */
102 #define	Z_POOL_BIND		49	/* pool bind failed */
103 #define	Z_INVALID_PROPERTY	50	/* invalid property value */
104 
105 /*
106  * Warning: these are shared with the admin/install consolidation.
107  * Do not insert states between any of the currently defined states,
108  * and any new states must be evaluated for impact on range comparisons.
109  */
110 #define	ZONE_STATE_CONFIGURED		0
111 #define	ZONE_STATE_INCOMPLETE		1
112 #define	ZONE_STATE_INSTALLED		2
113 #define	ZONE_STATE_READY		3
114 #define	ZONE_STATE_RUNNING		4
115 #define	ZONE_STATE_SHUTTING_DOWN	5
116 #define	ZONE_STATE_DOWN			6
117 #define	ZONE_STATE_MOUNTED		7
118 
119 #define	ZONE_STATE_MAXSTRLEN	14
120 
121 #define	LIBZONECFG_PATH		"libzonecfg.so.1"
122 
123 #define	ZONE_CONFIG_ROOT	"/etc/zones"
124 #define	ZONE_INDEX_FILE		ZONE_CONFIG_ROOT "/index"
125 
126 #define	MAXUSERNAME		(sizeof (((struct utmpx *)0)->ut_name))
127 #define	MAXAUTHS		4096
128 #define	ZONE_MGMT_PROF		"Zone Management"
129 
130 /* Owner, group, and mode (defined by packaging) for the config directory */
131 #define	ZONE_CONFIG_UID		0		/* root */
132 #define	ZONE_CONFIG_GID		3		/* sys */
133 #define	ZONE_CONFIG_MODE	0755
134 
135 /* Owner, group, and mode (defined by packaging) for the index file */
136 #define	ZONE_INDEX_UID		0		/* root */
137 #define	ZONE_INDEX_GID		3		/* sys */
138 #define	ZONE_INDEX_MODE		0644
139 
140 /* The maximum length of the VERSION string in the pkginfo(4) file. */
141 #define	ZONE_PKG_VERSMAX	256
142 
143 /*
144  * Shortened alias names for the zones rctls.
145  */
146 #define	ALIAS_MAXLWPS		"max-lwps"
147 #define	ALIAS_MAXSHMMEM		"max-shm-memory"
148 #define	ALIAS_MAXSHMIDS		"max-shm-ids"
149 #define	ALIAS_MAXMSGIDS		"max-msg-ids"
150 #define	ALIAS_MAXSEMIDS		"max-sem-ids"
151 #define	ALIAS_MAXLOCKEDMEM	"locked"
152 #define	ALIAS_MAXSWAP		"swap"
153 #define	ALIAS_SHARES		"cpu-shares"
154 #define	ALIAS_CPUCAP		"cpu-cap"
155 #define	ALIAS_MAXPROCS		"max-processes"
156 
157 /* Default name for zone detached manifest */
158 #define	ZONE_DETACHED	"SUNWdetached.xml"
159 
160 /*
161  * Bit flag definitions for passing into libzonecfg functions.
162  */
163 #define	ZONE_DRY_RUN		0x01
164 
165 /*
166  * The integer field expresses the current values on a get.
167  * On a put, it represents the new values if >= 0 or "don't change" if < 0.
168  */
169 struct zoneent {
170 	char	zone_name[ZONENAME_MAX];	/* name of the zone */
171 	int	zone_state;	/* configured | incomplete | installed */
172 	char	zone_path[MAXPATHLEN];		/* path to zone storage */
173 	uuid_t	zone_uuid;			/* unique ID for zone */
174 	char	zone_newname[ZONENAME_MAX];	/* for doing renames */
175 };
176 
177 typedef struct zone_dochandle *zone_dochandle_t;	/* opaque handle */
178 
179 typedef uint_t zone_state_t;
180 
181 typedef struct zone_fsopt {
182 	struct zone_fsopt *zone_fsopt_next;
183 	char		   zone_fsopt_opt[MAX_MNTOPT_STR];
184 } zone_fsopt_t;
185 
186 struct zone_fstab {
187 	char		zone_fs_special[MAXPATHLEN]; 	/* special file */
188 	char		zone_fs_dir[MAXPATHLEN];	/* mount point */
189 	char		zone_fs_type[FSTYPSZ];		/* e.g. ufs */
190 	zone_fsopt_t   *zone_fs_options;		/* mount options */
191 	char		zone_fs_raw[MAXPATHLEN];	/* device to fsck */
192 };
193 
194 struct zone_nwiftab {
195 	char	zone_nwif_address[INET6_ADDRSTRLEN]; /* shared-ip only */
196 	char	zone_nwif_allowed_address[INET6_ADDRSTRLEN]; /* excl-ip only */
197 	char	zone_nwif_physical[LIFNAMSIZ];
198 	char	zone_nwif_defrouter[INET6_ADDRSTRLEN];
199 };
200 
201 struct zone_devtab {
202 	char	zone_dev_match[MAXPATHLEN];
203 };
204 
205 struct zone_rctlvaltab {
206 	char	zone_rctlval_priv[MAXNAMELEN];
207 	char	zone_rctlval_limit[MAXNAMELEN];
208 	char	zone_rctlval_action[MAXNAMELEN];
209 	struct zone_rctlvaltab *zone_rctlval_next;
210 };
211 
212 struct zone_rctltab {
213 	char	zone_rctl_name[MAXNAMELEN];
214 	struct zone_rctlvaltab *zone_rctl_valptr;
215 };
216 
217 struct zone_attrtab {
218 	char	zone_attr_name[MAXNAMELEN];
219 	char	zone_attr_type[MAXNAMELEN];
220 	char	zone_attr_value[2 * BUFSIZ];
221 };
222 
223 struct zone_dstab {
224 	char	zone_dataset_name[MAXNAMELEN];
225 };
226 
227 struct zone_psettab {
228 	char	zone_ncpu_min[MAXNAMELEN];
229 	char	zone_ncpu_max[MAXNAMELEN];
230 	char	zone_importance[MAXNAMELEN];
231 };
232 
233 struct zone_mcaptab {
234 	char	zone_physmem_cap[MAXNAMELEN];
235 };
236 
237 struct zone_pkgtab {
238 	char	zone_pkg_name[MAXNAMELEN];
239 	char	zone_pkg_version[ZONE_PKG_VERSMAX];
240 };
241 
242 struct zone_devpermtab {
243 	char	zone_devperm_name[MAXPATHLEN];
244 	uid_t	zone_devperm_uid;
245 	gid_t	zone_devperm_gid;
246 	mode_t	zone_devperm_mode;
247 	char	*zone_devperm_acl;
248 };
249 
250 struct zone_admintab {
251 	char	zone_admin_user[MAXUSERNAME];
252 	char	zone_admin_auths[MAXAUTHS];
253 };
254 
255 typedef struct zone_userauths {
256 	char			user[MAXUSERNAME];
257 	char			zonename[ZONENAME_MAX];
258 	struct zone_userauths	*next;
259 } zone_userauths_t;
260 
261 typedef struct {
262 	uu_avl_node_t	zpe_entry;
263 	char		*zpe_name;
264 	char		*zpe_vers;
265 } zone_pkg_entry_t;
266 
267 typedef enum zone_iptype {
268 	ZS_SHARED,
269 	ZS_EXCLUSIVE
270 } zone_iptype_t;
271 
272 /*
273  * Basic configuration management routines.
274  */
275 extern	zone_dochandle_t	zonecfg_init_handle(void);
276 extern	int	zonecfg_get_handle(const char *, zone_dochandle_t);
277 extern	int	zonecfg_get_snapshot_handle(const char *, zone_dochandle_t);
278 extern	int	zonecfg_get_template_handle(const char *, const char *,
279     zone_dochandle_t);
280 extern	int	zonecfg_get_xml_handle(const char *, zone_dochandle_t);
281 extern	int	zonecfg_check_handle(zone_dochandle_t);
282 extern	void	zonecfg_fini_handle(zone_dochandle_t);
283 extern	int	zonecfg_destroy(const char *, boolean_t);
284 extern	int	zonecfg_destroy_snapshot(const char *);
285 extern	int	zonecfg_save(zone_dochandle_t);
286 extern	int	zonecfg_create_snapshot(const char *);
287 extern	char	*zonecfg_strerror(int);
288 extern	int	zonecfg_access(const char *, int);
289 extern	void	zonecfg_set_root(const char *);
290 extern	const char *zonecfg_get_root(void);
291 extern	boolean_t zonecfg_in_alt_root(void);
292 extern	int	zonecfg_num_resources(zone_dochandle_t, char *);
293 extern	int	zonecfg_del_all_resources(zone_dochandle_t, char *);
294 extern	boolean_t zonecfg_valid_ncpus(char *, char *);
295 extern	boolean_t zonecfg_valid_importance(char *);
296 extern	int	zonecfg_str_to_bytes(char *, uint64_t *);
297 extern	boolean_t zonecfg_valid_memlimit(char *, uint64_t *);
298 extern	boolean_t zonecfg_valid_alias_limit(char *, char *, uint64_t *);
299 
300 /*
301  * Zone name, path to zone directory, autoboot setting, pool, boot
302  * arguments, and scheduling-class.
303  */
304 extern	int	zonecfg_validate_zonename(const char *);
305 extern	int	zonecfg_get_name(zone_dochandle_t, char *, size_t);
306 extern	int	zonecfg_set_name(zone_dochandle_t, char *);
307 extern	int	zonecfg_get_zonepath(zone_dochandle_t, char *, size_t);
308 extern	int	zonecfg_set_zonepath(zone_dochandle_t, char *);
309 extern	int	zonecfg_get_autoboot(zone_dochandle_t, boolean_t *);
310 extern	int	zonecfg_set_autoboot(zone_dochandle_t, boolean_t);
311 extern	int	zonecfg_get_iptype(zone_dochandle_t, zone_iptype_t *);
312 extern	int	zonecfg_set_iptype(zone_dochandle_t, zone_iptype_t);
313 extern	int	zonecfg_get_pool(zone_dochandle_t, char *, size_t);
314 extern	int	zonecfg_set_pool(zone_dochandle_t, char *);
315 extern	int	zonecfg_get_bootargs(zone_dochandle_t, char *, size_t);
316 extern	int	zonecfg_set_bootargs(zone_dochandle_t, char *);
317 extern	int	zonecfg_get_sched_class(zone_dochandle_t, char *, size_t);
318 extern	int	zonecfg_set_sched(zone_dochandle_t, char *);
319 extern	int	zonecfg_get_dflt_sched_class(zone_dochandle_t, char *, int);
320 
321 /*
322  * Set/retrieve the brand for the zone
323  */
324 extern	int	zonecfg_get_brand(zone_dochandle_t, char *, size_t);
325 extern	int	zonecfg_set_brand(zone_dochandle_t, char *);
326 
327 /*
328  * Filesystem configuration.
329  */
330 extern	int	zonecfg_add_filesystem(zone_dochandle_t, struct zone_fstab *);
331 extern	int	zonecfg_delete_filesystem(zone_dochandle_t,
332     struct zone_fstab *);
333 extern	int	zonecfg_modify_filesystem(zone_dochandle_t,
334     struct zone_fstab *, struct zone_fstab *);
335 extern	int	zonecfg_lookup_filesystem(zone_dochandle_t,
336     struct zone_fstab *);
337 extern	int	zonecfg_add_fs_option(struct zone_fstab *, char *);
338 extern	int	zonecfg_remove_fs_option(struct zone_fstab *, char *);
339 extern	void	zonecfg_free_fs_option_list(zone_fsopt_t *);
340 extern	int 	zonecfg_find_mounts(char *, int(*)(const struct mnttab *,
341     void *), void *);
342 
343 /*
344  * Network interface configuration.
345  */
346 extern	int	zonecfg_add_nwif(zone_dochandle_t, struct zone_nwiftab *);
347 extern	int	zonecfg_delete_nwif(zone_dochandle_t, struct zone_nwiftab *);
348 extern	int	zonecfg_modify_nwif(zone_dochandle_t, struct zone_nwiftab *,
349     struct zone_nwiftab *);
350 extern	int	zonecfg_lookup_nwif(zone_dochandle_t, struct zone_nwiftab *);
351 
352 /*
353  * Hostid emulation configuration.
354  */
355 extern	int	zonecfg_get_hostid(zone_dochandle_t, char *, size_t);
356 extern	int	zonecfg_set_hostid(zone_dochandle_t, const char *);
357 
358 /*
359  * Allowed FS mounts configuration.
360  */
361 extern int	zonecfg_get_fs_allowed(zone_dochandle_t, char *, size_t);
362 extern int	zonecfg_set_fs_allowed(zone_dochandle_t, const char *);
363 
364 /*
365  * Device configuration and rule matching.
366  */
367 extern	int	zonecfg_add_dev(zone_dochandle_t, struct zone_devtab *);
368 extern	int	zonecfg_delete_dev(zone_dochandle_t, struct zone_devtab *);
369 extern	int	zonecfg_modify_dev(zone_dochandle_t, struct zone_devtab *,
370     struct zone_devtab *);
371 extern	int	zonecfg_lookup_dev(zone_dochandle_t, struct zone_devtab *);
372 
373 /*
374  * Resource control configuration.
375  */
376 extern	int	zonecfg_add_rctl(zone_dochandle_t, struct zone_rctltab *);
377 extern	int	zonecfg_delete_rctl(zone_dochandle_t, struct zone_rctltab *);
378 extern	int	zonecfg_modify_rctl(zone_dochandle_t, struct zone_rctltab *,
379     struct zone_rctltab *);
380 extern	int	zonecfg_lookup_rctl(zone_dochandle_t, struct zone_rctltab *);
381 extern	int	zonecfg_add_rctl_value(struct zone_rctltab *,
382     struct zone_rctlvaltab *);
383 extern	int	zonecfg_remove_rctl_value(struct zone_rctltab *,
384     struct zone_rctlvaltab *);
385 extern	void	zonecfg_free_rctl_value_list(struct zone_rctlvaltab *);
386 extern	boolean_t zonecfg_aliased_rctl_ok(zone_dochandle_t, char *);
387 extern	int	zonecfg_set_aliased_rctl(zone_dochandle_t, char *, uint64_t);
388 extern	int	zonecfg_get_aliased_rctl(zone_dochandle_t, char *, uint64_t *);
389 extern	int	zonecfg_rm_aliased_rctl(zone_dochandle_t, char *);
390 extern	int	zonecfg_apply_rctls(char *, zone_dochandle_t);
391 
392 /*
393  * Generic attribute configuration and type/value extraction.
394  */
395 extern	int	zonecfg_add_attr(zone_dochandle_t, struct zone_attrtab *);
396 extern	int	zonecfg_delete_attr(zone_dochandle_t, struct zone_attrtab *);
397 extern	int	zonecfg_modify_attr(zone_dochandle_t, struct zone_attrtab *,
398     struct zone_attrtab *);
399 extern	int	zonecfg_lookup_attr(zone_dochandle_t, struct zone_attrtab *);
400 extern	int	zonecfg_get_attr_boolean(const struct zone_attrtab *,
401     boolean_t *);
402 extern	int	zonecfg_get_attr_int(const struct zone_attrtab *, int64_t *);
403 extern	int	zonecfg_get_attr_string(const struct zone_attrtab *, char *,
404     size_t);
405 extern	int	zonecfg_get_attr_uint(const struct zone_attrtab *, uint64_t *);
406 
407 /*
408  * ZFS configuration.
409  */
410 extern	int	zonecfg_add_ds(zone_dochandle_t, struct zone_dstab *);
411 extern	int	zonecfg_delete_ds(zone_dochandle_t, struct zone_dstab *);
412 extern	int	zonecfg_modify_ds(zone_dochandle_t, struct zone_dstab *,
413     struct zone_dstab *);
414 extern	int	zonecfg_lookup_ds(zone_dochandle_t, struct zone_dstab *);
415 
416 /*
417  * cpu-set configuration.
418  */
419 extern	int	zonecfg_add_pset(zone_dochandle_t, struct zone_psettab *);
420 extern	int	zonecfg_delete_pset(zone_dochandle_t);
421 extern	int	zonecfg_modify_pset(zone_dochandle_t, struct zone_psettab *);
422 extern	int	zonecfg_lookup_pset(zone_dochandle_t, struct zone_psettab *);
423 
424 /*
425  * mem-cap configuration.
426  */
427 extern	int	zonecfg_delete_mcap(zone_dochandle_t);
428 extern	int	zonecfg_modify_mcap(zone_dochandle_t, struct zone_mcaptab *);
429 extern	int	zonecfg_lookup_mcap(zone_dochandle_t, struct zone_mcaptab *);
430 
431 /*
432  * Temporary pool support functions.
433  */
434 extern	int	zonecfg_destroy_tmp_pool(char *, char *, int);
435 extern	int	zonecfg_bind_tmp_pool(zone_dochandle_t, zoneid_t, char *, int);
436 extern	int	zonecfg_bind_pool(zone_dochandle_t, zoneid_t, char *, int);
437 extern	boolean_t zonecfg_warn_poold(zone_dochandle_t);
438 extern	int	zonecfg_get_poolname(zone_dochandle_t, char *, char *, size_t);
439 
440 /*
441  * Miscellaneous utility functions.
442  */
443 extern	int	zonecfg_enable_rcapd(char *, int);
444 
445 /*
446  * attach/detach support.
447  */
448 extern	int	zonecfg_get_attach_handle(const char *, const char *,
449     const char *, boolean_t, zone_dochandle_t);
450 extern	int	zonecfg_attach_manifest(int, zone_dochandle_t,
451     zone_dochandle_t);
452 extern	int	zonecfg_detach_save(zone_dochandle_t, uint_t);
453 extern	boolean_t zonecfg_detached(const char *);
454 extern	void	zonecfg_rm_detached(zone_dochandle_t, boolean_t forced);
455 extern	int	zonecfg_dev_manifest(zone_dochandle_t);
456 extern	int	zonecfg_devperms_apply(zone_dochandle_t, const char *,
457     uid_t, gid_t, mode_t, const char *);
458 extern	void	zonecfg_set_swinv(zone_dochandle_t);
459 extern	int	zonecfg_add_pkg(zone_dochandle_t, char *, char *);
460 
461 /*
462  * External zone verification support.
463  */
464 extern	int	zonecfg_verify_save(zone_dochandle_t, char *);
465 
466 /*
467  * '*ent' iterator routines.
468  */
469 extern	int	zonecfg_setfsent(zone_dochandle_t);
470 extern	int	zonecfg_getfsent(zone_dochandle_t, struct zone_fstab *);
471 extern	int	zonecfg_endfsent(zone_dochandle_t);
472 extern	int	zonecfg_setnwifent(zone_dochandle_t);
473 extern	int	zonecfg_getnwifent(zone_dochandle_t, struct zone_nwiftab *);
474 extern	int	zonecfg_endnwifent(zone_dochandle_t);
475 extern	int	zonecfg_setdevent(zone_dochandle_t);
476 extern	int	zonecfg_getdevent(zone_dochandle_t, struct zone_devtab *);
477 extern	int	zonecfg_enddevent(zone_dochandle_t);
478 extern	int	zonecfg_setattrent(zone_dochandle_t);
479 extern	int	zonecfg_getattrent(zone_dochandle_t, struct zone_attrtab *);
480 extern	int	zonecfg_endattrent(zone_dochandle_t);
481 extern	int	zonecfg_setrctlent(zone_dochandle_t);
482 extern	int	zonecfg_getrctlent(zone_dochandle_t, struct zone_rctltab *);
483 extern	int	zonecfg_endrctlent(zone_dochandle_t);
484 extern	int	zonecfg_setdsent(zone_dochandle_t);
485 extern	int	zonecfg_getdsent(zone_dochandle_t, struct zone_dstab *);
486 extern	int	zonecfg_enddsent(zone_dochandle_t);
487 extern	int	zonecfg_getpsetent(zone_dochandle_t, struct zone_psettab *);
488 extern	int	zonecfg_getmcapent(zone_dochandle_t, struct zone_mcaptab *);
489 extern	int	zonecfg_getpkgdata(zone_dochandle_t, uu_avl_pool_t *,
490     uu_avl_t *);
491 extern	int	zonecfg_setdevperment(zone_dochandle_t);
492 extern	int	zonecfg_getdevperment(zone_dochandle_t,
493     struct zone_devpermtab *);
494 extern	int	zonecfg_enddevperment(zone_dochandle_t);
495 extern	int	zonecfg_setadminent(zone_dochandle_t);
496 extern	int	zonecfg_getadminent(zone_dochandle_t, struct zone_admintab *);
497 extern	int	zonecfg_endadminent(zone_dochandle_t);
498 
499 /*
500  * Privilege-related functions.
501  */
502 extern	int	zonecfg_default_privset(priv_set_t *, const char *);
503 extern	int	zonecfg_get_privset(zone_dochandle_t, priv_set_t *,
504     char **);
505 extern	int	zonecfg_get_limitpriv(zone_dochandle_t, char **);
506 extern	int	zonecfg_set_limitpriv(zone_dochandle_t, char *);
507 
508 /*
509  * Higher-level routines.
510  */
511 extern  int	zone_get_brand(char *, char *, size_t);
512 extern	int	zone_get_rootpath(char *, char *, size_t);
513 extern	int	zone_get_devroot(char *, char *, size_t);
514 extern	int	zone_get_zonepath(char *, char *, size_t);
515 extern	int	zone_get_state(char *, zone_state_t *);
516 extern	int	zone_set_state(char *, zone_state_t);
517 extern	char	*zone_state_str(zone_state_t);
518 extern	int	zonecfg_get_name_by_uuid(const uuid_t, char *, size_t);
519 extern	int	zonecfg_get_uuid(const char *, uuid_t);
520 extern	int	zonecfg_default_brand(char *, size_t);
521 
522 /*
523  * Iterator for configured zones.
524  */
525 extern FILE		*setzoneent(void);
526 extern char		*getzoneent(FILE *);
527 extern struct zoneent	*getzoneent_private(FILE *);
528 extern void		endzoneent(FILE *);
529 
530 /*
531  * File-system-related convenience functions.
532  */
533 extern boolean_t zonecfg_valid_fs_type(const char *);
534 
535 /*
536  * Network-related convenience functions.
537  */
538 extern boolean_t zonecfg_same_net_address(char *, char *);
539 extern int zonecfg_valid_net_address(char *, struct lifreq *);
540 extern boolean_t zonecfg_ifname_exists(sa_family_t, char *);
541 
542 /*
543  * Rctl-related common functions.
544  */
545 extern boolean_t zonecfg_is_rctl(const char *);
546 extern boolean_t zonecfg_valid_rctlname(const char *);
547 extern boolean_t zonecfg_valid_rctlblk(const rctlblk_t *);
548 extern boolean_t zonecfg_valid_rctl(const char *, const rctlblk_t *);
549 extern int zonecfg_construct_rctlblk(const struct zone_rctlvaltab *,
550     rctlblk_t *);
551 
552 /*
553  * Live Upgrade support functions.  Shared between ON and install gate.
554  */
555 extern FILE *zonecfg_open_scratch(const char *, boolean_t);
556 extern int zonecfg_lock_scratch(FILE *);
557 extern void zonecfg_close_scratch(FILE *);
558 extern int zonecfg_get_scratch(FILE *, char *, size_t, char *, size_t, char *,
559     size_t);
560 extern int zonecfg_find_scratch(FILE *, const char *, const char *, char *,
561     size_t);
562 extern int zonecfg_reverse_scratch(FILE *, const char *, char *, size_t,
563     char *, size_t);
564 extern int zonecfg_add_scratch(FILE *, const char *, const char *,
565     const char *);
566 extern int zonecfg_delete_scratch(FILE *, const char *);
567 extern boolean_t zonecfg_is_scratch(const char *);
568 
569 /*
570  * zoneadmd support functions.  Shared between zoneadm and brand hook code.
571  */
572 extern void zonecfg_init_lock_file(const char *, char **);
573 extern void zonecfg_release_lock_file(const char *, int);
574 extern int zonecfg_grab_lock_file(const char *, int *);
575 extern boolean_t zonecfg_lock_file_held(int *);
576 extern int zonecfg_ping_zoneadmd(const char *);
577 extern int zonecfg_call_zoneadmd(const char *, zone_cmd_arg_t *, char *,
578     boolean_t);
579 extern int zonecfg_insert_userauths(zone_dochandle_t, char *, char *);
580 extern int zonecfg_remove_userauths(zone_dochandle_t, char *, char *,
581     boolean_t);
582 extern int zonecfg_add_admin(zone_dochandle_t, struct zone_admintab *,
583     char *);
584 extern int zonecfg_delete_admin(zone_dochandle_t,
585     struct zone_admintab *, char *);
586 extern int zonecfg_modify_admin(zone_dochandle_t, struct zone_admintab *,
587     struct zone_admintab *, char *);
588 extern int zonecfg_delete_admins(zone_dochandle_t, char *);
589 extern int zonecfg_lookup_admin(zone_dochandle_t, struct zone_admintab *);
590 extern int zonecfg_authorize_users(zone_dochandle_t, char *);
591 extern int zonecfg_update_userauths(zone_dochandle_t, char *);
592 extern int zonecfg_deauthorize_user(zone_dochandle_t, char *, char *);
593 extern int zonecfg_deauthorize_users(zone_dochandle_t, char *);
594 extern boolean_t zonecfg_valid_auths(const char *, const char *);
595 
596 #ifdef __cplusplus
597 }
598 #endif
599 
600 #endif	/* _LIBZONECFG_H */
601