Replaced LAUNCH_INHERIT_NS with LAUNCH_SET_NS, which has the opposite effect
This commit is contained in:
@@ -203,7 +203,7 @@ static int validate_ns(int flags, const struct namespace_entry *ns, size_t count
|
||||
return EFAULT;
|
||||
}
|
||||
|
||||
if ((flags & LAUNCH_INHERIT_NS) && count) {
|
||||
if (!(flags & LAUNCH_SET_NS) && count) {
|
||||
/* TODO better error messages */
|
||||
set_error_msg("cannot create a new namespace and inherit an existing one");
|
||||
return EINVAL;
|
||||
@@ -238,7 +238,7 @@ static int collect_names(const struct launch_info *info, struct launch_ctx *ctx)
|
||||
size_t ns_count = info->ns_count;
|
||||
const struct namespace_entry *ns = info->ns;
|
||||
|
||||
if (info->flags & LAUNCH_INHERIT_NS) {
|
||||
if (!(info->flags & LAUNCH_SET_NS)) {
|
||||
ns_count = ctx->inherited_ns_len;
|
||||
ns = ctx->inherited_ns;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ static int count_handles(const struct launch_info *info, struct launch_ctx *ctx)
|
||||
const struct namespace_entry *ns = info->ns;
|
||||
bool auto_ns = false;
|
||||
|
||||
if (info->flags & LAUNCH_INHERIT_NS) {
|
||||
if (!(info->flags & LAUNCH_SET_NS)) {
|
||||
ns_len = ctx->inherited_ns_len;
|
||||
ns = ctx->inherited_ns;
|
||||
auto_ns = true;
|
||||
@@ -302,6 +302,9 @@ static int count_handles(const struct launch_info *info, struct launch_ctx *ctx)
|
||||
* all other handle types are used internally by launch() */
|
||||
case MX_B_TUNNEL_LDSVC:
|
||||
case MX_B_TUNNEL_EXPORT:
|
||||
case MX_B_RESOURCE_ROOT:
|
||||
case MX_B_RESOURCE_IOPORT:
|
||||
case MX_B_RESOURCE_IRQ:
|
||||
case MX_B_USER0:
|
||||
case MX_B_USER1:
|
||||
case MX_B_USER2:
|
||||
@@ -373,7 +376,7 @@ static int collect_handles(const struct launch_info *info, struct launch_ctx *ct
|
||||
ctx->stdio[i] = fd_handle;
|
||||
}
|
||||
|
||||
if (info->flags & LAUNCH_INHERIT_NS) {
|
||||
if (!(info->flags & LAUNCH_SET_NS)) {
|
||||
for (size_t i = 0; i < ctx->inherited_ns_len; i++) {
|
||||
const struct namespace_entry *ent = &ctx->inherited_ns[i];
|
||||
|
||||
@@ -605,7 +608,7 @@ static void success_cleanup(struct launch_ctx *ctx)
|
||||
|
||||
static int inherit_namespace(const struct launch_info *info, struct launch_ctx *ctx)
|
||||
{
|
||||
if (!(info->flags & LAUNCH_INHERIT_NS)) {
|
||||
if (info->flags & LAUNCH_SET_NS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -633,27 +636,6 @@ static mx_handle_t request_v1(mx_handle_t ldsvc, const char *name)
|
||||
|
||||
mx_tunnel_write(ldsvc, msg_buf, msg_len, NULL, 0);
|
||||
|
||||
#if 0
|
||||
mx_signals_t sig = 0;
|
||||
mx_status_t err = mx_object_wait(ldsvc,
|
||||
MX_TUNNEL_READABLE | MX_TUNNEL_REMOTE_CLOSED,
|
||||
mx_deadline_after(MX_SEC(3)), &sig);
|
||||
|
||||
if (sig & MX_TUNNEL_REMOTE_CLOSED) {
|
||||
return MX_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (err == MX_ERR_TIMED_OUT) {
|
||||
return MX_NULL_HANDLE;
|
||||
}
|
||||
|
||||
size_t nr_handles = 0;
|
||||
mx_tunnel_read(ldsvc, NULL, 0, NULL, 0, &msg_len, &nr_handles);
|
||||
|
||||
unsigned char resp_buf[msg_len];
|
||||
mx_handle_t handles[nr_handles];
|
||||
#endif
|
||||
|
||||
mx_handle_t handle;
|
||||
|
||||
mx_tunnel_read(ldsvc,
|
||||
@@ -1091,20 +1073,31 @@ static int send_exec_bootstrap_message(const struct launch_info *args, struct la
|
||||
*/
|
||||
int tmp = 0;
|
||||
default_handles[tmp++] = ARG_HANDLE(ctx->new_task, MX_B_HND(MX_B_TASK_SELF, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(vdso_vmo, MX_B_HND(MX_B_VMO_VDSO, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(vdso_vmo, MX_B_HND(MX_B_VMO_VDSO, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(ctx->exec_vmo, MX_B_HND(MX_B_VMO_EXEC, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(ctx->new_vmar, MX_B_HND(MX_B_VMAR_ROOT, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(ctx->exec.remote_exec_vmar, MX_B_HND(MX_B_VMAR_EXEC, 0));
|
||||
default_handles[tmp++] = ARG_HANDLE(ctx->bootstrap_remote, MX_B_HND(MX_B_TUNNEL_BTSTP, 0));
|
||||
|
||||
const char *default_argv[] = { args->path };
|
||||
int default_argc = sizeof default_argv / sizeof *default_argv;
|
||||
|
||||
const char **argv = args->argv;
|
||||
int argc = args->argc;
|
||||
|
||||
if (!argv) {
|
||||
argv = default_argv;
|
||||
argc = default_argc;
|
||||
}
|
||||
|
||||
mx_handle_t *raw_handles;
|
||||
|
||||
size_t msg_len;
|
||||
mx_bootstrap_msg_t *msg = build_bootstrap_message(
|
||||
args->argc, args->argv,
|
||||
argc, argv,
|
||||
0, NULL,
|
||||
ctx->name_count, ctx->names,
|
||||
ctx->b_handle_count, ctx->b_handles,
|
||||
ctx->name_count, ctx->names,
|
||||
ctx->b_handle_count, ctx->b_handles,
|
||||
&msg_len, &raw_handles);
|
||||
|
||||
mx_tunnel_write_etc(ctx->bootstrap_local,
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
#define NS_ENTRY_PATH(p, s) { .path = (p), .src = (s), .fd = -1, .handle = MX_NULL_HANDLE }
|
||||
|
||||
enum launch_flags {
|
||||
/* inherit parent task's namespace. if this flag is set,
|
||||
* launch_info.ns must be NULL. */
|
||||
LAUNCH_INHERIT_NS = 0x01u,
|
||||
/* don't inherit parent task's namespace. */
|
||||
LAUNCH_SET_NS = 0x01u,
|
||||
/* use launch_info.fd as the new task's stdio file descriptors */
|
||||
LAUNCH_SET_FD = 0x02u,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user