vplat.c (ea8dc4b6d2251b437950c0056bc626b311c73c27) | vplat.c (ffbafc5382b8d46def826aec8c419ad31dff8ebd) |
---|---|
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 --- 4 unchanged lines hidden (view full) --- 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 */ | 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 --- 4 unchanged lines hidden (view full) --- 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 |
|
21/* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28/* --- 1302 unchanged lines hidden (view full) --- 1331 } 1332 1333 if (zone_get_rootpath(zone_name, rootpath, sizeof (rootpath)) != Z_OK) { 1334 zerror(zlogp, B_TRUE, "unable to determine zone root"); 1335 goto bad; 1336 } 1337 1338 if ((handle = zonecfg_init_handle()) == NULL) { | 22/* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29/* --- 1302 unchanged lines hidden (view full) --- 1332 } 1333 1334 if (zone_get_rootpath(zone_name, rootpath, sizeof (rootpath)) != Z_OK) { 1335 zerror(zlogp, B_TRUE, "unable to determine zone root"); 1336 goto bad; 1337 } 1338 1339 if ((handle = zonecfg_init_handle()) == NULL) { |
1339 zerror(zlogp, B_TRUE, 1340 "could not get zone configuration handle"); | 1340 zerror(zlogp, B_TRUE, "getting zone configuration handle"); |
1341 goto bad; 1342 } 1343 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK || 1344 zonecfg_setfsent(handle) != Z_OK) { 1345 zerror(zlogp, B_FALSE, "invalid configuration"); 1346 goto bad; 1347 } 1348 --- 901 unchanged lines hidden (view full) --- 2250 argv[0] = DEVFSADM; 2251 argv[1] = (char *)arg; 2252 argv[2] = zone_name; 2253 argv[3] = NULL; 2254 status = forkexec(zlogp, DEVFSADM_PATH, argv); 2255 if (status == 0 || status == -1) 2256 return (status); 2257 zerror(zlogp, B_FALSE, "%s call (%s %s %s) unexpectedly returned %d", | 1341 goto bad; 1342 } 1343 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK || 1344 zonecfg_setfsent(handle) != Z_OK) { 1345 zerror(zlogp, B_FALSE, "invalid configuration"); 1346 goto bad; 1347 } 1348 --- 901 unchanged lines hidden (view full) --- 2250 argv[0] = DEVFSADM; 2251 argv[1] = (char *)arg; 2252 argv[2] = zone_name; 2253 argv[3] = NULL; 2254 status = forkexec(zlogp, DEVFSADM_PATH, argv); 2255 if (status == 0 || status == -1) 2256 return (status); 2257 zerror(zlogp, B_FALSE, "%s call (%s %s %s) unexpectedly returned %d", |
2258 DEVFSADM, DEVFSADM_PATH, arg, zone_name, status); | 2258 DEVFSADM, DEVFSADM_PATH, arg, zone_name, status); |
2259 return (-1); 2260} 2261 2262static int 2263devfsadm_register(zlog_t *zlogp) 2264{ 2265 /* 2266 * Ready the zone's devices. 2267 */ 2268 return (devfsadm_call(zlogp, "-z")); 2269} 2270 2271static int 2272devfsadm_unregister(zlog_t *zlogp) 2273{ 2274 return (devfsadm_call(zlogp, "-Z")); 2275} 2276 2277static int | 2259 return (-1); 2260} 2261 2262static int 2263devfsadm_register(zlog_t *zlogp) 2264{ 2265 /* 2266 * Ready the zone's devices. 2267 */ 2268 return (devfsadm_call(zlogp, "-z")); 2269} 2270 2271static int 2272devfsadm_unregister(zlog_t *zlogp) 2273{ 2274 return (devfsadm_call(zlogp, "-Z")); 2275} 2276 2277static int |
2278get_privset(zlog_t *zlogp, priv_set_t *privs, boolean_t mount_cmd) 2279{ 2280 int error = -1; 2281 zone_dochandle_t handle; 2282 char *privname = NULL; 2283 2284 if (mount_cmd) { 2285 if (zonecfg_default_privset(privs) == Z_OK) 2286 return (0); 2287 zerror(zlogp, B_FALSE, 2288 "failed to determine the zone's default privilege set"); 2289 return (-1); 2290 } 2291 2292 if ((handle = zonecfg_init_handle()) == NULL) { 2293 zerror(zlogp, B_TRUE, "getting zone configuration handle"); 2294 return (-1); 2295 } 2296 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) { 2297 zerror(zlogp, B_FALSE, "invalid configuration"); 2298 zonecfg_fini_handle(handle); 2299 return (-1); 2300 } 2301 2302 switch (zonecfg_get_privset(handle, privs, &privname)) { 2303 case Z_OK: 2304 error = 0; 2305 break; 2306 case Z_PRIV_PROHIBITED: 2307 zerror(zlogp, B_FALSE, "privilege \"%s\" is not permitted " 2308 "within the zone's privilege set", privname); 2309 break; 2310 case Z_PRIV_REQUIRED: 2311 zerror(zlogp, B_FALSE, "required privilege \"%s\" is missing " 2312 "from the zone's privilege set", privname); 2313 break; 2314 case Z_PRIV_UNKNOWN: 2315 zerror(zlogp, B_FALSE, "unknown privilege \"%s\" specified " 2316 "in the zone's privilege set", privname); 2317 break; 2318 default: 2319 zerror(zlogp, B_FALSE, "failed to determine the zone's " 2320 "privilege set"); 2321 break; 2322 } 2323 2324 free(privname); 2325 zonecfg_fini_handle(handle); 2326 return (error); 2327} 2328 2329static int |
|
2278get_rctls(zlog_t *zlogp, char **bufp, size_t *bufsizep) 2279{ 2280 nvlist_t *nvl = NULL; 2281 char *nvl_packed = NULL; 2282 size_t nvl_size = 0; 2283 nvlist_t **nvlv = NULL; 2284 int rctlcount = 0; 2285 int error = -1; --- 73 unchanged lines hidden (view full) --- 2359 "valid value for rctl '%s'", 2360 rctlval->zone_rctlval_priv, 2361 rctlval->zone_rctlval_limit, 2362 rctlval->zone_rctlval_action, 2363 name); 2364 goto out; 2365 } 2366 if (nvlist_add_uint64(nvlv[i], "privilege", | 2330get_rctls(zlog_t *zlogp, char **bufp, size_t *bufsizep) 2331{ 2332 nvlist_t *nvl = NULL; 2333 char *nvl_packed = NULL; 2334 size_t nvl_size = 0; 2335 nvlist_t **nvlv = NULL; 2336 int rctlcount = 0; 2337 int error = -1; --- 73 unchanged lines hidden (view full) --- 2411 "valid value for rctl '%s'", 2412 rctlval->zone_rctlval_priv, 2413 rctlval->zone_rctlval_limit, 2414 rctlval->zone_rctlval_action, 2415 name); 2416 goto out; 2417 } 2418 if (nvlist_add_uint64(nvlv[i], "privilege", |
2367 rctlblk_get_privilege(rctlblk)) != 0) { | 2419 rctlblk_get_privilege(rctlblk)) != 0) { |
2368 zerror(zlogp, B_FALSE, "%s failed", 2369 "nvlist_add_uint64"); 2370 goto out; 2371 } 2372 if (nvlist_add_uint64(nvlv[i], "limit", | 2420 zerror(zlogp, B_FALSE, "%s failed", 2421 "nvlist_add_uint64"); 2422 goto out; 2423 } 2424 if (nvlist_add_uint64(nvlv[i], "limit", |
2373 rctlblk_get_value(rctlblk)) != 0) { | 2425 rctlblk_get_value(rctlblk)) != 0) { |
2374 zerror(zlogp, B_FALSE, "%s failed", 2375 "nvlist_add_uint64"); 2376 goto out; 2377 } 2378 if (nvlist_add_uint64(nvlv[i], "action", 2379 (uint_t)rctlblk_get_local_action(rctlblk, NULL)) 2380 != 0) { 2381 zerror(zlogp, B_FALSE, "%s failed", --- 48 unchanged lines hidden (view full) --- 2430static int 2431get_zone_pool(zlog_t *zlogp, char *poolbuf, size_t bufsz) 2432{ 2433 zone_dochandle_t handle; 2434 int error; 2435 2436 if ((handle = zonecfg_init_handle()) == NULL) { 2437 zerror(zlogp, B_TRUE, "getting zone configuration handle"); | 2426 zerror(zlogp, B_FALSE, "%s failed", 2427 "nvlist_add_uint64"); 2428 goto out; 2429 } 2430 if (nvlist_add_uint64(nvlv[i], "action", 2431 (uint_t)rctlblk_get_local_action(rctlblk, NULL)) 2432 != 0) { 2433 zerror(zlogp, B_FALSE, "%s failed", --- 48 unchanged lines hidden (view full) --- 2482static int 2483get_zone_pool(zlog_t *zlogp, char *poolbuf, size_t bufsz) 2484{ 2485 zone_dochandle_t handle; 2486 int error; 2487 2488 if ((handle = zonecfg_init_handle()) == NULL) { 2489 zerror(zlogp, B_TRUE, "getting zone configuration handle"); |
2438 return (-1); | 2490 return (Z_NOMEM); |
2439 } | 2491 } |
2440 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) { | 2492 error = zonecfg_get_snapshot_handle(zone_name, handle); 2493 if (error != Z_OK) { |
2441 zerror(zlogp, B_FALSE, "invalid configuration"); 2442 zonecfg_fini_handle(handle); | 2494 zerror(zlogp, B_FALSE, "invalid configuration"); 2495 zonecfg_fini_handle(handle); |
2443 return (-1); | 2496 return (error); |
2444 } 2445 error = zonecfg_get_pool(handle, poolbuf, bufsz); 2446 zonecfg_fini_handle(handle); 2447 return (error); 2448} 2449 2450static int 2451get_datasets(zlog_t *zlogp, char **bufp, size_t *bufsizep) --- 319 unchanged lines hidden (view full) --- 2771 if (zonecfg_in_alt_root()) 2772 resolve_lofs(zlogp, rootpath, sizeof (rootpath)); 2773 2774 if ((privs = priv_allocset()) == NULL) { 2775 zerror(zlogp, B_TRUE, "%s failed", "priv_allocset"); 2776 return (-1); 2777 } 2778 priv_emptyset(privs); | 2497 } 2498 error = zonecfg_get_pool(handle, poolbuf, bufsz); 2499 zonecfg_fini_handle(handle); 2500 return (error); 2501} 2502 2503static int 2504get_datasets(zlog_t *zlogp, char **bufp, size_t *bufsizep) --- 319 unchanged lines hidden (view full) --- 2824 if (zonecfg_in_alt_root()) 2825 resolve_lofs(zlogp, rootpath, sizeof (rootpath)); 2826 2827 if ((privs = priv_allocset()) == NULL) { 2828 zerror(zlogp, B_TRUE, "%s failed", "priv_allocset"); 2829 return (-1); 2830 } 2831 priv_emptyset(privs); |
2779 if (zonecfg_get_privset(privs) != Z_OK) { 2780 zerror(zlogp, B_TRUE, "Failed to initialize privileges"); | 2832 if (get_privset(zlogp, privs, mount_cmd) != 0) |
2781 goto error; | 2833 goto error; |
2782 } | 2834 |
2783 if (!mount_cmd && get_rctls(zlogp, &rctlbuf, &rctlbufsz) != 0) { 2784 zerror(zlogp, B_FALSE, "Unable to get list of rctls"); 2785 goto error; 2786 } | 2835 if (!mount_cmd && get_rctls(zlogp, &rctlbuf, &rctlbufsz) != 0) { 2836 zerror(zlogp, B_FALSE, "Unable to get list of rctls"); 2837 goto error; 2838 } |
2839 |
|
2787 if (get_datasets(zlogp, &zfsbuf, &zfsbufsz) != 0) { 2788 zerror(zlogp, B_FALSE, "Unable to get list of ZFS datasets"); 2789 goto error; 2790 } 2791 2792 kzone = zone_name; 2793 2794 /* --- 286 unchanged lines hidden --- | 2840 if (get_datasets(zlogp, &zfsbuf, &zfsbufsz) != 0) { 2841 zerror(zlogp, B_FALSE, "Unable to get list of ZFS datasets"); 2842 goto error; 2843 } 2844 2845 kzone = zone_name; 2846 2847 /* --- 286 unchanged lines hidden --- |