From 5ce44dadcf84c1490a487f1639fef77e4b322d78 Mon Sep 17 00:00:00 2001 From: midipix Date: Jul 03 2020 15:54:54 +0000 Subject: logging: added toks_log_token_info(). --- diff --git a/project/common.mk b/project/common.mk index 0827ef8..91ba8b1 100644 --- a/project/common.mk +++ b/project/common.mk @@ -30,6 +30,7 @@ INTERNAL_SRCS = \ src/internal/toksvc_open_impl.c \ src/log/toks_log_lpc_message.c \ src/log/toks_log_service_info.c \ + src/log/toks_log_token_info.c \ src/service/toks_service_abort.c \ src/service/toks_service_ioctl.c \ src/service/toks_service_start.c \ diff --git a/src/internal/toksvc_log_impl.h b/src/internal/toksvc_log_impl.h index c27178c..83ecf45 100644 --- a/src/internal/toksvc_log_impl.h +++ b/src/internal/toksvc_log_impl.h @@ -51,6 +51,9 @@ void toks_log_get_arbitrary_process_name( void toks_log_service_info( struct toks_daemon_ctx *); +void toks_log_token_info( + struct toks_daemon_ctx *); + void toks_log_lpc_request( struct toks_daemon_ctx *, const nt_tty_port_msg *); diff --git a/src/log/toks_log_token_info.c b/src/log/toks_log_token_info.c new file mode 100644 index 0000000..b95ebd3 --- /dev/null +++ b/src/log/toks_log_token_info.c @@ -0,0 +1,103 @@ +/*********************************************************/ +/* toksvc: a framework-native token broker service */ +/* Copyright (C) 2020 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */ +/*********************************************************/ + +#include +#include + +#include +#include "toksvc_driver_impl.h" +#include "toksvc_daemon_impl.h" +#include "toksvc_log_impl.h" + +void toks_log_token_info(struct toks_daemon_ctx * dctx) +{ + struct toks_driver_ctx * drvctx = dctx->driver_ctx; + + TOKS_LOG_LEVEL(drvctx,1); + + int idx; + char path[2048]; + char tokstr[64]; + struct toks_token * token; + + toks_log_service_info(dctx); + + token = toks_get_driver_tokens(dctx->driver_ctx); + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_1, + "\n",0); + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "%-11s%-55s%-12s%-14s%s\n", + "token no.", + "token id.", + "token pid", + "token syspid", + "token refstr", + 0); + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "%-11s%-55s%-12s%-14s%s\n", + "=========", + "=========", + "=========", + "============", + "============", + 0); + + for (idx=0; idxutokens; token++) { + if (token->self) { + toks_log_get_process_name( + token->client.hprocess, + path,sizeof(path)); + + ntapi->sprintf( + tokstr, + "%08x-%08x-%08x-%08x-%08x-%08x", + token->keys.key[0], + token->keys.key[1], + token->keys.key[2], + token->keys.key[3], + token->keys.key[4], + token->keys.key[5]); + + if (token->client.tokpid) { + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "#%-10d%-55s%-12d%-14d%s\n", + ++idx,tokstr, + token->client.tokpid, + token->client.cid.process_id, + token->meta.key); + } else { + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "#%-10d%-55s%-12s%-14d%s\n", + ++idx,tokstr,"N/A", + token->client.cid.process_id, + token->meta.key); + } + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_2, + "%-11s%s.\n",(char[]){0},path); + + toks_log_write( + drvctx, + TOKS_LOG_ENTRY_SUB_LEVEL_1, + "\n",0); + } + } +}