pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for kernel debugging, winsg, disk+net transfer timeouts, 2024-05-29
Posted by Anonymous on Wed 29th May 2024 16:26
raw | new post

  1. From 1478e624662fbc138e808e275fe696880a22bfa4 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 29 May 2024 12:36:44 +0200
  4. Subject: [PATCH 1/5] sys: Prefix debug output
  5.  %x-->0x%x,%p-->0x%p,%o-->0%o,NTSTATUS-->0x%x
  6.  
  7. Prefix debug output %x-->0x%x,%p-->0x%p,%o-->0%o,NTSTATUS-->0x%x
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. sys/nfs41_driver.c | 168 ++++++++++++++++++++++++---------------------
  12.  1 file changed, 90 insertions(+), 78 deletions(-)
  13.  
  14. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  15. index c5c8c8f..6918abb 100644
  16. --- a/sys/nfs41_driver.c
  17. +++ b/sys/nfs41_driver.c
  18. @@ -503,7 +503,7 @@ void print_debug_header(
  19.      PIO_STACK_LOCATION IrpSp = RxContext->CurrentIrpSp;
  20.  
  21.      if (IrpSp) {
  22. -        DbgP("FileOject %p name '%wZ' access r=%d,w=%d,d=%d share r=%d,w=%d,d=%d\n",
  23. +        DbgP("FileOject 0x%p name '%wZ' access r=%d,w=%d,d=%d share r=%d,w=%d,d=%d\n",
  24.              IrpSp->FileObject, &IrpSp->FileObject->FileName,
  25.              IrpSp->FileObject->ReadAccess, IrpSp->FileObject->WriteAccess,
  26.              IrpSp->FileObject->DeleteAccess, IrpSp->FileObject->SharedRead,
  27. @@ -616,7 +616,7 @@ NTSTATUS marshal_nfs41_header(
  28.              entry->version, entry->session, entry->open_state);
  29.  #endif /* DEBUG_MARSHAL_HEADER */
  30.      else {
  31. -        DbgP("[upcall header] Invalid filename %p\n", entry);
  32. +        DbgP("[upcall header] Invalid filename 0x%p\n", entry);
  33.          status = STATUS_INTERNAL_ERROR;
  34.      }
  35.  out:
  36. @@ -774,11 +774,11 @@ NTSTATUS marshal_nfs41_open(
  37.  
  38.  #ifdef DEBUG_MARSHAL_DETAIL
  39.      DbgP("marshal_nfs41_open: name='%wZ' mask=0x%x access=0x%x attrs=0x%x "
  40. -         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o "
  41. +         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=0%o "
  42.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  43.           "owner_local_uid=%lu owner_group_local_gid=%lu "
  44.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  45. -         "srv_open=%p ea=%p\n",
  46. +         "srv_open=0x%p ea=0x%p\n",
  47.           entry->filename, entry->u.Open.access_mask,
  48.           entry->u.Open.access_mode, entry->u.Open.attrs, entry->u.Open.copts,
  49.           entry->u.Open.disp, entry->u.Open.open_owner_id, entry->u.Open.mode,
  50. @@ -848,9 +848,10 @@ NTSTATUS marshal_nfs41_rw(
  51.      *len = header_len;
  52.  
  53.  
  54.  
  55.  #ifdef DEBUG_MARSHAL_DETAIL
  56.  
  57. -    DbgP("marshal_nfs41_rw: len=%lu offset=%llu MdlAddress=%p Userspace=%p\n",
  58.  
  59. -         entry->buf_len, entry->u.ReadWrite.offset,
  60.  
  61. -         entry->u.ReadWrite.MdlAddress, entry->buf);
  62.  
  63. +    DbgP("marshal_nfs41_rw: len=%lu offset=%llu "
  64. +        "MdlAddress=0x%p Userspace=0x%p\n",
  65. +        entry->buf_len, entry->u.ReadWrite.offset,
  66. +        entry->u.ReadWrite.MdlAddress, entry->buf);
  67.  #endif
  68.  
  69.  out:
  70.  
  71.      return status;
  72.  
  73. @@ -969,7 +970,7 @@ NTSTATUS marshal_nfs41_close(
  74.      *len = header_len;
  75.  
  76.  #ifdef DEBUG_MARSHAL_DETAIL
  77. -    DbgP("marshal_nfs41_close: name='%wZ' remove=%d srv_open=%p renamed=%d\n",
  78. +    DbgP("marshal_nfs41_close: name='%wZ' remove=%d srv_open=0x%p renamed=%d\n",
  79.          entry->filename->Length?entry->filename:&SLASH,
  80.          entry->u.Close.remove, entry->u.Close.srv_open, entry->u.Close.renamed);
  81.  #endif
  82. @@ -1333,7 +1334,7 @@ NTSTATUS marshal_nfs41_setacl(
  83.      *len = header_len;
  84.  
  85.  
  86.  
  87.  #ifdef DEBUG_MARSHAL_DETAIL
  88.  
  89. -    DbgP("marshal_nfs41_setacl: class=0x%x sec_desc_len=%lu\n",
  90.  
  91. +    DbgP("marshal_nfs41_setacl: class=0x%x sec_desc_len=%lu\n",
  92.           entry->u.Acl.query, entry->buf_len);
  93.  
  94.  #endif
  95.  
  96.  out:
  97.  
  98. @@ -1359,7 +1360,7 @@ void nfs41_invalidate_cache (
  99.  
  100.      RtlCopyMemory(&srv_open, buf, sizeof(HANDLE));
  101.  #ifdef DEBUG_INVALIDATE_CACHE
  102. -    DbgP("nfs41_invalidate_cache: received srv_open=%p '%wZ'\n",
  103. +    DbgP("nfs41_invalidate_cache: received srv_open=0x%p '%wZ'\n",
  104.          srv_open, srv_open->pAlreadyPrefixedName);
  105.  #endif
  106.      if (MmIsAddressValid(srv_open))
  107. @@ -1429,7 +1430,8 @@ NTSTATUS handle_upcall(
  108.      status = SeImpersonateClientEx(entry->psec_ctx, NULL);
  109.  #endif /* NFS41_DRIVER_STABILITY_HACKS */
  110.      if (status != STATUS_SUCCESS) {
  111. -        print_error("SeImpersonateClientEx failed %x\n", status);
  112. +        print_error("handle_upcall: "
  113. +            "SeImpersonateClientEx() failed 0x%x\n", status);
  114.          goto out;
  115.      }
  116.  
  117.  
  118.  
  119. @@ -1556,7 +1558,8 @@ NTSTATUS nfs41_UpcallCreate(
  120.                      FALSE, entry->psec_ctx);
  121.          if (status != STATUS_SUCCESS) {
  122.              print_error("nfs41_UpcallCreate: "
  123. -                "SeCreateClientSecurityFromSubjectContext failed with %x\n",
  124. +                "SeCreateClientSecurityFromSubjectContext() "
  125. +                "failed with 0x%x\n",
  126.                  status);
  127.              RxFreePool(entry);
  128.             entry = NULL;
  129. @@ -1628,7 +1631,7 @@ retry_wait:
  130.      case STATUS_ALERTED:
  131.          DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  132.              "returned status(=%ld), "
  133. -            "retry waiting for '%s' entry=%p xid=%lld\n",
  134. +            "retry waiting for '%s' entry=0x%p xid=%lld\n",
  135.              (long)status,
  136.              ENTRY_OPCODE2STRING(entry),
  137.              entry,
  138. @@ -1643,7 +1646,7 @@ retry_wait:
  139.              ExReleaseFastMutex(&entry->lock);
  140.              break;
  141.          }
  142. -        DbgP("[upcall] abandoning '%s' entry=%p xid=%lld\n",
  143. +        DbgP("[upcall] abandoning '%s' entry=0x%p xid=%lld\n",
  144.              ENTRY_OPCODE2STRING(entry),
  145.              entry,
  146.              (entry?entry->xid:-1LL));
  147. @@ -1738,7 +1741,7 @@ void unmarshal_nfs41_header(
  148.      RtlCopyMemory(&tmp->errno, *buf, sizeof(tmp->errno));
  149.      *buf += sizeof(tmp->errno);
  150.  #ifdef DEBUG_MARSHAL_HEADER
  151. -    DbgP("[downcall header] xid=%lld opcode='%s' status=%d errno=%d\n", tmp->xid,
  152. +    DbgP("[downcall header] xid=%lld opcode='%s' status=0x%x errno=%d\n", tmp->xid,
  153.          ENTRY_OPCODE2STRING(tmp), tmp->status, tmp->errno);
  154.  #endif
  155.  }
  156. @@ -1858,7 +1861,7 @@ NTSTATUS unmarshal_nfs41_open(
  157.  #endif
  158.      }
  159.  #ifdef DEBUG_MARSHAL_DETAIL
  160. -    DbgP("unmarshal_nfs41_open: open_state 0x%x mode %o "
  161. +    DbgP("unmarshal_nfs41_open: open_state 0x%x mode 0%o "
  162.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  163.          "owner_local_uid %u owner_group_local_gid %u "
  164.  #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  165. @@ -2474,7 +2477,7 @@ NTSTATUS nfs41_DeleteConnection (
  166.          if (NodeType(VNetRoot) == RDBSS_NTC_V_NETROOT)
  167.  
  168.          {
  169.  
  170.  #ifdef DEBUG_MOUNT
  171.  
  172. -            DbgP("Calling RxFinalizeConnection for NetRoot %p from VNetRoot %p\n",
  173.  
  174. +            DbgP("Calling RxFinalizeConnection for NetRoot 0x%p from VNetRoot 0x%p\n",
  175.  
  176.                  VNetRoot->NetRoot, VNetRoot);
  177.  
  178.  #endif
  179.  
  180.              status = RxFinalizeConnection(VNetRoot->NetRoot, VNetRoot, TRUE);
  181.  
  182. @@ -2751,7 +2754,7 @@ NTSTATUS map_mount_errors(
  183.      case ERROR_INTERNAL_ERROR:  return STATUS_INTERNAL_ERROR;
  184.      default:
  185.          print_error("map_mount_errors: "
  186. -            "failed to map windows ERROR_%d to NTSTATUS; "
  187. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  188.              "defaulting to STATUS_INSUFFICIENT_RESOURCES\n", status);
  189.          return STATUS_INSUFFICIENT_RESOURCES;
  190.      }
  191. @@ -2884,7 +2887,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  192.      IN ULONG EaLength,
  193.      IN OUT PNFS41_MOUNT_CONFIG Config)
  194.  {
  195. -    DbgP("--> nfs41_MountConfig_ParseOptions(EaBuffer=%p,EaLength=%ld)\n",
  196. +    DbgP("--> nfs41_MountConfig_ParseOptions(EaBuffer=0x%p,EaLength=%ld)\n",
  197.          (void *)EaBuffer,
  198.          (long)EaLength);
  199.      NTSTATUS  status = STATUS_SUCCESS;
  200. @@ -2896,8 +2899,8 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  201.  
  202.      status = IoCheckEaBufferValidity(EaBuffer, EaLength, &error_offset);
  203.      if (status) {
  204. -        DbgP("status(=%d)=IoCheckEaBufferValidity"
  205. -            "(eainfo=%p, buflen=%lu, &(error_offset=%d)) failed\n",
  206. +        DbgP("status(=0x%x)=IoCheckEaBufferValidity"
  207. +            "(eainfo=0x%p, buflen=%lu, &(error_offset=%d)) failed\n",
  208.              (int)status, (void *)EaBuffer, EaLength,
  209.              (int)error_offset);
  210.          goto out;
  211. @@ -2905,7 +2908,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  212.  
  213.      Option = EaBuffer;
  214.      while (status == STATUS_SUCCESS) {
  215. -        DbgP("Option=%p\n", (void *)Option);
  216. +        DbgP("Option=0x%p\n", (void *)Option);
  217.          Name = (LPWSTR)Option->EaName;
  218.          NameLen = Option->EaNameLength/sizeof(WCHAR);
  219.  
  220. @@ -3063,12 +3066,13 @@ NTSTATUS nfs41_GetLUID(
  221.          FALSE, &clnt_sec_ctx);
  222.      if (status) {
  223.          print_error("nfs41_GetLUID: SeCreateClientSecurityFromSubjectContext "
  224. -             "failed %x\n", status);
  225. +             "failed 0x%x\n", status);
  226.          goto release_sec_ctx;
  227.  
  228.      }
  229.  
  230.      status = SeQueryAuthenticationIdToken(clnt_sec_ctx.ClientToken, id);
  231.  
  232.      if (status) {
  233.  
  234. -        print_error("SeQueryAuthenticationIdToken failed %x\n", status);
  235.  
  236. +        print_error("nfs41_GetLUID: "
  237. +            "SeQueryAuthenticationIdToken() failed 0x%x\n", status);
  238.  
  239.          goto release_clnt_sec_ctx;
  240.  
  241.      }
  242.  
  243.  release_clnt_sec_ctx:
  244.  
  245. @@ -3103,10 +3107,10 @@ NTSTATUS nfs41_get_sec_ctx(
  246.          FALSE, out_ctx);
  247.      if (status != STATUS_SUCCESS) {
  248.          print_error("SeCreateClientSecurityFromSubjectContext "
  249. -            "failed with %x\n", status);
  250. +            "failed with 0x%x\n", status);
  251.      }
  252.  
  253.  #ifdef DEBUG_MOUNT
  254.  
  255. -    DbgP("Created client security token %p\n", out_ctx->ClientToken);
  256.  
  257. +    DbgP("Created client security token 0x%p\n", out_ctx->ClientToken);
  258.  
  259.  #endif
  260.  
  261.      SeReleaseSubjectContext(&ctx);
  262.  
  263.  
  264.  
  265. @@ -3141,7 +3145,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  266.      print_net_root(0, pNetRoot);
  267.  
  268.      print_v_net_root(0, pVNetRoot);
  269.  
  270. -    DbgP("pVNetRoot=%p pNetRoot=%p pSrvCall=%p\n", pVNetRoot, pNetRoot, pSrvCall);
  271. +    DbgP("pVNetRoot=0x%p pNetRoot=0x%p pSrvCall=0x%p\n", pVNetRoot, pNetRoot, pSrvCall);
  272.      DbgP("pNetRoot='%wZ' Type=%d pSrvCallName='%wZ' VirtualNetRootStatus=0x%x "
  273.          "NetRootStatus=0x%x\n", pNetRoot->pNetRootName,
  274.          pNetRoot->Type, pSrvCall->pSrvCallName,
  275. @@ -3179,7 +3183,8 @@ NTSTATUS nfs41_CreateVNetRoot(
  276.  
  277.      if (pCreateNetRootContext->RxContext->Create.EaLength) {
  278.          /* Codepath for nfs_mount.exe */
  279. -        DbgP("Codepath for nfs_mount.exe, Create->{ EaBuffer=%p, EaLength=%ld }\n",
  280. +        DbgP("Codepath for nfs_mount.exe, "
  281. +            "Create->{ EaBuffer=0x%p, EaLength=%ld }\n",
  282.              pCreateNetRootContext->RxContext->Create.EaBuffer,
  283.              (long)pCreateNetRootContext->RxContext->Create.EaLength);
  284.  
  285. @@ -3210,7 +3215,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  286.               * We can only support UNC paths when we got valid
  287.               * mount options via nfs_mount.exe before this point.
  288.               */
  289. -            DbgP("pNetRootContext(=%p) not initalised yet\n",
  290. +            DbgP("pNetRootContext(=0x%p) not initalised yet\n",
  291.                  pNetRootContext);
  292.              status = STATUS_NFS_SHARE_NOT_MOUNTED;
  293.              goto out_free;
  294. @@ -3309,8 +3314,10 @@ NTSTATUS nfs41_CreateVNetRoot(
  295.              existing_mount = (nfs41_mount_entry *)CONTAINING_RECORD(pEntry,
  296.  
  297.                      nfs41_mount_entry, next);
  298.  
  299.  #ifdef DEBUG_MOUNT
  300.  
  301. -            DbgP("comparing %x.%x with %x.%x\n", luid.HighPart, luid.LowPart,
  302.  
  303. -                existing_mount->login_id.HighPart, existing_mount->login_id.LowPart);
  304.  
  305. +            DbgP("comparing 0x%x.0x%x with 0x%x.0x%x\n",
  306. +                luid.HighPart, luid.LowPart,
  307. +                existing_mount->login_id.HighPart,
  308. +                existing_mount->login_id.LowPart);
  309.  #endif
  310.  
  311.              if (RtlEqualLuid(&luid, &existing_mount->login_id)) {
  312.  
  313.  #ifdef DEBUG_MOUNT
  314.  
  315. @@ -3400,7 +3407,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  316.          ASSERT(existing_mount != NULL);
  317.  
  318.          /* modify existing mount entry */
  319.  
  320.  #ifdef DEBUG_MOUNT
  321.  
  322. -        DbgP("Using existing %d flavor session 0x%x\n",
  323.  
  324. +        DbgP("Using existing %d flavor session 0x%x\n",
  325.              pVNetRootContext->sec_flavor);
  326.  
  327.  #endif
  328.  
  329.          switch (pVNetRootContext->sec_flavor) {
  330.  
  331. @@ -3464,7 +3471,7 @@ VOID nfs41_ExtractNetRootName(
  332.      NetRootName->Length = NetRootName->MaximumLength
  333.                  = (USHORT)((PCHAR)w - (PCHAR)wlow);
  334.  #ifdef DEBUG_MOUNT
  335. -    DbgP("In: pSrvCall %p PathName='%wZ' SrvCallName='%wZ' Out: NetRootName='%wZ'\n",
  336. +    DbgP("In: pSrvCall 0x%p PathName='%wZ' SrvCallName='%wZ' Out: NetRootName='%wZ'\n",
  337.          SrvCall, FilePathName, SrvCall->pSrvCallName, NetRootName);
  338.  #endif
  339.      return;
  340. @@ -3535,7 +3542,7 @@ NTSTATUS nfs41_FinalizeNetRoot(
  341.          if (mount_tmp == NULL)
  342.  
  343.              break;
  344.  
  345.  #ifdef DEBUG_MOUNT
  346.  
  347. -        DbgP("Removing entry luid %x.%x from mount list\n",
  348.  
  349. +        DbgP("Removing entry luid 0x%x.0x%x from mount list\n",
  350.              mount_tmp->login_id.HighPart, mount_tmp->login_id.LowPart);
  351.  
  352.  #endif
  353.  
  354.          if (mount_tmp->authsys_session != INVALID_HANDLE_VALUE) {
  355.  
  356. @@ -3716,8 +3723,8 @@ NTSTATUS map_open_errors(
  357.      case ERROR_BAD_FILE_TYPE:           return STATUS_NOT_A_DIRECTORY;
  358.      case ERROR_INTERNAL_ERROR:          return STATUS_INTERNAL_ERROR;
  359.      default:
  360. -        print_error("[ERROR] nfs41_Create: upcall returned ERROR_%d returning "
  361. -            "STATUS_INSUFFICIENT_RESOURCES\n", status);
  362. +        print_error("[ERROR] nfs41_Create: upcall returned ERROR_0x%x "
  363. +            "returning STATUS_INSUFFICIENT_RESOURCES\n", status);
  364.      case ERROR_OUTOFMEMORY:             return STATUS_INSUFFICIENT_RESOURCES;
  365.      }
  366.  }
  367.  
  368. @@ -3935,7 +3942,7 @@ NTSTATUS nfs41_Create(
  369.          if (ea && AnsiStrEq(&NfsV3Attributes, ea->EaName, ea->EaNameLength)) {
  370.  
  371.              nfs3_attrs *attrs = (nfs3_attrs *)(ea->EaName + ea->EaNameLength + 1);
  372.  
  373.  #ifdef DEBUG_OPEN
  374.  
  375. -            DbgP("creating file with mode %o\n", attrs->mode);
  376.  
  377. +            DbgP("creating file with mode 0%o\n", attrs->mode);
  378.  
  379.  #endif
  380.  
  381.              entry->u.Open.mode = attrs->mode;
  382.  
  383.          }
  384.  
  385. @@ -4063,7 +4070,7 @@ retry_on_link:
  386.          goto out_free;
  387.  
  388.      }
  389.  
  390.  #ifdef DEBUG_OPEN
  391.  
  392. -    DbgP("nfs41_Create: created FOBX %p\n", RxContext->pFobx);
  393.  
  394. +    DbgP("nfs41_Create: created FOBX 0x%p\n", RxContext->pFobx);
  395.  
  396.  #endif
  397.      nfs41_fobx = (PNFS41_FOBX)(RxContext->pFobx)->Context;
  398.      nfs41_fobx->nfs41_open_state = entry->open_state;
  399. @@ -4174,7 +4181,7 @@ retry_on_link:
  400.          } else if (!entry->u.Open.deleg_type && !Fcb->OpenCount) {
  401.  
  402.              nfs41_fcb_list_entry *oentry;
  403.  
  404.  #ifdef DEBUG_OPEN
  405.  
  406. -            DbgP("nfs41_Create: received no delegations: srv_open=%p "
  407. +            DbgP("nfs41_Create: received no delegations: srv_open=0x%p "
  408.                  "ctime=%llu\n", SrvOpen, entry->ChangeTime);
  409.  #endif
  410.              oentry = RxAllocatePoolWithTag(NonPagedPoolNx,
  411. @@ -4263,7 +4270,7 @@ ULONG nfs41_ExtendForCache(
  412.      PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
  413.  
  414.      DbgEn();
  415.  
  416.      print_debug_header(RxContext);
  417.  
  418. -    DbgP("input: byte count 0x%x filesize 0x%x alloc size 0x%x\n",
  419.  
  420. +    DbgP("input: byte count 0x%x filesize 0x%x alloc size 0x%x\n",
  421.          LowIoContext->ParamsFor.ReadWrite.ByteCount, *pNewFileSize,
  422.  
  423.          *pNewAllocationSize);
  424.  
  425.  #endif
  426.  
  427. @@ -4272,8 +4279,8 @@ ULONG nfs41_ExtendForCache(
  428.          pNewAllocationSize->QuadPart;
  429.  
  430.      nfs41_fcb->StandardInfo.EndOfFile.QuadPart = pNewFileSize->QuadPart;
  431.  
  432.  #ifdef DEBUG_CACHE
  433.  
  434. -    DbgP("new filesize 0x%x new allocation size 0x%x\n", *pNewFileSize,
  435.  
  436. -        *pNewAllocationSize);
  437.  
  438. +    DbgP("new filesize 0x%x new allocation size 0x%x\n",
  439. +        *pNewFileSize, *pNewAllocationSize);
  440.  #endif
  441.  
  442.  #ifdef DEBUG_CACHE
  443.  
  444.      DbgEx();
  445.  
  446. @@ -4294,7 +4301,7 @@ VOID nfs41_remove_fcb_entry(
  447.                  nfs41_fcb_list_entry, next);
  448.  
  449.          if (cur->fcb == fcb) {
  450.  
  451.  #ifdef DEBUG_CLOSE
  452.  
  453. -            DbgP("nfs41_remove_srvopen_entry: Found match for fcb=%p\n", fcb);
  454.  
  455. +            DbgP("nfs41_remove_srvopen_entry: Found match for fcb=0x%p\n", fcb);
  456.  
  457.  #endif
  458.  
  459.              RemoveEntryList(pEntry);
  460.  
  461.              RxFreePool(cur);
  462.  
  463. @@ -4302,8 +4309,8 @@ VOID nfs41_remove_fcb_entry(
  464.          }
  465.  
  466.          if (pEntry->Flink == &openlist.head) {
  467.  
  468.  #ifdef DEBUG_CLOSE
  469.  
  470. -            DbgP("nfs41_remove_srvopen_entry: reached EOL looking for fcb "
  471.  
  472. -                "%p\n", fcb);
  473.  
  474. +            DbgP("nfs41_remove_srvopen_entry: reached EOL looking "
  475. +                "for fcb 0x%p\n", fcb);
  476.  #endif
  477.  
  478.              break;
  479.  
  480.          }
  481.  
  482. @@ -4322,7 +4329,7 @@ NTSTATUS map_close_errors(
  483.      case ERROR_FILE_INVALID:    return STATUS_FILE_INVALID;
  484.      default:
  485.          print_error("map_close_errors: "
  486. -            "failed to map windows ERROR_%d to NTSTATUS; "
  487. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  488.              "defaulting to STATUS_INTERNAL_ERROR\n", status);
  489.      case ERROR_INTERNAL_ERROR:  return STATUS_INTERNAL_ERROR;
  490.      }
  491. @@ -4458,7 +4465,7 @@ NTSTATUS map_querydir_errors(
  492.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  493.      default:
  494.          print_error("map_querydir_errors: "
  495. -            "failed to map windows ERROR_%d to NTSTATUS; "
  496. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  497.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", status);
  498.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  499.      }
  500. @@ -4604,7 +4611,7 @@ NTSTATUS map_volume_errors(
  501.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  502.      default:
  503.          print_error("map_volume_errors: "
  504. -            "failed to map windows ERROR_%d to NTSTATUS; "
  505. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  506.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", status);
  507.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  508.      }
  509. @@ -4805,8 +4812,9 @@ VOID nfs41_update_fcb_list(
  510.                  cur->ChangeTime != ChangeTime) {
  511.  
  512.  #if defined(DEBUG_FILE_SET) || defined(DEBUG_ACL_SET) || \
  513.  
  514.      defined(DEBUG_WRITE) || defined(DEBUG_EA_SET)
  515.  
  516. -            DbgP("nfs41_update_fcb_list: Found match for fcb %p: updating "
  517.  
  518. -                "%llu to %llu\n", fcb, cur->ChangeTime, ChangeTime);
  519.  
  520. +            DbgP("nfs41_update_fcb_list: Found match for fcb 0x%p: "
  521. +                "updating %llu to %llu\n",
  522. +                fcb, cur->ChangeTime, ChangeTime);
  523.  #endif
  524.  
  525.              cur->ChangeTime = ChangeTime;
  526.  
  527.              break;
  528.  
  529. @@ -4816,7 +4824,7 @@ VOID nfs41_update_fcb_list(
  530.  #if defined(DEBUG_FILE_SET) || defined(DEBUG_ACL_SET) || \
  531.  
  532.      defined(DEBUG_WRITE) || defined(DEBUG_EA_SET)
  533.  
  534.              DbgP("nfs41_update_fcb_list: reached EOL loooking for "
  535.  
  536. -                "fcb=%p\n", fcb);
  537.  
  538. +                "fcb=0x%p\n", fcb);
  539.  
  540.  #endif
  541.  
  542.              break;
  543.  
  544.          }
  545.  
  546. @@ -4828,7 +4836,8 @@ VOID nfs41_update_fcb_list(
  547.  void print_nfs3_attrs(
  548.  
  549.      nfs3_attrs *attrs)
  550.  
  551.  {
  552.  
  553. -    DbgP("type=%d mode=%o nlink=%d size=%d atime=%x mtime=%x ctime=%x\n",
  554.  
  555. +    DbgP("type=%d mode=0%o nlink=%d size=%d "
  556. +        "atime=0x%x mtime=0x%x ctime=0x%x\n",
  557.  
  558.          attrs->type, attrs->mode, attrs->nlink, attrs->size, attrs->atime,
  559.  
  560.          attrs->mtime, attrs->ctime);
  561.  
  562.  }
  563.  
  564. @@ -4886,7 +4895,7 @@ NTSTATUS map_setea_error(
  565.      case ERROR_INTERNAL_ERROR:          return STATUS_INTERNAL_ERROR;
  566.      default:
  567.          print_error("map_setea_error: "
  568. -            "failed to map windows ERROR_%d to NTSTATUS; "
  569. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  570.              "defaulting to STATUS_INVALID_PARAMETER\n", error);
  571.      case ERROR_INVALID_PARAMETER:       return STATUS_INVALID_PARAMETER;
  572.      }
  573. @@ -4973,7 +4982,7 @@ NTSTATUS nfs41_SetEaInformation(
  574.          attrs = (nfs3_attrs *)(eainfo->EaName + eainfo->EaNameLength + 1);
  575.  
  576.  #ifdef DEBUG_EA_SET
  577.  
  578.          print_nfs3_attrs(attrs);
  579.  
  580. -        DbgP("old mode is %o new mode is %o\n", nfs41_fcb->mode, attrs->mode);
  581.  
  582. +        DbgP("old mode is 0%o new mode is 0%o\n", nfs41_fcb->mode, attrs->mode);
  583.  
  584.  #endif
  585.  
  586.          entry->u.SetEa.mode = attrs->mode;
  587.  
  588.      } else {
  589.  
  590. @@ -4981,8 +4990,8 @@ NTSTATUS nfs41_SetEaInformation(
  591.          status = IoCheckEaBufferValidity(eainfo, buflen, &error_offset);
  592.          if (status) {
  593.              DbgP("nfs41_SetEaInformation: "
  594. -                "status(=%d)=IoCheckEaBufferValidity"
  595. -                "(eainfo=%p, buflen=%lu, &(error_offset=%d))\n",
  596. +                "status(=0x%x)=IoCheckEaBufferValidity"
  597. +                "(eainfo=0x%p, buflen=%lu, &(error_offset=%d))\n",
  598.                  (int)status, (void *)eainfo, buflen,
  599.                  (int)error_offset);
  600.              nfs41_UpcallDestroy(entry);
  601. @@ -5306,7 +5315,7 @@ NTSTATUS map_query_acl_error(
  602.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  603.      default:
  604.          print_error("map_query_acl_error: "
  605. -            "failed to map windows ERROR_%d to NTSTATUS; "
  606. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  607.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", error);
  608.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  609.      }
  610. @@ -5512,7 +5521,7 @@ NTSTATUS nfs41_SetSecurityInformation(
  611.          status = RtlGetDaclSecurityDescriptor(sec_desc, &present, &acl,
  612.  
  613.                      &dacl_default);
  614.  
  615.          if (status) {
  616.  
  617. -            DbgP("RtlGetDaclSecurityDescriptor failed %x\n", status);
  618.  
  619. +            DbgP("RtlGetDaclSecurityDescriptor failed 0x%x\n", status);
  620.  
  621.              goto out;
  622.  
  623.          }
  624.  
  625.          if (present == FALSE) {
  626.  
  627. @@ -5572,7 +5581,7 @@ NTSTATUS map_queryfile_error(
  628.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  629.      default:
  630.          print_error("map_queryfile_error: "
  631. -            "failed to map windows ERROR_%d to NTSTATUS; "
  632. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  633.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", error);
  634.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  635.      }
  636. @@ -5640,7 +5649,8 @@ NTSTATUS nfs41_QueryFileInformation(
  637.          pVNetRootContext->session, nfs41_fobx->nfs41_open_state,
  638.          pNetRootContext->nfs41d_version, SrvOpen->pAlreadyPrefixedName, &entry);
  639.      if (status) {
  640. -        print_error("nfs41_UpcallCreate() failed, status=%d\n", status);
  641. +        print_error("nfs41_UpcallCreate() failed, status=0x%x\n",
  642. +            status);
  643.          goto out;
  644.      }
  645.  
  646. @@ -5650,7 +5660,8 @@ NTSTATUS nfs41_QueryFileInformation(
  647.  
  648.      status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
  649.      if (status) {
  650. -        print_error("nfs41_UpcallWaitForReply() failed, status=%d\n", status);
  651. +        print_error("nfs41_UpcallWaitForReply() failed, status=0x%x\n",
  652. +            status);
  653.          goto out;
  654.      }
  655.  
  656. @@ -5689,7 +5700,7 @@ NTSTATUS nfs41_QueryFileInformation(
  657.              if (nfs41_fcb->StandardInfo.AllocationSize.QuadPart >
  658.  
  659.                      std_info->AllocationSize.QuadPart) {
  660.  
  661.  #ifdef DEBUG_FILE_QUERY
  662.  
  663. -                DbgP("Old AllocationSize is bigger: saving %x\n",
  664.  
  665. +                DbgP("Old AllocationSize is bigger: saving 0x%x\n",
  666.                      nfs41_fcb->StandardInfo.AllocationSize.QuadPart);
  667.  
  668.  #endif
  669.  
  670.                  std_info->AllocationSize.QuadPart =
  671.  
  672. @@ -5698,7 +5709,7 @@ NTSTATUS nfs41_QueryFileInformation(
  673.              if (nfs41_fcb->StandardInfo.EndOfFile.QuadPart >
  674.  
  675.                      std_info->EndOfFile.QuadPart) {
  676.  
  677.  #ifdef DEBUG_FILE_QUERY
  678.  
  679. -                DbgP("Old EndOfFile is bigger: saving %x\n",
  680.  
  681. +                DbgP("Old EndOfFile is bigger: saving 0x%x\n",
  682.                      nfs41_fcb->StandardInfo.EndOfFile);
  683.  
  684.  #endif
  685.  
  686.                  std_info->EndOfFile.QuadPart =
  687.  
  688. @@ -5759,7 +5770,7 @@ NTSTATUS map_setfile_error(
  689.      case ERROR_INTERNAL_ERROR:          return STATUS_INTERNAL_ERROR;
  690.      default:
  691.          print_error("map_setfile_error: "
  692. -            "failed to map windows ERROR_%d to NTSTATUS; "
  693. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  694.              "defaulting to STATUS_INVALID_PARAMETER\n", error);
  695.      case ERROR_INVALID_PARAMETER:       return STATUS_INVALID_PARAMETER;
  696.      }
  697. @@ -6050,7 +6061,7 @@ NTSTATUS nfs41_ComputeNewBufferingState(
  698.              FCB_STATE_WRITECACHING_ENABLED | FCB_STATE_WRITEBUFFERING_ENABLED);
  699.      }
  700.  #ifdef DEBUG_TIME_BASED_COHERENCY
  701. -    DbgP("nfs41_ComputeNewBufferingState: '%wZ' pSrvOpen %p Old %08x New %08x\n",
  702. +    DbgP("nfs41_ComputeNewBufferingState: '%wZ' pSrvOpen 0x%p Old %08x New %08x\n",
  703.           pSrvOpen->pAlreadyPrefixedName, pSrvOpen, oldFlags,
  704.           pSrvOpen->BufferingFlags);
  705.      *pNewBufferingState = pSrvOpen->BufferingFlags;
  706. @@ -6064,7 +6075,7 @@ void print_readwrite_args(
  707.      PLOWIO_CONTEXT LowIoContext  = &RxContext->LowIoContext;
  708.  
  709.  
  710.  
  711.      print_debug_header(RxContext);
  712.  
  713. -    DbgP("Bytecount 0x%x Byteoffset 0x%x Buffer %p\n",
  714.  
  715. +    DbgP("Bytecount 0x%x Byteoffset 0x%x Buffer 0x%p\n",
  716.          LowIoContext->ParamsFor.ReadWrite.ByteCount,
  717.  
  718.          LowIoContext->ParamsFor.ReadWrite.ByteOffset,
  719.  
  720.          LowIoContext->ParamsFor.ReadWrite.Buffer);
  721.  
  722. @@ -6108,7 +6119,7 @@ void enable_caching(
  723.                  nfs41_fcb_list_entry, next);
  724.          if (cur->fcb == SrvOpen->pFcb) {
  725.  #ifdef DEBUG_TIME_BASED_COHERENCY
  726. -            DbgP("enable_caching: Looked&Found match for fcb=%p '%wZ'\n",
  727. +            DbgP("enable_caching: Looked&Found match for fcb=0x%p '%wZ'\n",
  728.                  SrvOpen->pFcb, SrvOpen->pAlreadyPrefixedName);
  729.  #endif
  730.              cur->skip = FALSE;
  731. @@ -6117,7 +6128,7 @@ void enable_caching(
  732.          }
  733.          if (pEntry->Flink == &openlist.head) {
  734.  #ifdef DEBUG_TIME_BASED_COHERENCY
  735. -            DbgP("enable_caching: reached EOL looking for fcb=%p '%wZ'\n",
  736. +            DbgP("enable_caching: reached EOL looking for fcb=0x%p '%wZ'\n",
  737.                  SrvOpen->pFcb, SrvOpen->pAlreadyPrefixedName);
  738.  #endif
  739.              break;
  740. @@ -6127,7 +6138,7 @@ void enable_caching(
  741.      if (!found && nfs41_fobx->deleg_type) {
  742.  
  743.          nfs41_fcb_list_entry *oentry;
  744.  
  745.  #ifdef DEBUG_TIME_BASED_COHERENCY
  746. -        DbgP("enable_caching: delegation recalled: srv_open=%p\n", SrvOpen);
  747. +        DbgP("enable_caching: delegation recalled: srv_open=0x%p\n", SrvOpen);
  748.  #endif
  749.          oentry = RxAllocatePoolWithTag(NonPagedPoolNx,
  750.              sizeof(nfs41_fcb_list_entry), NFS41_MM_POOLTAG_OPEN);
  751. @@ -6157,7 +6168,7 @@ NTSTATUS map_readwrite_errors(
  752.      case ERROR_INTERNAL_ERROR:          return STATUS_INTERNAL_ERROR;
  753.      default:
  754.          print_error("map_readwrite_errors: "
  755. -            "failed to map windows ERROR_%d to NTSTATUS; "
  756. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  757.              "defaulting to STATUS_NET_WRITE_FAULT\n", status);
  758.      case ERROR_NET_WRITE_FAULT:         return STATUS_NET_WRITE_FAULT;
  759.      }
  760. @@ -6438,7 +6449,7 @@ NTSTATUS map_lock_errors(
  761.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  762.      default:
  763.          print_error("map_lock_errors: "
  764. -            "failed to map windows ERROR_%d to NTSTATUS; "
  765. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  766.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", status);
  767.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  768.      }
  769. @@ -6660,7 +6671,7 @@ NTSTATUS map_symlink_errors(
  770.      case ERROR_INTERNAL_ERROR:      return STATUS_INTERNAL_ERROR;
  771.      default:
  772.          print_error("map_symlink_errors: "
  773. -            "failed to map windows ERROR_%d to NTSTATUS; "
  774. +            "failed to map windows ERROR_0x%x to NTSTATUS; "
  775.              "defaulting to STATUS_INVALID_NETWORK_RESPONSE\n", status);
  776.      case ERROR_BAD_NET_RESP:        return STATUS_INVALID_NETWORK_RESPONSE;
  777.      }
  778. @@ -6975,7 +6986,7 @@ NTSTATUS nfs41_FsdDispatch (
  779.      DbgEn();
  780.      DbgP("CURRENT IRP = %d.%d\n", IrpSp->MajorFunction, IrpSp->MinorFunction);
  781.      if(IrpSp->FileObject)
  782. -        DbgP("FileOject %p Filename '%wZ'\n", IrpSp->FileObject,
  783. +        DbgP("FileOject 0x%p Filename '%wZ'\n", IrpSp->FileObject,
  784.                  &IrpSp->FileObject->FileName);
  785.  #endif
  786.  
  787. @@ -6993,8 +7004,9 @@ NTSTATUS nfs41_FsdDispatch (
  788.  
  789.  
  790.  out:
  791.  
  792.  #ifdef DEBUG_FSDDISPATCH
  793.  
  794. -    DbgP("IoStatus status = 0x%x info = 0x%x\n", Irp->IoStatus.Status,
  795.  
  796. -         Irp->IoStatus.Information);
  797.  
  798. +    DbgP("IoStatus status = 0x%x info = 0x%x\n",
  799. +        Irp->IoStatus.Status,
  800. +        Irp->IoStatus.Information);
  801.      DbgEx();
  802.  
  803.  #endif
  804.  
  805.      return status;
  806.  
  807. @@ -7172,7 +7184,7 @@ VOID fcbopen_main(PVOID ctx)
  808.                      nfs41_fcb_list_entry, next);
  809.  
  810.  
  811.  
  812.  #ifdef DEBUG_TIME_BASED_COHERENCY
  813.  
  814. -            DbgP("fcbopen_main: Checking attributes for fcb=%p "
  815.  
  816. +            DbgP("fcbopen_main: Checking attributes for fcb=0x%p "
  817.  
  818.                  "change_time=%llu skipping=%d\n", cur->fcb,
  819.  
  820.                  cur->ChangeTime, cur->skip);
  821.  #endif
  822. @@ -7227,7 +7239,7 @@ VOID fcbopen_main(PVOID ctx)
  823.                      }
  824.  
  825.                      if (psrvEntry->Flink == &cur->fcb->SrvOpenList) {
  826.  
  827.  #ifdef DEBUG_TIME_BASED_COHERENCY
  828.  
  829. -                        DbgP("fcbopen_main: reached end of srvopen for fcb %p\n",
  830.  
  831. +                        DbgP("fcbopen_main: reached end of srvopen for fcb 0x%p\n",
  832.  
  833.                              cur->fcb);
  834.  
  835.  #endif
  836.  
  837.                          break;
  838.  
  839. @@ -7367,6 +7379,6 @@ unload:
  840.      }
  841.  
  842.      RxUnload(drv);
  843.  
  844.  
  845.  
  846. -    DbgP("driver unloaded %p\n", drv);
  847.  
  848. +    DbgP("driver unloaded 0x%p\n", drv);
  849.  
  850.      DbgR();
  851.  
  852.  }
  853.  
  854. --
  855. 2.43.0
  856.  
  857. From d5ae3e66224399aae2a5e6928ce44c7c1ea74880 Mon Sep 17 00:00:00 2001
  858. From: Roland Mainz <roland.mainz@nrubsig.org>
  859. Date: Wed, 29 May 2024 12:44:50 +0200
  860. Subject: [PATCH 2/5] tests/winsg: Add Win32-style /? help option
  861.  
  862. Add Win32-style /? help option
  863.  
  864. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  865. ---
  866. tests/winsg/winsg.c | 5 +++--
  867.  1 file changed, 3 insertions(+), 2 deletions(-)
  868.  
  869. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  870. index 8c8996a..0a90dc6 100644
  871. --- a/tests/winsg/winsg.c
  872. +++ b/tests/winsg/winsg.c
  873. @@ -227,7 +227,7 @@ static
  874.  int usage(void)
  875.  {
  876.      (void)fprintf(stderr, "Usage: "
  877. -        "winsg [-] -g group [-c command | /C command]]\n"
  878. +        "winsg [-] [/? | -h | --help] -g group [-c command | /C command]]\n"
  879.          "Execute command as different primary group ID\n"
  880.          "\n"
  881.          "Examples:\n"
  882. @@ -307,7 +307,8 @@ int main(int ac, char *av[])
  883.              newgrpname = av[i+1];
  884.              i++;
  885.          }
  886. -        else if ((!strcmp(av[i], "-h")) ||
  887. +        else if ((!strcmp(av[i], "/?")) ||
  888. +                (!strcmp(av[i], "-h")) ||
  889.                  (!strcmp(av[i], "--help")) ||
  890.                  (!strcmp(av[i], "--usage"))) {
  891.              retval = usage();
  892. --
  893. 2.43.0
  894.  
  895. From f59dd32f555ce243a0458dd483d536adcb1229ce Mon Sep 17 00:00:00 2001
  896. From: Roland Mainz <roland.mainz@nrubsig.org>
  897. Date: Wed, 29 May 2024 13:09:35 +0200
  898. Subject: [PATCH 3/5] tests/winsg: Add winsg -L to list groups available in
  899.  user token
  900.  
  901. Add winsg -L option to list groups available in user token.
  902.  
  903. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  904. ---
  905. tests/winsg/winsg.c | 85 ++++++++++++++++++++++++++++++++++++++++++---
  906.  1 file changed, 81 insertions(+), 4 deletions(-)
  907.  
  908. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  909. index 0a90dc6..eadd25f 100644
  910. --- a/tests/winsg/winsg.c
  911. +++ b/tests/winsg/winsg.c
  912. @@ -157,6 +157,54 @@ bool is_group_in_token(HANDLE tok, PSID qsid)
  913.      return false;
  914.  }
  915.  
  916. +static
  917. +int print_groups_in_token(HANDLE tok)
  918. +{
  919. +    DWORD tokdatalen;
  920. +    PTOKEN_GROUPS ptgroups;
  921. +    char namebuffer[GNLEN+1];
  922. +    DWORD namesize = GNLEN+1;
  923. +    char domainbuffer[UNLEN+1];
  924. +    DWORD domainbuffer_size = sizeof(domainbuffer);
  925. +    SID_NAME_USE name_use;
  926. +
  927. +    tokdatalen = sizeof(TOKEN_GROUPS)+GETTOKINFO_EXTRA_BUFFER;
  928. +    ptgroups = _alloca(tokdatalen);
  929. +    if (!GetTokenInformation(tok, TokenGroups, ptgroups,
  930. +        tokdatalen, &tokdatalen)) {
  931. +        D((void)fprintf(stderr, "print_groups_in_token: "
  932. +            "GetTokenInformation(tok=0x%p, TokenGroups) failed, "
  933. +            "status=%d.\n",
  934. +            (void *)tok, (int)GetLastError()));
  935. +        return 1;
  936. +    }
  937. +
  938. +    int i;
  939. +    D(
  940. +        (void)fprintf(stderr, "print_groups_in_token: got %d groups\n",
  941. +            (int)ptgroups->GroupCount)
  942. +    );
  943. +    for (i = 0 ; i < ptgroups->GroupCount ; i++) {
  944. +        if (!(ptgroups->Groups[i].Attributes & SE_GROUP_ENABLED)) {
  945. +            continue;
  946. +        }
  947. +
  948. +        if (!LookupAccountSidA(NULL, ptgroups->Groups[i].Sid,
  949. +            namebuffer, &namesize, domainbuffer, &domainbuffer_size, &name_use)) {
  950. +            D((void)fprintf(stderr, "print_groups_in_token: "
  951. +                "LookupAccountSidA() failed, status=%d.\n",
  952. +                (int)GetLastError()));
  953. +            continue;
  954. +        }
  955. +
  956. +        (void)printf("group='%s'\n", namebuffer);
  957. +    }
  958. +
  959. +    D((void)puts("is_group_in_token: #no match"));
  960. +
  961. +    return 0;
  962. +}
  963. +
  964.  static
  965.  bool get_group_sid(const char *groupname, PSID pgsid, PDWORD pgsid_size)
  966.  {
  967. @@ -226,8 +274,10 @@ void win32cmd_quotearg(char *s1, const char *s2)
  968.  static
  969.  int usage(void)
  970.  {
  971. -    (void)fprintf(stderr, "Usage: "
  972. -        "winsg [-] [/? | -h | --help] -g group [-c command | /C command]]\n"
  973. +    (void)fprintf(stderr,
  974. +        "Usage: winsg [-] -g group [-c command | /C command]]\n"
  975. +        "Usage: winsg -L\n"
  976. +        "Usage: winsg /? | -h | --help\n"
  977.          "Execute command as different primary group ID\n"
  978.          "\n"
  979.          "Examples:\n"
  980. @@ -244,6 +294,10 @@ int usage(void)
  981.              "'abc4':\n"
  982.          "\t\twinsg abc4 -c '/bin/id.exe -a'\n"
  983.          "\n"
  984. +        "\t5. List currently available groups which can be passed to "
  985. +            "winsg -g ...\n"
  986. +        "\t\twinsg -L\n"
  987. +        "\n"
  988.          "Please report bugs to "
  989.          "Roland Mainz <roland.mainz@nrubsig.org>.\n");
  990.  
  991. @@ -267,6 +321,8 @@ int main(int ac, char *av[])
  992.      int subcmdret = EXIT_FAILURE;
  993.      int retval = 1;
  994.      int i;
  995. +    bool cmd_runasgroup = false;
  996. +    bool cmd_list_token = false;
  997.  
  998.      for (i=1 ; i < ac ; i++) {
  999.          D((void)fprintf(stderr, "# i=%d, av[i]='%s'\n", i, av[i]));
  1000. @@ -286,6 +342,7 @@ int main(int ac, char *av[])
  1001.                  goto done;
  1002.              }
  1003.  
  1004. +            cmd_runasgroup = true;
  1005.              st = SHELLTYPE_SYSTEM;
  1006.              cmd_arg_index = i+1;
  1007.              break;
  1008. @@ -299,6 +356,7 @@ int main(int ac, char *av[])
  1009.                  goto done;
  1010.              }
  1011.  
  1012. +            cmd_runasgroup = true;
  1013.              st = SHELLTYPE_CMD;
  1014.              cmd_arg_index = i+1;
  1015.              break;
  1016. @@ -306,6 +364,7 @@ int main(int ac, char *av[])
  1017.          else if (!strcmp(av[i], "-g")) {
  1018.              newgrpname = av[i+1];
  1019.              i++;
  1020. +            cmd_runasgroup = true;
  1021.          }
  1022.          else if ((!strcmp(av[i], "/?")) ||
  1023.                  (!strcmp(av[i], "-h")) ||
  1024. @@ -314,6 +373,9 @@ int main(int ac, char *av[])
  1025.              retval = usage();
  1026.              goto done;
  1027.          }
  1028. +        else if (!strcmp(av[i], "-L")) {
  1029. +            cmd_list_token = true;
  1030. +        }
  1031.          else if ((av[i][0] == '-') || (av[i][0] == '/')) {
  1032.              (void)fprintf(stderr, "%s: "
  1033.                  "Unsupported option '%s'.\n", av[0], av[i]);
  1034. @@ -322,29 +384,39 @@ int main(int ac, char *av[])
  1035.          }
  1036.          else {
  1037.              if ((i == 1) && (*av[i] != '-')) {
  1038. +                cmd_runasgroup = true;
  1039.                  newgrpname = av[i];
  1040.                  continue;
  1041.              }
  1042.  
  1043. +            cmd_runasgroup = true;
  1044.              cmd_arg_index = i+1;
  1045.              st = SHELLTYPE_NONE;
  1046.              break;
  1047.          }
  1048.      }
  1049.  
  1050. +    if (((int)cmd_runasgroup+(int)cmd_list_token) > 1) {
  1051. +        (void)fprintf(stderr, "%s: Incompatible option combination\n",
  1052. +            av[0]);
  1053. +        retval = 1;
  1054. +        goto done;
  1055. +    }
  1056. +
  1057.      /*
  1058.       * Handle newgrp(1)-like behaviour (run new shell (in our
  1059.       * case cmd.exe) with requested group), e.g. ...
  1060.       * $ winsg -g cygwingrp1
  1061.       * $ winsg cygwingrp1
  1062.       */
  1063. -    if ((st == SHELLTYPE_NOT_SET) && (cmd_arg_index == -1)) {
  1064. +    if (cmd_runasgroup &&
  1065. +        (st == SHELLTYPE_NOT_SET) && (cmd_arg_index == -1)) {
  1066.          st = SHELLTYPE_NONE;
  1067.          /* set |cmd_arg_index| to the end of |av|, which is |NULL| */
  1068.          cmd_arg_index = i;
  1069.      }
  1070.  
  1071. -    if (!newgrpname) {
  1072. +    if (cmd_runasgroup && (!newgrpname)) {
  1073.          (void)fprintf(stderr, "%s: No group name given.\n", av[0]);
  1074.          retval = 1;
  1075.          goto done;
  1076. @@ -364,6 +436,11 @@ int main(int ac, char *av[])
  1077.          goto done;
  1078.      }
  1079.  
  1080. +    if (cmd_list_token) {
  1081. +        retval = print_groups_in_token(tok);
  1082. +        goto done;
  1083. +    }
  1084. +
  1085.      D(
  1086.          char pgroupname[GNLEN+1];
  1087.  
  1088. --
  1089. 2.43.0
  1090.  
  1091. From af1f8dbf6da7dfc7907579bcb0ef7d24096410a0 Mon Sep 17 00:00:00 2001
  1092. From: Roland Mainz <roland.mainz@nrubsig.org>
  1093. Date: Wed, 29 May 2024 13:17:52 +0200
  1094. Subject: [PATCH 4/5] tests/winsg: Add winsg /g option as alias for -g
  1095.  
  1096. Add winsg /g option as alias for -g
  1097.  
  1098. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1099. ---
  1100. tests/winsg/winsg.c | 20 +++++++++++---------
  1101.  1 file changed, 11 insertions(+), 9 deletions(-)
  1102.  
  1103. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  1104. index eadd25f..9cb0a92 100644
  1105. --- a/tests/winsg/winsg.c
  1106. +++ b/tests/winsg/winsg.c
  1107. @@ -275,24 +275,25 @@ static
  1108.  int usage(void)
  1109.  {
  1110.      (void)fprintf(stderr,
  1111. -        "Usage: winsg [-] -g group [-c command | /C command]]\n"
  1112. +        "Usage: winsg [-] -g group [-c command]\n"
  1113. +        "Usage: winsg [-] /g group [/C command]\n"
  1114.          "Usage: winsg -L\n"
  1115.          "Usage: winsg /? | -h | --help\n"
  1116.          "Execute command as different primary group ID\n"
  1117.          "\n"
  1118.          "Examples:\n"
  1119.          "\t1. Run new cmd.exe with primary group 'abc1':\n"
  1120. -        "\t\twinsg -g abc1 /C\n"
  1121. +        "\t\twinsg /g abc1 /C\n"
  1122.          "\n"
  1123. -        "\t2. Run new Cygwin bash with primary group 'abc2':\n"
  1124. -        "\t\twinsg -g abc2 /C\n"
  1125. +        "\t2. Run new Cygwin shell (bash) with primary group 'abc2':\n"
  1126. +        "\t\twinsg -g abc2 -g\n"
  1127.          "\n"
  1128.          "\t3. Start /bin/id from cmd.exe with primary group 'abc3':\n"
  1129. -        "\t\twinsg abc3 /C 'C:\\cygwin64\\bin\\id.exe -a'\n"
  1130. +        "\t\twinsg /g abc3 /C 'C:\\cygwin64\\bin\\id.exe -a'\n"
  1131.          "\n"
  1132. -        "\t4. Start /bin/id from Cygwin bash with primary group "
  1133. -            "'abc4':\n"
  1134. -        "\t\twinsg abc4 -c '/bin/id.exe -a'\n"
  1135. +        "\t4. Start /bin/id from Cygwin shell (bash) with primary "
  1136. +            "group 'abc4':\n"
  1137. +        "\t\twinsg -g abc4 -c '/bin/id.exe -a'\n"
  1138.          "\n"
  1139.          "\t5. List currently available groups which can be passed to "
  1140.              "winsg -g ...\n"
  1141. @@ -361,7 +362,8 @@ int main(int ac, char *av[])
  1142.              cmd_arg_index = i+1;
  1143.              break;
  1144.          }
  1145. -        else if (!strcmp(av[i], "-g")) {
  1146. +        else if ((!strcmp(av[i], "-g")) ||
  1147. +            (!strcmp(av[i], "/g"))) {
  1148.              newgrpname = av[i+1];
  1149.              i++;
  1150.              cmd_runasgroup = true;
  1151. --
  1152. 2.43.0
  1153.  
  1154. From a7d107f9665be771aec45daac257e77aec231bd6 Mon Sep 17 00:00:00 2001
  1155. From: Roland Mainz <roland.mainz@nrubsig.org>
  1156. Date: Wed, 29 May 2024 13:51:15 +0200
  1157. Subject: [PATCH 5/5] sys: Disk+net transfer timeouts are too small for
  1158.  100baseT+ssh tunnel networks
  1159.  
  1160. Disk and network transfer timeouts are too small for
  1161. 100baseT+ssh tunnel networks, so switch calculations from 2*100MB/s
  1162. (e.g. 1000baseT ethernet) to 2*10MB/s (e.g 100baseT ethernet)
  1163.  
  1164. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  1165. ---
  1166. sys/nfs41_driver.c | 24 ++++++++++++++++--------
  1167.  1 file changed, 16 insertions(+), 8 deletions(-)
  1168.  
  1169. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  1170. index 6918abb..5dcb745 100644
  1171. --- a/sys/nfs41_driver.c
  1172. +++ b/sys/nfs41_driver.c
  1173. @@ -482,6 +482,16 @@ typedef enum _NULMRX_STORAGE_TYPE_CODES {
  1174.  #define RDR_STARTING    7
  1175.  
  1176.  #define RDR_STARTED     8
  1177.  
  1178.  
  1179.  
  1180. +/*
  1181. + * Assume network speed is 10MB/s (100base-T ethernet, lowest common
  1182. + * denominator which we support) plus disk speed is 10MB/s so add
  1183. + * time to transfer requested bytes over the network and read from
  1184. + * disk.
  1185. + * FIXME: What about ssh-tunneled NFSv4 mounts - should this be a
  1186. + * tuneable/mount option ?
  1187. + */
  1188. +#define EXTRA_TIMEOUT_PER_BYTE(size)  ((2LL * (size)) / (10*1024*1024LL))
  1189. +
  1190.  nfs41_init_driver_state nfs41_init_state = NFS41_INIT_DRIVER_STARTABLE;
  1191.  
  1192.  nfs41_start_driver_state nfs41_start_state = NFS41_START_DRIVER_STARTABLE;
  1193.  
  1194.  
  1195. @@ -6223,10 +6233,9 @@ NTSTATUS nfs41_Read(
  1196.          async = entry->async_op = TRUE;
  1197.  
  1198.      }
  1199.  
  1200.  
  1201.  
  1202. -    /* assume network speed is 100MB/s and disk speed is 100MB/s so add
  1203.  
  1204. -     * time to transfer requested bytes over the network and read from disk
  1205.  
  1206. -     */
  1207.  
  1208. -    io_delay = pVNetRootContext->timeout + 2 * entry->buf_len / 104857600;
  1209.  
  1210. +    /* Add extra timeout depending on buffer size */
  1211. +    io_delay = pVNetRootContext->timeout +
  1212. +        EXTRA_TIMEOUT_PER_BYTE(entry->buf_len);
  1213.      status = nfs41_UpcallWaitForReply(entry, io_delay);
  1214.  
  1215.      if (status) goto out;
  1216.  
  1217.  
  1218.  
  1219. @@ -6342,10 +6351,9 @@ NTSTATUS nfs41_Write(
  1220.          async = entry->async_op = TRUE;
  1221.  
  1222.      }
  1223.  
  1224.  
  1225.  
  1226. -    /* assume network speed is 100MB/s and disk speed is 100MB/s so add
  1227.  
  1228. -     * time to transfer requested bytes over the network and write to disk
  1229.  
  1230. -     */
  1231.  
  1232. -    io_delay = pVNetRootContext->timeout + 2 * entry->buf_len / 104857600;
  1233.  
  1234. +    /* Add extra timeout depending on buffer size */
  1235. +    io_delay = pVNetRootContext->timeout +
  1236. +        EXTRA_TIMEOUT_PER_BYTE(entry->buf_len);
  1237.      status = nfs41_UpcallWaitForReply(entry, io_delay);
  1238.  
  1239.      if (status) goto out;
  1240.  
  1241.  
  1242.  
  1243. --
  1244. 2.43.0

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