Difference between
modified post 8f8515cf4 by Anonymous on Sat 24th Feb 2024 10:31
original post c610291ae by Anonymous on Thu 22nd Feb 2024 17:53
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c | |
| 2 | - | index a7ce502..8807589 100644 | |
| 2 | + | index a7ce502..a86c3ae 100644 | |
| 3 | 3 | --- a/daemon/nfs41_daemon.c | |
| 4 | 4 | +++ b/daemon/nfs41_daemon.c | |
| 5 | - | @@ -73,6 +73,79 @@ static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t * | |
| 5 | + | @@ -73,6 +73,89 @@ static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t * | |
| 6 | 6 | DWORD len = UNLEN + 1; | |
| 7 | 7 | int status = NO_ERROR; | |
| 8 | 8 | ||
| 9 | 9 | +#if 1 | |
| 10 | + | +#if 1 | |
| 10 | 19 | + HANDLE currthrtoken = GetCurrentThreadToken(); | |
| 20 | + | +#endif | |
| 11 | 21 | + TOKEN_USER *tu = NULL; | |
| 12 | 22 | + DWORD tulen = 0; | |
| 13 | 23 | + TOKEN_PRIMARY_GROUP *tg = NULL; | |
| 14 | 24 | + DWORD tglen = 0; | |
| 15 | 25 | + | |
| 16 | 26 | + if (!GetTokenInformation(currthrtoken, TokenUser, NULL, 0, &tulen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) { | |
| 17 | 27 | + eprintf("GetTokenInformation: TokenUser failed %d\n", (int)GetLastError()); | |
| 18 | 28 | + goto xdone; | |
| 19 | 29 | + } | |
| 20 | 30 | + | |
| 21 | 31 | + tu = (PTOKEN_USER)malloc(tulen); | |
| 22 | 32 | + if (!tu) { | |
| 23 | 33 | + eprintf("malloc(%d) PTOKEN_USER failed\n", (int)tulen); | |
| 24 | 34 | + goto xdone; | |
| 25 | 35 | + } | |
| 26 | 36 | + | |
| 27 | 37 | + /* Get the token user information from the access token. */ | |
| 28 | 38 | + if (!GetTokenInformation(currthrtoken, TokenUser, tu, tulen, &tulen)) { | |
| 29 | 39 | + eprintf("GetTokenInformation: TokenUser 2 failed %d\n", (int)GetLastError()); | |
| 30 | 40 | + goto xdone; | |
| 31 | 41 | + } | |
| 32 | 42 | + | |
| 33 | 43 | + /* get the account/domain name of the SID */ | |
| 34 | 44 | + char name[256]; | |
| 35 | 45 | + char domname[256]; | |
| 36 | 46 | + DWORD nlen = sizeof(name); | |
| 37 | 47 | + DWORD dlen = sizeof(domname); | |
| 38 | 48 | + SID_NAME_USE nameuse = 0; | |
| 39 | 49 | + if (!LookupAccountSidA(NULL, tu->User.Sid, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) { | |
| 40 | 50 | + eprintf("GetTokenInformation: user LookupAccountSidA failed %d\n", (int)GetLastError()); | |
| 41 | 51 | + goto xdone; | |
| 42 | 52 | + } | |
| 43 | 53 | + | |
| 44 | 54 | + DPRINTF(0, ("map_current_user_to_ids: name='%s'\n", name)); | |
| 45 | 55 | + | |
| 46 | 56 | + /* | |
| 47 | 57 | + * group | |
| 48 | 58 | + */ | |
| 49 | 59 | + | |
| 50 | 60 | + if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, NULL, 0, &tglen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) { | |
| 51 | 61 | + eprintf("GetTokenInformation: TokenPrimaryGroup failed %d\n", (int)GetLastError()); | |
| 52 | 62 | + goto xdone; | |
| 53 | 63 | + } | |
| 54 | 64 | + | |
| 55 | 65 | + tg = (PTOKEN_PRIMARY_GROUP)malloc(tglen); | |
| 56 | 66 | + if (!tg) { | |
| 57 | 67 | + eprintf("malloc(%d) PTOKEN_PRIMARY_GROUP failed %d\n", tglen, (int)GetLastError()); | |
| 58 | 68 | + goto xdone; | |
| 59 | 69 | + } | |
| 60 | 70 | + | |
| 61 | 71 | + /* Get the token user information from the access token. */ | |
| 62 | 72 | + if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, tg, tglen, &tglen)) { | |
| 63 | 73 | + eprintf("GetTokenInformation: TokenPrimaryGroup 2 failed %d\n", (int)GetLastError()); | |
| 64 | 74 | + goto xdone; | |
| 65 | 75 | + } | |
| 66 | 76 | + | |
| 67 | 77 | + /* get the account/domain name of the SID */ | |
| 68 | 78 | + nlen = sizeof(name); | |
| 69 | 79 | + dlen = sizeof(domname); | |
| 70 | 80 | + nameuse = 0; | |
| 71 | 81 | + if (!LookupAccountSidA(NULL, tg->PrimaryGroup, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) { | |
| 72 | 82 | + eprintf("GetTokenInformation: group LookupAccountSidA failed %d\n", (int)GetLastError()); | |
| 73 | 83 | + goto xdone; | |
| 74 | 84 | + } | |
| 75 | 85 | + DPRINTF(0, ("map_current_user_to_ids: group='%s'\n", name)); | |
| 76 | 86 | + | |
| 77 | 87 | +xdone: | |
| 78 | 88 | + free(tu); | |
| 79 | 89 | + free(tg); | |
| 80 | 90 | +#endif | |
| 81 | 91 | + | |
| 82 | 92 | if (!GetUserNameA(username, &len)) { | |
| 83 | 93 | status = GetLastError(); | |
| 84 | 94 | eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status); | |
| 85 | 95 |
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.
nrubsig.kpaste.net RSS