diff --git a/include/toksvc/toksvc.h b/include/toksvc/toksvc.h index 0958d9b..485717f 100644 --- a/include/toksvc/toksvc.h +++ b/include/toksvc/toksvc.h @@ -55,6 +55,8 @@ extern "C" { #define TOKS_DRIVER_ACTION_RELEASE 0X200000 #define TOKS_DRIVER_ACTION_ABORT 0X400000 +#define TOKS_DRIVER_ACTION_NTOKENS_GET 0X1000000 + /* message options */ #define TOKS_OPT_SYSTEM_PID 0x0000 #define TOKS_OPT_FRAMEWORK_PID 0x0001 diff --git a/src/driver/toks_amain.c b/src/driver/toks_amain.c index c179626..e3acc67 100644 --- a/src/driver/toks_amain.c +++ b/src/driver/toks_amain.c @@ -143,6 +143,12 @@ int toks_main(char ** argv, char ** envp) } } + if (dctx->cctx->drvflags & TOKS_DRIVER_ACTION_NTOKENS_GET) { + toks_dprintf(STDOUT_FILENO, + "toks_ntokens:%d\n", + toks_get_driver_ntokens(dctx)); + } + return (dctx->cctx->drvflags & TOKS_DRIVER_MODE_SERVER) ? NT_STATUS_SERVICE_NOTIFICATION : toks_exit(dctx,ret); diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index 5156d47..62ad5e8 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -287,6 +287,7 @@ int toks_get_driver_ctx( struct argv_entry * msecs; struct toks_token_string key; size_t keylen; + uintptr_t opdata; nt_guid svcguid; const char * program; const char * refstr; @@ -444,6 +445,12 @@ int toks_get_driver_ctx( case TAG_LOGFILE: cctx.logfile = entry->arg; break; + + case TAG_NTOKENSGET: + cctx.drvflags &= ~(uint64_t)TOKS_DRIVER_MODE_SERVER; + cctx.drvflags |= TOKS_DRIVER_MODE_CLIENT; + cctx.drvflags |= TOKS_DRIVER_ACTION_NTOKENS_GET; + break; } } else /* strict */ @@ -695,6 +702,28 @@ int toks_get_driver_ctx( return toks_get_driver_ctx_fail(meta); } + + if (cctx.drvflags & TOKS_DRIVER_ACTION_NTOKENS_GET) { + status = toks_service_ioctl( + &ctx->ctx,TOKS_IOCTL_GET_TOKEN_COUNT, + &opdata,0); + + switch (status) { + case NT_STATUS_SUCCESS: + ctx->ntokens = opdata; + break; + + default: + if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) + toks_dprintf(STDERR_FILENO, + "%s: error: could not obtain the current " + "overall number of tokens " + "(check the system's documentation) [0x%x].", + program,status); + + return toks_get_driver_ctx_fail(meta); + } + } } *pctx = &ctx->ctx; diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index ad0ea05..8c50cf0 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -43,6 +43,7 @@ enum app_tags { TAG_CSYSPID, TAG_LOGFILE, TAG_LOGLEVEL, + TAG_NTOKENSGET, }; struct toks_ticks { diff --git a/src/skin/toks_skin_default.c b/src/skin/toks_skin_default.c index 25e6f5c..3b5be49 100644 --- a/src/skin/toks_skin_default.c +++ b/src/skin/toks_skin_default.c @@ -73,5 +73,9 @@ const struct argv_option toks_default_options[] = { {"log-level", 'O',TAG_LOGLEVEL,ARGV_OPTARG_REQUIRED,0,0,"", "set the log level to %s in the range of 0..9"}, + {"get-token-pool-size", 'n',TAG_NTOKENSGET,ARGV_OPTARG_NONE,0,0,0, + "connect to the server and output the current overall " + "number of tokens"}, + {0,0,0,0,0,0,0,0} };