zoneadm.c (948f2876ce2a3010558f4f6937e16086ebcd36f2) zoneadm.c (1100f00d5652de2808b73c61bcfdb3fc87ef1fc8)
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

--- 3110 unchanged lines hidden (view full) ---

3119 return (Z_ERR);
3120 return (Z_OK);
3121}
3122
3123static int
3124install_func(int argc, char *argv[])
3125{
3126 char cmdbuf[MAXPATHLEN];
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

--- 3110 unchanged lines hidden (view full) ---

3119 return (Z_ERR);
3120 return (Z_OK);
3121}
3122
3123static int
3124install_func(int argc, char *argv[])
3125{
3126 char cmdbuf[MAXPATHLEN];
3127 char postcmdbuf[MAXPATHLEN];
3127 int lockfd;
3128 int arg, err, subproc_err;
3129 char zonepath[MAXPATHLEN];
3130 brand_handle_t bh = NULL;
3131 int status;
3132 boolean_t nodataset = B_FALSE;
3128 int lockfd;
3129 int arg, err, subproc_err;
3130 char zonepath[MAXPATHLEN];
3131 brand_handle_t bh = NULL;
3132 int status;
3133 boolean_t nodataset = B_FALSE;
3134 boolean_t do_postinstall = B_FALSE;
3133 char opts[128];
3134
3135 if (target_zone == NULL) {
3136 sub_usage(SHELP_INSTALL, CMD_INSTALL);
3137 return (Z_USAGE);
3138 }
3139
3140 if (zonecfg_in_alt_root()) {

--- 17 unchanged lines hidden (view full) ---

3158 (void) strcpy(cmdbuf, EXEC_PREFIX);
3159 if (brand_get_install(bh, target_zone, zonepath, cmdbuf + EXEC_LEN,
3160 sizeof (cmdbuf) - EXEC_LEN, 0, NULL) != 0) {
3161 zerror("invalid brand configuration: missing install resource");
3162 brand_close(bh);
3163 return (Z_ERR);
3164 }
3165
3135 char opts[128];
3136
3137 if (target_zone == NULL) {
3138 sub_usage(SHELP_INSTALL, CMD_INSTALL);
3139 return (Z_USAGE);
3140 }
3141
3142 if (zonecfg_in_alt_root()) {

--- 17 unchanged lines hidden (view full) ---

3160 (void) strcpy(cmdbuf, EXEC_PREFIX);
3161 if (brand_get_install(bh, target_zone, zonepath, cmdbuf + EXEC_LEN,
3162 sizeof (cmdbuf) - EXEC_LEN, 0, NULL) != 0) {
3163 zerror("invalid brand configuration: missing install resource");
3164 brand_close(bh);
3165 return (Z_ERR);
3166 }
3167
3168 (void) strcpy(postcmdbuf, EXEC_PREFIX);
3169 if (brand_get_postinstall(bh, target_zone, zonepath,
3170 postcmdbuf + EXEC_LEN, sizeof (postcmdbuf) - EXEC_LEN, 0, NULL)
3171 != 0) {
3172 zerror("invalid brand configuration: missing postinstall "
3173 "resource");
3174 brand_close(bh);
3175 return (Z_ERR);
3176 } else if (strlen(postcmdbuf) > EXEC_LEN) {
3177 do_postinstall = B_TRUE;
3178 }
3179
3166 (void) strcpy(opts, "?x:");
3167 if (!is_native_zone) {
3168 /*
3169 * Fetch the list of recognized command-line options from
3170 * the brand configuration file.
3171 */
3172 if (brand_get_installopts(bh, opts + strlen(opts),
3173 sizeof (opts) - strlen(opts)) != 0) {

--- 22 unchanged lines hidden (view full) ---

3196 if (is_native_zone) {
3197 sub_usage(SHELP_INSTALL, CMD_INSTALL);
3198 return (Z_USAGE);
3199 }
3200
3201 /*
3202 * This option isn't for zoneadm, so append it to
3203 * the command line passed to the brand-specific
3180 (void) strcpy(opts, "?x:");
3181 if (!is_native_zone) {
3182 /*
3183 * Fetch the list of recognized command-line options from
3184 * the brand configuration file.
3185 */
3186 if (brand_get_installopts(bh, opts + strlen(opts),
3187 sizeof (opts) - strlen(opts)) != 0) {

--- 22 unchanged lines hidden (view full) ---

3210 if (is_native_zone) {
3211 sub_usage(SHELP_INSTALL, CMD_INSTALL);
3212 return (Z_USAGE);
3213 }
3214
3215 /*
3216 * This option isn't for zoneadm, so append it to
3217 * the command line passed to the brand-specific
3204 * install routine.
3218 * install and postinstall routines.
3205 */
3206 if (addopt(cmdbuf, optopt, optarg,
3207 sizeof (cmdbuf)) != Z_OK) {
3208 zerror("Install command line too long");
3209 return (Z_ERR);
3210 }
3219 */
3220 if (addopt(cmdbuf, optopt, optarg,
3221 sizeof (cmdbuf)) != Z_OK) {
3222 zerror("Install command line too long");
3223 return (Z_ERR);
3224 }
3225 if (addopt(postcmdbuf, optopt, optarg,
3226 sizeof (postcmdbuf)) != Z_OK) {
3227 zerror("Post-Install command line too long");
3228 return (Z_ERR);
3229 }
3211 break;
3212 }
3213 }
3214
3215 if (!is_native_zone) {
3216 for (; optind < argc; optind++) {
3217 if (addopt(cmdbuf, 0, argv[optind],
3218 sizeof (cmdbuf)) != Z_OK) {
3219 zerror("Install command line too long");
3220 return (Z_ERR);
3221 }
3230 break;
3231 }
3232 }
3233
3234 if (!is_native_zone) {
3235 for (; optind < argc; optind++) {
3236 if (addopt(cmdbuf, 0, argv[optind],
3237 sizeof (cmdbuf)) != Z_OK) {
3238 zerror("Install command line too long");
3239 return (Z_ERR);
3240 }
3241 if (addopt(postcmdbuf, 0, argv[optind],
3242 sizeof (postcmdbuf)) != Z_OK) {
3243 zerror("Post-Install command line too long");
3244 return (Z_ERR);
3245 }
3222 }
3223 }
3224
3225 if (sanity_check(target_zone, CMD_INSTALL, B_FALSE, B_TRUE, B_FALSE)
3226 != Z_OK)
3227 return (Z_ERR);
3228 if (verify_details(CMD_INSTALL, argv) != Z_OK)
3229 return (Z_ERR);

--- 47 unchanged lines hidden (view full) ---

3277 }
3278
3279 if ((err = zone_set_state(target_zone, ZONE_STATE_INSTALLED)) != Z_OK) {
3280 errno = err;
3281 zperror2(target_zone, gettext("could not set state"));
3282 goto done;
3283 }
3284
3246 }
3247 }
3248
3249 if (sanity_check(target_zone, CMD_INSTALL, B_FALSE, B_TRUE, B_FALSE)
3250 != Z_OK)
3251 return (Z_ERR);
3252 if (verify_details(CMD_INSTALL, argv) != Z_OK)
3253 return (Z_ERR);

--- 47 unchanged lines hidden (view full) ---

3301 }
3302
3303 if ((err = zone_set_state(target_zone, ZONE_STATE_INSTALLED)) != Z_OK) {
3304 errno = err;
3305 zperror2(target_zone, gettext("could not set state"));
3306 goto done;
3307 }
3308
3309 if (do_postinstall) {
3310 status = do_subproc(postcmdbuf);
3311
3312 if ((subproc_err =
3313 subproc_status(gettext("brand-specific post-install"),
3314 status, B_FALSE)) != ZONE_SUBPROC_OK) {
3315 err = Z_ERR;
3316 (void) zone_set_state(target_zone,
3317 ZONE_STATE_INCOMPLETE);
3318 }
3319 }
3320
3285done:
3286 /*
3287 * If the install script exited with ZONE_SUBPROC_USAGE or
3288 * ZONE_SUBPROC_NOTCOMPLETE, try to clean up the zone and leave the
3289 * zone in the CONFIGURED state so that another install can be
3290 * attempted without requiring an uninstall first.
3291 */
3292 if ((subproc_err == ZONE_SUBPROC_USAGE) ||

--- 2408 unchanged lines hidden ---
3321done:
3322 /*
3323 * If the install script exited with ZONE_SUBPROC_USAGE or
3324 * ZONE_SUBPROC_NOTCOMPLETE, try to clean up the zone and leave the
3325 * zone in the CONFIGURED state so that another install can be
3326 * attempted without requiring an uninstall first.
3327 */
3328 if ((subproc_err == ZONE_SUBPROC_USAGE) ||

--- 2408 unchanged lines hidden ---