vplat.c (3bc21d0a9c7b31b1132c254e389a4114c23bcf00) vplat.c (c5cd6260c3d6c06a9359df595ad9dddbfd00a80e)
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

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

147
148static m_label_t *zlabel = NULL;
149static m_label_t *zid_label = NULL;
150static priv_set_t *zprivs = NULL;
151
152/* from libsocket, not in any header file */
153extern int getnetmaskbyaddr(struct in_addr, struct in_addr *);
154
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

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

147
148static m_label_t *zlabel = NULL;
149static m_label_t *zid_label = NULL;
150static priv_set_t *zprivs = NULL;
151
152/* from libsocket, not in any header file */
153extern int getnetmaskbyaddr(struct in_addr, struct in_addr *);
154
155/* from zoneadmd */
156extern char query_hook[];
157
155/*
156 * An optimization for build_mnttable: reallocate (and potentially copy the
157 * data) only once every N times through the loop.
158 */
159#define MNTTAB_HUNK 32
160
161/*
162 * Private autofs system call

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

3132 if (nvlv != NULL)
3133 free(nvlv);
3134 if (handle != NULL)
3135 zonecfg_fini_handle(handle);
3136 return (error);
3137}
3138
3139static int
158/*
159 * An optimization for build_mnttable: reallocate (and potentially copy the
160 * data) only once every N times through the loop.
161 */
162#define MNTTAB_HUNK 32
163
164/*
165 * Private autofs system call

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

3135 if (nvlv != NULL)
3136 free(nvlv);
3137 if (handle != NULL)
3138 zonecfg_fini_handle(handle);
3139 return (error);
3140}
3141
3142static int
3143get_implicit_datasets(zlog_t *zlogp, char **retstr)
3144{
3145 char cmdbuf[2 * MAXPATHLEN];
3146
3147 if (query_hook[0] == '\0')
3148 return (0);
3149
3150 if (snprintf(cmdbuf, sizeof (cmdbuf), "%s datasets", query_hook)
3151 > sizeof (cmdbuf))
3152 return (-1);
3153
3154 if (do_subproc(zlogp, cmdbuf, retstr) != 0)
3155 return (-1);
3156
3157 return (0);
3158}
3159
3160static int
3140get_datasets(zlog_t *zlogp, char **bufp, size_t *bufsizep)
3141{
3142 zone_dochandle_t handle;
3143 struct zone_dstab dstab;
3144 size_t total, offset, len;
3145 int error = -1;
3146 char *str = NULL;
3161get_datasets(zlog_t *zlogp, char **bufp, size_t *bufsizep)
3162{
3163 zone_dochandle_t handle;
3164 struct zone_dstab dstab;
3165 size_t total, offset, len;
3166 int error = -1;
3167 char *str = NULL;
3168 char *implicit_datasets = NULL;
3169 int implicit_len = 0;
3147
3148 *bufp = NULL;
3149 *bufsizep = 0;
3150
3151 if ((handle = zonecfg_init_handle()) == NULL) {
3152 zerror(zlogp, B_TRUE, "getting zone configuration handle");
3153 return (-1);
3154 }
3155 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
3156 zerror(zlogp, B_FALSE, "invalid configuration");
3157 zonecfg_fini_handle(handle);
3158 return (-1);
3159 }
3160
3170
3171 *bufp = NULL;
3172 *bufsizep = 0;
3173
3174 if ((handle = zonecfg_init_handle()) == NULL) {
3175 zerror(zlogp, B_TRUE, "getting zone configuration handle");
3176 return (-1);
3177 }
3178 if (zonecfg_get_snapshot_handle(zone_name, handle) != Z_OK) {
3179 zerror(zlogp, B_FALSE, "invalid configuration");
3180 zonecfg_fini_handle(handle);
3181 return (-1);
3182 }
3183
3184 if (get_implicit_datasets(zlogp, &implicit_datasets) != 0) {
3185 zerror(zlogp, B_FALSE, "getting implicit datasets failed");
3186 goto out;
3187 }
3188
3161 if (zonecfg_setdsent(handle) != Z_OK) {
3162 zerror(zlogp, B_FALSE, "%s failed", "zonecfg_setdsent");
3163 goto out;
3164 }
3165
3166 total = 0;
3167 while (zonecfg_getdsent(handle, &dstab) == Z_OK)
3168 total += strlen(dstab.zone_dataset_name) + 1;
3169 (void) zonecfg_enddsent(handle);
3170
3189 if (zonecfg_setdsent(handle) != Z_OK) {
3190 zerror(zlogp, B_FALSE, "%s failed", "zonecfg_setdsent");
3191 goto out;
3192 }
3193
3194 total = 0;
3195 while (zonecfg_getdsent(handle, &dstab) == Z_OK)
3196 total += strlen(dstab.zone_dataset_name) + 1;
3197 (void) zonecfg_enddsent(handle);
3198
3199 if (implicit_datasets != NULL)
3200 implicit_len = strlen(implicit_datasets);
3201 if (implicit_len > 0)
3202 total += implicit_len + 1;
3203
3171 if (total == 0) {
3172 error = 0;
3173 goto out;
3174 }
3175
3176 if ((str = malloc(total)) == NULL) {
3177 zerror(zlogp, B_TRUE, "memory allocation failed");
3178 goto out;

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

3188 (void) strlcpy(str + offset, dstab.zone_dataset_name,
3189 total - offset);
3190 offset += len;
3191 if (offset < total - 1)
3192 str[offset++] = ',';
3193 }
3194 (void) zonecfg_enddsent(handle);
3195
3204 if (total == 0) {
3205 error = 0;
3206 goto out;
3207 }
3208
3209 if ((str = malloc(total)) == NULL) {
3210 zerror(zlogp, B_TRUE, "memory allocation failed");
3211 goto out;

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

3221 (void) strlcpy(str + offset, dstab.zone_dataset_name,
3222 total - offset);
3223 offset += len;
3224 if (offset < total - 1)
3225 str[offset++] = ',';
3226 }
3227 (void) zonecfg_enddsent(handle);
3228
3229 if (implicit_len > 0)
3230 (void) strlcpy(str + offset, implicit_datasets, total - offset);
3231
3196 error = 0;
3197 *bufp = str;
3198 *bufsizep = total;
3199
3200out:
3201 if (error != 0 && str != NULL)
3202 free(str);
3203 if (handle != NULL)
3204 zonecfg_fini_handle(handle);
3232 error = 0;
3233 *bufp = str;
3234 *bufsizep = total;
3235
3236out:
3237 if (error != 0 && str != NULL)
3238 free(str);
3239 if (handle != NULL)
3240 zonecfg_fini_handle(handle);
3241 if (implicit_datasets != NULL)
3242 free(implicit_datasets);
3205
3206 return (error);
3207}
3208
3209static int
3210validate_datasets(zlog_t *zlogp)
3211{
3212 zone_dochandle_t handle;

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

4527 brand_close(bh);
4528 zerror(zlogp, B_FALSE, "unable to determine branded zone's "
4529 "halt callback.");
4530 goto error;
4531 }
4532 brand_close(bh);
4533
4534 if ((strlen(cmdbuf) > EXEC_LEN) &&
3243
3244 return (error);
3245}
3246
3247static int
3248validate_datasets(zlog_t *zlogp)
3249{
3250 zone_dochandle_t handle;

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

4565 brand_close(bh);
4566 zerror(zlogp, B_FALSE, "unable to determine branded zone's "
4567 "halt callback.");
4568 goto error;
4569 }
4570 brand_close(bh);
4571
4572 if ((strlen(cmdbuf) > EXEC_LEN) &&
4535 (do_subproc(zlogp, cmdbuf) != Z_OK)) {
4573 (do_subproc(zlogp, cmdbuf, NULL) != Z_OK)) {
4536 zerror(zlogp, B_FALSE, "%s failed", cmdbuf);
4537 goto error;
4538 }
4539
4540 if (!unmount_cmd) {
4541 zone_iptype_t iptype;
4542
4543 if (zone_getattr(zoneid, ZONE_ATTR_FLAGS, &flags,

--- 103 unchanged lines hidden ---
4574 zerror(zlogp, B_FALSE, "%s failed", cmdbuf);
4575 goto error;
4576 }
4577
4578 if (!unmount_cmd) {
4579 zone_iptype_t iptype;
4580
4581 if (zone_getattr(zoneid, ZONE_ATTR_FLAGS, &flags,

--- 103 unchanged lines hidden ---