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;
|
return EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & LAUNCH_INHERIT_NS) && count) {
|
if (!(flags & LAUNCH_SET_NS) && count) {
|
||||||
/* TODO better error messages */
|
/* TODO better error messages */
|
||||||
set_error_msg("cannot create a new namespace and inherit an existing one");
|
set_error_msg("cannot create a new namespace and inherit an existing one");
|
||||||
return EINVAL;
|
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;
|
size_t ns_count = info->ns_count;
|
||||||
const struct namespace_entry *ns = info->ns;
|
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_count = ctx->inherited_ns_len;
|
||||||
ns = ctx->inherited_ns;
|
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;
|
const struct namespace_entry *ns = info->ns;
|
||||||
bool auto_ns = false;
|
bool auto_ns = false;
|
||||||
|
|
||||||
if (info->flags & LAUNCH_INHERIT_NS) {
|
if (!(info->flags & LAUNCH_SET_NS)) {
|
||||||
ns_len = ctx->inherited_ns_len;
|
ns_len = ctx->inherited_ns_len;
|
||||||
ns = ctx->inherited_ns;
|
ns = ctx->inherited_ns;
|
||||||
auto_ns = true;
|
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() */
|
* all other handle types are used internally by launch() */
|
||||||
case MX_B_TUNNEL_LDSVC:
|
case MX_B_TUNNEL_LDSVC:
|
||||||
case MX_B_TUNNEL_EXPORT:
|
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_USER0:
|
||||||
case MX_B_USER1:
|
case MX_B_USER1:
|
||||||
case MX_B_USER2:
|
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;
|
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++) {
|
for (size_t i = 0; i < ctx->inherited_ns_len; i++) {
|
||||||
const struct namespace_entry *ent = &ctx->inherited_ns[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)
|
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;
|
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);
|
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_handle_t handle;
|
||||||
|
|
||||||
mx_tunnel_read(ldsvc,
|
mx_tunnel_read(ldsvc,
|
||||||
@@ -1097,11 +1079,22 @@ static int send_exec_bootstrap_message(const struct launch_info *args, struct la
|
|||||||
default_handles[tmp++] = ARG_HANDLE(ctx->exec.remote_exec_vmar, MX_B_HND(MX_B_VMAR_EXEC, 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));
|
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;
|
mx_handle_t *raw_handles;
|
||||||
|
|
||||||
size_t msg_len;
|
size_t msg_len;
|
||||||
mx_bootstrap_msg_t *msg = build_bootstrap_message(
|
mx_bootstrap_msg_t *msg = build_bootstrap_message(
|
||||||
args->argc, args->argv,
|
argc, argv,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
ctx->name_count, ctx->names,
|
ctx->name_count, ctx->names,
|
||||||
ctx->b_handle_count, ctx->b_handles,
|
ctx->b_handle_count, ctx->b_handles,
|
||||||
|
|||||||
@@ -13,9 +13,8 @@
|
|||||||
#define NS_ENTRY_PATH(p, s) { .path = (p), .src = (s), .fd = -1, .handle = MX_NULL_HANDLE }
|
#define NS_ENTRY_PATH(p, s) { .path = (p), .src = (s), .fd = -1, .handle = MX_NULL_HANDLE }
|
||||||
|
|
||||||
enum launch_flags {
|
enum launch_flags {
|
||||||
/* inherit parent task's namespace. if this flag is set,
|
/* don't inherit parent task's namespace. */
|
||||||
* launch_info.ns must be NULL. */
|
LAUNCH_SET_NS = 0x01u,
|
||||||
LAUNCH_INHERIT_NS = 0x01u,
|
|
||||||
/* use launch_info.fd as the new task's stdio file descriptors */
|
/* use launch_info.fd as the new task's stdio file descriptors */
|
||||||
LAUNCH_SET_FD = 0x02u,
|
LAUNCH_SET_FD = 0x02u,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user