[PATCH v3 3/5] ntdll: Implement NtQueryInformationToken(TokenElevationType).
Zebediah Figura
z.figura12 at gmail.com
Tue Feb 16 23:31:11 CST 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/ntdll/unix/security.c | 8 ++++++--
server/protocol.def | 8 ++++++++
server/token.c | 20 +++++++++++++++++---
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/unix/security.c b/dlls/ntdll/unix/security.c
index fc9cc9d4572..04f1b43a5cb 100644
--- a/dlls/ntdll/unix/security.c
+++ b/dlls/ntdll/unix/security.c
@@ -391,11 +391,15 @@ NTSTATUS WINAPI NtQueryInformationToken( HANDLE token, TOKEN_INFORMATION_CLASS c
break;
case TokenElevationType:
+ SERVER_START_REQ( get_token_elevation )
{
TOKEN_ELEVATION_TYPE *type = info;
- FIXME("QueryInformationToken( ..., TokenElevationType, ...) semi-stub\n");
- *type = TokenElevationTypeFull;
+
+ req->handle = wine_server_obj_handle( token );
+ status = wine_server_call( req );
+ if (!status) *type = reply->elevation;
}
+ SERVER_END_REQ;
break;
case TokenElevation:
diff --git a/server/protocol.def b/server/protocol.def
index fb3ee3a52de..43899bee240 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3433,6 +3433,14 @@ struct handle_info
@END
+/* Get the token elevation type */
+ at REQ(get_token_elevation)
+ obj_handle_t handle; /* handle to the token */
+ at REPLY
+ int elevation; /* token elevation type */
+ at END
+
+
/* Create I/O completion port */
@REQ(create_completion)
unsigned int access; /* desired access to a port */
diff --git a/server/token.c b/server/token.c
index 2ae1cb1780a..5499841dd50 100644
--- a/server/token.c
+++ b/server/token.c
@@ -126,6 +126,7 @@ struct token
ACL *default_dacl; /* the default DACL to assign to objects created by this user */
TOKEN_SOURCE source; /* source of the token */
int impersonation_level; /* impersonation level this token is capable of if non-primary token */
+ int elevation; /* elevation type */
};
struct privilege
@@ -541,7 +542,7 @@ static struct token *create_token( unsigned primary, const SID *user,
const LUID_AND_ATTRIBUTES *privs, unsigned int priv_count,
const ACL *default_dacl, TOKEN_SOURCE source,
const luid_t *modified_id,
- int impersonation_level )
+ int impersonation_level, int elevation )
{
struct token *token = alloc_object( &token_ops );
if (token)
@@ -563,6 +564,7 @@ static struct token *create_token( unsigned primary, const SID *user,
token->impersonation_level = impersonation_level;
token->default_dacl = NULL;
token->primary_group = NULL;
+ token->elevation = elevation;
/* copy user */
token->user = memdup( user, security_sid_len( user ));
@@ -678,7 +680,7 @@ struct token *token_duplicate( struct token *src_token, unsigned primary,
token = create_token( primary, src_token->user, NULL, 0,
NULL, 0, src_token->default_dacl,
src_token->source, modified_id,
- impersonation_level );
+ impersonation_level, src_token->elevation );
if (!token) return token;
/* copy groups */
@@ -890,7 +892,7 @@ struct token *token_create_admin( void )
static const TOKEN_SOURCE admin_source = {"SeMgr", {0, 0}};
token = create_token( TRUE, user_sid, admin_groups, ARRAY_SIZE( admin_groups ),
admin_privs, ARRAY_SIZE( admin_privs ), default_dacl,
- admin_source, NULL, -1 );
+ admin_source, NULL, -1, TokenElevationTypeFull );
/* we really need a primary group */
assert( token->primary_group );
}
@@ -1665,3 +1667,15 @@ DECL_HANDLER(set_token_default_dacl)
release_object( token );
}
}
+
+DECL_HANDLER(get_token_elevation)
+{
+ struct token *token;
+
+ if ((token = (struct token *)get_handle_obj( current->process, req->handle,
+ TOKEN_QUERY, &token_ops )))
+ {
+ reply->elevation = token->elevation;
+ release_object( token );
+ }
+}
--
2.20.1
More information about the wine-devel
mailing list