diff --git a/src/client/toks_client_acquire.c b/src/client/toks_client_acquire.c index ea0783f..51e38b9 100644 --- a/src/client/toks_client_acquire.c +++ b/src/client/toks_client_acquire.c @@ -58,6 +58,8 @@ int32_t toks_client_acquire(struct toks_driver_ctx * dctx) if (toks_get_driver_tokpid(dctx)) { msg.data.ipcinfo.ctrlsvc.keys.reserved = toks_get_driver_tokpid(dctx); msg.data.ipcinfo.ctrlsvc.options = TOKS_OPT_FRAMEWORK_PID; + } else { + msg.data.ipcinfo.ctrlsvc.keys.reserved = toks_get_driver_tsyspid(dctx); } if (refstr && (reflen = toks_strlen(refstr))) { diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index fc63806..dc3df1f 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -252,6 +252,7 @@ int toks_get_driver_ctx( struct argv_entry * entry; struct argv_entry * uuid; struct argv_entry * pid; + struct argv_entry * syspid; struct argv_entry * msecs; struct toks_token_string key; size_t keylen; @@ -261,6 +262,7 @@ int toks_get_driver_ctx( const char * ch; int ntokens; int32_t tokpid; + int32_t tsyspid; int64_t timeout; void * hkernel32; char * targv[TOKS_SARGV_ELEMENTS]; @@ -289,6 +291,7 @@ int toks_get_driver_ctx( uuid = 0; tokpid = 0; + tsyspid = 0; keylen = 0; ntokens = 0; timeout = (-1); @@ -343,6 +346,16 @@ int toks_get_driver_ctx( tokpid = tokpid * 10 + (*ch - '0'); break; + case TAG_SYSPID: + syspid = entry; + + for (tsyspid=0, ch=entry->arg; *ch && (tsyspid>=0); ch++) + if ((*ch < '0') || (*ch >'9')) + tsyspid = -1; + else + tsyspid = tsyspid * 10 + (*ch - '0'); + break; + case TAG_TIMEOUT: msecs = entry; @@ -407,11 +420,19 @@ int toks_get_driver_ctx( if ((cctx.drvflags & TOKS_DRIVER_MODE_CLIENT) && (tokpid < 0)) { if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) toks_dprintf(STDERR_FILENO, - "%s: error: %s is not a valid process id.", + "%s: error: %s is not a valid framework process id.", program,pid->arg); return toks_get_driver_ctx_fail(meta); } + if ((cctx.drvflags & TOKS_DRIVER_MODE_CLIENT) && (tsyspid < 0)) { + if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) + toks_dprintf(STDERR_FILENO, + "%s: error: %s is not a valid system process id.", + program,syspid->arg); + return toks_get_driver_ctx_fail(meta); + } + if ((cctx.drvflags & TOKS_DRIVER_MODE_CLIENT) && (timeout < (-1))) { if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) toks_dprintf(STDERR_FILENO, @@ -487,6 +508,7 @@ int toks_get_driver_ctx( &ctx->ticks.pcfreq); ctx->tokpid = tokpid; + ctx->tsyspid = tsyspid; ctx->ntokens = ntokens; ctx->timeout = timeout; ctx->ctx.program = program; diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index 2057126..c4350d7 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -38,6 +38,7 @@ enum app_tags { TAG_TIMEOUT, TAG_REFSTR, TAG_PID, + TAG_SYSPID, }; struct toks_ticks { @@ -63,6 +64,7 @@ struct toks_driver_ctx_impl { int nwaiters; int ntokens; int tokpid; + int tsyspid; nt_guid uuid; }; @@ -211,6 +213,13 @@ static inline int toks_get_driver_tokpid(const struct toks_driver_ctx * dctx) return ictx->tokpid; } +static inline int toks_get_driver_tsyspid(const struct toks_driver_ctx * dctx) +{ + struct toks_driver_ctx_impl * ictx; + ictx = toks_get_driver_ictx(dctx); + return ictx->tsyspid; +} + static inline char * toks_get_driver_refstr(const struct toks_driver_ctx * dctx) { struct toks_driver_ctx_impl * ictx; diff --git a/src/skin/toks_skin_default.c b/src/skin/toks_skin_default.c index a759589..6012a97 100644 --- a/src/skin/toks_skin_default.c +++ b/src/skin/toks_skin_default.c @@ -44,6 +44,10 @@ const struct argv_option toks_default_options[] = { "assign the token to the framework process " "identified by %s"}, + {"syspid", 'P',TAG_SYSPID,ARGV_OPTARG_REQUIRED,0,0,"", + "assign the token to the system process " + "identified by %s"}, + {"release", 'r',TAG_RELEASE,ARGV_OPTARG_REQUIRED,0,0,"", "release the key specified by %s."},