PageRenderTime 49ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/source3/utils/sharesec.c

https://bitbucket.org/resara/rdssamba4
C | 717 lines | 532 code | 128 blank | 57 comment | 120 complexity | bf8308251ad8e8c2089d21f357ed1ffb MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, BSD-3-Clause, GPL-3.0, LGPL-2.1
  1. /*
  2. * Unix SMB/Netbios implementation.
  3. * Utility for managing share permissions
  4. *
  5. * Copyright (C) Tim Potter 2000
  6. * Copyright (C) Jeremy Allison 2000
  7. * Copyright (C) Jelmer Vernooij 2003
  8. * Copyright (C) Gerald (Jerry) Carter 2005.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #include "includes.h"
  24. #include "popt_common.h"
  25. #include "../libcli/security/security.h"
  26. #include "passdb/machine_sid.h"
  27. static TALLOC_CTX *ctx;
  28. enum acl_mode { SMB_ACL_DELETE,
  29. SMB_ACL_MODIFY,
  30. SMB_ACL_ADD,
  31. SMB_ACL_SET,
  32. SMB_SD_DELETE,
  33. SMB_SD_SETSDDL,
  34. SMB_SD_VIEWSDDL,
  35. SMB_ACL_VIEW };
  36. struct perm_value {
  37. const char *perm;
  38. uint32 mask;
  39. };
  40. /* These values discovered by inspection */
  41. static const struct perm_value special_values[] = {
  42. { "R", SEC_RIGHTS_FILE_READ },
  43. { "W", SEC_RIGHTS_FILE_WRITE },
  44. { "X", SEC_RIGHTS_FILE_EXECUTE },
  45. { "D", SEC_STD_DELETE },
  46. { "P", SEC_STD_WRITE_DAC },
  47. { "O", SEC_STD_WRITE_OWNER },
  48. { NULL, 0 },
  49. };
  50. #define SEC_RIGHTS_DIR_CHANGE ( SEC_RIGHTS_DIR_READ|SEC_STD_DELETE|\
  51. SEC_RIGHTS_DIR_WRITE|SEC_DIR_TRAVERSE )
  52. static const struct perm_value standard_values[] = {
  53. { "READ", SEC_RIGHTS_DIR_READ|SEC_DIR_TRAVERSE },
  54. { "CHANGE", SEC_RIGHTS_DIR_CHANGE },
  55. { "FULL", SEC_RIGHTS_DIR_ALL },
  56. { NULL, 0 },
  57. };
  58. /********************************************************************
  59. print an ACE on a FILE
  60. ********************************************************************/
  61. static void print_ace(FILE *f, struct security_ace *ace)
  62. {
  63. const struct perm_value *v;
  64. int do_print = 0;
  65. uint32 got_mask;
  66. fprintf(f, "%s:", sid_string_tos(&ace->trustee));
  67. /* Ace type */
  68. if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED) {
  69. fprintf(f, "ALLOWED");
  70. } else if (ace->type == SEC_ACE_TYPE_ACCESS_DENIED) {
  71. fprintf(f, "DENIED");
  72. } else {
  73. fprintf(f, "%d", ace->type);
  74. }
  75. /* Not sure what flags can be set in a file ACL */
  76. fprintf(f, "/%d/", ace->flags);
  77. /* Standard permissions */
  78. for (v = standard_values; v->perm; v++) {
  79. if (ace->access_mask == v->mask) {
  80. fprintf(f, "%s", v->perm);
  81. return;
  82. }
  83. }
  84. /* Special permissions. Print out a hex value if we have
  85. leftover bits in the mask. */
  86. got_mask = ace->access_mask;
  87. again:
  88. for (v = special_values; v->perm; v++) {
  89. if ((ace->access_mask & v->mask) == v->mask) {
  90. if (do_print) {
  91. fprintf(f, "%s", v->perm);
  92. }
  93. got_mask &= ~v->mask;
  94. }
  95. }
  96. if (!do_print) {
  97. if (got_mask != 0) {
  98. fprintf(f, "0x%08x", ace->access_mask);
  99. } else {
  100. do_print = 1;
  101. goto again;
  102. }
  103. }
  104. }
  105. /********************************************************************
  106. print an ascii version of a security descriptor on a FILE handle
  107. ********************************************************************/
  108. static void sec_desc_print(FILE *f, struct security_descriptor *sd)
  109. {
  110. uint32 i;
  111. fprintf(f, "REVISION:%d\n", sd->revision);
  112. /* Print owner and group sid */
  113. fprintf(f, "OWNER:%s\n", sid_string_tos(sd->owner_sid));
  114. fprintf(f, "GROUP:%s\n", sid_string_tos(sd->group_sid));
  115. /* Print aces */
  116. for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
  117. struct security_ace *ace = &sd->dacl->aces[i];
  118. fprintf(f, "ACL:");
  119. print_ace(f, ace);
  120. fprintf(f, "\n");
  121. }
  122. }
  123. /********************************************************************
  124. parse an ACE in the same format as print_ace()
  125. ********************************************************************/
  126. static bool parse_ace(struct security_ace *ace, const char *orig_str)
  127. {
  128. char *p;
  129. const char *cp;
  130. char *tok;
  131. unsigned int atype = 0;
  132. unsigned int aflags = 0;
  133. unsigned int amask = 0;
  134. struct dom_sid sid;
  135. uint32_t mask;
  136. const struct perm_value *v;
  137. char *str = SMB_STRDUP(orig_str);
  138. TALLOC_CTX *frame = talloc_stackframe();
  139. if (!str) {
  140. TALLOC_FREE(frame);
  141. return False;
  142. }
  143. ZERO_STRUCTP(ace);
  144. p = strchr_m(str,':');
  145. if (!p) {
  146. fprintf(stderr, "ACE '%s': missing ':'.\n", orig_str);
  147. SAFE_FREE(str);
  148. TALLOC_FREE(frame);
  149. return False;
  150. }
  151. *p = '\0';
  152. p++;
  153. /* Try to parse numeric form */
  154. if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 &&
  155. string_to_sid(&sid, str)) {
  156. goto done;
  157. }
  158. /* Try to parse text form */
  159. if (!string_to_sid(&sid, str)) {
  160. fprintf(stderr, "ACE '%s': failed to convert '%s' to SID\n",
  161. orig_str, str);
  162. SAFE_FREE(str);
  163. TALLOC_FREE(frame);
  164. return False;
  165. }
  166. cp = p;
  167. if (!next_token_talloc(frame, &cp, &tok, "/")) {
  168. fprintf(stderr, "ACE '%s': failed to find '/' character.\n",
  169. orig_str);
  170. SAFE_FREE(str);
  171. TALLOC_FREE(frame);
  172. return False;
  173. }
  174. if (strncmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
  175. atype = SEC_ACE_TYPE_ACCESS_ALLOWED;
  176. } else if (strncmp(tok, "DENIED", strlen("DENIED")) == 0) {
  177. atype = SEC_ACE_TYPE_ACCESS_DENIED;
  178. } else {
  179. fprintf(stderr, "ACE '%s': missing 'ALLOWED' or 'DENIED' "
  180. "entry at '%s'\n", orig_str, tok);
  181. SAFE_FREE(str);
  182. TALLOC_FREE(frame);
  183. return False;
  184. }
  185. /* Only numeric form accepted for flags at present */
  186. /* no flags on share permissions */
  187. if (!(next_token_talloc(frame, &cp, &tok, "/") &&
  188. sscanf(tok, "%i", &aflags) && aflags == 0)) {
  189. fprintf(stderr, "ACE '%s': bad integer flags entry at '%s'\n",
  190. orig_str, tok);
  191. SAFE_FREE(str);
  192. TALLOC_FREE(frame);
  193. return False;
  194. }
  195. if (!next_token_talloc(frame, &cp, &tok, "/")) {
  196. fprintf(stderr, "ACE '%s': missing / at '%s'\n",
  197. orig_str, tok);
  198. SAFE_FREE(str);
  199. TALLOC_FREE(frame);
  200. return False;
  201. }
  202. if (strncmp(tok, "0x", 2) == 0) {
  203. if (sscanf(tok, "%i", &amask) != 1) {
  204. fprintf(stderr, "ACE '%s': bad hex number at '%s'\n",
  205. orig_str, tok);
  206. TALLOC_FREE(frame);
  207. SAFE_FREE(str);
  208. return False;
  209. }
  210. goto done;
  211. }
  212. for (v = standard_values; v->perm; v++) {
  213. if (strcmp(tok, v->perm) == 0) {
  214. amask = v->mask;
  215. goto done;
  216. }
  217. }
  218. p = tok;
  219. while(*p) {
  220. bool found = False;
  221. for (v = special_values; v->perm; v++) {
  222. if (v->perm[0] == *p) {
  223. amask |= v->mask;
  224. found = True;
  225. }
  226. }
  227. if (!found) {
  228. fprintf(stderr, "ACE '%s': bad permission value at "
  229. "'%s'\n", orig_str, p);
  230. TALLOC_FREE(frame);
  231. SAFE_FREE(str);
  232. return False;
  233. }
  234. p++;
  235. }
  236. if (*p) {
  237. TALLOC_FREE(frame);
  238. SAFE_FREE(str);
  239. return False;
  240. }
  241. done:
  242. mask = amask;
  243. init_sec_ace(ace, &sid, atype, mask, aflags);
  244. SAFE_FREE(str);
  245. TALLOC_FREE(frame);
  246. return True;
  247. }
  248. /********************************************************************
  249. ********************************************************************/
  250. static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const char *szACL, size_t *sd_size )
  251. {
  252. struct security_descriptor *sd = NULL;
  253. struct security_ace *ace;
  254. struct security_acl *theacl;
  255. int num_ace;
  256. const char *pacl;
  257. int i;
  258. if ( !szACL )
  259. return NULL;
  260. pacl = szACL;
  261. num_ace = count_chars( pacl, ',' ) + 1;
  262. if ( !(ace = talloc_zero_array( mem_ctx, struct security_ace, num_ace )) )
  263. return NULL;
  264. for ( i=0; i<num_ace; i++ ) {
  265. char *end_acl = strchr_m( pacl, ',' );
  266. fstring acl_string;
  267. strncpy( acl_string, pacl, MIN( PTR_DIFF( end_acl, pacl ), sizeof(fstring)-1) );
  268. acl_string[MIN( PTR_DIFF( end_acl, pacl ), sizeof(fstring)-1)] = '\0';
  269. if ( !parse_ace( &ace[i], acl_string ) )
  270. return NULL;
  271. pacl = end_acl;
  272. pacl++;
  273. }
  274. if ( !(theacl = make_sec_acl( mem_ctx, NT4_ACL_REVISION, num_ace, ace )) )
  275. return NULL;
  276. sd = make_sec_desc( mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE,
  277. NULL, NULL, NULL, theacl, sd_size);
  278. return sd;
  279. }
  280. /* add an ACE to a list of ACEs in a struct security_acl */
  281. static bool add_ace(TALLOC_CTX *mem_ctx, struct security_acl **the_acl, struct security_ace *ace)
  282. {
  283. struct security_acl *new_ace;
  284. struct security_ace *aces;
  285. if (! *the_acl) {
  286. return (((*the_acl) = make_sec_acl(mem_ctx, 3, 1, ace)) != NULL);
  287. }
  288. if (!(aces = SMB_CALLOC_ARRAY(struct security_ace, 1+(*the_acl)->num_aces))) {
  289. return False;
  290. }
  291. memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(struct
  292. security_ace));
  293. memcpy(aces+(*the_acl)->num_aces, ace, sizeof(struct security_ace));
  294. new_ace = make_sec_acl(mem_ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces);
  295. SAFE_FREE(aces);
  296. (*the_acl) = new_ace;
  297. return True;
  298. }
  299. /* The MSDN is contradictory over the ordering of ACE entries in an ACL.
  300. However NT4 gives a "The information may have been modified by a
  301. computer running Windows NT 5.0" if denied ACEs do not appear before
  302. allowed ACEs. */
  303. static int ace_compare(struct security_ace *ace1, struct security_ace *ace2)
  304. {
  305. if (sec_ace_equal(ace1, ace2))
  306. return 0;
  307. if (ace1->type != ace2->type)
  308. return ace2->type - ace1->type;
  309. if (dom_sid_compare(&ace1->trustee, &ace2->trustee))
  310. return dom_sid_compare(&ace1->trustee, &ace2->trustee);
  311. if (ace1->flags != ace2->flags)
  312. return ace1->flags - ace2->flags;
  313. if (ace1->access_mask != ace2->access_mask)
  314. return ace1->access_mask - ace2->access_mask;
  315. if (ace1->size != ace2->size)
  316. return ace1->size - ace2->size;
  317. return memcmp(ace1, ace2, sizeof(struct security_ace));
  318. }
  319. static void sort_acl(struct security_acl *the_acl)
  320. {
  321. uint32 i;
  322. if (!the_acl) return;
  323. TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare);
  324. for (i=1;i<the_acl->num_aces;) {
  325. if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) {
  326. int j;
  327. for (j=i; j<the_acl->num_aces-1; j++) {
  328. the_acl->aces[j] = the_acl->aces[j+1];
  329. }
  330. the_acl->num_aces--;
  331. } else {
  332. i++;
  333. }
  334. }
  335. }
  336. static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *the_acl, enum acl_mode mode)
  337. {
  338. struct security_descriptor *sd = NULL;
  339. struct security_descriptor *old = NULL;
  340. size_t sd_size = 0;
  341. uint32 i, j;
  342. if (mode != SMB_ACL_SET && mode != SMB_SD_DELETE) {
  343. if (!(old = get_share_security( mem_ctx, sharename, &sd_size )) ) {
  344. fprintf(stderr, "Unable to retrieve permissions for share "
  345. "[%s]\n", sharename);
  346. return -1;
  347. }
  348. }
  349. if ( (mode != SMB_ACL_VIEW && mode != SMB_SD_DELETE) &&
  350. !(sd = parse_acl_string(mem_ctx, the_acl, &sd_size )) ) {
  351. fprintf( stderr, "Failed to parse acl\n");
  352. return -1;
  353. }
  354. switch (mode) {
  355. case SMB_ACL_VIEW:
  356. sec_desc_print( stdout, old);
  357. return 0;
  358. case SMB_ACL_DELETE:
  359. for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
  360. bool found = False;
  361. for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
  362. if (sec_ace_equal(&sd->dacl->aces[i], &old->dacl->aces[j])) {
  363. uint32 k;
  364. for (k=j; k<old->dacl->num_aces-1;k++) {
  365. old->dacl->aces[k] = old->dacl->aces[k+1];
  366. }
  367. old->dacl->num_aces--;
  368. found = True;
  369. break;
  370. }
  371. }
  372. if (!found) {
  373. printf("ACL for ACE:");
  374. print_ace(stdout, &sd->dacl->aces[i]);
  375. printf(" not found\n");
  376. }
  377. }
  378. break;
  379. case SMB_ACL_MODIFY:
  380. for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
  381. bool found = False;
  382. for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
  383. if (dom_sid_equal(&sd->dacl->aces[i].trustee,
  384. &old->dacl->aces[j].trustee)) {
  385. old->dacl->aces[j] = sd->dacl->aces[i];
  386. found = True;
  387. }
  388. }
  389. if (!found) {
  390. printf("ACL for SID %s not found\n",
  391. sid_string_tos(&sd->dacl->aces[i].trustee));
  392. }
  393. }
  394. if (sd->owner_sid) {
  395. old->owner_sid = sd->owner_sid;
  396. }
  397. if (sd->group_sid) {
  398. old->group_sid = sd->group_sid;
  399. }
  400. break;
  401. case SMB_ACL_ADD:
  402. for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
  403. add_ace(mem_ctx, &old->dacl, &sd->dacl->aces[i]);
  404. }
  405. break;
  406. case SMB_ACL_SET:
  407. old = sd;
  408. break;
  409. case SMB_SD_DELETE:
  410. if (!delete_share_security(sharename)) {
  411. fprintf( stderr, "Failed to delete security descriptor for "
  412. "share [%s]\n", sharename );
  413. return -1;
  414. }
  415. return 0;
  416. default:
  417. fprintf(stderr, "invalid command\n");
  418. return -1;
  419. }
  420. /* Denied ACE entries must come before allowed ones */
  421. sort_acl(old->dacl);
  422. if ( !set_share_security( sharename, old ) ) {
  423. fprintf( stderr, "Failed to store acl for share [%s]\n", sharename );
  424. return 2;
  425. }
  426. return 0;
  427. }
  428. static int set_sharesec_sddl(const char *sharename, const char *sddl)
  429. {
  430. struct security_descriptor *sd;
  431. bool ret;
  432. sd = sddl_decode(talloc_tos(), sddl, get_global_sam_sid());
  433. if (sd == NULL) {
  434. fprintf(stderr, "Failed to parse acl\n");
  435. return -1;
  436. }
  437. ret = set_share_security(sharename, sd);
  438. TALLOC_FREE(sd);
  439. if (!ret) {
  440. fprintf(stderr, "Failed to store acl for share [%s]\n",
  441. sharename);
  442. return -1;
  443. }
  444. return 0;
  445. }
  446. static int view_sharesec_sddl(const char *sharename)
  447. {
  448. struct security_descriptor *sd;
  449. size_t sd_size;
  450. char *acl;
  451. sd = get_share_security(talloc_tos(), sharename, &sd_size);
  452. if (sd == NULL) {
  453. fprintf(stderr, "Unable to retrieve permissions for share "
  454. "[%s]\n", sharename);
  455. return -1;
  456. }
  457. acl = sddl_encode(talloc_tos(), sd, get_global_sam_sid());
  458. TALLOC_FREE(sd);
  459. if (acl == NULL) {
  460. fprintf(stderr, "Unable to sddl-encode permissions for share "
  461. "[%s]\n", sharename);
  462. return -1;
  463. }
  464. printf("%s\n", acl);
  465. TALLOC_FREE(acl);
  466. return 0;
  467. }
  468. /********************************************************************
  469. main program
  470. ********************************************************************/
  471. int main(int argc, const char *argv[])
  472. {
  473. int opt;
  474. int retval = 0;
  475. enum acl_mode mode = SMB_ACL_SET;
  476. static char *the_acl = NULL;
  477. fstring sharename;
  478. bool force_acl = False;
  479. int snum;
  480. poptContext pc;
  481. bool initialize_sid = False;
  482. struct poptOption long_options[] = {
  483. POPT_AUTOHELP
  484. { "remove", 'r', POPT_ARG_STRING, &the_acl, 'r', "Remove ACEs", "ACL" },
  485. { "modify", 'm', POPT_ARG_STRING, &the_acl, 'm', "Modify existing ACEs", "ACL" },
  486. { "add", 'a', POPT_ARG_STRING, &the_acl, 'a', "Add ACEs", "ACL" },
  487. { "replace", 'R', POPT_ARG_STRING, &the_acl, 'R', "Overwrite share permission ACL", "ACLS" },
  488. { "delete", 'D', POPT_ARG_NONE, NULL, 'D', "Delete the entire security descriptor" },
  489. { "setsddl", 'S', POPT_ARG_STRING, the_acl, 'S',
  490. "Set the SD in sddl format" },
  491. { "viewsddl", 'V', POPT_ARG_NONE, the_acl, 'V',
  492. "View the SD in sddl format" },
  493. { "view", 'v', POPT_ARG_NONE, NULL, 'v', "View current share permissions" },
  494. { "machine-sid", 'M', POPT_ARG_NONE, NULL, 'M', "Initialize the machine SID" },
  495. { "force", 'F', POPT_ARG_NONE, NULL, 'F', "Force storing the ACL", "ACLS" },
  496. POPT_COMMON_SAMBA
  497. { NULL }
  498. };
  499. if ( !(ctx = talloc_stackframe()) ) {
  500. fprintf( stderr, "Failed to initialize talloc context!\n");
  501. return -1;
  502. }
  503. /* set default debug level to 1 regardless of what smb.conf sets */
  504. setup_logging( "sharesec", DEBUG_STDERR);
  505. load_case_tables();
  506. lp_set_cmdline("log level", "1");
  507. pc = poptGetContext("sharesec", argc, argv, long_options, 0);
  508. poptSetOtherOptionHelp(pc, "sharename\n");
  509. while ((opt = poptGetNextOpt(pc)) != -1) {
  510. switch (opt) {
  511. case 'r':
  512. the_acl = smb_xstrdup(poptGetOptArg(pc));
  513. mode = SMB_ACL_DELETE;
  514. break;
  515. case 'm':
  516. the_acl = smb_xstrdup(poptGetOptArg(pc));
  517. mode = SMB_ACL_MODIFY;
  518. break;
  519. case 'a':
  520. the_acl = smb_xstrdup(poptGetOptArg(pc));
  521. mode = SMB_ACL_ADD;
  522. break;
  523. case 'R':
  524. the_acl = smb_xstrdup(poptGetOptArg(pc));
  525. mode = SMB_ACL_SET;
  526. break;
  527. case 'D':
  528. mode = SMB_SD_DELETE;
  529. break;
  530. case 'S':
  531. mode = SMB_SD_SETSDDL;
  532. the_acl = smb_xstrdup(poptGetOptArg(pc));
  533. break;
  534. case 'V':
  535. mode = SMB_SD_VIEWSDDL;
  536. break;
  537. case 'v':
  538. mode = SMB_ACL_VIEW;
  539. break;
  540. case 'F':
  541. force_acl = True;
  542. break;
  543. case 'M':
  544. initialize_sid = True;
  545. break;
  546. }
  547. }
  548. setlinebuf(stdout);
  549. lp_load_with_registry_shares( get_dyn_CONFIGFILE(), False, False, False,
  550. True );
  551. /* check for initializing secrets.tdb first */
  552. if ( initialize_sid ) {
  553. struct dom_sid *sid = get_global_sam_sid();
  554. if ( !sid ) {
  555. fprintf( stderr, "Failed to retrieve Machine SID!\n");
  556. return 3;
  557. }
  558. printf ("%s\n", sid_string_tos( sid ) );
  559. return 0;
  560. }
  561. if ( mode == SMB_ACL_VIEW && force_acl ) {
  562. fprintf( stderr, "Invalid combination of -F and -v\n");
  563. return -1;
  564. }
  565. /* get the sharename */
  566. if(!poptPeekArg(pc)) {
  567. poptPrintUsage(pc, stderr, 0);
  568. return -1;
  569. }
  570. fstrcpy(sharename, poptGetArg(pc));
  571. snum = lp_servicenumber( sharename );
  572. if ( snum == -1 && !force_acl ) {
  573. fprintf( stderr, "Invalid sharename: %s\n", sharename);
  574. return -1;
  575. }
  576. switch (mode) {
  577. case SMB_SD_SETSDDL:
  578. retval = set_sharesec_sddl(sharename, the_acl);
  579. break;
  580. case SMB_SD_VIEWSDDL:
  581. retval = view_sharesec_sddl(sharename);
  582. break;
  583. default:
  584. retval = change_share_sec(ctx, sharename, the_acl, mode);
  585. break;
  586. }
  587. talloc_destroy(ctx);
  588. return retval;
  589. }