151 * Note that this code really does require all the contract calls, which are
152 * all the static functions preceding this (have a look at zone_enter; without
153 * that code zone_enter will kick back EINVAL).
154 */
155 int
156 zdoor_fattach(zoneid_t zoneid, const char *service, int door, int detach_only)
157 {
158 int fd = 0;
159 int len = 0;
160 int pid = 0;
161 int stat = 0;
162 int tmpl_fd = 0;
163 char path[MAXPATHLEN] = {0};
164 ctid_t ct = -1;
165
166 if (zoneid < 0) {
167 zdoor_debug("zdoor_fattach: zoneid < 0");
168 return (ZDOOR_ARGS_ERROR);
169 }
170
171 if (path == NULL) {
172 zdoor_debug("zdoor_fattach: NULL PATH");
173 return (ZDOOR_ARGS_ERROR);
174 }
175
176 if ((tmpl_fd = init_template()) < 0) {
177 zdoor_warn("zdoor_fattach: init contract for %d:%s failed",
178 zoneid, service);
179 return (ZDOOR_ERROR);
180 }
181
182 len = snprintf(NULL, 0, ZDOOR_FMT_STR, service) + 1;
183 if (len > MAXPATHLEN)
184 return (ZDOOR_ARGS_ERROR);
185 (void) snprintf(path, len, ZDOOR_FMT_STR, service);
186
187 zdoor_info("zdoor_fattach: ensuring %s", path);
188
189 pid = fork();
190 if (pid < 0) {
191 (void) ct_tmpl_clear(tmpl_fd);
192 zdoor_error("zdoor_fattach: unable to fork for zone_enter: %s",
|
151 * Note that this code really does require all the contract calls, which are
152 * all the static functions preceding this (have a look at zone_enter; without
153 * that code zone_enter will kick back EINVAL).
154 */
155 int
156 zdoor_fattach(zoneid_t zoneid, const char *service, int door, int detach_only)
157 {
158 int fd = 0;
159 int len = 0;
160 int pid = 0;
161 int stat = 0;
162 int tmpl_fd = 0;
163 char path[MAXPATHLEN] = {0};
164 ctid_t ct = -1;
165
166 if (zoneid < 0) {
167 zdoor_debug("zdoor_fattach: zoneid < 0");
168 return (ZDOOR_ARGS_ERROR);
169 }
170
171 if (service == NULL) {
172 zdoor_debug("zdoor_fattach: NULL service");
173 return (ZDOOR_ARGS_ERROR);
174 }
175
176 if ((tmpl_fd = init_template()) < 0) {
177 zdoor_warn("zdoor_fattach: init contract for %d:%s failed",
178 zoneid, service);
179 return (ZDOOR_ERROR);
180 }
181
182 len = snprintf(NULL, 0, ZDOOR_FMT_STR, service) + 1;
183 if (len > MAXPATHLEN)
184 return (ZDOOR_ARGS_ERROR);
185 (void) snprintf(path, len, ZDOOR_FMT_STR, service);
186
187 zdoor_info("zdoor_fattach: ensuring %s", path);
188
189 pid = fork();
190 if (pid < 0) {
191 (void) ct_tmpl_clear(tmpl_fd);
192 zdoor_error("zdoor_fattach: unable to fork for zone_enter: %s",
|