pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

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

    
11
diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
2-
index a7ce502..8807589 100644
2+
index a7ce502..a86c3ae 100644
33
--- a/daemon/nfs41_daemon.c
44
+++ 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 *
66
     DWORD len = UNLEN + 1;
77
     int status = NO_ERROR;
88
99
+#if 1
10+
+#if 1
1019
+    HANDLE currthrtoken = GetCurrentThreadToken();
20+
+#endif
1121
+    TOKEN_USER *tu = NULL;
1222
+    DWORD tulen = 0;
1323
+    TOKEN_PRIMARY_GROUP *tg = NULL;
1424
+    DWORD tglen = 0;
1525
+
1626
+    if (!GetTokenInformation(currthrtoken, TokenUser, NULL, 0, &tulen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) {
1727
+        eprintf("GetTokenInformation: TokenUser failed %d\n", (int)GetLastError());
1828
+        goto xdone;
1929
+    }
2030
+
2131
+    tu = (PTOKEN_USER)malloc(tulen);
2232
+    if (!tu) {
2333
+        eprintf("malloc(%d) PTOKEN_USER failed\n", (int)tulen);
2434
+        goto xdone;
2535
+    }
2636
+
2737
+    /* Get the token user information from the access token. */
2838
+    if (!GetTokenInformation(currthrtoken, TokenUser, tu, tulen, &tulen)) {
2939
+        eprintf("GetTokenInformation: TokenUser 2 failed %d\n", (int)GetLastError());
3040
+        goto xdone;
3141
+    }
3242
+
3343
+    /* get the account/domain name of the SID */
3444
+    char name[256];
3545
+    char domname[256];
3646
+    DWORD nlen = sizeof(name);
3747
+    DWORD dlen = sizeof(domname);
3848
+    SID_NAME_USE nameuse = 0;
3949
+    if (!LookupAccountSidA(NULL, tu->User.Sid, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) {
4050
+        eprintf("GetTokenInformation: user LookupAccountSidA failed %d\n", (int)GetLastError());
4151
+	goto xdone;
4252
+    }
4353
+
4454
+    DPRINTF(0, ("map_current_user_to_ids: name='%s'\n", name));
4555
+
4656
+    /*
4757
+     * group
4858
+     */
4959
+
5060
+    if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, NULL, 0, &tglen) && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) {
5161
+        eprintf("GetTokenInformation: TokenPrimaryGroup failed %d\n", (int)GetLastError());
5262
+        goto xdone;
5363
+    }
5464
+
5565
+    tg = (PTOKEN_PRIMARY_GROUP)malloc(tglen);
5666
+    if (!tg) {
5767
+        eprintf("malloc(%d) PTOKEN_PRIMARY_GROUP failed %d\n", tglen, (int)GetLastError());
5868
+        goto xdone;
5969
+    }
6070
+
6171
+    /* Get the token user information from the access token. */
6272
+    if (!GetTokenInformation(currthrtoken, TokenPrimaryGroup, tg, tglen, &tglen)) {
6373
+        eprintf("GetTokenInformation: TokenPrimaryGroup 2 failed %d\n", (int)GetLastError());
6474
+        goto xdone;
6575
+    }
6676
+
6777
+    /* get the account/domain name of the SID */
6878
+    nlen = sizeof(name);
6979
+    dlen = sizeof(domname);
7080
+    nameuse = 0;
7181
+    if (!LookupAccountSidA(NULL, tg->PrimaryGroup, name, &nlen, domname, &dlen, (PSID_NAME_USE)&nameuse)) {
7282
+        eprintf("GetTokenInformation: group LookupAccountSidA failed %d\n", (int)GetLastError());
7383
+	goto xdone;
7484
+    }
7585
+    DPRINTF(0, ("map_current_user_to_ids: group='%s'\n", name));
7686
+
7787
+xdone:
7888
+    free(tu);
7989
+    free(tg);
8090
+#endif
8191
+
8292
     if (!GetUserNameA(username, &len)) {
8393
         status = GetLastError();
8494
         eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status);
8595

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at