pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for impersonation fixes, nfs_install rewrite+misc, 2024-04-26
Posted by Anonymous on Fri 26th Apr 2024 15:03
raw | new post

  1. From 97087498e1359a59aa0af1e5ed5d5e2df0e32729 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 26 Apr 2024 00:39:57 +0200
  4. Subject: [PATCH 1/8] cygwin: msnfs41client run_daemon/sys_run_daemon should
  5.  use sync(1)
  6.  
  7. msnfs41client run_daemon/sys_run_daemon should use sync(1) before
  8. starting the NFSv4.1 client daemon, to limit any filesystem damage
  9. if the nfs41_client.sys kernel module crashes on startup.
  10.  
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. cygwin/devel/msnfs41client.bash | 8 ++++++++
  14.  1 file changed, 8 insertions(+)
  15.  
  16. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  17. index 1325d6f..7359f9d 100644
  18. --- a/cygwin/devel/msnfs41client.bash
  19. +++ b/cygwin/devel/msnfs41client.bash
  20. @@ -168,6 +168,10 @@ function nfsclient_rundeamon
  21.                 "$(uname -a)" \
  22.                 "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  23.  
  24. +       # sync before starting nfs41 client daemon, to limit the damage
  25. +       # if the kernel module generates a crash on startup
  26. +       sync
  27. +
  28.         set -o xtrace
  29.  
  30.         typeset -a nfsd_args=(
  31. @@ -261,6 +265,10 @@ function nfsclient_system_rundeamon
  32.                 "$(uname -a)" \
  33.                 "$(is_windows_admin_account ; printf "%d\n" $((${?}?0:1)))"
  34.  
  35. +       # sync before starting nfs41 client daemon, to limit the damage
  36. +       # if the kernel module generates a crash on startup
  37. +       sync
  38. +
  39.         set -o xtrace
  40.  
  41.         typeset -a nfsd_args=(
  42. --
  43. 2.43.0
  44.  
  45. From 0da8b2b93ec34db26b7725b47b8672d77d205074 Mon Sep 17 00:00:00 2001
  46. From: Roland Mainz <roland.mainz@nrubsig.org>
  47. Date: Fri, 26 Apr 2024 00:43:28 +0200
  48. Subject: [PATCH 2/8] daemon: Add comment to |write_downcall()| that
  49.  |IOCTL_NFS41_WRITE| will stop impersonation
  50.  
  51. Add comment to |write_downcall()| that |IOCTL_NFS41_WRITE| will stop
  52. user impersonation, just to avoid confusion when debugging.
  53.  
  54. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  55. ---
  56. daemon/nfs41_daemon.c | 4 ++++
  57.  1 file changed, 4 insertions(+)
  58.  
  59. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  60. index 78393be..b4f59e3 100644
  61. --- a/daemon/nfs41_daemon.c
  62. +++ b/daemon/nfs41_daemon.c
  63. @@ -183,6 +183,10 @@ write_downcall:
  64.          upcall_marshall(&upcall, inbuf, (uint32_t)inbuf_len, (uint32_t*)&outbuf_len);
  65.  
  66.          DPRINTF(2, ("making a downcall: outbuf_len %ld\n\n", outbuf_len));
  67. +        /*
  68. +         * Note: Caller impersonation ends here - nfs41_driver.sys
  69. +         * |IOCTL_NFS41_WRITE| calls |SeStopImpersonatingClient()|
  70. +         */
  71.          status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE,
  72.              inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL);
  73.          if (!status) {
  74. --
  75. 2.43.0
  76.  
  77. From 1d742ec8a5e0531b2ea46a1b9e01d507f10127f5 Mon Sep 17 00:00:00 2001
  78. From: Roland Mainz <roland.mainz@nrubsig.org>
  79. Date: Fri, 26 Apr 2024 00:48:13 +0200
  80. Subject: [PATCH 3/8] daemon: |handle_mount()| should reject mount requests
  81.  without impersonation
  82.  
  83. |handle_mount()| should reject mount requests without impersonation
  84. thread token.
  85.  
  86. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  87. ---
  88. daemon/mount.c | 19 +++++++++++++++++++
  89.  1 file changed, 19 insertions(+)
  90.  
  91. diff --git a/daemon/mount.c b/daemon/mount.c
  92. index 7ab88be..1631864 100644
  93. --- a/daemon/mount.c
  94. +++ b/daemon/mount.c
  95. @@ -3,6 +3,7 @@
  96.   *
  97.   * Olga Kornievskaia <aglo@umich.edu>
  98.   * Casey Bodley <cbodley@umich.edu>
  99. + * Roland Mainz <roland.mainz@nrubsig.org>
  100.   *
  101.   * This library is free software; you can redistribute it and/or modify it
  102.   * under the terms of the GNU Lesser General Public License as published by
  103. @@ -71,6 +72,24 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
  104.  
  105.      EASSERT(args->hostport != NULL);
  106.  
  107. +#define MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN 1
  108. +
  109. +#ifdef MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN
  110. +    logprintf("mount(hostport='%s', path='%s') request\n",
  111. +        args->hostport?args->hostport:"<NULL>",
  112. +        args->path?args->path:"<NULL>");
  113. +
  114. +    HANDLE tok;
  115. +    if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &tok)) {
  116. +        (void)CloseHandle(tok);
  117. +    }
  118. +    else {
  119. +        eprintf("handle_mount: Thread has no impersonation token\n");
  120. +        status = ERROR_NO_IMPERSONATION_TOKEN;
  121. +        goto out;
  122. +    }
  123. +#endif /* MOUNT_REJECT_REQUESTS_WITHOUT_IMPERSONATION_TOKEN */
  124. +
  125.      if ((args->path == NULL) || (strlen(args->path) == 0)) {
  126.          DPRINTF(1, ("handle_mount: empty mount root\n"));
  127.          status = ERROR_BAD_NETPATH;
  128. --
  129. 2.43.0
  130.  
  131. From fb4ba5f8e4789b3f35a8fd02f0486fcaf3011426 Mon Sep 17 00:00:00 2001
  132. From: Roland Mainz <roland.mainz@nrubsig.org>
  133. Date: Fri, 26 Apr 2024 01:06:19 +0200
  134. Subject: [PATCH 4/8] daemon: Add build option to print impersonation token
  135.  user info for |DPRINTF()|
  136.  
  137. Add build option to print impersonation token user info for |DPRINTF()|
  138.  
  139. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  140. ---
  141. daemon/daemon_debug.c | 40 ++++++++++++++++++++++++++++++++++++++++
  142.  1 file changed, 40 insertions(+)
  143.  
  144. diff --git a/daemon/daemon_debug.c b/daemon/daemon_debug.c
  145. index 54fb411..ffc6ee2 100644
  146. --- a/daemon/daemon_debug.c
  147. +++ b/daemon/daemon_debug.c
  148. @@ -73,12 +73,52 @@ void open_log_files()
  149.  }
  150.  #endif
  151.  
  152. +#define DPRINTF_PRINT_IMPERSONATION_USER 1
  153.  
  154.  void dprintf_out(LPCSTR format, ...)
  155.  {
  156.      va_list args;
  157.      va_start(args, format);
  158. +#ifdef DPRINTF_PRINT_IMPERSONATION_USER
  159. +    char username[UNLEN+1];
  160. +    char groupname[GNLEN+1];
  161. +    HANDLE tok;
  162. +    const char *tok_src;
  163. +    bool free_tok = false;
  164. +
  165. +    if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &tok)) {
  166. +        tok_src = "impersonated_user";
  167. +        free_tok = true;
  168. +    }
  169. +    else {
  170. +        int lasterr = GetLastError();
  171. +        if (lasterr == ERROR_CANT_OPEN_ANONYMOUS) {
  172. +            tok_src = "anon_user";
  173. +        }
  174. +        else {
  175. +            tok_src = "proc_user";
  176. +        }
  177. +
  178. +        tok = GetCurrentProcessToken();
  179. +    }
  180. +
  181. +    if (!get_token_user_name(tok, username)) {
  182. +        (void)strcpy(username, "<unknown>");
  183. +    }
  184. +    if (!get_token_primarygroup_name(tok, groupname)) {
  185. +        (void)strcpy(groupname, "<unknown>");
  186. +    }
  187. +
  188. +    (void)fprintf(dlog_file, "%04x/%s='%s'/%s' ",
  189. +        (int)GetCurrentThreadId(),
  190. +        tok_src, username, groupname);
  191. +
  192. +    if (free_tok) {
  193. +        (void)CloseHandle(tok);
  194. +    }
  195. +#else
  196.      (void)fprintf(dlog_file, "%04x: ", (int)GetCurrentThreadId());
  197. +#endif /* DPRINTF_PRINT_IMPERSONATION_USER */
  198.      (void)vfprintf(dlog_file, format, args);
  199.      (void)fflush(dlog_file);
  200.      va_end(args);
  201. --
  202. 2.43.0
  203.  
  204. From 507db1179237605deb68bfb353567066a25e0d65 Mon Sep 17 00:00:00 2001
  205. From: Roland Mainz <roland.mainz@nrubsig.org>
  206. Date: Fri, 26 Apr 2024 01:10:19 +0200
  207. Subject: [PATCH 5/8] daemon: Workaround for Win10 bug that |GetAddrInfoExA()|
  208.  ends impersonation
  209.  
  210. Add workaround for Win10 bug that |GetAddrInfoExA()| ends user
  211. impersonation. The workaround creates a copy of the current
  212. impersonation/thread token, and sets that as thread token
  213. once |GetAddrInfoExA()| returns.
  214.  
  215. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  216. ---
  217. daemon/nfs41_server.c | 42 ++++++++++++++++++++++++++++++++++++++++++
  218.  1 file changed, 42 insertions(+)
  219.  
  220. diff --git a/daemon/nfs41_server.c b/daemon/nfs41_server.c
  221. index 23660dc..adfcdb4 100644
  222. --- a/daemon/nfs41_server.c
  223. +++ b/daemon/nfs41_server.c
  224. @@ -3,6 +3,7 @@
  225.   *
  226.   * Olga Kornievskaia <aglo@umich.edu>
  227.   * Casey Bodley <cbodley@umich.edu>
  228. + * Roland Mainz <roland.mainz@nrubsig.org>
  229.   *
  230.   * This library is free software; you can redistribute it and/or modify it
  231.   * under the terms of the GNU Lesser General Public License as published by
  232. @@ -311,7 +312,36 @@ int nfs41_server_resolve(
  233.      hints.ai_flags    |= AI_FILESERVER;
  234.  #endif
  235.  
  236. +/*
  237. + * Windows bug: |GetAddrInfoExA()| ends impersonation
  238. + * Tested on CYGWIN_NT-10.0-19045 3.6.0-0.115.g579064bf4d40.x86
  239. + */
  240. +#define WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG 1
  241. +
  242. +#ifdef WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG
  243. +    HANDLE tok;
  244. +
  245. +    /*
  246. +     * Windows bug: |GetAddrInfoExA()| ends impersonation, so we copy
  247. +     * the current (impersonation) thread token, and later
  248. +     * set it after we are done with |GetAddrInfoExA()|
  249. +     */
  250. +    if (!OpenThreadToken(GetCurrentThread(),
  251. +        TOKEN_QUERY|TOKEN_IMPERSONATE, FALSE, &tok)) {
  252. +        tok = INVALID_HANDLE_VALUE;
  253. +        DPRINTF(0, ("nfs41_server_resolve: OpenThreadToken() failed, "
  254. +            "lasterr=%d.\n", (int)GetLastError()));
  255. +    }
  256. +#endif /* WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG */
  257. +
  258.  retry_getaddrinfoex:
  259. +#ifdef WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG
  260. +    if (!SetThreadToken(NULL, tok)) {
  261. +        DPRINTF(0, ("nfs41_server_resolve: SetThreadToken() failed, "
  262. +            "lasterr=%d\n", (int)GetLastError()));
  263. +    }
  264. +#endif /* WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG */
  265. +
  266.      wse = GetAddrInfoExA(hostname, service, 0, NULL, &hints, &res,
  267.          NULL, NULL, NULL, NULL);
  268.      if (wse != 0) {
  269. @@ -330,6 +360,13 @@ retry_getaddrinfoex:
  270.          goto out;
  271.      }
  272.  
  273. +#ifdef WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG
  274. +    if (!SetThreadToken(NULL, tok)) {
  275. +        DPRINTF(0, ("nfs41_server_resolve: SetThreadToken() failed, "
  276. +            "lasterr=%d\n", (int)GetLastError()));
  277. +    }
  278. +#endif /* WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG */
  279. +
  280.      for (info = res; info != NULL; info = info->ai_next) {
  281.          DPRINTF(SRVLVL, ("GetAddrInfoExA() returned: info.{ai_family=%d}\n",
  282.              info->ai_family));
  283. @@ -398,5 +435,10 @@ out:
  284.          DPRINTF(SRVLVL, ("<-- nfs41_server_resolve('%s':%u) returning "
  285.              "OK { %s }\n", hostname, port, buff));
  286.      }
  287. +
  288. +#ifdef WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG
  289. +    /* FIXME: We leak the token here */
  290. +#endif /* WINDOWS_GETADDRINFOEXA_STOPS_IMPERSONATION_BUG */
  291. +
  292.      return status;
  293.  }
  294. --
  295. 2.43.0
  296.  
  297. From 64e94f0633c194c90a1de8263101e8af422dbd21 Mon Sep 17 00:00:00 2001
  298. From: Martin Wege <martin.l.wege@gmail.com>
  299. Date: Fri, 26 Apr 2024 11:36:54 +0200
  300. Subject: [PATCH 6/8] tests: Provide correct start sequence for w32time service
  301.  
  302. Provide correct start sequence for w32time service.
  303.  
  304. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  305. ---
  306. tests/manual_testing.txt | 3 ++-
  307.  1 file changed, 2 insertions(+), 1 deletion(-)
  308.  
  309. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  310. index 473fad7..fe40f2c 100644
  311. --- a/tests/manual_testing.txt
  312. +++ b/tests/manual_testing.txt
  313. @@ -32,7 +32,8 @@
  314.  #   NFSv4.1 server).
  315.  #   For example on Windows add timeserver 10.49.0.6 like this:
  316.  #   ---- snip ----
  317. -#   net start w32time
  318. +#   sc config w32time start=auto
  319. +#   sc start w32time
  320.  #   w32tm /config /update /manualpeerlist:10.49.0.6
  321.  #   ---- snip ----
  322.  #   (see https://stackoverflow.com/questions/22862236/how-to-sync-windows-time-from-a-ntp-time-server-in-command)
  323. --
  324. 2.43.0
  325.  
  326. From ed398d610abd5cb9a085ad6c2ae1ca0c85c8aa97 Mon Sep 17 00:00:00 2001
  327. From: Martin Wege <martin.l.wege@gmail.com>
  328. Date: Fri, 26 Apr 2024 11:40:12 +0200
  329. Subject: [PATCH 7/8] daemon:  Fix annoying spelling error
  330.  
  331. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  332. ---
  333. daemon/nfs41_daemon.c | 2 +-
  334.  1 file changed, 1 insertion(+), 1 deletion(-)
  335.  
  336. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  337. index b4f59e3..2703d9b 100644
  338. --- a/daemon/nfs41_daemon.c
  339. +++ b/daemon/nfs41_daemon.c
  340. @@ -169,7 +169,7 @@ static unsigned int nfsd_worker_thread_main(void *args)
  341.          }
  342.  
  343.          if (upcall.opcode == NFS41_SHUTDOWN) {
  344. -            printf("Shutting down..\n");
  345. +            printf("Shutting down...\n");
  346.              exit(0);
  347.          }
  348.  
  349. --
  350. 2.43.0
  351.  
  352. From b70db61bbf776268bd3540fcde1405ac4357c80d Mon Sep 17 00:00:00 2001
  353. From: Roland Mainz <roland.mainz@nrubsig.org>
  354. Date: Fri, 26 Apr 2024 15:52:14 +0200
  355. Subject: [PATCH 8/8] install: Rewrite nfs_install
  356.  
  357. Rewrite nfs_install, as the old code had many problems with
  358. buffer overflows&&other issues reported by DrMemory.
  359.  
  360. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  361. ---
  362. build.vc19/nfs_install/nfs_install.vcxproj    |   4 -
  363.  .../nfs_install/nfs_install.vcxproj.filters   |   8 -
  364.  cygwin/devel/msnfs41client.bash               |   2 +-
  365.  install/nfs_install.c                         | 198 +++++-
  366.  install/nfsreginst.c                          | 655 ------------------
  367.  install/nfsreginst.h                          |  98 ---
  368.  install/sources                               |   2 +-
  369.  7 files changed, 178 insertions(+), 789 deletions(-)
  370.  delete mode 100644 install/nfsreginst.c
  371.  delete mode 100644 install/nfsreginst.h
  372.  
  373. diff --git a/build.vc19/nfs_install/nfs_install.vcxproj b/build.vc19/nfs_install/nfs_install.vcxproj
  374. index ce0b42a..d7a336f 100644
  375. --- a/build.vc19/nfs_install/nfs_install.vcxproj
  376. +++ b/build.vc19/nfs_install/nfs_install.vcxproj
  377. @@ -150,12 +150,8 @@
  378.      </Link>
  379.    </ItemDefinitionGroup>
  380.    <ItemGroup>
  381. -    <ClCompile Include="..\..\install\nfsreginst.c" />
  382.      <ClCompile Include="..\..\install\nfs_install.c" />
  383.    </ItemGroup>
  384. -  <ItemGroup>
  385. -    <ClInclude Include="..\..\install\nfsreginst.h" />
  386. -  </ItemGroup>
  387.    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  388.    <ImportGroup Label="ExtensionTargets">
  389.    </ImportGroup>
  390. diff --git a/build.vc19/nfs_install/nfs_install.vcxproj.filters b/build.vc19/nfs_install/nfs_install.vcxproj.filters
  391. index ae29609..80174df 100644
  392. --- a/build.vc19/nfs_install/nfs_install.vcxproj.filters
  393. +++ b/build.vc19/nfs_install/nfs_install.vcxproj.filters
  394. @@ -18,13 +18,5 @@
  395.      <ClCompile Include="..\..\install\nfs_install.c">
  396.        <Filter>Source Files</Filter>
  397.      </ClCompile>
  398. -    <ClCompile Include="..\..\install\nfsreginst.c">
  399. -      <Filter>Source Files</Filter>
  400. -    </ClCompile>
  401. -  </ItemGroup>
  402. -  <ItemGroup>
  403. -    <ClInclude Include="..\..\install\nfsreginst.h">
  404. -      <Filter>Header Files</Filter>
  405. -    </ClInclude>
  406.    </ItemGroup>
  407.  </Project>
  408. \ No newline at end of file
  409. diff --git a/cygwin/devel/msnfs41client.bash b/cygwin/devel/msnfs41client.bash
  410. index 7359f9d..207153f 100644
  411. --- a/cygwin/devel/msnfs41client.bash
  412. +++ b/cygwin/devel/msnfs41client.bash
  413. @@ -74,7 +74,7 @@ function nfsclient_install
  414.                 #regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder' 'RDPNP,LanmanWorkstation,webclient'
  415.  
  416.                 printf 'before nfs_install: ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  417. -               nfs_install
  418. +               nfs_install -D
  419.                 printf 'after nfs_install:  ProviderOrder="%s"\n' "$( strings -a '/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/NetworkProvider/Order/ProviderOrder')"
  420.  
  421.                 rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
  422. diff --git a/install/nfs_install.c b/install/nfs_install.c
  423. index 16ba660..cab3f8f 100644
  424. --- a/install/nfs_install.c
  425. +++ b/install/nfs_install.c
  426. @@ -1,8 +1,8 @@
  427. -/* NFSv4.1 client for Windows
  428. - * Copyright (C) 2012 The Regents of the University of Michigan
  429. +/*
  430. + * NFSv4.1 client for Windows
  431. + * Copyright (C) 2024 Roland Mainz
  432.   *
  433. - * Olga Kornievskaia <aglo@umich.edu>
  434. - * Casey Bodley <cbodley@umich.edu>
  435. + * Roland Mainz <roland.mainz@nrubsig.org>
  436.   *
  437.   * This library is free software; you can redistribute it and/or modify it
  438.   * under the terms of the GNU Lesser General Public License as published by
  439. @@ -20,31 +20,185 @@
  440.   */
  441.  
  442.  /*
  443. - *
  444. - *     This file is just for prepending nfs41_driver to the
  445. - *     correct regestry entry
  446. - *
  447. + * nfs_install.exe - Tool to prepending nfs41_driver to the
  448. + * correct regestry entry
  449.   */
  450.  
  451.  #if ((__STDC_VERSION__-0) < 201710L)
  452.  #error Code requires ISO C17
  453.  #endif
  454.  
  455. -#include <tchar.h>
  456. +#define UNICODE 1
  457. +#define _UNICODE 1
  458. +
  459. +#include <windows.h>
  460. +#include <stdio.h>
  461. +#include <stdbool.h>
  462. +#include <string.h>
  463. +
  464. +#define RDRSERVICE          "nfs41_driver"
  465. +#define PROVIDER_NAME       RDRSERVICE
  466. +
  467. +#define PROVIDER_ORDER_KEY  "SYSTEM\\CurrentControlSet\\Control\\NetworkProvider\\Order"
  468.  
  469. -#include "nfs41_driver.h"
  470. -#include "nfsreginst.h"
  471. +#define PROVIDER_NAME_COMMA (PROVIDER_NAME ",")
  472.  
  473. -void __cdecl _tmain(int argc, TCHAR *argv[])
  474. +#define DPRINTF(level, fmt) \
  475. +    if ((level) <= _dprintf_debug_level) { \
  476. +        (void)printf fmt; \
  477. +    }
  478. +
  479. +static int _dprintf_debug_level = 0;
  480. +
  481. +int main(int ac, char *av[])
  482.  {
  483. -       if(argc == 1 || _tstoi(argv[1]) == 1)
  484. -       {
  485. -               RdrSetupProviderOrder();
  486. -       }
  487. -       else
  488. -       {
  489. -               while( RdrRemoveProviderFromOrder() ) {};
  490. -       }
  491. -
  492. -       return;
  493. +    bool install_regkey = false;
  494. +    bool uninstall_regkey = false;
  495. +    bool provider_name_already_in_key = false;
  496. +    int d_ac = 0;
  497. +    int res = 1;
  498. +    HKEY hKey;
  499. +    DWORD dataSize = 0;
  500. +    char *new_buffer = NULL;
  501. +    char *originalValue = NULL;
  502. +
  503. +    if ((ac > 1) && (!strcmp(av[1], "-D"))) {
  504. +        _dprintf_debug_level = 1;
  505. +        d_ac++;
  506. +    }
  507. +
  508. +    if ((ac == (2+d_ac)) && (!strcmp(av[1+d_ac], "0"))) {
  509. +        uninstall_regkey = true;
  510. +        DPRINTF(1, ("# Uninstalling key...\n"));
  511. +    }
  512. +    else if (ac == (1+d_ac)) {
  513. +        install_regkey = true;
  514. +        DPRINTF(1, ("# Installing key...\n"));
  515. +    }
  516. +    else {
  517. +        (void)fprintf(stderr, "%s: Unsupported argument\n", av[0]);
  518. +        return 1;
  519. +    }
  520. +
  521. +    LSTATUS result = RegOpenKeyExA(
  522. +        HKEY_LOCAL_MACHINE,
  523. +        PROVIDER_ORDER_KEY,
  524. +        0,
  525. +        KEY_ALL_ACCESS,
  526. +        &hKey);
  527. +
  528. +    if (result != ERROR_SUCCESS) {
  529. +        (void)fprintf(stderr, "%s: Error opening registry key: %d\n",
  530. +            av[0], result);
  531. +        return 1;
  532. +    }
  533. +
  534. +    /*
  535. +     * Get the current value of the ProviderOrder key
  536. +     */
  537. +    result = RegQueryValueExA(hKey, "ProviderOrder", NULL, NULL, NULL, &dataSize);
  538. +
  539. +    DPRINTF(1, ("# RegQueryValueExA(), result=%d, dataSize=%d\n",
  540. +        (int)result, (int)dataSize));
  541. +
  542. +    originalValue = malloc(dataSize+1);
  543. +
  544. +    if (!originalValue) {
  545. +        (void)fprintf(stderr, "%s: Out of memory\n", av[0]);
  546. +        res = 1;
  547. +        goto out;
  548. +    }
  549. +
  550. +    if (dataSize > 0) {
  551. +        /* Read the existing data */
  552. +        result = RegQueryValueExA(hKey, "ProviderOrder", NULL, NULL,
  553. +            originalValue, &dataSize);
  554. +        if (result != ERROR_SUCCESS) {
  555. +            (void)fprintf(stderr, "%s: Error reading registry value: %d\n",
  556. +                av[0], result);
  557. +            res = 1;
  558. +            goto out;
  559. +        }
  560. +
  561. +        DPRINTF(1, ("# data='%s'\n", originalValue));
  562. +    }
  563. +    else {
  564. +        DPRINTF(1, ("# no data\n"));
  565. +        /* If no data existed, set the dataSize to 0 */
  566. +        dataSize = 0;
  567. +    }
  568. +
  569. +    if (strstr(originalValue, PROVIDER_NAME_COMMA) ||
  570. +        (!strcmp(originalValue, PROVIDER_NAME))) {
  571. +        DPRINTF(1, ("# original key value has '%s'\n", PROVIDER_NAME));
  572. +        provider_name_already_in_key = true;
  573. +    }
  574. +
  575. +    if (install_regkey && (!provider_name_already_in_key)) {
  576. +        size_t new_buffer_len = dataSize+strlen(PROVIDER_NAME_COMMA)+2;
  577. +        new_buffer = malloc(new_buffer_len);
  578. +
  579. +        if (!new_buffer) {
  580. +            (void)fprintf(stderr, "%s: Out of memory\n", av[0]);
  581. +            res = 1;
  582. +            goto out;
  583. +        }
  584. +
  585. +        if ((dataSize > 0) && (originalValue[0] != ',')) {
  586. +            (void)snprintf(new_buffer, new_buffer_len, "%s,%s",
  587. +                PROVIDER_NAME, originalValue);
  588. +        }
  589. +        else {
  590. +            (void)strcpy_s(new_buffer, new_buffer_len, PROVIDER_NAME);
  591. +        }
  592. +    }
  593. +    else {
  594. +        new_buffer = _strdup(originalValue);
  595. +        if (!new_buffer) {
  596. +            (void)fprintf(stderr, "%s: Out of memory\n", av[0]);
  597. +            res = 1;
  598. +            goto out;
  599. +        }
  600. +    }
  601. +
  602. +    if (uninstall_regkey) {
  603. +        char *s;
  604. +
  605. +        DPRINTF(1, ("# value before removal '%s'\n", new_buffer));
  606. +        while (s = strstr(new_buffer, PROVIDER_NAME_COMMA)) {
  607. +            if (s) {
  608. +                char *end = s+strlen(PROVIDER_NAME_COMMA);
  609. +                (void)memmove(s, end, strlen(end)+1);
  610. +                DPRINTF(1, ("# value after removal '%s'\n", new_buffer));
  611. +            }
  612. +        }
  613. +
  614. +        if (!strcmp(new_buffer, PROVIDER_NAME)) {
  615. +            new_buffer[0] = '\0';
  616. +        }
  617. +    }
  618. +
  619. +    DPRINTF(1, ("# writing '%s'\n", new_buffer));
  620. +
  621. +    /*
  622. +     * Set the new value of the ProviderOrder key
  623. +     */
  624. +    result = RegSetValueExA(hKey, "ProviderOrder", 0, REG_SZ,
  625. +        new_buffer, (DWORD)strlen(new_buffer));
  626. +
  627. +    if (result != ERROR_SUCCESS) {
  628. +        (void)fprintf(stderr, "%s: Error setting registry value: %d\n",
  629. +            av[0], result);
  630. +        res = 1;
  631. +    }
  632. +    else {
  633. +        res = 0;
  634. +    }
  635. +
  636. +out:
  637. +    free(new_buffer);
  638. +    free(originalValue);
  639. +    (void)RegCloseKey(hKey);
  640. +
  641. +    return res;
  642.  }
  643. diff --git a/install/nfsreginst.c b/install/nfsreginst.c
  644. deleted file mode 100644
  645. index df7565c..0000000
  646. --- a/install/nfsreginst.c
  647. +++ /dev/null
  648. @@ -1,655 +0,0 @@
  649. -/* NFSv4.1 client for Windows
  650. - * Copyright (C) 2012 The Regents of the University of Michigan
  651. - *
  652. - * Olga Kornievskaia <aglo@umich.edu>
  653. - * Casey Bodley <cbodley@umich.edu>
  654. - *
  655. - * This library is free software; you can redistribute it and/or modify it
  656. - * under the terms of the GNU Lesser General Public License as published by
  657. - * the Free Software Foundation; either version 2.1 of the License, or (at
  658. - * your option) any later version.
  659. - *
  660. - * This library is distributed in the hope that it will be useful, but
  661. - * without any warranty; without even the implied warranty of merchantability
  662. - * or fitness for a particular purpose.  See the GNU Lesser General Public
  663. - * License for more details.
  664. - *
  665. - * You should have received a copy of the GNU Lesser General Public License
  666. - * along with this library; if not, write to the Free Software Foundation,
  667. - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  668. - */
  669. -
  670. -/*++
  671. -
  672. -Module Name:
  673. -
  674. -    nfsreginst.c
  675. -
  676. ---*/
  677. -
  678. -#include "nfsreginst.h"
  679. -
  680. -
  681. -
  682. -REGENTRY ProviderOrderKeyValues[] =
  683. -{
  684. -    { TEXT("ProviderOrder"), REG_SZ, 0,   0 }
  685. -};
  686. -
  687. -BOOL RdrSetupProviderOrder( void )
  688. -{
  689. -    LPTSTR pOrderString = NULL;
  690. -    ULONG_PTR len;
  691. -    BOOL success = TRUE;
  692. -    LPTSTR pNewOrderString;
  693. -
  694. -    while( RdrRemoveProviderFromOrder() ) {};
  695. -
  696. -    len = RdrGetProviderOrderString( &pOrderString ) * sizeof(TCHAR);
  697. -    if ( (len > 0) && pOrderString )
  698. -    {
  699. -        len += sizeof( PROVIDER_NAME ) + (2 * sizeof(TCHAR)); // add 2 for comma delimeter and null
  700. -        pNewOrderString = malloc( len );
  701. -        if ( pNewOrderString )
  702. -        {
  703. -            StringCbCopy( pNewOrderString, len, PROVIDER_NAME );
  704. -            StringCbCat( pNewOrderString, len, TEXT(",") );
  705. -            StringCbCat( pNewOrderString, len, pOrderString );
  706. -            success = RdrSetProviderOrderString( pNewOrderString );
  707. -            free( pNewOrderString );
  708. -        }
  709. -    }
  710. -    else
  711. -    {
  712. -        success = RdrSetProviderOrderString( PROVIDER_NAME );
  713. -    }
  714. -    if ( pOrderString )
  715. -    {
  716. -        free( pOrderString );
  717. -    }
  718. -
  719. -    return success;
  720. -}
  721. -
  722. -
  723. -ULONG_PTR RdrGetProviderOrderString( __out LPTSTR *OrderString )
  724. -{
  725. -    HKEY hOrderKey = NULL;
  726. -    ULONG_PTR len = 0;
  727. -
  728. -    if ( OpenKey( PROVIDER_ORDER_KEY, &hOrderKey ) )
  729. -    {
  730. -        if (hOrderKey == NULL)
  731. -            return 0;
  732. -
  733. -        ReadRegistryKeyValues( hOrderKey,
  734. -                               sizeof(ProviderOrderKeyValues) / sizeof(REGENTRY),
  735. -                               ProviderOrderKeyValues);
  736. -
  737. -        RegCloseKey(hOrderKey);
  738. -        len = ProviderOrderKeyValues[0].dwLength / sizeof( TCHAR ) - 1;
  739. -        *OrderString = (LPTSTR) ProviderOrderKeyValues[0].pvValue;
  740. -    }
  741. -
  742. -    return len;
  743. -}
  744. -
  745. -
  746. -BOOL RdrSetProviderOrderString( __in LPTSTR OrderString )
  747. -{
  748. -    HKEY hOrderKey;
  749. -    BOOL rc = FALSE;
  750. -
  751. -    if ( CreateKey( PROVIDER_ORDER_KEY, &hOrderKey ) )
  752. -    {
  753. -        ProviderOrderKeyValues[0].dwLength = (DWORD)(( _tcsclen( OrderString ) + 1 ) * sizeof( TCHAR ));
  754. -        ProviderOrderKeyValues[0].pvValue = OrderString;
  755. -        WriteRegistryKeyValues( hOrderKey,
  756. -                                sizeof(ProviderOrderKeyValues) / sizeof(REGENTRY),
  757. -                                ProviderOrderKeyValues);
  758. -        RegCloseKey(hOrderKey);
  759. -
  760. -        rc = TRUE;
  761. -    }
  762. -
  763. -    return rc;
  764. -}
  765. -
  766. -
  767. -BOOL RdrRemoveProviderFromOrder( void )
  768. -{
  769. -    LPTSTR pCompare = NULL, OrderString = NULL, pOrig = NULL, Provider = PROVIDER_NAME;
  770. -    BOOL match = FALSE;
  771. -    ULONG_PTR len = 0;
  772. -
  773. -    len = RdrGetProviderOrderString( &pOrig );
  774. -    OrderString = pOrig;
  775. -    if ( OrderString && Provider && *Provider )
  776. -    {
  777. -        pCompare = Provider;
  778. -
  779. -        while ( *OrderString )
  780. -        {
  781. -            if ( _toupper(*OrderString) != _toupper(*pCompare++) )
  782. -            {
  783. -                pCompare = Provider;
  784. -                while ( ( *OrderString != TEXT(',') ) && ( *OrderString != TEXT('\0') ) )
  785. -                {
  786. -                    OrderString++;
  787. -                }
  788. -            }
  789. -            if ( *OrderString != TEXT('\0') ) OrderString++;
  790. -            if ( *pCompare == TEXT('\0') )
  791. -            {
  792. -                if ( ( *OrderString == TEXT(',') ) || ( *OrderString == TEXT('\0') ) )
  793. -                {
  794. -                    LPTSTR pNewString;
  795. -                    len += 4096;
  796. -                    pNewString = malloc( len ); //Yes, this is a little larger than necessary
  797. -                    //No, I don't care that much
  798. -                    StringCchCopy(pNewString, len, pOrig);
  799. -                    //if ((DWORD_PTR)OrderString - (DWORD_PTR)pOrig - (DWORD_PTR)pCompare + (DWORD_PTR)Provider == 0 ) OrderString += 1;
  800. -                    if ( *OrderString == TEXT(',') )
  801. -                    {
  802. -                    StringCchCopy(pNewString + (DWORD_PTR)OrderString - (DWORD_PTR)pOrig - (DWORD_PTR)pCompare + (DWORD_PTR)Provider, len, OrderString + 1);
  803. -                    }
  804. -                    else
  805. -                    {
  806. -                        StringCchCopy(pNewString + (DWORD_PTR)OrderString - (DWORD_PTR)pOrig - (DWORD_PTR)pCompare + (DWORD_PTR)Provider - 1, len, OrderString);
  807. -                    }
  808. -                    match = RdrSetProviderOrderString( pNewString );
  809. -                    free(pNewString);
  810. -                    break;
  811. -                }
  812. -                else    // hmm, it's a substring of another provider name
  813. -                {
  814. -                    while ( ( *OrderString != TEXT(',') ) && ( *OrderString != TEXT('\0') ) )
  815. -                    {
  816. -                        OrderString++;
  817. -                    }
  818. -                    pCompare = Provider;
  819. -                }
  820. -            }
  821. -
  822. -        }
  823. -    }
  824. -    free( pOrig );
  825. -
  826. -    return match;
  827. -}
  828. -
  829. -void
  830. -ReadRegistryKeyValues(
  831. -    HKEY       hCurrentKey,
  832. -    DWORD      NumberOfValues,
  833. -    PREGENTRY pValues)
  834. -/*++
  835. -
  836. -Routine Description:
  837. -
  838. -    This routine reads a bunch of values associated with a given key.
  839. -
  840. -Arguments:
  841. -
  842. -    hCurrentKey - the key
  843. -
  844. -    NumberOfValues - the number of values
  845. -
  846. -    pValues - the array of values
  847. -
  848. -Return Value:
  849. -
  850. -   None
  851. -
  852. ---*/
  853. -{
  854. -    //
  855. -    // Iterate through table reading the values along the way
  856. -    //
  857. -
  858. -    DWORD  i;
  859. -
  860. -    for (i = 0; i < NumberOfValues; i++)
  861. -    {
  862. -        DWORD dwType;
  863. -        LPTSTR pszKey;
  864. -
  865. -        dwType  = pValues[i].dwType;
  866. -        pszKey  = pValues[i].pszKey;
  867. -
  868. -        switch (dwType)
  869. -        {
  870. -        case REG_SZ:
  871. -            GetRegsz(hCurrentKey, pszKey, &pValues[i].pvValue,
  872. -                     &pValues[i].dwLength);
  873. -            break;
  874. -
  875. -        case REG_DWORD:
  876. -            GetRegdw(hCurrentKey, pszKey,  &pValues[i].pvValue,
  877. -                     &pValues[i].dwLength);
  878. -            break;
  879. -
  880. -        case REG_EXPAND_SZ:
  881. -            GetRegesz(hCurrentKey, pszKey, &pValues[i].pvValue,
  882. -                      &pValues[i].dwLength);
  883. -            break;
  884. -
  885. -        case REG_MULTI_SZ:
  886. -            GetRegmsz(hCurrentKey, pszKey, &pValues[i].pvValue,
  887. -                      &pValues[i].dwLength);
  888. -            break;
  889. -
  890. -        case REG_BINARY:
  891. -            break;
  892. -
  893. -        default:
  894. -            break;
  895. -
  896. -        }
  897. -    }
  898. -}
  899. -
  900. -//
  901. -// Get a REG_SZ value and stick it in the table entry, along with the
  902. -// length
  903. -//
  904. -
  905. -BOOL GetRegsz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD *pdwLength)
  906. -{
  907. -    BYTE  achValue[1024];
  908. -
  909. -    DWORD dwLength;
  910. -    LONG  Status;
  911. -    DWORD dwType   = REG_SZ;
  912. -    PBYTE pszValue = NULL;
  913. -
  914. -
  915. -
  916. -    if ( (NULL == pszKey) || (NULL == ppvValue) ||
  917. -         (NULL == hKey)   || (NULL == pdwLength))
  918. -    {
  919. -        return FALSE;
  920. -    }
  921. -
  922. -#ifdef _DEBUG
  923. -    FillMemory(achValue, sizeof(achValue), 0xcd);
  924. -#endif
  925. -
  926. -    dwLength = sizeof(achValue);
  927. -
  928. -
  929. -    Status = RegGetValue( hKey,
  930. -                               NULL,
  931. -                               pszKey,
  932. -                               0x0000002, //RRF_RD_REG_SZ
  933. -                               &dwType,
  934. -                               (PVOID) &achValue[0],
  935. -                               &dwLength);
  936. -
  937. -    if ((ERROR_SUCCESS != Status) || (REG_SZ != dwType) )
  938. -    {
  939. -        return FALSE;
  940. -    }
  941. -
  942. -    pszValue = malloc(dwLength);
  943. -
  944. -    if (NULL == pszValue)
  945. -    {
  946. -        return FALSE;
  947. -    }
  948. -
  949. -
  950. -    CopyMemory(pszValue, achValue, dwLength);
  951. -
  952. -    *ppvValue  = pszValue;
  953. -    *pdwLength = dwLength;
  954. -
  955. -    return TRUE;
  956. -}
  957. -
  958. -//
  959. -// Get the value of a REG_EXPAND_SZ and its length
  960. -//
  961. -
  962. -BOOL GetRegesz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD * pdwLength)
  963. -{
  964. -    BYTE  achValue[1024];
  965. -
  966. -    DWORD dwLength;
  967. -    LONG  Status;
  968. -    DWORD dwType   = REG_EXPAND_SZ;
  969. -    PBYTE pszValue = NULL;
  970. -
  971. -
  972. -    if ( (NULL == pszKey) || (NULL == ppvValue) ||
  973. -         (NULL == hKey)   || (NULL == pdwLength))
  974. -    {
  975. -        return FALSE;
  976. -    }
  977. -
  978. -#ifdef _DEBUG
  979. -    FillMemory(achValue, sizeof(achValue), 0xcd);
  980. -#endif
  981. -
  982. -    dwLength = sizeof(achValue);
  983. -
  984. -    Status = RegQueryValueEx( hKey,
  985. -                               pszKey,
  986. -                               NULL,
  987. -                               &dwType,
  988. -                               (PUCHAR) &achValue[0],
  989. -                               &dwLength);
  990. -
  991. -    if ((ERROR_SUCCESS != Status) || (REG_EXPAND_SZ != dwType))
  992. -    {
  993. -        return FALSE;
  994. -    }
  995. -
  996. -    pszValue = malloc(dwLength);
  997. -
  998. -    if (NULL == pszValue)
  999. -    {
  1000. -        return FALSE;
  1001. -    }
  1002. -
  1003. -    CopyMemory(pszValue, achValue, dwLength);
  1004. -
  1005. -    *ppvValue  = pszValue;
  1006. -    *pdwLength = dwLength;
  1007. -
  1008. -    return TRUE;
  1009. -}
  1010. -
  1011. -
  1012. -//
  1013. -// Get value and length of REG_MULTI_SZ
  1014. -//
  1015. -
  1016. -BOOL GetRegmsz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount( *pdwLength) PVOID * ppvValue, __out DWORD * pdwLength)
  1017. -{
  1018. -    //BYTE  achValue[1024];
  1019. -    BYTE  achValue[2048];    // careful, some of these strings are quite long
  1020. -
  1021. -    DWORD dwLength;
  1022. -    LONG  Status;
  1023. -    DWORD dwType   = REG_MULTI_SZ;
  1024. -    PBYTE pszValue = NULL;
  1025. -
  1026. -
  1027. -    if ( (NULL == pszKey) || (NULL == ppvValue) ||
  1028. -        (NULL == hKey)    || (NULL == pdwLength))
  1029. -    {
  1030. -        return FALSE;
  1031. -    }
  1032. -
  1033. -#ifdef _DEBUG
  1034. -    FillMemory(achValue, sizeof(achValue), 0xcd);
  1035. -#endif
  1036. -
  1037. -
  1038. -    dwLength = sizeof(achValue);
  1039. -
  1040. -
  1041. -    Status = RegQueryValueEx( hKey,
  1042. -                               pszKey,
  1043. -                               NULL,
  1044. -                               &dwType,
  1045. -                               (PUCHAR) &achValue[0],
  1046. -                               &dwLength);
  1047. -
  1048. -    if ((ERROR_SUCCESS != Status) || (REG_MULTI_SZ != dwType))
  1049. -    {
  1050. -        return FALSE;
  1051. -    }
  1052. -
  1053. -    pszValue = malloc(dwLength);
  1054. -
  1055. -    if (NULL == pszValue)
  1056. -    {
  1057. -        return FALSE;
  1058. -    }
  1059. -
  1060. -    CopyMemory(pszValue, achValue, dwLength);
  1061. -
  1062. -    *ppvValue  = pszValue;
  1063. -    *pdwLength = dwLength;
  1064. -
  1065. -    return TRUE;
  1066. -}
  1067. -
  1068. -
  1069. -//
  1070. -// Get value and length of REG_DWORD
  1071. -//
  1072. -
  1073. -
  1074. -BOOL GetRegdw(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD * pdwLength)
  1075. -{
  1076. -    DWORD dwValue = 0;
  1077. -
  1078. -    DWORD dwLength;
  1079. -    LONG  Status;
  1080. -    DWORD dwType   = REG_DWORD;
  1081. -
  1082. -
  1083. -
  1084. -    if ( (NULL == pszKey) || (NULL == ppvValue) ||
  1085. -         (NULL == hKey)   || (NULL == pdwLength) )
  1086. -    {
  1087. -        return FALSE;
  1088. -    }
  1089. -
  1090. -    dwLength = sizeof(dwValue);
  1091. -
  1092. -
  1093. -    Status = RegQueryValueEx( hKey,
  1094. -                               pszKey,
  1095. -                               NULL,
  1096. -                               &dwType,
  1097. -                               (PUCHAR) &dwValue,
  1098. -                               &dwLength);
  1099. -
  1100. -    if ((ERROR_SUCCESS != Status) || (REG_DWORD != dwType))
  1101. -    {
  1102. -        return FALSE;
  1103. -    }
  1104. -
  1105. -    *ppvValue  = (PVOID) (ULONG_PTR) dwValue;
  1106. -    *pdwLength = dwLength;
  1107. -
  1108. -    return TRUE;
  1109. -}
  1110. -
  1111. -
  1112. -
  1113. -void
  1114. -WriteRegistryKeyValues(
  1115. -    HKEY        hCurrentKey,
  1116. -    DWORD       NumberOfValues,
  1117. -    PREGENTRY  pValues)
  1118. -/*++
  1119. -
  1120. -Routine Description:
  1121. -
  1122. -    This routine reads a bunch of values associated with a given key.
  1123. -
  1124. -Arguments:
  1125. -
  1126. -    hCurrentKey - the key
  1127. -
  1128. -    NumberOfValues - the number of values
  1129. -
  1130. -    pValues - the array of values
  1131. -
  1132. -Return Value:
  1133. -
  1134. -   None
  1135. -
  1136. ---*/
  1137. -{
  1138. -    DWORD i;
  1139. -
  1140. -
  1141. -    for (i = 0; i < NumberOfValues; i++)
  1142. -    {
  1143. -        DWORD dwType;
  1144. -        PVOID pvValue;
  1145. -        DWORD dwLength;
  1146. -        LPTSTR pszKey;
  1147. -
  1148. -        pszKey   = pValues[i].pszKey;
  1149. -        dwType   = pValues[i].dwType;
  1150. -        dwLength = pValues[i].dwLength;
  1151. -        pvValue  = pValues[i].pvValue;
  1152. -
  1153. -        switch (dwType)
  1154. -        {
  1155. -        case REG_SZ:
  1156. -            AddValue(hCurrentKey, pszKey, dwType, dwLength, pvValue);
  1157. -            break;
  1158. -
  1159. -        case REG_DWORD:
  1160. -            AddValue(hCurrentKey, pszKey, dwType, dwLength, &pvValue);
  1161. -            break;
  1162. -
  1163. -        case REG_EXPAND_SZ:
  1164. -            AddValue(hCurrentKey, pszKey, dwType, dwLength, pvValue);
  1165. -            break;
  1166. -
  1167. -        case REG_MULTI_SZ:
  1168. -            AddValue(hCurrentKey, pszKey, dwType, dwLength, pvValue);
  1169. -            break;
  1170. -
  1171. -        case REG_BINARY:
  1172. -            //
  1173. -            // There are no binary values we need to copy. If we did, we'd
  1174. -            // put something here
  1175. -            //
  1176. -
  1177. -            break;
  1178. -
  1179. -        default:
  1180. -            break;
  1181. -
  1182. -        }
  1183. -    }
  1184. -}
  1185. -
  1186. -//
  1187. -// Open a key so we can read the values
  1188. -//
  1189. -
  1190. -
  1191. -BOOL OpenKey(
  1192. -    __in LPTSTR pszKey,
  1193. -    __out PHKEY phKey)
  1194. -/*++
  1195. -
  1196. -Routine Description:
  1197. -
  1198. -    This routine opens a registry key.
  1199. -
  1200. -Arguments:
  1201. -
  1202. -    pszKey - the name of the key relative to HKEY_LOCAL_MACHINE
  1203. -
  1204. -    phKey - the key handlle
  1205. -
  1206. -Return Value:
  1207. -
  1208. -    TRUE if successful, otherwise FALSE
  1209. -
  1210. ---*/
  1211. -{
  1212. -    HKEY  hNewKey = 0;
  1213. -    DWORD Status;
  1214. -
  1215. -    Status = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  1216. -                            pszKey,
  1217. -                            0,
  1218. -                            KEY_QUERY_VALUE,
  1219. -                            &hNewKey);
  1220. -
  1221. -    if (ERROR_SUCCESS != Status)
  1222. -    {
  1223. -        *phKey = NULL;
  1224. -        return FALSE;
  1225. -    }
  1226. -    else
  1227. -    {
  1228. -        *phKey = hNewKey;
  1229. -        return TRUE;
  1230. -    }
  1231. -}
  1232. -
  1233. -
  1234. -BOOL CreateKey(__in LPTSTR pszKey, __out PHKEY phKey)
  1235. -/*++
  1236. -
  1237. -Routine Description:
  1238. -
  1239. -    This routine creates a registry key.
  1240. -
  1241. -Arguments:
  1242. -
  1243. -    pszKey - the name of the key relative to HKEY_LOCAL_MACHINE
  1244. -
  1245. -    phKey - the key handlle
  1246. -
  1247. -Return Value:
  1248. -
  1249. -    TRUE if successful, otherwise FALSE
  1250. -
  1251. ---*/
  1252. -{
  1253. -    LONG   Status;
  1254. -    DWORD  Disposition;
  1255. -
  1256. -    Status =  RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  1257. -                               pszKey,
  1258. -                               0,
  1259. -                               REG_NONE,
  1260. -                               REG_OPTION_NON_VOLATILE,
  1261. -                               KEY_ALL_ACCESS,
  1262. -                               NULL,
  1263. -                               phKey,
  1264. -                               &Disposition);
  1265. -
  1266. -    if ( ERROR_SUCCESS == Status)
  1267. -    {
  1268. -        return TRUE;
  1269. -    }
  1270. -    else
  1271. -    {
  1272. -        return FALSE;
  1273. -    }
  1274. -}
  1275. -
  1276. -
  1277. -//
  1278. -// Add a value to the registry
  1279. -//
  1280. -
  1281. -
  1282. -BOOL AddValue(__in HKEY hKey, __in LPTSTR pszKey, __in DWORD dwType, __in DWORD dwLength, __in PVOID pvValue)
  1283. -{
  1284. -
  1285. -    BOOL fSuccess = TRUE;
  1286. -    LONG Status   = ERROR_SUCCESS;
  1287. -
  1288. -    Status = RegSetValueEx( hKey,
  1289. -                             pszKey,
  1290. -                             0,
  1291. -                             dwType,
  1292. -                             pvValue,
  1293. -                             dwLength);
  1294. -
  1295. -
  1296. -    if (Status != ERROR_SUCCESS)
  1297. -    {
  1298. -        fSuccess = FALSE;
  1299. -        //RegCloseKey(hKey);
  1300. -    }
  1301. -
  1302. -    return fSuccess;
  1303. -}
  1304. diff --git a/install/nfsreginst.h b/install/nfsreginst.h
  1305. deleted file mode 100644
  1306. index 3624775..0000000
  1307. --- a/install/nfsreginst.h
  1308. +++ /dev/null
  1309. @@ -1,98 +0,0 @@
  1310. -/* NFSv4.1 client for Windows
  1311. - * Copyright (C) 2012 The Regents of the University of Michigan
  1312. - *
  1313. - * Olga Kornievskaia <aglo@umich.edu>
  1314. - * Casey Bodley <cbodley@umich.edu>
  1315. - *
  1316. - * This library is free software; you can redistribute it and/or modify it
  1317. - * under the terms of the GNU Lesser General Public License as published by
  1318. - * the Free Software Foundation; either version 2.1 of the License, or (at
  1319. - * your option) any later version.
  1320. - *
  1321. - * This library is distributed in the hope that it will be useful, but
  1322. - * without any warranty; without even the implied warranty of merchantability
  1323. - * or fitness for a particular purpose.  See the GNU Lesser General Public
  1324. - * License for more details.
  1325. - *
  1326. - * You should have received a copy of the GNU Lesser General Public License
  1327. - * along with this library; if not, write to the Free Software Foundation,
  1328. - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  1329. - */
  1330. -
  1331. -/*++
  1332. -
  1333. -Copyright (c) 1997 - 1999  Microsoft Corporation
  1334. -
  1335. -Module Name:
  1336. -
  1337. -    srfunc.h
  1338. -
  1339. -Abstract:
  1340. -
  1341. ---*/
  1342. -
  1343. -#include <windows.h>
  1344. -#include <stdlib.h>
  1345. -#include <tchar.h>
  1346. -#include <strsafe.h>
  1347. -
  1348. -#include "nfs41_driver.h"
  1349. -
  1350. -typedef struct {
  1351. -    LPTSTR pszKey;
  1352. -    DWORD  dwType;
  1353. -    DWORD  dwLength;
  1354. -    PVOID  pvValue;
  1355. -} REGENTRY, *PREGENTRY;
  1356. -
  1357. -void
  1358. -ReadRegistryKeyValues(
  1359. -    HKEY hKey,
  1360. -    DWORD Count,
  1361. -    PREGENTRY pValues);
  1362. -
  1363. -void
  1364. -WriteRegistryKeyValues(
  1365. -    HKEY hKey,
  1366. -    DWORD Count,
  1367. -    PREGENTRY pValues);
  1368. -
  1369. -
  1370. -//
  1371. -// routines for manipulating registry key values
  1372. -//
  1373. -
  1374. -BOOL GetRegsz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD *pdwLength);
  1375. -
  1376. -BOOL GetRegesz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD * pdwLength);
  1377. -
  1378. -BOOL GetRegmsz(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD * pdwLength);
  1379. -
  1380. -BOOL GetRegdw(__in HKEY hKey, __in LPTSTR pszKey, __deref_out_bcount(*pdwLength) PVOID * ppvValue, __out DWORD * pdwLength);
  1381. -
  1382. -
  1383. -//
  1384. -// routines for manipulating registry keys
  1385. -//
  1386. -
  1387. -BOOL OpenKey(
  1388. -    __in LPTSTR pszKey,
  1389. -    __out PHKEY phKey);
  1390. -
  1391. -BOOL CreateKey(__in LPTSTR pszKey, __out PHKEY phKey);
  1392. -BOOL AddValue(__in HKEY hKey, __in LPTSTR pszKey, __in DWORD dwType, __in DWORD dwLength, __in PVOID pvValue);
  1393. -
  1394. -BOOL      RdrSetupProviderOrder( void );
  1395. -BOOL      RdrRemoveProviderFromOrder( void );
  1396. -
  1397. -ULONG_PTR RdrGetProviderOrderString( __out LPTSTR *OrderString );
  1398. -BOOL      RdrSetProviderOrderString( __in LPTSTR OrderString );
  1399. -
  1400. -
  1401. -typedef BOOL (*ACTIONVECTOR) ( void );
  1402. -
  1403. -#define RDRSERVICE          TEXT("nfs41_driver")
  1404. -#define PROVIDER_NAME       RDRSERVICE
  1405. -
  1406. -#define PROVIDER_ORDER_KEY  TEXT("System\\CurrentControlSet\\Control\\NetworkProvider\\Order")
  1407. -
  1408. diff --git a/install/sources b/install/sources
  1409. index 71c5e6b..6c56519 100644
  1410. --- a/install/sources
  1411. +++ b/install/sources
  1412. @@ -1,6 +1,6 @@
  1413.  TARGETTYPE=PROGRAM
  1414.  TARGETNAME=nfs_install
  1415. -SOURCES=nfs_install.c nfsreginst.c
  1416. +SOURCES=nfs_install.c
  1417.  UMTYPE=console
  1418.  USE_MSVCRT=1
  1419.  INCLUDES=..\sys
  1420. --
  1421. 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