diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-04-29 11:34:05 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-04-29 11:34:05 +0400 |
commit | 12eac211c9d8cfe8304b0232cd472bc005d71745 (patch) | |
tree | 3e68a921140bc36e4f15d20194f2a96db1b5fc6a /winsup/cygwin/uinfo.cc | |
parent | 541820d0eefe3859162cce48946c9649752b9b3b (diff) |
* advapi32.cc (GetTokenInformation): Remove.
(SetTokenInformation): Remove.
* grp.cc: Replace above functions throughout with their ntdll.dll
equivalent.
* sec_auth.cc: Ditto.
* syscalls.cc: Ditto.
* uinfo.cc: Ditto.
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r-- | winsup/cygwin/uinfo.cc | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index dd2d6ed9c..dd87bd5f0 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -59,32 +59,35 @@ cygheap_user::init () else set_name ("unknown"); - DWORD siz; + NTSTATUS status; + ULONG size; PSECURITY_DESCRIPTOR psd; - if (!GetTokenInformation (hProcToken, TokenPrimaryGroup, - &groups.pgsid, sizeof (cygsid), &siz)) - system_printf ("GetTokenInformation (TokenPrimaryGroup), %E"); + status = NtQueryInformationToken (hProcToken, TokenPrimaryGroup, + &groups.pgsid, sizeof (cygsid), &size); + if (!NT_SUCCESS (status)) + system_printf ("NtQueryInformationToken (TokenPrimaryGroup), %p", status); /* Get the SID from current process and store it in effec_cygsid */ - if (!GetTokenInformation (hProcToken, TokenUser, &effec_cygsid, - sizeof (cygsid), &siz)) + status = NtQueryInformationToken (hProcToken, TokenUser, &effec_cygsid, + sizeof (cygsid), &size); + if (!NT_SUCCESS (status)) { - system_printf ("GetTokenInformation (TokenUser), %E"); + system_printf ("NtQueryInformationToken (TokenUser), %p", status); return; } /* Set token owner to the same value as token user */ - if (!SetTokenInformation (hProcToken, TokenOwner, &effec_cygsid, - sizeof (cygsid))) - debug_printf ("SetTokenInformation(TokenOwner), %E"); + status = NtSetInformationToken (hProcToken, TokenOwner, &effec_cygsid, + sizeof (cygsid)); + if (!NT_SUCCESS (status)) + debug_printf ("NtSetInformationToken(TokenOwner), %p", status); /* Standard way to build a security descriptor with the usual DACL */ PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024); psd = (PSECURITY_DESCRIPTOR) (sec_user_nih (sa_buf, sid()))->lpSecurityDescriptor; - NTSTATUS status; BOOLEAN acl_exists, dummy; TOKEN_DEFAULT_DACL dacl; @@ -94,9 +97,10 @@ cygheap_user::init () { /* Set the default DACL and the process DACL */ - if (!SetTokenInformation (hProcToken, TokenDefaultDacl, &dacl, - sizeof (dacl))) - system_printf ("SetTokenInformation (TokenDefaultDacl), %E"); + status = NtSetInformationToken (hProcToken, TokenDefaultDacl, &dacl, + sizeof (dacl)); + if (!NT_SUCCESS (status)) + system_printf ("NtSetInformationToken (TokenDefaultDacl), %p", status); if ((status = NtSetSecurityObject (NtCurrentProcess (), DACL_SECURITY_INFORMATION, psd))) system_printf ("NtSetSecurityObject, %lx", status); @@ -128,9 +132,12 @@ internal_getlogin (cygheap_user &user) if (gsid != user.groups.pgsid) { /* Set primary group to the group in /etc/passwd. */ - if (!SetTokenInformation (hProcToken, TokenPrimaryGroup, - &gsid, sizeof gsid)) - debug_printf ("SetTokenInformation(TokenPrimaryGroup), %E"); + NTSTATUS status = NtSetInformationToken (hProcToken, + TokenPrimaryGroup, + &gsid, sizeof gsid); + if (!NT_SUCCESS (status)) + debug_printf ("NtSetInformationToken (TokenPrimaryGroup), %p", + status); else user.groups.pgsid = gsid; clear_procimptoken (); |