- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index a7ce502..8807589 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -73,6 +73,79 @@ static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t *
- DWORD len = UNLEN + 1;
- int status = NO_ERROR;
- +#if 1
- + HANDLE currthrtoken = GetCurrentThreadToken();
- + TOKEN_USER *tu = NULL;
- + DWORD tulen = 0;
- + TOKEN_PRIMARY_GROUP *tg = NULL;
- + DWORD tglen = 0;
- +
- + if (!GetTokenInformation(currthrtoken, TokenUser, NULL, 0, &tulen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) {
- + eprintf("GetTokenInformation: TokenUser failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- +
- + tu = (PTOKEN_USER)malloc(tulen);
- + if (!tu) {
- + eprintf("malloc(%d) PTOKEN_USER failed\n", (int)tulen);
- + goto xdone;
- + }
- +
- + /* Get the token user information from the access token. */
- + if (!GetTokenInformation(currthrtoken, TokenUser, tu, tulen, &tulen)) {
- + eprintf("GetTokenInformation: TokenUser 2 failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- +
- + /* get the account/domain name of the SID */
- + char name[256];
- + char domname[256];
- + DWORD nlen = sizeof(name);
- + DWORD dlen = sizeof(domname);
- + SID_NAME_USE nameuse = 0;
- + if (!LookupAccountSidA(NULL, tu->User.Sid, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) {
- + eprintf("GetTokenInformation: user LookupAccountSidA failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- +
- + DPRINTF(0, ("map_current_user_to_ids: name='%s'\n", name));
- +
- + /*
- + * group
- + */
- +
- + if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, NULL, 0, &tglen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) {
- + eprintf("GetTokenInformation: TokenPrimaryGroup failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- +
- + tg = (PTOKEN_PRIMARY_GROUP)malloc(tglen);
- + if (!tg) {
- + eprintf("malloc(%d) PTOKEN_PRIMARY_GROUP failed %d\n", tglen, (int)GetLastError());
- + goto xdone;
- + }
- +
- + /* Get the token user information from the access token. */
- + if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, tg, tglen, &tglen)) {
- + eprintf("GetTokenInformation: TokenPrimaryGroup 2 failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- +
- + /* get the account/domain name of the SID */
- + nlen = sizeof(name);
- + dlen = sizeof(domname);
- + nameuse = 0;
- + if (!LookupAccountSidA(NULL, tg->PrimaryGroup, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) {
- + eprintf("GetTokenInformation: group LookupAccountSidA failed %d\n", (int)GetLastError());
- + goto xdone;
- + }
- + DPRINTF(0, ("map_current_user_to_ids: group='%s'\n", name));
- +
- +xdone:
- + free(tu);
- + free(tg);
- +#endif
- +
- if (!GetUserNameA(username, &len)) {
- status = GetLastError();
- eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status);
map_current_user_to_ids with |GetCurrentThreadToken()| info
Posted by Anonymous on Thu 22nd Feb 2024 17:53
raw | new post
view followups (newest first): map_current_user_to_ids with |GetCurrentThreadToken()| info by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.