pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41_client: idmap support with Cygwin getent passwd/group prototype
Posted by Anonymous on Fri 13th Oct 2023 16:15
raw | new post
modification of post by Anonymous (view diff)

  1. diff --git a/daemon/acl.c b/daemon/acl.c
  2. index e65548e..a0c01c5 100644
  3. --- a/daemon/acl.c
  4. +++ b/daemon/acl.c
  5. @@ -20,16 +20,18 @@
  6.   */
  7.  
  8.  #include <Windows.h>
  9. +#include <stdio.h>
  10.  #include <strsafe.h>
  11. -#include <sddl.h>
  12. -
  13. -#include "nfs41_ops.h"
  14. -#include "nfs41_build_features.h"
  15. -#include "delegation.h"
  16. -#include "daemon_debug.h"
  17. -#include "util.h"
  18. +#include <sddl.h>
  19. +
  20. +#include "nfs41_ops.h"
  21. +#include "nfs41_build_features.h"
  22. +#include "delegation.h"
  23. +#include "daemon_debug.h"
  24. +#include "util.h"
  25.  #include "upcall.h"
  26.  #include "nfs41_xdr.h"
  27. +#include "idmap.h"
  28.  
  29.  //#define DEBUG_ACLS
  30.  #define ACLLVL 2 /* dprintf level for acl logging */
  31. @@ -58,32 +60,32 @@ static int create_unknownsid(WELL_KNOWN_SID_TYPE type, PSID *sid,
  32.      *sid = NULL;
  33.  
  34.      status = CreateWellKnownSid(type, NULL, *sid, sid_len);
  35. -    dprintf(ACLLVL, "create_unknownsid: CreateWellKnownSid type %d returned %d "
  36. -            "GetLastError %d sid len %d needed\n", type, status,
  37. -            GetLastError(), *sid_len);
  38. -    if (status) {
  39. -        status = ERROR_INTERNAL_ERROR;
  40. -        goto err;
  41. -    }
  42. -    status = GetLastError();
  43. -    if (status != ERROR_INSUFFICIENT_BUFFER)
  44. -        goto err;
  45. -
  46. -    *sid = malloc(*sid_len);
  47. -    if (*sid == NULL) {
  48. -        status = ERROR_INSUFFICIENT_BUFFER;
  49. -        goto err;
  50. -    }
  51. -    status = CreateWellKnownSid(type, NULL, *sid, sid_len);
  52. -    if (status)
  53. -        return ERROR_SUCCESS;
  54. -    free(*sid);
  55. -    *sid = NULL;
  56. -    status = GetLastError();
  57. -err:
  58. -    eprintf("create_unknownsid: CreateWellKnownSid failed with %d\n", status);
  59. -    return status;
  60. -}
  61. +    dprintf(ACLLVL, "create_unknownsid: CreateWellKnownSid type %d returned %d "
  62. +            "GetLastError %d sid len %d needed\n", type, status,
  63. +            GetLastError(), *sid_len);
  64. +    if (status) {
  65. +        status = ERROR_INTERNAL_ERROR;
  66. +        goto err;
  67. +    }
  68. +    status = GetLastError();
  69. +    if (status != ERROR_INSUFFICIENT_BUFFER)
  70. +        goto err;
  71. +
  72. +    *sid = malloc(*sid_len);
  73. +    if (*sid == NULL) {
  74. +        status = ERROR_INSUFFICIENT_BUFFER;
  75. +        goto err;
  76. +    }
  77. +    status = CreateWellKnownSid(type, NULL, *sid, sid_len);
  78. +    if (status)
  79. +        return ERROR_SUCCESS;
  80. +    free(*sid);
  81. +    *sid = NULL;
  82. +    status = GetLastError();
  83. +err:
  84. +    eprintf("create_unknownsid: CreateWellKnownSid failed with %d\n", status);
  85. +    return status;
  86. +}
  87.  
  88.  static void convert_nfs4name_2_user_domain(LPSTR nfs4name,
  89.                                             LPSTR *domain)
  90. @@ -95,142 +97,142 @@ static void convert_nfs4name_2_user_domain(LPSTR nfs4name,
  91.              *domain = &p[1];
  92.              break;
  93.          }
  94. -    }
  95. -}
  96. -
  97. -#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  98. -/*
  99. - * Allocate a SID from SECURITY_SAMBA_UNIX_AUTHORITY, which encodes an
  100. - * UNIX/POSIX uid directly into a SID.
  101. - *
  102. - * Examples:
  103. - * UID 1616 gets mapped to "Unix_User+1616", encoding the UID into the
  104. - * SID as "S-1-22-1-1616":
  105. - * $ getent passwd Unix_User+1616
  106. - * Unix_User+1616:*:4278191696:4278191696:U-Unix_User616,S-1-22-1-1616:/:/sbin/nologin
  107. - *
  108. - * GID 1984 gets mapped to "Unix_Group+1984", encoding the GID into the
  109. - * SID as "S-1-22-2-1984":
  110. - * $ getent group Unix_Group+1984
  111. - * Unix_Group+1984:S-1-22-2-1984:4278192064:
  112. - *
  113. - */
  114. -
  115. -#define SECURITY_SAMBA_UNIX_AUTHORITY { { 0,0,0,0,0,22 } }
  116. -SID_IDENTIFIER_AUTHORITY sid_id_auth = SECURITY_SAMBA_UNIX_AUTHORITY;
  117. -
  118. -static
  119. -BOOL allocate_unixuser_sid(unsigned long uid, PSID *pSid)
  120. -{
  121. -    PSID sid = NULL;
  122. -    PSID malloced_sid = NULL;
  123. -    DWORD sid_len;
  124. -
  125. -    if (AllocateAndInitializeSid(&sid_id_auth, 2, 1, (DWORD)uid,
  126. -        0, 0, 0, 0, 0, 0, &sid)) {
  127. -        sid_len = GetLengthSid(sid);
  128. -
  129. -        malloced_sid = malloc(sid_len);
  130. -
  131. -        if (malloced_sid) {
  132. -            /*
  133. -             * |AllocateAndInitializeSid()| has an own memory
  134. -             * allocator, but we need the sid in memory from
  135. -             * |malloc()|
  136. -             */
  137. -            if (CopySid(sid_len, malloced_sid, sid)) {
  138. -                FreeSid(sid);
  139. -                *pSid = malloced_sid;
  140. -                dprintf(ACLLVL, "allocate_unixuser_sid(): Allocated "
  141. -                    "Unix_User+%lu: success, len=%ld\n",
  142. -                    uid, (long)sid_len);
  143. -                return TRUE;
  144. -            }
  145. -        }
  146. -    }
  147. -
  148. -    FreeSid(sid);
  149. -    free(malloced_sid);
  150. -    dprintf(ACLLVL, "allocate_unixuser_sid(): Failed to allocate "
  151. -        "SID for Unix_User+%lu: error code %d\n",
  152. -        uid, GetLastError());
  153. -    return FALSE;
  154. -}
  155. -
  156. -static
  157. -BOOL allocate_unixgroup_sid(unsigned long gid, PSID *pSid)
  158. -{
  159. -    PSID sid = NULL;
  160. -    PSID malloced_sid = NULL;
  161. -    DWORD sid_len;
  162. -
  163. -    if (AllocateAndInitializeSid(&sid_id_auth, 2, 2, (DWORD)gid,
  164. -        0, 0, 0, 0, 0, 0, &sid)) {
  165. -        sid_len = GetLengthSid(sid);
  166. -
  167. -        malloced_sid = malloc(sid_len);
  168. -
  169. -        if (malloced_sid) {
  170. -            /*
  171. -             * |AllocateAndInitializeSid()| has an own memory
  172. -             * allocator, but we need the sid in memory from
  173. -             * |malloc()|
  174. -             */
  175. -            if (CopySid(sid_len, malloced_sid, sid)) {
  176. -                FreeSid(sid);
  177. -                *pSid = malloced_sid;
  178. -                dprintf(ACLLVL, "allocate_unixgroup_sid(): Allocated "
  179. -                    "Unix_Group+%lu: success, len=%ld\n",
  180. -                    gid, (long)sid_len);
  181. -                return TRUE;
  182. -            }
  183. -        }
  184. -    }
  185. -
  186. -    FreeSid(sid);
  187. -    free(malloced_sid);
  188. -    dprintf(ACLLVL, "allocate_unixgroup_sid(): Failed to allocate "
  189. -        "SID for Unix_Group+%lu: error code %d\n",
  190. -        gid, GetLastError());
  191. -    return FALSE;
  192. -}
  193. -#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  194. -
  195. -static int map_name_2_sid(int query, DWORD *sid_len, PSID *sid, LPCSTR name)
  196. -{
  197. -    int status = ERROR_INTERNAL_ERROR;
  198. -    SID_NAME_USE sid_type;
  199. -    LPSTR tmp_buf = NULL;
  200. -    DWORD tmp = 0;
  201. -#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  202. -    signed long user_uid = -1;
  203. -    signed long group_gid = -1;
  204. -#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  205. -
  206. -#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  207. -    if (query & OWNER_SECURITY_INFORMATION) {
  208. -        if (!strcmp(name, "rmainz")) {
  209. -            name = "roland_mainz";
  210. -            dprintf(ACLLVL, "map_name_2_sid: remap rmainz --> roland_mainz\n");
  211. -        }
  212. -        else if (!strcmp(name, "197608")) {
  213. -            name = "roland_mainz";
  214. -            dprintf(ACLLVL, "map_name_2_sid: remap 197608 --> roland_mainz\n");
  215. -        }
  216. -        else if (!strcmp(name, "1616")) {
  217. -            name = "roland_mainz";
  218. -            dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
  219. -        }
  220. -    }
  221. -#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  222. -
  223. -    status = LookupAccountName(NULL, name, NULL, sid_len, NULL, &tmp, &sid_type);
  224. -    dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): LookupAccountName returned %d "
  225. -            "GetLastError %d name len %d domain len %d\n",
  226. -            query, name, status, GetLastError(), *sid_len, tmp);
  227. -    if (status)
  228. -        return ERROR_INTERNAL_ERROR;
  229. -
  230. +    }
  231. +}
  232. +
  233. +#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  234. +/*
  235. + * Allocate a SID from SECURITY_SAMBA_UNIX_AUTHORITY, which encodes an
  236. + * UNIX/POSIX uid directly into a SID.
  237. + *
  238. + * Examples:
  239. + * UID 1616 gets mapped to "Unix_User+1616", encoding the UID into the
  240. + * SID as "S-1-22-1-1616":
  241. + * $ getent passwd Unix_User+1616
  242. + * Unix_User+1616:*:4278191696:4278191696:U-Unix_User616,S-1-22-1-1616:/:/sbin/nologin
  243. + *
  244. + * GID 1984 gets mapped to "Unix_Group+1984", encoding the GID into the
  245. + * SID as "S-1-22-2-1984":
  246. + * $ getent group Unix_Group+1984
  247. + * Unix_Group+1984:S-1-22-2-1984:4278192064:
  248. + *
  249. + */
  250. +
  251. +#define SECURITY_SAMBA_UNIX_AUTHORITY { { 0,0,0,0,0,22 } }
  252. +SID_IDENTIFIER_AUTHORITY sid_id_auth = SECURITY_SAMBA_UNIX_AUTHORITY;
  253. +
  254. +static
  255. +BOOL allocate_unixuser_sid(unsigned long uid, PSID *pSid)
  256. +{
  257. +    PSID sid = NULL;
  258. +    PSID malloced_sid = NULL;
  259. +    DWORD sid_len;
  260. +
  261. +    if (AllocateAndInitializeSid(&sid_id_auth, 2, 1, (DWORD)uid,
  262. +        0, 0, 0, 0, 0, 0, &sid)) {
  263. +        sid_len = GetLengthSid(sid);
  264. +
  265. +        malloced_sid = malloc(sid_len);
  266. +
  267. +        if (malloced_sid) {
  268. +            /*
  269. +             * |AllocateAndInitializeSid()| has an own memory
  270. +             * allocator, but we need the sid in memory from
  271. +             * |malloc()|
  272. +             */
  273. +            if (CopySid(sid_len, malloced_sid, sid)) {
  274. +                FreeSid(sid);
  275. +                *pSid = malloced_sid;
  276. +                dprintf(ACLLVL, "allocate_unixuser_sid(): Allocated "
  277. +                    "Unix_User+%lu: success, len=%ld\n",
  278. +                    uid, (long)sid_len);
  279. +                return TRUE;
  280. +            }
  281. +        }
  282. +    }
  283. +
  284. +    FreeSid(sid);
  285. +    free(malloced_sid);
  286. +    dprintf(ACLLVL, "allocate_unixuser_sid(): Failed to allocate "
  287. +        "SID for Unix_User+%lu: error code %d\n",
  288. +        uid, GetLastError());
  289. +    return FALSE;
  290. +}
  291. +
  292. +static
  293. +BOOL allocate_unixgroup_sid(unsigned long gid, PSID *pSid)
  294. +{
  295. +    PSID sid = NULL;
  296. +    PSID malloced_sid = NULL;
  297. +    DWORD sid_len;
  298. +
  299. +    if (AllocateAndInitializeSid(&sid_id_auth, 2, 2, (DWORD)gid,
  300. +        0, 0, 0, 0, 0, 0, &sid)) {
  301. +        sid_len = GetLengthSid(sid);
  302. +
  303. +        malloced_sid = malloc(sid_len);
  304. +
  305. +        if (malloced_sid) {
  306. +            /*
  307. +             * |AllocateAndInitializeSid()| has an own memory
  308. +             * allocator, but we need the sid in memory from
  309. +             * |malloc()|
  310. +             */
  311. +            if (CopySid(sid_len, malloced_sid, sid)) {
  312. +                FreeSid(sid);
  313. +                *pSid = malloced_sid;
  314. +                dprintf(ACLLVL, "allocate_unixgroup_sid(): Allocated "
  315. +                    "Unix_Group+%lu: success, len=%ld\n",
  316. +                    gid, (long)sid_len);
  317. +                return TRUE;
  318. +            }
  319. +        }
  320. +    }
  321. +
  322. +    FreeSid(sid);
  323. +    free(malloced_sid);
  324. +    dprintf(ACLLVL, "allocate_unixgroup_sid(): Failed to allocate "
  325. +        "SID for Unix_Group+%lu: error code %d\n",
  326. +        gid, GetLastError());
  327. +    return FALSE;
  328. +}
  329. +#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  330. +
  331. +static int map_name_2_sid(int query, DWORD *sid_len, PSID *sid, LPCSTR name)
  332. +{
  333. +    int status = ERROR_INTERNAL_ERROR;
  334. +    SID_NAME_USE sid_type;
  335. +    LPSTR tmp_buf = NULL;
  336. +    DWORD tmp = 0;
  337. +#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  338. +    signed long user_uid = -1;
  339. +    signed long group_gid = -1;
  340. +#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  341. +
  342. +#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  343. +    if (query & OWNER_SECURITY_INFORMATION) {
  344. +        if (!strcmp(name, "rmainz")) {
  345. +            name = "roland_mainz";
  346. +            dprintf(ACLLVL, "map_name_2_sid: remap rmainz --> roland_mainz\n");
  347. +        }
  348. +        else if (!strcmp(name, "197608")) {
  349. +            name = "roland_mainz";
  350. +            dprintf(ACLLVL, "map_name_2_sid: remap 197608 --> roland_mainz\n");
  351. +        }
  352. +        else if (!strcmp(name, "1616")) {
  353. +            name = "roland_mainz";
  354. +            dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
  355. +        }
  356. +    }
  357. +#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  358. +
  359. +    status = LookupAccountName(NULL, name, NULL, sid_len, NULL, &tmp, &sid_type);
  360. +    dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): LookupAccountName returned %d "
  361. +            "GetLastError %d name len %d domain len %d\n",
  362. +            query, name, status, GetLastError(), *sid_len, tmp);
  363. +    if (status)
  364. +        return ERROR_INTERNAL_ERROR;
  365. +
  366.      status = GetLastError();
  367.      switch(status) {
  368.      case ERROR_INSUFFICIENT_BUFFER:
  369. @@ -243,14 +245,14 @@ static int map_name_2_sid(int query, DWORD *sid_len, PSID *sid, LPCSTR name)
  370.          if (tmp_buf == NULL)
  371.              goto out_free_sid;
  372.          status = LookupAccountName(NULL, name, *sid, sid_len, tmp_buf,
  373. -                                    &tmp, &sid_type);
  374. -        free(tmp_buf);
  375. -        if (!status) {
  376. -            eprintf("map_name_2_sid(query=%x,name='%s'): LookupAccountName failed "
  377. -                    "with %d\n", query, name, GetLastError());
  378. -            goto out_free_sid;
  379. -        } else {
  380. -#ifdef DEBUG_ACLS
  381. +                                    &tmp, &sid_type);
  382. +        free(tmp_buf);
  383. +        if (!status) {
  384. +            eprintf("map_name_2_sid(query=%x,name='%s'): LookupAccountName failed "
  385. +                    "with %d\n", query, name, GetLastError());
  386. +            goto out_free_sid;
  387. +        } else {
  388. +#ifdef DEBUG_ACLS
  389.              LPSTR ssid = NULL;
  390.              if (IsValidSid(*sid))
  391.                  if (ConvertSidToStringSidA(*sid, &ssid))
  392. @@ -264,115 +266,101 @@ static int map_name_2_sid(int query, DWORD *sid_len, PSID *sid, LPCSTR name)
  393.              if (ssid) LocalFree(ssid);
  394.  #endif
  395.          }
  396. -        status = ERROR_SUCCESS;
  397. -        break;
  398. -    case ERROR_NONE_MAPPED:
  399. -#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  400. -        dprintf(1, "map_name_2_sid(query=%x,name='%s'): none mapped, "
  401. -            "trying Unix_User+/Unix_Group+ mapping\n",
  402. -            query, name);
  403. -
  404. -        if ((user_uid == -1) && (query & OWNER_SECURITY_INFORMATION)) {
  405. -            if (isdigit(name[0])) {
  406. -                user_uid = atol(name);
  407. -            }
  408. -            else if(!strcmp(name, "nobody")) {
  409. -                user_uid = 65534;
  410. -            }
  411. -            else if(!strcmp(name, "root")) {
  412. -                user_uid = 0;
  413. -            }
  414. -            else if(!strcmp(name, "rmainz")) {
  415. -                user_uid = 1616;
  416. -            }
  417. -            else if(!strcmp(name, "swulsch")) {
  418. -                user_uid = 1818;
  419. -            }
  420. -            else if(!strcmp(name, "mwenzel")) {
  421. -                user_uid = 8239;
  422. -            }
  423. -            else if(!strcmp(name, "test001")) {
  424. -                user_uid = 1000;
  425. -            }
  426. -        }
  427. -
  428. -        if ((group_gid == -1) && (query & GROUP_SECURITY_INFORMATION)) {
  429. -            if (isdigit(name[0])) {
  430. -                group_gid = atol(name);
  431. -            }
  432. -            else if(!strcmp(name, "nobody")) {
  433. -                group_gid = 65534;
  434. -            }
  435. -            else if(!strcmp(name, "root")) {
  436. -                group_gid = 0;
  437. -            }
  438. -            else if(!strcmp(name, "rmainz")) {
  439. -                group_gid = 1616;
  440. -            }
  441. -            else if(!strcmp(name, "swulsch")) {
  442. -                group_gid = 1818;
  443. -            }
  444. -            else if(!strcmp(name, "mwenzel")) {
  445. -                group_gid = 8239;
  446. -            }
  447. -            else if(!strcmp(name, "test001")) {
  448. -                group_gid = 1000;
  449. -            }
  450. -        }
  451. -
  452. -        if (user_uid != -1) {
  453. -            if (allocate_unixuser_sid(user_uid, sid)) {
  454. -                dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  455. -                    "allocate_unixuser_sid(uid=%ld) success\n",
  456. -                    query, name, user_uid);
  457. -                return ERROR_SUCCESS;
  458. -            }
  459. -
  460. -            status = GetLastError();
  461. -            dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  462. -                "allocate_unixuser_sid(uid=%ld) failed, error=%d\n",
  463. -                query, name, user_uid, status);
  464. -            return status;
  465. -        }
  466. -
  467. -        if (group_gid != -1) {
  468. -            if (allocate_unixgroup_sid(group_gid, sid)) {
  469. -                dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  470. -                    "allocate_unixgroup_sid(gid=%ld) success\n",
  471. -                    query, name, group_gid);
  472. -                return ERROR_SUCCESS;
  473. -            }
  474. -
  475. -            status = GetLastError();
  476. -            dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  477. -                "allocate_unixgroup_sid(gid=%ld) failed, error=%d\n",
  478. -                query, name, group_gid, status);
  479. -            return status;
  480. -        }
  481. -#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  482. -
  483. -        dprintf(1, "map_name_2_sid(query=%x,name='%s'): none mapped, "
  484. -            "using WinNullSid mapping\n",
  485. -            query, name);
  486. -
  487. -        status = create_unknownsid(WinNullSid, sid, sid_len);
  488. -        if (status)
  489. -            goto out_free_sid;
  490. -        break;
  491. -    default:
  492. -        dprintf(1, "map_name_2_sid(query=%x,name='%s'): error %d not handled\n",
  493. -            query, name, GetLastError());
  494. -        break;
  495. -    }
  496. -out:
  497. -    return status;
  498. -out_free_sid:
  499. -    status = GetLastError();
  500. -    free(*sid);
  501. -    *sid = NULL;
  502. -    goto out;
  503. -}
  504. -
  505. +        status = ERROR_SUCCESS;
  506. +        break;
  507. +    case ERROR_NONE_MAPPED:
  508. +#ifdef NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID
  509. +        dprintf(1, "map_name_2_sid(query=%x,name='%s'): none mapped, "
  510. +            "trying Unix_User+/Unix_Group+ mapping\n",
  511. +            query, name);
  512. +
  513. +        if ((user_uid == -1) && (query & OWNER_SECURITY_INFORMATION)) {
  514. +            uid_t map_uid = -1;
  515. +            gid_t gid_dummy = -1;
  516. +
  517. +            if (nfs41_idmap_name_to_ids(
  518. +                global_idmap_context,
  519. +                name,
  520. +                &map_uid,
  521. +                &gid_dummy) == 0) {
  522. +                user_uid = map_uid;
  523. +            }
  524. +            else {
  525. +                dprintf(1, "map_name_2_sid(query=%x,name='%s'): nfs41_idmap_name_to_ids() failed\n",
  526. +                    query, name);
  527. +                /* fixme: try harder here, "1234" should to to |atol()| */
  528. +            }
  529. +        }
  530. +
  531. +        if ((group_gid == -1) && (query & GROUP_SECURITY_INFORMATION)) {
  532. +            gid_t map_gid = -1;
  533. +
  534. +            if (nfs41_idmap_group_to_gid(
  535. +                global_idmap_context,
  536. +                name,
  537. +                &map_gid) == 0) {
  538. +                group_gid = map_gid;
  539. +            }
  540. +            else {
  541. +                dprintf(1, "map_name_2_sid(query=%x,name='%s'): nfs41_idmap_group_to_gid() failed\n",
  542. +                    query, name);
  543. +                /* fixme: try harder here, "1234" should to to |atol()| */
  544. +            }
  545. +        }
  546. +
  547. +        if (user_uid != -1) {
  548. +            if (allocate_unixuser_sid(user_uid, sid)) {
  549. +                dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  550. +                    "allocate_unixuser_sid(uid=%ld) success\n",
  551. +                    query, name, user_uid);
  552. +                return ERROR_SUCCESS;
  553. +            }
  554. +
  555. +            status = GetLastError();
  556. +            dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  557. +                "allocate_unixuser_sid(uid=%ld) failed, error=%d\n",
  558. +                query, name, user_uid, status);
  559. +            return status;
  560. +        }
  561. +
  562. +        if (group_gid != -1) {
  563. +            if (allocate_unixgroup_sid(group_gid, sid)) {
  564. +                dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  565. +                    "allocate_unixgroup_sid(gid=%ld) success\n",
  566. +                    query, name, group_gid);
  567. +                return ERROR_SUCCESS;
  568. +            }
  569. +
  570. +            status = GetLastError();
  571. +            dprintf(ACLLVL, "map_name_2_sid(query=%x,name='%s'): "
  572. +                "allocate_unixgroup_sid(gid=%ld) failed, error=%d\n",
  573. +                query, name, group_gid, status);
  574. +            return status;
  575. +        }
  576. +#endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
  577. +
  578. +        dprintf(1, "map_name_2_sid(query=%x,name='%s'): none mapped, "
  579. +            "using WinNullSid mapping\n",
  580. +            query, name);
  581. +
  582. +        status = create_unknownsid(WinNullSid, sid, sid_len);
  583. +        if (status)
  584. +            goto out_free_sid;
  585. +        break;
  586. +    default:
  587. +        dprintf(1, "map_name_2_sid(query=%x,name='%s'): error %d not handled\n",
  588. +            query, name, GetLastError());
  589. +        break;
  590. +    }
  591. +out:
  592. +    return status;
  593. +out_free_sid:
  594. +    status = GetLastError();
  595. +    free(*sid);
  596. +    *sid = NULL;
  597. +    goto out;
  598. +}
  599. +
  600.  static void free_sids(PSID *sids, int count)
  601.  {
  602.      int i;
  603. @@ -426,14 +414,14 @@ static int convert_nfs4acl_2_dacl(nfsacl41 *acl, int file_type,
  604.                                               &sid_len, &flag);
  605.          if (status) {
  606.              free_sids(sids, i);
  607. -            goto out;
  608. -        }
  609. -        if (!flag) {
  610. -            status = map_name_2_sid(0xFFFF /* fixme: Unknown whether user or group */,
  611. -                &sid_len, &sids[i], acl->aces[i].who);
  612. -            if (status) {
  613. -                free_sids(sids, i);
  614. -                goto out;
  615. +            goto out;
  616. +        }
  617. +        if (!flag) {
  618. +            status = map_name_2_sid(0xFFFF /* fixme: Unknown whether user or group */,
  619. +                &sid_len, &sids[i], acl->aces[i].who);
  620. +            if (status) {
  621. +                free_sids(sids, i);
  622. +                goto out;
  623.              }
  624.          }
  625.          size += sid_len - sizeof(DWORD);
  626. @@ -541,30 +529,30 @@ static int handle_getacl(nfs41_upcall *upcall)
  627.      if (args->query & OWNER_SECURITY_INFORMATION) {
  628.          // parse user@domain. currently ignoring domain part XX
  629.          convert_nfs4name_2_user_domain(info.owner, &domain);
  630. -        dprintf(ACLLVL, "handle_getacl: OWNER_SECURITY_INFORMATION: for user=%s "
  631. -                "domain=%s\n", info.owner, domain?domain:"<null>");
  632. -        sid_len = 0;
  633. -        status = map_name_2_sid(OWNER_SECURITY_INFORMATION, &sid_len, &osid, info.owner);
  634. -        if (status)
  635. -            goto out;
  636. -        status = SetSecurityDescriptorOwner(&sec_desc, osid, TRUE);
  637. +        dprintf(ACLLVL, "handle_getacl: OWNER_SECURITY_INFORMATION: for user=%s "
  638. +                "domain=%s\n", info.owner, domain?domain:"<null>");
  639. +        sid_len = 0;
  640. +        status = map_name_2_sid(OWNER_SECURITY_INFORMATION, &sid_len, &osid, info.owner);
  641. +        if (status)
  642. +            goto out;
  643. +        status = SetSecurityDescriptorOwner(&sec_desc, osid, TRUE);
  644.          if (!status) {
  645.              status = GetLastError();
  646.              eprintf("handle_getacl: SetSecurityDescriptorOwner failed with "
  647.                      "%d\n", status);
  648. -            goto out;
  649. -        }
  650. -    }
  651. -
  652. -    if (args->query & GROUP_SECURITY_INFORMATION) {
  653. -        convert_nfs4name_2_user_domain(info.owner_group, &domain);
  654. -        dprintf(ACLLVL, "handle_getacl: GROUP_SECURITY_INFORMATION: for %s "
  655. -                "domain=%s\n", info.owner_group, domain?domain:"<null>");
  656. -        sid_len = 0;
  657. -        status = map_name_2_sid(GROUP_SECURITY_INFORMATION, &sid_len, &gsid, info.owner_group);
  658. -        if (status)
  659. -            goto out;
  660. -        status = SetSecurityDescriptorGroup(&sec_desc, gsid, TRUE);
  661. +            goto out;
  662. +        }
  663. +    }
  664. +
  665. +    if (args->query & GROUP_SECURITY_INFORMATION) {
  666. +        convert_nfs4name_2_user_domain(info.owner_group, &domain);
  667. +        dprintf(ACLLVL, "handle_getacl: GROUP_SECURITY_INFORMATION: for %s "
  668. +                "domain=%s\n", info.owner_group, domain?domain:"<null>");
  669. +        sid_len = 0;
  670. +        status = map_name_2_sid(GROUP_SECURITY_INFORMATION, &sid_len, &gsid, info.owner_group);
  671. +        if (status)
  672. +            goto out;
  673. +        status = SetSecurityDescriptorGroup(&sec_desc, gsid, TRUE);
  674.          if (!status) {
  675.              status = GetLastError();
  676.              eprintf("handle_getacl: SetSecurityDescriptorGroup failed with "
  677. @@ -1018,7 +1006,7 @@ static int marshall_setacl(unsigned char *buffer, uint32_t *length, nfs41_upcall
  678.  }
  679.  
  680.  const nfs41_upcall_op nfs41_op_setacl = {
  681. -    parse_setacl,
  682. -    handle_setacl,
  683. -    marshall_setacl
  684. -};
  685. +    parse_setacl,
  686. +    handle_setacl,
  687. +    marshall_setacl
  688. +};
  689. diff --git a/daemon/idmap.c b/daemon/idmap.c
  690. index 0dfa8ef..8df1271 100644
  691. --- a/daemon/idmap.c
  692. +++ b/daemon/idmap.c
  693. @@ -31,6 +31,7 @@
  694.  #include "list.h"
  695.  #include "daemon_debug.h"
  696.  
  697. +#define CYGWIN_GETENT_USERDATA 1
  698.  
  699.  #define IDLVL 2 /* dprintf level for idmap logging */
  700.  
  701. @@ -375,6 +376,221 @@ out:
  702.      return status;
  703.  }
  704.  
  705. +#ifdef CYGWIN_GETENT_USERDATA
  706. +int cygwin_getent_passwd(const char *name, char *res_loginname, uid_t *res_uid, gid_t *res_gid)
  707. +{
  708. +    char cmdbuff[1024];
  709. +    char passwd_line[1024];
  710. +    FILE* getent_pipe = NULL;
  711. +    int res = 1;
  712. +    unsigned long uid = -1;
  713. +    unsigned long gid = -1;
  714. +    struct _cypwent {
  715. +        char* loginname;
  716. +        char* passwd;
  717. +        char* uidstr;
  718. +        char* gidstr;
  719. +        char* comment;
  720. +        char* homedir;
  721. +        char* shell;
  722. +    } pwent = { 0 };
  723. +#define PWENT_ENTRY(var, prevvar) \
  724. +    (((var) = strchr((prevvar), ':'))?(*(var)++ = '\0',(var)):(NULL))
  725. +
  726. +#if 1
  727. +    /* hack for testing, map "roland_mainz" to rmainz account */
  728. +    if ((!_stricmp(name, "rmainz")) || (!stricmp(name, "1616"))) {
  729. +        uid = 1616;
  730. +        gid = 1616;
  731. +        pwent.loginname = "rmainz";
  732. +        goto found;
  733. +    }
  734. +    if ((!_stricmp(name, "nobody")) || (!stricmp(name, "65534"))) {
  735. +        uid = 65534;
  736. +        gid = 65534;
  737. +        pwent.loginname = "nobody";
  738. +        goto found;
  739. +    }
  740. +    if ((!_stricmp(name, "root")) || (!stricmp(name, "0"))) {
  741. +        uid = 0;
  742. +        gid = 0;
  743. +        pwent.loginname = "root";
  744. +        goto found;
  745. +    }
  746. +    if ((!_stricmp(name, "iam")) || (!stricmp(name, "2010"))) {
  747. +        uid = 2010;
  748. +        gid = 2010;
  749. +        pwent.loginname = "iam";
  750. +        goto found;
  751. +    }
  752. +    if ((!_stricmp(name, "swulsch")) || (!stricmp(name, "1818"))) {
  753. +        uid = 1818;
  754. +        gid = 1818;
  755. +        pwent.loginname = "swulsch";
  756. +        goto found;
  757. +    }
  758. +    if ((!_stricmp(name, "mwenzel")) || (!stricmp(name, "8239"))) {
  759. +        uid = 8239;
  760. +        gid = 8239;
  761. +        pwent.loginname = "mwenzel";
  762. +        goto found;
  763. +    }
  764. +#endif
  765. +
  766. +    /* fixme: better quoting for |name| needed */
  767. +    (void)snprintf(cmdbuff, sizeof(cmdbuff), "%s passwd \"%s\"",
  768. +        "C:\\cygwin64\\bin\\getent.exe",
  769. +        name);
  770. +    if ((getent_pipe = _popen(cmdbuff, "rt")) == NULL) {
  771. +        (void)perror("cygwin_getent_passwd: getent failed");
  772. +        return 1;
  773. +    }
  774. +
  775. +    if (fgets(passwd_line, sizeof(passwd_line), getent_pipe)) {
  776. +        pwent.loginname = passwd_line;
  777. +        if (!PWENT_ENTRY(pwent.passwd, pwent.loginname)) goto fail;
  778. +        if (!PWENT_ENTRY(pwent.uidstr, pwent.passwd)) goto fail;
  779. +        if (!PWENT_ENTRY(pwent.gidstr, pwent.uidstr)) goto fail;
  780. +        if (!PWENT_ENTRY(pwent.comment, pwent.gidstr)) goto fail;
  781. +        if (!PWENT_ENTRY(pwent.homedir, pwent.comment)) goto fail;
  782. +        PWENT_ENTRY(pwent.shell, pwent.homedir);
  783. +
  784. +        errno = 0;
  785. +        uid = strtol(pwent.uidstr, NULL, 10);
  786. +        if (errno != 0)
  787. +            goto fail;
  788. +
  789. +        errno = 0;
  790. +        gid = strtol(pwent.gidstr, NULL, 10);
  791. +        if (errno != 0)
  792. +            goto fail;
  793. +
  794. +
  795. +#if 1
  796. +        (void)printf("cygwin_getent_passwd(): name='%s'\n", name);
  797. +        (void)printf("loginname\t='%s'\n", pwent.loginname);
  798. +        (void)printf("passwd\t='%s'\n", pwent.passwd);
  799. +        (void)printf("uidstr\t='%s' (%lu)\n", pwent.uidstr, (unsigned long)uid);
  800. +        (void)printf("gidstr\t='%s' (%lu)\n", pwent.gidstr, (unsigned long)gid);
  801. +        (void)printf("comment\t='%s'\n", pwent.comment);
  802. +        (void)printf("homedir\t='%s'\n", pwent.homedir);
  803. +        (void)printf("shell\t='%s'\n", pwent.shell);
  804. +#endif
  805. +
  806. +found:
  807. +        if (res_loginname)
  808. +            (void)strcpy_s(res_loginname, VAL_LEN, pwent.loginname);
  809. +        *res_uid = uid;
  810. +        *res_gid = gid;
  811. +        res = 0;
  812. +    }
  813. +    
  814. +
  815. +fail:
  816. +    if (getent_pipe)
  817. +        (void)_pclose(getent_pipe);
  818. +
  819. +    if (res != 0) {
  820. +        (void)printf("cygwin_getent_passwd(): NO MATCH FOR name='%s'\n", name);
  821. +    }
  822. +
  823. +    return res;
  824. +}
  825. +
  826. +int cygwin_getent_group(const char* name, char* res_group_name, gid_t* res_gid)
  827. +{
  828. +    char cmdbuff[1024];
  829. +    char group_line[1024];
  830. +    FILE* getent_pipe = NULL;
  831. +    int res = 1;
  832. +    unsigned long gid = -1;
  833. +    struct _cygrent
  834. +    {
  835. +        char* group_name;
  836. +        char* passwd;
  837. +        char* gidstr;
  838. +        char* userlist;
  839. +    } grent = { 0 };
  840. +
  841. +#if 1
  842. +    if ((!_stricmp(name, "rmainz")) || (!stricmp(name, "1616"))) {
  843. +        gid = 1616;
  844. +        grent.group_name = "rmainz";
  845. +        goto found;
  846. +    }
  847. +    if ((!_stricmp(name, "nogroup")) || (!stricmp(name, "65534"))) {
  848. +        gid = 65534;
  849. +        grent.group_name = "nogroup";
  850. +        goto found;
  851. +    }
  852. +    if ((!_stricmp(name, "root")) || (!stricmp(name, "0"))) {
  853. +        gid = 0;
  854. +        grent.group_name = "root";
  855. +        goto found;
  856. +    }
  857. +    if ((!_stricmp(name, "iam")) || (!stricmp(name, "2010"))) {
  858. +        gid = 2010;
  859. +        grent.group_name = "iam";
  860. +        goto found;
  861. +    }
  862. +    if ((!_stricmp(name, "swulsch")) || (!stricmp(name, "1818"))) {
  863. +        gid = 1818;
  864. +        grent.group_name = "swulsch";
  865. +        goto found;
  866. +    }
  867. +    if ((!_stricmp(name, "mwenzel")) || (!stricmp(name, "8239"))) {
  868. +        gid = 8239;
  869. +        grent.group_name = "mwenzel";
  870. +        goto found;
  871. +    }
  872. +#endif
  873. +
  874. +    /* fixme: better quoting for |name| needed */
  875. +    (void)snprintf(cmdbuff, sizeof(cmdbuff), "%s group \"%s\"",
  876. +        "C:\\cygwin64\\bin\\getent.exe",
  877. +        name);
  878. +    if ((getent_pipe = _popen(cmdbuff, "rt")) == NULL)
  879. +    {
  880. +        (void)perror("getent failed");
  881. +        return 1;
  882. +    }
  883. +
  884. +    if (fgets(group_line, sizeof(group_line), getent_pipe))
  885. +    {
  886. +        grent.group_name = group_line;
  887. +        if (!PWENT_ENTRY(grent.passwd, grent.group_name)) goto fail;
  888. +        if (!PWENT_ENTRY(grent.gidstr, grent.passwd)) goto fail;
  889. +        PWENT_ENTRY(grent.userlist, grent.gidstr);
  890. +
  891. +        errno = 0;
  892. +        gid = strtol(grent.gidstr, NULL, 10);
  893. +        if (errno != 0)
  894. +            goto fail;
  895. +
  896. +        (void)printf("cygwin_getent_group(): name='%s'\n", name);
  897. +        (void)printf("group_name\t='%s'\n", grent.group_name);
  898. +        (void)printf("passwd\t='%s'\n", grent.passwd);
  899. +        (void)printf("gidstr\t='%s' (%lu)\n", grent.gidstr, (unsigned long)gid);
  900. +        (void)printf("userlist\t='%s'\n", grent.userlist);
  901. +
  902. +found:
  903. +        if (res_group_name)
  904. +            (void)strcpy_s(res_group_name, VAL_LEN, grent.group_name);
  905. +        *res_gid = gid;
  906. +        res = 0;
  907. +    }
  908. +
  909. +fail:
  910. +    if (getent_pipe)
  911. +        (void)_pclose(getent_pipe);
  912. +
  913. +    if (res != 0) {
  914. +        (void)printf("cygwin_getent_group(): NO MATCH FOR name='%s'\n", name);
  915. +    }
  916. +
  917. +    return res;
  918. +}
  919. +#endif /* CYGWIN_GETENT_USERDATA */
  920.  
  921.  /* generic cache */
  922.  typedef struct list_entry* (*entry_alloc_fn)();
  923. @@ -665,10 +881,10 @@ static int idmap_lookup_user(
  924.      if (status == NO_ERROR) {
  925.          /* don't return expired entries; query new attributes
  926.           * and overwrite the entry with cache_insert() */
  927. -        if (time(NULL) - user->last_updated < context->config.cache_ttl)
  928. +        if ((time(NULL) - user->last_updated) < context->config.cache_ttl)
  929.              goto out;
  930.      }
  931. -
  932. +#if 0
  933.      /* send the query to the ldap server */
  934.      status = idmap_query_attrs(context, lookup,
  935.          attributes, optional, values, NUM_ATTRIBUTES);
  936. @@ -705,7 +921,91 @@ static int idmap_lookup_user(
  937.          goto out_free_values;
  938.      }
  939.      user->last_updated = time(NULL);
  940. -
  941. +#else
  942. +    if (lookup->attr == ATTR_USER_NAME) {
  943. +       char principal_name[VAL_LEN];
  944. +       uid_t cy_uid = 0;
  945. +       gid_t cy_gid = 0;
  946. +
  947. +       status = ERROR_NOT_FOUND;
  948. +
  949. +        if (!cygwin_getent_passwd(lookup->value, NULL, &cy_uid, &cy_gid)) {
  950. +            eprintf("# ATTR_USER_NAME: cygwin_getent_passwd: returned '%s', uid=%d, gid=%d\n", lookup->value, (int)cy_uid, (int)cy_gid);
  951. +           (void)snprintf(principal_name, sizeof(principal_name), "%s@%s", lookup->value, "GLOBAL.LOC");
  952. +            StringCchCopyA(user->username, VAL_LEN, lookup->value);
  953. +            StringCchCopyA(user->principal, VAL_LEN, principal_name);
  954. +            user->uid = cy_uid;
  955. +            user->gid = cy_gid;
  956. +           status = 0;
  957. +       }
  958. +    }
  959. +    else if (lookup->attr == ATTR_PRINCIPAL) {
  960. +       char search_name[VAL_LEN];
  961. +       char principal_name[VAL_LEN];
  962. +       char *s;
  963. +       uid_t cy_uid = 0;
  964. +       gid_t cy_gid = 0;
  965. +
  966. +       status = ERROR_NOT_FOUND;
  967. +
  968. +       /*
  969. +        * strip '@' from principal name and use that for getent
  970. +        * fixme: This does not work with multiple domains
  971. +        */
  972. +       (void)strcpy_s(search_name, sizeof(search_name), lookup->value);
  973. +       if (s = strchr(search_name, '@'))
  974. +           *s = '\0';
  975. +
  976. +        if (!cygwin_getent_passwd(search_name, NULL, &cy_uid, &cy_gid)) {
  977. +            eprintf("# ATTR_PRINCIPAL: cygwin_getent_passwd: returned '%s', uid=%d, gid=%d\n", lookup->value, (int)cy_uid, (int)cy_gid);
  978. +           (void)snprintf(principal_name, sizeof(principal_name), "%s@%s", lookup->value, "GLOBAL.LOC");
  979. +
  980. +           if (!_stricmp(principal_name, lookup->value)) {
  981. +                StringCchCopyA(user->username, VAL_LEN, search_name);
  982. +                StringCchCopyA(user->principal, VAL_LEN, principal_name);
  983. +                user->uid = cy_uid;
  984. +                user->gid = cy_gid;
  985. +               status = 0;
  986. +           }
  987. +       }
  988. +    }
  989. +    else if (lookup->attr == ATTR_UID) {
  990. +        uid_t search_uid = (uid_t)(lookup->value);
  991. +       char search_name[VAL_LEN];
  992. +       char res_username[VAL_LEN];
  993. +       char principal_name[VAL_LEN];
  994. +       uid_t cy_uid = 0;
  995. +       gid_t cy_gid = 0;
  996. +
  997. +       status = ERROR_NOT_FOUND;
  998. +
  999. +       (void)snprintf(search_name, sizeof(search_name), "%lu", (unsigned long)search_uid);
  1000. +
  1001. +        if (!cygwin_getent_passwd(search_name, res_username, &cy_uid, &cy_gid)) {
  1002. +            eprintf("# ATTR_UID: cygwin_getent_passwd: returned '%s', uid=%d, gid=%d\n", res_username, (int)cy_uid, (int)cy_gid);
  1003. +           (void)snprintf(principal_name, sizeof(principal_name), "%s@%s", res_username, "GLOBAL.LOC");
  1004. +
  1005. +            StringCchCopyA(user->username, VAL_LEN, res_username);
  1006. +            StringCchCopyA(user->principal, VAL_LEN, principal_name);
  1007. +            user->uid = cy_uid;
  1008. +            user->gid = cy_gid;
  1009. +            status = 0;
  1010. +       }
  1011. +    }
  1012. +    else
  1013. +    {
  1014. +        status = ERROR_NOT_FOUND;
  1015. +    }
  1016. +    
  1017. +    if (status == 0) {
  1018. +        user->last_updated = time(NULL);
  1019. +       eprintf("## idmap_lookup_user: found username='%s', principal='%s', uid=%lu, gid=%lu\n",
  1020. +               user->username,
  1021. +               user->principal,
  1022. +               (unsigned long)user->uid,
  1023. +               (unsigned long)user->gid);
  1024. +    }
  1025. +#endif
  1026.      if (context->config.cache_ttl) {
  1027.          /* insert the entry into the cache */
  1028.          cache_insert(&context->users, lookup, &user->entry);
  1029. @@ -732,10 +1032,10 @@ static int idmap_lookup_group(
  1030.      if (status == NO_ERROR) {
  1031.          /* don't return expired entries; query new attributes
  1032.           * and overwrite the entry with cache_insert() */
  1033. -        if (time(NULL) - group->last_updated < context->config.cache_ttl)
  1034. +        if ((time(NULL) - group->last_updated) < context->config.cache_ttl)
  1035.              goto out;
  1036.      }
  1037. -
  1038. +#if 0
  1039.      /* send the query to the ldap server */
  1040.      status = idmap_query_attrs(context, lookup,
  1041.          attributes, 0, values, NUM_ATTRIBUTES);
  1042. @@ -758,7 +1058,48 @@ static int idmap_lookup_group(
  1043.          goto out_free_values;
  1044.      }
  1045.      group->last_updated = time(NULL);
  1046. +#else
  1047. +    if (lookup->attr == ATTR_GROUP_NAME) {
  1048. +       gid_t cy_gid = 0;
  1049. +
  1050. +       status = ERROR_NOT_FOUND;
  1051. +
  1052. +        if (!cygwin_getent_group(lookup->value, NULL, &cy_gid)) {
  1053. +            eprintf("# ATTR_GROUP_NAME: cygwin_getent_group: returned '%s', gid=%d\n", lookup->value, (int)cy_gid);
  1054. +            StringCchCopyA(group->name, VAL_LEN, lookup->value);
  1055. +            group->gid = cy_gid;
  1056. +           status = 0;
  1057. +       }
  1058. +    }
  1059. +    else if (lookup->attr == ATTR_GID) {
  1060. +        gid_t search_gid = (gid_t)(lookup->value);
  1061. +        char search_name[VAL_LEN];
  1062. +       char res_groupname[VAL_LEN];
  1063. +       gid_t cy_gid = 0;
  1064. +
  1065. +       status = ERROR_NOT_FOUND;
  1066. +
  1067. +       (void)snprintf(search_name, sizeof(search_name), "%lu", (unsigned long)search_gid);
  1068. +
  1069. +        if (!cygwin_getent_group(search_name, res_groupname, &cy_gid)) {
  1070. +            eprintf("# ATTR_GID: cygwin_getent_group: returned '%s', gid=%d\n", res_groupname, (int)cy_gid);
  1071. +            StringCchCopyA(group->name, VAL_LEN, res_groupname);
  1072. +            group->gid = cy_gid;
  1073. +            status = 0;
  1074. +       }
  1075. +    }
  1076. +    else
  1077. +    {
  1078. +        status = ERROR_NOT_FOUND;
  1079. +    }
  1080.  
  1081. +    if (status == 0) {
  1082. +        group->last_updated = time(NULL);
  1083. +       eprintf("## idmap_lookup_group: found name='%s', gid=%lu\n",
  1084. +               group->name,
  1085. +               (unsigned long)group->gid);
  1086. +    }
  1087. +#endif
  1088.      if (context->config.cache_ttl) {
  1089.          /* insert the entry into the cache */
  1090.          cache_insert(&context->groups, lookup, &group->entry);
  1091. @@ -770,6 +1111,10 @@ out:
  1092.      return status;
  1093.  }
  1094.  
  1095. +#if 1
  1096. +/* hack!! */
  1097. +struct idmap_context *global_idmap_context = NULL;
  1098. +#endif
  1099.  
  1100.  /* public idmap interface */
  1101.  int nfs41_idmap_create(
  1102. @@ -795,6 +1140,7 @@ int nfs41_idmap_create(
  1103.          goto out_err_free;
  1104.      }
  1105.  
  1106. +#if 0
  1107.      /* initialize ldap and configure options */
  1108.      context->ldap = ldap_init(context->config.hostname, context->config.port);
  1109.      if (context->ldap == NULL) {
  1110. @@ -824,8 +1170,15 @@ int nfs41_idmap_create(
  1111.              goto out_err_free;
  1112.          }
  1113.      }
  1114. +#else
  1115. +    eprintf("nfs41_idmap_create: Force context->config.timeout = 6000;\n");
  1116. +    context->config.timeout = 6000;
  1117. +#endif
  1118.  
  1119.      *context_out = context;
  1120. +#if 1
  1121. +global_idmap_context = context;
  1122. +#endif
  1123.  out:
  1124.      return status;
  1125.  
  1126. diff --git a/daemon/idmap.h b/daemon/idmap.h
  1127. index 6a78476..9016ddb 100644
  1128. --- a/daemon/idmap.h
  1129. +++ b/daemon/idmap.h
  1130. @@ -64,4 +64,9 @@ int nfs41_idmap_gid_to_group(
  1131.      char *name_out,
  1132.      size_t len);
  1133.  
  1134. +#if 1
  1135. +/* hack!! */
  1136. +extern struct idmap_context *global_idmap_context;
  1137. +#endif
  1138. +
  1139.  #endif /* !IDMAP_H */
  1140. diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
  1141. index bb485cb..0d7403e 100644
  1142. --- a/daemon/nfs41_daemon.c
  1143. +++ b/daemon/nfs41_daemon.c
  1144. @@ -42,8 +42,8 @@ static const char FILE_NETCONFIG[] = "C:\\etc\\netconfig";
  1145.  
  1146.  /* Globals */
  1147.  char localdomain_name[NFS41_HOSTNAME_LEN];
  1148. -int default_uid = 666;
  1149. -int default_gid = 777;
  1150. +int default_uid = 12666;
  1151. +int default_gid = 12777;
  1152.  
  1153.  #ifndef STANDALONE_NFSD //make sure to define it in "sources" not here
  1154.  #include "service.h"
  1155. @@ -389,6 +389,11 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
  1156.          exit(1);
  1157.      }
  1158.  
  1159. +#if 1
  1160. +    /* force enable for cygwin getent passwd/group testing */
  1161. +    cmd_args.ldap_enable = TRUE;
  1162. +#endif
  1163. +
  1164.      nfs41_server_list_init();
  1165.  
  1166.      if (cmd_args.ldap_enable) {
  1167. diff --git a/daemon/open.c b/daemon/open.c
  1168. index e59939b..94a6ba2 100644
  1169. --- a/daemon/open.c
  1170. +++ b/daemon/open.c
  1171. @@ -18,23 +18,24 @@
  1172.   * along with this library; if not, write to the Free Software Foundation,
  1173.   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  1174.   */
  1175. -
  1176. -#include <Windows.h>
  1177. -#include <stdio.h>
  1178. -#include <ctype.h>
  1179. -#include <strsafe.h>
  1180. -
  1181. -#include "nfs41_ops.h"
  1182. -#include "nfs41_build_features.h"
  1183. -#include "delegation.h"
  1184. -#include "from_kernel.h"
  1185. -#include "daemon_debug.h"
  1186. -#include "upcall.h"
  1187. -#include "util.h"
  1188. -
  1189. -static int create_open_state(
  1190. -    IN const char *path,
  1191. -    IN uint32_t open_owner_id,
  1192. +
  1193. +#include <Windows.h>
  1194. +#include <stdio.h>
  1195. +#include <ctype.h>
  1196. +#include <strsafe.h>
  1197. +
  1198. +#include "nfs41_ops.h"
  1199. +#include "nfs41_build_features.h"
  1200. +#include "delegation.h"
  1201. +#include "from_kernel.h"
  1202. +#include "daemon_debug.h"
  1203. +#include "upcall.h"
  1204. +#include "util.h"
  1205. +#include "idmap.h"
  1206. +
  1207. +static int create_open_state(
  1208. +    IN const char *path,
  1209. +    IN uint32_t open_owner_id,
  1210.      OUT nfs41_open_state **state_out)
  1211.  {
  1212.      int status;
  1213. @@ -293,38 +294,38 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
  1214.      status = safe_read(&buffer, &length, &args->disposition, sizeof(ULONG));
  1215.      if (status) goto out;
  1216.      status = safe_read(&buffer, &length, &args->open_owner_id, sizeof(LONG));
  1217. -    if (status) goto out;
  1218. -    status = safe_read(&buffer, &length, &args->mode, sizeof(DWORD));
  1219. -    if (status) goto out;
  1220. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1221. -    status = safe_read(&buffer, &length, &args->owner_local_uid, sizeof(DWORD));
  1222. -    if (status) goto out;
  1223. -    status = safe_read(&buffer, &length, &args->owner_group_local_gid, sizeof(DWORD));
  1224. -    if (status) goto out;
  1225. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1226. -    status = safe_read(&buffer, &length, &args->srv_open, sizeof(HANDLE));
  1227. -    if (status) goto out;
  1228. -    status = parse_abs_path(&buffer, &length, &args->symlink);
  1229. +    if (status) goto out;
  1230. +    status = safe_read(&buffer, &length, &args->mode, sizeof(DWORD));
  1231. +    if (status) goto out;
  1232. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1233. +    status = safe_read(&buffer, &length, &args->owner_local_uid, sizeof(DWORD));
  1234. +    if (status) goto out;
  1235. +    status = safe_read(&buffer, &length, &args->owner_group_local_gid, sizeof(DWORD));
  1236. +    if (status) goto out;
  1237. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1238. +    status = safe_read(&buffer, &length, &args->srv_open, sizeof(HANDLE));
  1239. +    if (status) goto out;
  1240. +    status = parse_abs_path(&buffer, &length, &args->symlink);
  1241.      if (status) goto out;
  1242.      status = safe_read(&buffer, &length, &args->ea, sizeof(HANDLE));
  1243.      if (status) goto out;
  1244.  
  1245. -    dprintf(1, "parsing NFS41_OPEN: filename='%s' access mask=%d "
  1246. -        "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
  1247. -        "(kernel) disposition=%d\n\topen_owner_id=%d mode=%o "
  1248. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1249. -        "owner_local_uid=%u owner_group_local_gid=%u "
  1250. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1251. -        "srv_open=%p symlink=%s ea=%p\n", args->path, args->access_mask,
  1252. -        args->access_mode, args->file_attrs, args->create_opts,
  1253. -        args->disposition, args->open_owner_id, args->mode,
  1254. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1255. -        (unsigned int)args->owner_local_uid, (unsigned int)args->owner_group_local_gid,
  1256. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1257. -        args->srv_open,
  1258. -        args->symlink.path, args->ea);
  1259. -    print_disposition(2, args->disposition);
  1260. -    print_access_mask(2, args->access_mask);
  1261. +    dprintf(1, "parsing NFS41_OPEN: filename='%s' access mask=%d "
  1262. +        "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
  1263. +        "(kernel) disposition=%d\n\topen_owner_id=%d mode=%o "
  1264. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1265. +        "owner_local_uid=%u owner_group_local_gid=%u "
  1266. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1267. +        "srv_open=%p symlink=%s ea=%p\n", args->path, args->access_mask,
  1268. +        args->access_mode, args->file_attrs, args->create_opts,
  1269. +        args->disposition, args->open_owner_id, args->mode,
  1270. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1271. +        (unsigned int)args->owner_local_uid, (unsigned int)args->owner_group_local_gid,
  1272. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1273. +        args->srv_open,
  1274. +        args->symlink.path, args->ea);
  1275. +    print_disposition(2, args->disposition);
  1276. +    print_access_mask(2, args->access_mask);
  1277.      print_share_mode(2, args->access_mode);
  1278.      print_create_attributes(2, args->create_opts);
  1279.  out:
  1280. @@ -655,123 +656,90 @@ static int handle_open(nfs41_upcall *upcall)
  1281.          }
  1282.  
  1283.          nfs_to_basic_info(&info, &args->basic_info);
  1284. -        nfs_to_standard_info(&info, &args->std_info);
  1285. -        args->mode = info.mode;
  1286. -        args->changeattr = info.change;
  1287. -
  1288. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1289. -        bitmap4 og_attr_request = { 0 };
  1290. -        nfs41_file_info og_info = { 0 };
  1291. -        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
  1292. -        nfsacl41 acl = { 0 };
  1293. -
  1294. -        /*
  1295. -         * gisburn:
  1296. -         * 1. We should cache owner/group information
  1297. -         * 2. We should always ask for
  1298. -         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
  1299. -         * attributes
  1300. -         */
  1301. -        og_attr_request.count = 2;
  1302. -        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  1303. -        og_info.owner = owner;
  1304. -        og_info.owner_group = group;
  1305. -        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
  1306. -        if (status) {
  1307. -            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
  1308. -            status);
  1309. -        }
  1310. -
  1311. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING
  1312. -        /*
  1313. -         * Map owner to local uid
  1314. -         *
  1315. -         * |owner| can be numeric string ("1616"), plain username
  1316. -         *  ("gisburn") or username@domain ("gisburn@sun.com")
  1317. -         */
  1318. -        /* stomp over '@' */
  1319. -        char *at_ch; /* pointer to '@' */
  1320. -        if (at_ch = strchr(og_info.owner, '@'))
  1321. -            *at_ch = '\0';
  1322. -
  1323. -        if (isdigit(og_info.owner[0])) {
  1324. -            args->owner_local_uid = atol(og_info.owner);
  1325. -        }
  1326. -        else if(!strcmp(og_info.owner, "nobody")) {
  1327. -            args->owner_local_uid = 65534;
  1328. -        }
  1329. -        else if(!strcmp(og_info.owner, "root")) {
  1330. -            args->owner_local_uid = 0;
  1331. -        }
  1332. -        else if(!strcmp(og_info.owner, "rmainz")) {
  1333. -            args->owner_local_uid = 1616;
  1334. -        }
  1335. -        else if(!strcmp(og_info.owner, "roland_mainz")) {
  1336. -            args->owner_local_uid = 197608;
  1337. -        }
  1338. -        else if(!strcmp(og_info.owner, "swulsch")) {
  1339. -            args->owner_local_uid = 1818;
  1340. -        }
  1341. -        else if(!strcmp(og_info.owner, "iam")) {
  1342. -            args->owner_local_uid = 2010;
  1343. -        }
  1344. -        else if(!strcmp(og_info.owner, "mwenzel")) {
  1345. -            args->owner_local_uid = 8239;
  1346. -        }
  1347. -        else if(!strcmp(og_info.owner, "test001")) {
  1348. -            args->owner_local_uid = 1000;
  1349. -        }
  1350. -        else {
  1351. -            args->owner_local_uid = 666; /* debug: number of the beast */
  1352. -        }
  1353. -
  1354. -        /*
  1355. -         * Map owner_group to local gid
  1356. -         *
  1357. -         * |owner_group| can be numeric string ("1616"), plain username
  1358. -         * ("gisgrp") or username@domain ("gisgrp@sun.com")
  1359. -         */
  1360. -        if (at_ch = strchr(og_info.owner_group, '@'))
  1361. -            *at_ch = '\0';
  1362. -        if (isdigit(og_info.owner_group[0])) {
  1363. -            args->owner_group_local_gid = atol(og_info.owner_group);
  1364. -        }
  1365. -        else if(!strcmp(og_info.owner_group, "nogroup")) {
  1366. -            args->owner_group_local_gid = 65534;
  1367. -        }
  1368. -        else if(!strcmp(og_info.owner_group, "root")) {
  1369. -            args->owner_group_local_gid = 0;
  1370. -        }
  1371. -        else if(!strcmp(og_info.owner_group, "Kein")) {
  1372. -            args->owner_group_local_gid = 197121;
  1373. -        }
  1374. -        else if(!strcmp(og_info.owner_group, "rmainz")) {
  1375. -            args->owner_group_local_gid = 1616;
  1376. -        }
  1377. -        else if(!strcmp(og_info.owner, "iam")) {
  1378. -            args->owner_group_local_gid = 2010;
  1379. -        }
  1380. -        else if(!strcmp(og_info.owner_group, "swulsch")) {
  1381. -            args->owner_group_local_gid = 1818;
  1382. -        }
  1383. -        else if(!strcmp(og_info.owner_group, "mwenzel")) {
  1384. -            args->owner_group_local_gid = 8239;
  1385. -        }
  1386. -        else if(!strcmp(og_info.owner_group, "test001")) {
  1387. -            args->owner_group_local_gid = 1000;
  1388. -        }
  1389. -        else {
  1390. -            args->owner_group_local_gid = 666; /* debug: number of the beast */
  1391. -        }
  1392. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING */
  1393. -
  1394. -        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  1395. -            (unsigned int)args->owner_local_uid, og_info.owner,
  1396. -            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
  1397. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1398. -    } else {
  1399. -        nfs41_file_info createattrs = { 0 };
  1400. -        uint32_t create = 0, createhowmode = 0, lookup_status = status;
  1401. +        nfs_to_standard_info(&info, &args->std_info);
  1402. +        args->mode = info.mode;
  1403. +        args->changeattr = info.change;
  1404. +
  1405. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1406. +        bitmap4 og_attr_request = { 0 };
  1407. +        nfs41_file_info og_info = { 0 };
  1408. +        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
  1409. +        nfsacl41 acl = { 0 };
  1410. +
  1411. +        /*
  1412. +         * gisburn:
  1413. +         * 1. We should cache owner/group information
  1414. +         * 2. We should always ask for
  1415. +         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
  1416. +         * attributes
  1417. +         */
  1418. +        og_attr_request.count = 2;
  1419. +        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
  1420. +        og_info.owner = owner;
  1421. +        og_info.owner_group = group;
  1422. +        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
  1423. +        if (status) {
  1424. +            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
  1425. +            status);
  1426. +        }
  1427. +
  1428. +        uid_t map_uid = -1;
  1429. +        gid_t gid_dummy = -1;
  1430. +        gid_t map_gid = -1;
  1431. +        char *at_ch; /* pointer to '@' */
  1432. +
  1433. +        /*
  1434. +         * Map owner to local uid
  1435. +         *
  1436. +         * |owner| can be numeric string ("1616"), plain username
  1437. +         *  ("gisburn") or username@domain ("gisburn@sun.com")
  1438. +         */
  1439. +        /* stomp over '@' */
  1440. +        if (at_ch = strchr(og_info.owner, '@'))
  1441. +            *at_ch = '\0';
  1442. +
  1443. +        if (nfs41_idmap_name_to_ids(
  1444. +            global_idmap_context,
  1445. +            og_info.owner,
  1446. +            &map_uid,
  1447. +            &gid_dummy) == 0) {
  1448. +             args->owner_local_uid = map_uid;
  1449. +        }
  1450. +        else {
  1451. +            args->owner_local_uid = 30666; /* debug: number of the beast */
  1452. +            eprintf("get_stat_data: no mapping for '%s', fake uid=%d\n",
  1453. +                og_info.owner, args->owner_local_uid);
  1454. +        }
  1455. +    
  1456. +        /*
  1457. +         * Map owner_group to local gid
  1458. +         *
  1459. +         * |owner_group| can be numeric string ("1616"), plain username
  1460. +         * ("gisgrp") or username@domain ("gisgrp@sun.com")
  1461. +         */
  1462. +        /* stomp over '@' */
  1463. +        if (at_ch = strchr(og_info.owner_group, '@'))
  1464. +            *at_ch = '\0';
  1465. +
  1466. +        if (nfs41_idmap_group_to_gid(
  1467. +            global_idmap_context,
  1468. +            og_info.owner_group,
  1469. +            &map_gid) == 0) {
  1470. +            args->owner_group_local_gid = map_gid;
  1471. +        }
  1472. +        else {
  1473. +            args->owner_group_local_gid = 30777; /* debug: number of the beast */
  1474. +            eprintf("get_stat_data: no mapping for '%s', fake gid=%d\n",
  1475. +                og_info.owner_group, args->owner_group_local_gid);
  1476. +        }
  1477. +
  1478. +        dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
  1479. +            (unsigned int)args->owner_local_uid, og_info.owner,
  1480. +            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
  1481. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1482. +    } else {
  1483. +        nfs41_file_info createattrs = { 0 };
  1484. +        uint32_t create = 0, createhowmode = 0, lookup_status = status;
  1485.  
  1486.          if (!lookup_status && (args->disposition == FILE_OVERWRITE ||
  1487.                  args->disposition == FILE_OVERWRITE_IF ||
  1488. @@ -875,18 +843,18 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
  1489.      status = safe_write(&buffer, length, &args->std_info, sizeof(args->std_info));
  1490.      if (status) goto out;
  1491.      status = safe_write(&buffer, length, &upcall->state_ref, sizeof(HANDLE));
  1492. -    if (status) goto out;
  1493. -    status = safe_write(&buffer, length, &args->mode, sizeof(args->mode));
  1494. -    if (status) goto out;
  1495. -#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1496. -    status = safe_write(&buffer, length, &args->owner_local_uid, sizeof(args->owner_local_uid));
  1497. -    if (status) goto out;
  1498. -    status = safe_write(&buffer, length, &args->owner_group_local_gid, sizeof(args->owner_group_local_gid));
  1499. -    if (status) goto out;
  1500. -#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1501. -    status = safe_write(&buffer, length, &args->changeattr, sizeof(args->changeattr));
  1502. -    if (status) goto out;
  1503. -    status = safe_write(&buffer, length, &args->deleg_type, sizeof(args->deleg_type));
  1504. +    if (status) goto out;
  1505. +    status = safe_write(&buffer, length, &args->mode, sizeof(args->mode));
  1506. +    if (status) goto out;
  1507. +#ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  1508. +    status = safe_write(&buffer, length, &args->owner_local_uid, sizeof(args->owner_local_uid));
  1509. +    if (status) goto out;
  1510. +    status = safe_write(&buffer, length, &args->owner_group_local_gid, sizeof(args->owner_group_local_gid));
  1511. +    if (status) goto out;
  1512. +#endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
  1513. +    status = safe_write(&buffer, length, &args->changeattr, sizeof(args->changeattr));
  1514. +    if (status) goto out;
  1515. +    status = safe_write(&buffer, length, &args->deleg_type, sizeof(args->deleg_type));
  1516.      if (status) goto out;
  1517.      if (upcall->last_error == ERROR_REPARSE) {
  1518.          unsigned short len = (args->symlink.len + 1) * sizeof(WCHAR);
  1519. diff --git a/libtirpc/src/auth_unix.c b/libtirpc/src/auth_unix.c
  1520. index ca8c908..8261b9e 100644
  1521. --- a/libtirpc/src/auth_unix.c
  1522. +++ b/libtirpc/src/auth_unix.c
  1523. @@ -213,10 +213,13 @@ authunix_create_default()
  1524.                 abort();
  1525.  #else
  1526.         // XXX Need to figure out what to do here!
  1527. -       uid = 666;
  1528. -       gid = 777;
  1529. +       uid = 10666;
  1530. +       gid = 10777;
  1531.         gids[0] = 0;
  1532.         len = 0;
  1533. +        (void)fprintf(stderr, "authunix_create_default(): fixme, "
  1534. +            "do not know what do to, returning fake uid=%d/gid=%d",
  1535. +            (int)uid, (int)gid);
  1536.  #endif
  1537.         /* XXX: interface problem; those should all have been unsigned */
  1538.         return (authunix_create(machname, uid, gid, len, gids));
  1539. diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
  1540. index f8ea548..44e1961 100644
  1541. --- a/sys/nfs41_build_features.h
  1542. +++ b/sys/nfs41_build_features.h
  1543. @@ -32,14 +32,14 @@
  1544.  /*
  1545.   * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
  1546.   */
  1547. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  1548. -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING 1
  1549. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
  1550. +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_TESTMAPPING 1
  1551.  
  1552.  /*
  1553.   * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
  1554.   * files which do not map to a local account a SID in the
  1555.   * Unix_User+x/Unix_Group+x range
  1556.   */
  1557. -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  1558. +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
  1559.  
  1560.  #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */

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