summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/daemon/ptyc_daemon_loop.c51
-rw-r--r--src/driver/ptyc_driver_ctx.c3
-rw-r--r--src/internal/argv/argv.h23
-rw-r--r--src/internal/ptycon_daemon_impl.h2
-rw-r--r--src/internal/ptycon_driver_impl.h2
-rw-r--r--src/internal/ptycon_nolibc_impl.c5
-rw-r--r--src/internal/ptycon_nolibc_impl.h4
-rw-r--r--src/pty/ptyc_spawn.c24
8 files changed, 111 insertions, 3 deletions
diff --git a/src/daemon/ptyc_daemon_loop.c b/src/daemon/ptyc_daemon_loop.c
index cacc879..b5a9538 100644
--- a/src/daemon/ptyc_daemon_loop.c
+++ b/src/daemon/ptyc_daemon_loop.c
@@ -22,8 +22,51 @@ static ptyc_daemon_routine * ptyc_daemon_vtbl[PTYC_VTBL_ELEMENTS] = {
0
};
+static int ptyc_init_pidmap_target_symlink(struct ptyc_daemon_ctx * dctx)
+{
+ int status;
+ void * hkeydir;
+
+ struct ptyc_driver_ctx_impl * ictx = ptyc_get_driver_ictx(dctx->driver_ctx);
+
+ if ((status = ntapi->tt_create_keyed_object_directory(
+ &hkeydir,
+ NT_SYMBOLIC_LINK_ALL_ACCESS,
+ ictx->rtdata->hpidmapdir,
+ pe_get_current_process_id())))
+ return status;
+
+ if ((status = ntapi->zw_set_information_object(
+ hkeydir,
+ NT_OBJECT_HANDLE_INFORMATION,
+ &(nt_object_handle_information){0,0},
+ sizeof(nt_object_handle_information))))
+ return status;
+
+ return ntapi->tt_create_keyed_object_directory_entry(
+ &ictx->hntpipc,
+ NT_SYMBOLIC_LINK_ALL_ACCESS,
+ hkeydir,
+ dctx->hport_daemon,0,
+ pe_get_current_process_id());
+}
+
+static int ptyc_init_ntpipc_target_symlink(struct ptyc_daemon_ctx * dctx)
+{
+ struct ptyc_driver_ctx_impl * ictx = ptyc_get_driver_ictx(dctx->driver_ctx);
+
+ return ntapi->tt_create_keyed_object_directory_entry(
+ &ictx->hntpipc,
+ NT_SYMBOLIC_LINK_ALL_ACCESS,
+ ictx->rtdata->hntpipcdir,
+ dctx->hport_daemon,0,
+ pe_get_current_process_id());
+}
+
int32_t __stdcall ptyc_daemon_loop(void * ctx)
{
+ int status;
+
struct ptyc_daemon_ctx * dctx;
nt_rtdata * rtdata;
@@ -41,6 +84,14 @@ int32_t __stdcall ptyc_daemon_loop(void * ctx)
dctx = (struct ptyc_daemon_ctx *)ctx;
+ /* pidmap daemon symlink */
+ if ((status = ptyc_init_pidmap_target_symlink(dctx)))
+ return status;
+
+ /* ntpipc daemon symlink */
+ if ((status = ptyc_init_ntpipc_target_symlink(dctx)))
+ return status;
+
/* init */
request = &inbuf;
ntapi->tt_aligned_block_memset(
diff --git a/src/driver/ptyc_driver_ctx.c b/src/driver/ptyc_driver_ctx.c
index 118fd7b..5be2ec7 100644
--- a/src/driver/ptyc_driver_ctx.c
+++ b/src/driver/ptyc_driver_ctx.c
@@ -172,6 +172,9 @@ static struct ptyc_driver_ctx_impl * ptyc_driver_ctx_alloc(
ictx->meta = meta;
ictx->ctx.ctx.units = ictx->units;
ictx->ctx.rtdata = rtdata;
+
+ ptyc_daemon_ctx.driver_ctx = &ictx->ctx.ctx;
+
return &ictx->ctx;
}
diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h
index 8753ebb..199e9c6 100644
--- a/src/internal/argv/argv.h
+++ b/src/internal/argv/argv.h
@@ -856,8 +856,10 @@ static void argv_show_status(
struct argv_ctx * ctx,
struct argv_meta * meta)
{
+ int i;
int argc;
char ** argv;
+ struct argv_keyval * keyv;
struct argv_entry * entry;
const struct argv_option * option;
char short_name[2] = {0};
@@ -887,6 +889,27 @@ static void argv_show_status(
else
argv_dprintf(fd,"[-%s,--%s]\n",
short_name,option->long_name);
+
+ if (entry->keyv) {
+ for (i=0,keyv=entry->keyv; keyv->keyword; i++,keyv++) {
+ switch (keyv->flags) {
+ case ARGV_KEYVAL_ASSIGN:
+ argv_dprintf(fd,"\tkeyval[%d]: <%s>=%s\n",
+ i,keyv->keyword,keyv->value);
+ break;
+
+ case ARGV_KEYVAL_OVERRIDE:
+ argv_dprintf(fd,"\tkeyval[%d]: <%s>:=%s\n",
+ i,keyv->keyword,keyv->value);
+ break;
+
+ default:
+ argv_dprintf(fd,"\tkeyval[%d]: <%s>\n",
+ i,keyv->keyword);
+ break;
+ }
+ }
+ }
} else {
argv_dprintf(fd,"<program arg> := %s\n",entry->arg);
}
diff --git a/src/internal/ptycon_daemon_impl.h b/src/internal/ptycon_daemon_impl.h
index 1595984..af2da25 100644
--- a/src/internal/ptycon_daemon_impl.h
+++ b/src/internal/ptycon_daemon_impl.h
@@ -18,6 +18,8 @@ enum ptyc_daemon_opcodes {
typedef int32_t __stdcall ptyc_daemon_routine(nt_tty_port_msg *);
struct ptyc_daemon_ctx {
+ struct ptyc_driver_ctx *driver_ctx;
+
nt_port_keys daemon_keys;
nt_port_attr daemon_attr;
nt_port_name daemon_name;
diff --git a/src/internal/ptycon_driver_impl.h b/src/internal/ptycon_driver_impl.h
index 1037894..3853751 100644
--- a/src/internal/ptycon_driver_impl.h
+++ b/src/internal/ptycon_driver_impl.h
@@ -61,6 +61,8 @@ struct ptyc_driver_ctx_impl {
struct ptyc_loop_ctx lctx;
struct ptyc_common_ctx cctx;
struct ptyc_driver_ctx ctx;
+ void * hntpipc;
+ void * hpidmap;
};
static inline struct ptyc_driver_ctx_impl * ptyc_get_driver_ictx(struct ptyc_driver_ctx * dctx)
diff --git a/src/internal/ptycon_nolibc_impl.c b/src/internal/ptycon_nolibc_impl.c
index 2319505..c489b98 100644
--- a/src/internal/ptycon_nolibc_impl.c
+++ b/src/internal/ptycon_nolibc_impl.c
@@ -61,6 +61,11 @@ char * ptyc_strrchr(const char * ch, int c)
return 0;
}
+int ptyc_isblank(int c)
+{
+ return ((c == 0x20) || (c == 0x09));
+}
+
#ifdef PTYC_EXPORT
int __stdcall ptycon_entry_point(void * hinstance, uint32_t reason, void * reserved)
{
diff --git a/src/internal/ptycon_nolibc_impl.h b/src/internal/ptycon_nolibc_impl.h
index 0c58141..c9caf13 100644
--- a/src/internal/ptycon_nolibc_impl.h
+++ b/src/internal/ptycon_nolibc_impl.h
@@ -16,6 +16,8 @@
#define strchr ptyc_strchr
#define strrchr ptyc_strrchr
+#define isblank ptyc_isblank
+
#define calloc ptyc_calloc
#define free ptyc_free
@@ -35,6 +37,8 @@ int ptyc_strncmp(const char * a, const char * b, size_t n);
char * ptyc_strchr(const char * ch, int c);
char * ptyc_strrchr(const char * ch, int c);
+int ptyc_isblank(int c);
+
void * ptyc_calloc(size_t n, size_t size);
void ptyc_free(void *);
diff --git a/src/pty/ptyc_spawn.c b/src/pty/ptyc_spawn.c
index f65aa53..f3f4706 100644
--- a/src/pty/ptyc_spawn.c
+++ b/src/pty/ptyc_spawn.c
@@ -60,6 +60,20 @@ int ptyc_spawn(struct ptyc_driver_ctx * dctx)
rtctx.hcwd = self->hcwd;
rtctx.hroot = sparams.hroot;
+ rtctx.hntpipcdir = self->hntpipcdir;
+ rtctx.hpidmapdir = self->hpidmapdir;
+ rtctx.hpidanydir = self->hpidanydir;
+ rtctx.hntpgrpdir = self->hntpgrpdir;
+
+ rtctx.htmpfsldir = self->htmpfsldir;
+ rtctx.htmpfslroot = self->htmpfslroot;
+
+ rtctx.hshmctldir = self->hshmctldir;
+ rtctx.hshmctlroot = self->hshmctlroot;
+
+ rtctx.hshmkeydir = self->hshmkeydir;
+ rtctx.hshmkeyroot = self->hshmkeyroot;
+
rtctx.tty_type = self->tty_type;
rtctx.tty_subtype = self->tty_subtype;
@@ -117,9 +131,13 @@ int ptyc_spawn(struct ptyc_driver_ctx * dctx)
return NT_STATUS_GENERIC_COMMAND_FAILED;
/* finalize */
- if (!(dctx->cctx->drvflags & (PTYC_DRIVER_DBG_RAW|PTYC_DRIVER_DBG_OVEN)))
- if ((status = ntapi->pty_close(ictx->cctx.hpts)))
- return status;
+ if (dctx->cctx->drvflags & (PTYC_DRIVER_DBG_RAW|PTYC_DRIVER_DBG_OVEN))
+ return NT_STATUS_SUCCESS;
+
+ if ((status = ntapi->pty_close(ictx->cctx.hpts)))
+ return status;
+
+ ictx->cctx.hpts = 0;
/* all done */
return NT_STATUS_SUCCESS;