Line data Source code
1 : /*
2 : Samba Unix/Linux SMB client library
3 : Distributed SMB/CIFS Server Management Utility
4 : Copyright (C) 2001 Steve French (sfrench@us.ibm.com)
5 : Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
6 : Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
7 : Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
8 : Copyright (C) 2008 Kai Blin (kai@samba.org)
9 :
10 : Originally written by Steve and Jim. Largely rewritten by tridge in
11 : November 2001.
12 :
13 : Reworked again by abartlet in December 2001
14 :
15 : Another overhaul, moving functionality into plug-ins loaded on demand by Kai
16 : in May 2008.
17 :
18 : This program is free software; you can redistribute it and/or modify
19 : it under the terms of the GNU General Public License as published by
20 : the Free Software Foundation; either version 3 of the License, or
21 : (at your option) any later version.
22 :
23 : This program is distributed in the hope that it will be useful,
24 : but WITHOUT ANY WARRANTY; without even the implied warranty of
25 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 : GNU General Public License for more details.
27 :
28 : You should have received a copy of the GNU General Public License
29 : along with this program. If not, see <http://www.gnu.org/licenses/>. */
30 :
31 : /*****************************************************/
32 : /* */
33 : /* Distributed SMB/CIFS Server Management Utility */
34 : /* */
35 : /* The intent was to make the syntax similar */
36 : /* to the NET utility (first developed in DOS */
37 : /* with additional interesting & useful functions */
38 : /* added in later SMB server network operating */
39 : /* systems). */
40 : /* */
41 : /*****************************************************/
42 :
43 : #include "includes.h"
44 : #include "lib/cmdline/cmdline.h"
45 : #include "utils/net.h"
46 : #include "secrets.h"
47 : #include "lib/netapi/netapi.h"
48 : #include "../libcli/security/security.h"
49 : #include "passdb.h"
50 : #include "messages.h"
51 : #include "cmdline_contexts.h"
52 : #include "lib/gencache.h"
53 : #include "auth/credentials/credentials.h"
54 : #include "source3/utils/passwd_proto.h"
55 : #include "auth/gensec/gensec.h"
56 : #include "lib/param/param.h"
57 :
58 : #ifdef WITH_FAKE_KASERVER
59 : #include "utils/net_afs.h"
60 : #endif
61 :
62 : /***********************************************************************/
63 : /* end of internationalization section */
64 : /***********************************************************************/
65 :
66 16 : enum netr_SchannelType get_sec_channel_type(const char *param)
67 : {
68 16 : if (!(param && *param)) {
69 10 : return get_default_sec_channel();
70 : } else {
71 6 : if (strequal(param, "PDC")) {
72 0 : return SEC_CHAN_BDC;
73 6 : } else if (strequal(param, "BDC")) {
74 0 : return SEC_CHAN_BDC;
75 6 : } else if (strequal(param, "MEMBER")) {
76 0 : return SEC_CHAN_WKSTA;
77 : #if 0
78 : } else if (strequal(param, "DOMAIN")) {
79 : return SEC_CHAN_DOMAIN;
80 : #endif
81 : } else {
82 6 : return get_default_sec_channel();
83 : }
84 : }
85 : }
86 :
87 0 : static int net_changetrustpw(struct net_context *c, int argc, const char **argv)
88 : {
89 0 : net_warn_member_options();
90 :
91 0 : if (net_ads_check_our_domain(c) == 0)
92 0 : return net_ads_changetrustpw(c, argc, argv);
93 :
94 0 : return net_rpc_changetrustpw(c, argc, argv);
95 : }
96 :
97 0 : static void set_line_buffering(FILE *f)
98 : {
99 0 : setvbuf(f, NULL, _IOLBF, 0);
100 0 : }
101 :
102 3 : static int net_primarytrust_dumpinfo(struct net_context *c, int argc,
103 : const char **argv)
104 : {
105 3 : int role = lp_server_role();
106 3 : const char *domain = lp_workgroup();
107 3 : struct secrets_domain_info1 *info = NULL;
108 3 : bool include_secrets = c->opt_force;
109 3 : char *str = NULL;
110 0 : NTSTATUS status;
111 :
112 3 : if (role >= ROLE_ACTIVE_DIRECTORY_DC) {
113 0 : d_printf(_("net primarytrust dumpinfo is only supported "
114 : "on a DOMAIN_MEMBER for now.\n"));
115 0 : return 1;
116 : }
117 :
118 3 : net_warn_member_options();
119 :
120 3 : if (c->opt_stdin) {
121 0 : set_line_buffering(stdin);
122 0 : set_line_buffering(stdout);
123 0 : set_line_buffering(stderr);
124 : }
125 :
126 3 : status = secrets_fetch_or_upgrade_domain_info(domain,
127 : talloc_tos(),
128 : &info);
129 3 : if (!NT_STATUS_IS_OK(status)) {
130 0 : d_fprintf(stderr,
131 0 : _("Unable to fetch the information for domain[%s] "
132 : "in the secrets database.\n"),
133 : domain);
134 0 : return 1;
135 : }
136 :
137 3 : str = secrets_domain_info_string(info, info, domain, include_secrets);
138 3 : if (str == NULL) {
139 0 : d_fprintf(stderr, "secrets_domain_info_string() failed.\n");
140 0 : return 1;
141 : }
142 :
143 3 : d_printf("%s", str);
144 3 : if (!c->opt_force) {
145 3 : d_printf(_("The password values are only included using "
146 : "-f flag.\n"));
147 : }
148 :
149 3 : TALLOC_FREE(info);
150 3 : return 0;
151 : }
152 :
153 : /**
154 : * Entrypoint for 'net primarytrust' code.
155 : *
156 : * @param argc Standard argc.
157 : * @param argv Standard argv without initial components.
158 : *
159 : * @return Integer status (0 means success).
160 : */
161 :
162 3 : static int net_primarytrust(struct net_context *c, int argc, const char **argv)
163 : {
164 3 : struct functable func[] = {
165 : {
166 : .funcname = "dumpinfo",
167 : .fn = net_primarytrust_dumpinfo,
168 : .valid_transports = NET_TRANSPORT_LOCAL,
169 : .description = N_("Dump the details of the "
170 : "workstation trust"),
171 : .usage = N_(" net [options] primarytrust "
172 : "dumpinfo'\n"
173 : " Dump the details of the "
174 : "workstation trust in "
175 : "secrets.tdb.\n"
176 : " Requires the -f flag to "
177 : "include the password values."),
178 : },
179 : {
180 : .funcname = NULL,
181 : },
182 : };
183 :
184 3 : return net_run_function(c, argc, argv, "net primarytrust", func);
185 : }
186 :
187 0 : static int net_changesecretpw(struct net_context *c, int argc,
188 : const char **argv)
189 : {
190 0 : char *trust_pw;
191 0 : int role = lp_server_role();
192 :
193 0 : if (role != ROLE_DOMAIN_MEMBER) {
194 0 : d_printf(_("Machine account password change only supported on a DOMAIN_MEMBER.\n"
195 : "Do NOT use this function unless you know what it does!\n"
196 : "This function will change the ADS Domain member "
197 : "machine account password in the secrets.tdb file!\n"));
198 0 : return 1;
199 : }
200 :
201 0 : net_warn_member_options();
202 :
203 0 : if(c->opt_force) {
204 0 : struct secrets_domain_info1 *info = NULL;
205 0 : struct secrets_domain_info1_change *prev = NULL;
206 0 : NTSTATUS status;
207 0 : struct timeval tv = timeval_current();
208 0 : NTTIME now = timeval_to_nttime(&tv);
209 :
210 0 : if (c->opt_stdin) {
211 0 : set_line_buffering(stdin);
212 0 : set_line_buffering(stdout);
213 0 : set_line_buffering(stderr);
214 : }
215 :
216 0 : trust_pw = get_pass(_("Enter machine password: "), c->opt_stdin);
217 0 : if (trust_pw == NULL) {
218 0 : d_fprintf(stderr,
219 0 : _("Error in reading machine password\n"));
220 0 : return 1;
221 : }
222 :
223 0 : status = secrets_prepare_password_change(lp_workgroup(),
224 : "localhost",
225 : trust_pw,
226 : talloc_tos(),
227 : &info, &prev);
228 0 : if (!NT_STATUS_IS_OK(status)) {
229 0 : d_fprintf(stderr,
230 0 : _("Unable to write the machine account password in the secrets database"));
231 0 : return 1;
232 : }
233 0 : if (prev != NULL) {
234 0 : d_fprintf(stderr,
235 0 : _("Pending machine account password change found - aborting."));
236 0 : status = secrets_failed_password_change("localhost",
237 0 : NT_STATUS_REQUEST_NOT_ACCEPTED,
238 0 : NT_STATUS_NOT_COMMITTED,
239 : info);
240 0 : if (!NT_STATUS_IS_OK(status)) {
241 0 : d_fprintf(stderr,
242 0 : _("Failed to abort machine account password change"));
243 : }
244 0 : return 1;
245 : }
246 0 : status = secrets_finish_password_change("localhost", now, info);
247 0 : if (!NT_STATUS_IS_OK(status)) {
248 0 : d_fprintf(stderr,
249 0 : _("Unable to write the machine account password in the secrets database"));
250 0 : return 1;
251 : }
252 :
253 0 : d_printf(_("Modified trust account password in secrets database\n"));
254 : }
255 : else {
256 0 : d_printf(_("Machine account password change requires the -f flag.\n"
257 : "Do NOT use this function unless you know what it does!\n"
258 : "This function will change the ADS Domain member "
259 : "machine account password in the secrets.tdb file!\n"));
260 : }
261 :
262 0 : return 0;
263 : }
264 :
265 : /**
266 : * @brief Set the authorised user for winbindd access in secrets.tdb
267 : */
268 0 : static int net_setauthuser(struct net_context *c, int argc, const char **argv)
269 : {
270 0 : const char *password = NULL;
271 0 : bool ok;
272 :
273 0 : if (!secrets_init()) {
274 0 : d_fprintf(stderr, _("Failed to open secrets.tdb.\n"));
275 0 : return 1;
276 : }
277 :
278 : /* Delete the settings. */
279 0 : if (argc >= 1) {
280 0 : if (strncmp(argv[0], "delete", 6) != 0) {
281 0 : d_fprintf(stderr,_("Usage:\n"));
282 0 : d_fprintf(stderr,
283 0 : _(" net setauthuser -U user[%%password] \n"
284 : " Set the auth user account to user"
285 : "password. Prompt for password if not "
286 : "specified.\n"));
287 0 : d_fprintf(stderr,
288 0 : _(" net setauthuser delete\n"
289 : " Delete the auth user setting.\n"));
290 0 : return 1;
291 : }
292 0 : secrets_delete_entry(SECRETS_AUTH_USER);
293 0 : secrets_delete_entry(SECRETS_AUTH_DOMAIN);
294 0 : secrets_delete_entry(SECRETS_AUTH_PASSWORD);
295 0 : return 0;
296 : }
297 :
298 0 : if (!c->opt_user_specified) {
299 0 : d_fprintf(stderr, _("Usage:\n"));
300 0 : d_fprintf(stderr,
301 0 : _(" net setauthuser -U user[%%password]\n"
302 : " Set the auth user account to user"
303 : "password. Prompt for password if not "
304 : "specified.\n"));
305 0 : d_fprintf(stderr,
306 0 : _(" net setauthuser delete\n"
307 : " Delete the auth user setting.\n"));
308 0 : return 1;
309 : }
310 :
311 0 : password = net_prompt_pass(c, _("the auth user"));
312 0 : if (password == NULL) {
313 0 : d_fprintf(stderr,_("Failed to get the auth users password.\n"));
314 0 : return 1;
315 : }
316 :
317 0 : ok = secrets_store_creds(c->creds);
318 0 : if (!ok) {
319 0 : d_fprintf(stderr, _("Failed storing auth user credentials\n"));
320 0 : return 1;
321 : }
322 :
323 0 : return 0;
324 : }
325 :
326 : /**
327 : * @brief Get the auth user settings
328 : */
329 0 : static int net_getauthuser(struct net_context *c, int argc, const char **argv)
330 : {
331 0 : char *user, *domain, *password;
332 :
333 : /* Lift data from secrets file */
334 :
335 0 : secrets_fetch_ipc_userpass(&user, &domain, &password);
336 :
337 0 : if ((!user || !*user) && (!domain || !*domain ) &&
338 0 : (!password || !*password)){
339 :
340 0 : SAFE_FREE(user);
341 0 : SAFE_FREE(domain);
342 0 : BURN_FREE_STR(password);
343 0 : d_printf(_("No authorised user configured\n"));
344 0 : return 0;
345 : }
346 :
347 : /* Pretty print authorised user info */
348 :
349 0 : d_printf("%s%s%s%s%s\n", domain ? domain : "",
350 0 : domain ? lp_winbind_separator(): "", user,
351 0 : password ? "%" : "", password ? password : "");
352 :
353 0 : SAFE_FREE(user);
354 0 : SAFE_FREE(domain);
355 0 : BURN_FREE_STR(password);
356 :
357 0 : return 0;
358 : }
359 : /*
360 : Retrieve our local SID or the SID for the specified name
361 : */
362 3 : static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
363 : {
364 3 : struct dom_sid sid;
365 3 : const char *name;
366 3 : struct dom_sid_buf sid_str;
367 :
368 3 : if (argc >= 1) {
369 3 : name = argv[0];
370 : }
371 : else {
372 0 : name = lp_netbios_name();
373 : }
374 :
375 3 : if(!initialize_password_db(false, NULL)) {
376 0 : d_fprintf(stderr, _("WARNING: Could not open passdb\n"));
377 0 : return 1;
378 : }
379 :
380 : /* first check to see if we can even access secrets, so we don't
381 : panic when we can't. */
382 :
383 3 : if (!secrets_init()) {
384 0 : d_fprintf(stderr,
385 0 : _("Unable to open secrets.tdb. Can't fetch domain "
386 : "SID for name: %s\n"), name);
387 0 : return 1;
388 : }
389 :
390 : /* Generate one, if it doesn't exist */
391 3 : get_global_sam_sid();
392 :
393 3 : if (!secrets_fetch_domain_sid(name, &sid)) {
394 0 : DEBUG(0, ("Can't fetch domain SID for name: %s\n", name));
395 0 : return 1;
396 : }
397 3 : d_printf(_("SID for domain %s is: %s\n"),
398 : name,
399 : dom_sid_str_buf(&sid, &sid_str));
400 3 : return 0;
401 : }
402 :
403 45 : static int net_setlocalsid(struct net_context *c, int argc, const char **argv)
404 : {
405 0 : struct dom_sid sid;
406 :
407 45 : if ( (argc != 1)
408 45 : || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
409 45 : || (!string_to_sid(&sid, argv[0]))
410 45 : || (sid.num_auths != 4)) {
411 0 : d_printf(_("Usage:"));
412 0 : d_printf(" net setlocalsid S-1-5-21-x-y-z\n");
413 0 : return 1;
414 : }
415 :
416 45 : if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) {
417 0 : DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
418 0 : return 1;
419 : }
420 :
421 45 : return 0;
422 : }
423 :
424 0 : static int net_setdomainsid(struct net_context *c, int argc, const char **argv)
425 : {
426 0 : struct dom_sid sid;
427 :
428 0 : if ( (argc != 1)
429 0 : || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
430 0 : || (!string_to_sid(&sid, argv[0]))
431 0 : || (sid.num_auths != 4)) {
432 0 : d_printf(_("Usage:"));
433 0 : d_printf(" net setdomainsid S-1-5-21-x-y-z\n");
434 0 : return 1;
435 : }
436 :
437 0 : if (!secrets_store_domain_sid(lp_workgroup(), &sid)) {
438 0 : DEBUG(0,("Can't store domain SID.\n"));
439 0 : return 1;
440 : }
441 :
442 0 : return 0;
443 : }
444 :
445 8 : static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
446 : {
447 2 : struct dom_sid domain_sid;
448 2 : struct dom_sid_buf sid_str;
449 :
450 8 : if (argc > 0) {
451 0 : d_printf(_("Usage:"));
452 0 : d_printf(" net getdomainsid\n");
453 0 : return 1;
454 : }
455 :
456 8 : if(!initialize_password_db(false, NULL)) {
457 0 : d_fprintf(stderr, _("WARNING: Could not open passdb\n"));
458 0 : return 1;
459 : }
460 :
461 : /* first check to see if we can even access secrets, so we don't
462 : panic when we can't. */
463 :
464 8 : if (!secrets_init()) {
465 0 : d_fprintf(stderr, _("Unable to open secrets.tdb. Can't fetch "
466 : "domain SID for name: %s\n"),
467 : get_global_sam_name());
468 0 : return 1;
469 : }
470 :
471 : /* Generate one, if it doesn't exist */
472 8 : get_global_sam_sid();
473 :
474 8 : if (!IS_DC) {
475 6 : if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) {
476 0 : d_fprintf(stderr, _("Could not fetch local SID\n"));
477 0 : return 1;
478 : }
479 6 : d_printf(_("SID for local machine %s is: %s\n"),
480 : lp_netbios_name(),
481 : dom_sid_str_buf(&domain_sid, &sid_str));
482 : }
483 8 : if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) {
484 0 : d_fprintf(stderr, _("Could not fetch domain SID\n"));
485 0 : return 1;
486 : }
487 :
488 8 : d_printf(_("SID for domain %s is: %s\n"),
489 : c->opt_workgroup,
490 : dom_sid_str_buf(&domain_sid, &sid_str));
491 :
492 8 : return 0;
493 : }
494 :
495 0 : static bool search_maxrid(struct pdb_search *search, const char *type,
496 : uint32_t *max_rid)
497 : {
498 0 : struct samr_displayentry *entries;
499 0 : uint32_t i, num_entries;
500 :
501 0 : if (search == NULL) {
502 0 : d_fprintf(stderr, _("get_maxrid: Could not search %s\n"), type);
503 0 : return false;
504 : }
505 :
506 0 : num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries);
507 0 : for (i=0; i<num_entries; i++)
508 0 : *max_rid = MAX(*max_rid, entries[i].rid);
509 0 : TALLOC_FREE(search);
510 0 : return true;
511 : }
512 :
513 0 : static uint32_t get_maxrid(void)
514 : {
515 0 : uint32_t max_rid = 0;
516 :
517 0 : if (!search_maxrid(pdb_search_users(talloc_tos(), 0), "users", &max_rid))
518 0 : return 0;
519 :
520 0 : if (!search_maxrid(pdb_search_groups(talloc_tos()), "groups", &max_rid))
521 0 : return 0;
522 :
523 0 : if (!search_maxrid(pdb_search_aliases(talloc_tos(),
524 0 : get_global_sam_sid()),
525 : "aliases", &max_rid))
526 0 : return 0;
527 :
528 0 : return max_rid;
529 : }
530 :
531 0 : static int net_maxrid(struct net_context *c, int argc, const char **argv)
532 : {
533 0 : uint32_t rid;
534 :
535 0 : if (argc != 0) {
536 0 : d_fprintf(stderr, "%s net maxrid\n", _("Usage:"));
537 0 : return 1;
538 : }
539 :
540 0 : if ((rid = get_maxrid()) == 0) {
541 0 : d_fprintf(stderr, _("can't get current maximum rid\n"));
542 0 : return 1;
543 : }
544 :
545 0 : d_printf(_("Currently used maximum rid: %d\n"), rid);
546 :
547 0 : return 0;
548 : }
549 :
550 : /* main function table */
551 : static struct functable net_func[] = {
552 : {
553 : "rpc",
554 : net_rpc,
555 : NET_TRANSPORT_RPC,
556 : N_("Run functions using RPC transport"),
557 : N_(" Use 'net help rpc' to get more extensive information "
558 : "about 'net rpc' commands.")
559 : },
560 : {
561 : "rap",
562 : net_rap,
563 : NET_TRANSPORT_RAP,
564 : N_("Run functions using RAP transport"),
565 : N_(" Use 'net help rap' to get more extensive information "
566 : "about 'net rap' commands.")
567 : },
568 : {
569 : "ads",
570 : net_ads,
571 : NET_TRANSPORT_ADS,
572 : N_("Run functions using ADS transport"),
573 : N_(" Use 'net help ads' to get more extensive information "
574 : "about 'net ads' commands.")
575 : },
576 :
577 : /* eventually these should auto-choose the transport ... */
578 : {
579 : "file",
580 : net_file,
581 : NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
582 : N_("Functions on remote opened files"),
583 : N_(" Use 'net help file' to get more information about 'net "
584 : "file' commands.")
585 : },
586 : {
587 : "share",
588 : net_share,
589 : NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
590 : N_("Functions on shares"),
591 : N_(" Use 'net help share' to get more information about 'net "
592 : "share' commands.")
593 : },
594 : {
595 : "session",
596 : net_rap_session,
597 : NET_TRANSPORT_RAP,
598 : N_("Manage sessions"),
599 : N_(" Use 'net help session' to get more information about "
600 : "'net session' commands.")
601 : },
602 : {
603 : "server",
604 : net_rap_server,
605 : NET_TRANSPORT_RAP,
606 : N_("List servers in workgroup"),
607 : N_(" Use 'net help server' to get more information about 'net "
608 : "server' commands.")
609 : },
610 : {
611 : "domain",
612 : net_rap_domain,
613 : NET_TRANSPORT_RAP,
614 : N_("List domains/workgroups on network"),
615 : N_(" Use 'net help domain' to get more information about 'net "
616 : "domain' commands.")
617 : },
618 : {
619 : "printq",
620 : net_rap_printq,
621 : NET_TRANSPORT_RAP,
622 : N_("Modify printer queue"),
623 : N_(" Use 'net help printq' to get more information about 'net "
624 : "printq' commands.")
625 : },
626 : {
627 : "user",
628 : net_user,
629 : NET_TRANSPORT_ADS | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
630 : N_("Manage users"),
631 : N_(" Use 'net help user' to get more information about 'net "
632 : "user' commands.")
633 : },
634 : {
635 : "group",
636 : net_group,
637 : NET_TRANSPORT_ADS | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
638 : N_("Manage groups"),
639 : N_(" Use 'net help group' to get more information about 'net "
640 : "group' commands.")
641 : },
642 : {
643 : "groupmap",
644 : net_groupmap,
645 : NET_TRANSPORT_LOCAL,
646 : N_("Manage group mappings"),
647 : N_(" Use 'net help groupmap' to get more information about "
648 : "'net groupmap' commands.")
649 : },
650 : {
651 : "sam",
652 : net_sam,
653 : NET_TRANSPORT_LOCAL,
654 : N_("Functions on the SAM database"),
655 : N_(" Use 'net help sam' to get more information about 'net "
656 : "sam' commands.")
657 : },
658 : {
659 : "validate",
660 : net_rap_validate,
661 : NET_TRANSPORT_RAP,
662 : N_("Validate username and password"),
663 : N_(" Use 'net help validate' to get more information about "
664 : "'net validate' commands.")
665 : },
666 : {
667 : "groupmember",
668 : net_rap_groupmember,
669 : NET_TRANSPORT_RAP,
670 : N_("Modify group memberships"),
671 : N_(" Use 'net help groupmember' to get more information about "
672 : "'net groupmember' commands.")
673 : },
674 : { "admin",
675 : net_rap_admin,
676 : NET_TRANSPORT_RAP,
677 : N_("Execute remote command on a remote OS/2 server"),
678 : N_(" Use 'net help admin' to get more information about 'net "
679 : "admin' commands.")
680 : },
681 : { "service",
682 : net_rap_service,
683 : NET_TRANSPORT_RAP,
684 : N_("List/modify running services"),
685 : N_(" Use 'net help service' to get more information about "
686 : "'net service' commands.")
687 : },
688 : {
689 : "password",
690 : net_rap_password,
691 : NET_TRANSPORT_RAP,
692 : N_("Change user password on target server"),
693 : N_(" Use 'net help password' to get more information about "
694 : "'net password' commands.")
695 : },
696 : {
697 : "primarytrust",
698 : net_primarytrust,
699 : NET_TRANSPORT_RPC,
700 : N_("Run functions related to the primary workstation trust."),
701 : N_(" Use 'net help primarytrust' to get more extensive information "
702 : "about 'net primarytrust' commands.")
703 : },
704 : { "changetrustpw",
705 : net_changetrustpw,
706 : NET_TRANSPORT_ADS | NET_TRANSPORT_RPC,
707 : N_("Change the trust password"),
708 : N_(" Use 'net help changetrustpw' to get more information "
709 : "about 'net changetrustpw'.")
710 : },
711 : { "changesecretpw",
712 : net_changesecretpw,
713 : NET_TRANSPORT_LOCAL,
714 : N_("Change the secret password"),
715 : N_(" net [options] changesecretpw\n"
716 : " Change the ADS domain member machine account password "
717 : "in secrets.tdb.\n"
718 : " Do NOT use this function unless you know what it does.\n"
719 : " Requires the -f flag to work.")
720 : },
721 : {
722 : "setauthuser",
723 : net_setauthuser,
724 : NET_TRANSPORT_LOCAL,
725 : N_("Set the winbind auth user"),
726 : N_(" net -U user[%%password] [-W domain] setauthuser\n"
727 : " Set the auth user, password (and optionally domain\n"
728 : " Will prompt for password if not given.\n"
729 : " net setauthuser delete\n"
730 : " Delete the existing auth user settings.")
731 : },
732 : {
733 : "getauthuser",
734 : net_getauthuser,
735 : NET_TRANSPORT_LOCAL,
736 : N_("Get the winbind auth user settings"),
737 : N_(" net getauthuser\n"
738 : " Get the current winbind auth user settings.")
739 : },
740 : { "time",
741 : net_time,
742 : NET_TRANSPORT_LOCAL,
743 : N_("Show/set time"),
744 : N_(" Use 'net help time' to get more information about 'net "
745 : "time' commands.")
746 : },
747 : { "lookup",
748 : net_lookup,
749 : NET_TRANSPORT_LOCAL,
750 : N_("Look up host names/IP addresses"),
751 : N_(" Use 'net help lookup' to get more information about 'net "
752 : "lookup' commands.")
753 : },
754 : { "g_lock",
755 : net_g_lock,
756 : NET_TRANSPORT_LOCAL,
757 : N_("Manipulate the global lock table"),
758 : N_(" Use 'net help g_lock' to get more information about "
759 : "'net g_lock' commands.")
760 : },
761 : { "join",
762 : net_join,
763 : NET_TRANSPORT_ADS | NET_TRANSPORT_RPC,
764 : N_("Join a domain/AD"),
765 : N_(" Use 'net help join' to get more information about 'net "
766 : "join'.")
767 : },
768 : { "offlinejoin",
769 : net_offlinejoin,
770 : NET_TRANSPORT_ADS | NET_TRANSPORT_RPC,
771 : N_("Perform offline domain join"),
772 : N_(" Use 'net help offlinejoin' to get more information about 'net "
773 : "offlinejoin'.")
774 : },
775 : { "dom",
776 : net_dom,
777 : NET_TRANSPORT_LOCAL,
778 : N_("Join/unjoin (remote) machines to/from a domain/AD"),
779 : N_(" Use 'net help dom' to get more information about 'net "
780 : "dom' commands.")
781 : },
782 : { "cache",
783 : net_cache,
784 : NET_TRANSPORT_LOCAL,
785 : N_("Operate on the cache tdb file"),
786 : N_(" Use 'net help cache' to get more information about 'net "
787 : "cache' commands.")
788 : },
789 : { "getlocalsid",
790 : net_getlocalsid,
791 : NET_TRANSPORT_LOCAL,
792 : N_("Get the SID for the local domain"),
793 : N_(" net getlocalsid")
794 : },
795 : { "setlocalsid",
796 : net_setlocalsid,
797 : NET_TRANSPORT_LOCAL,
798 : N_("Set the SID for the local domain"),
799 : N_(" net setlocalsid S-1-5-21-x-y-z")
800 : },
801 : { "setdomainsid",
802 : net_setdomainsid,
803 : NET_TRANSPORT_LOCAL,
804 : N_("Set domain SID on member servers"),
805 : N_(" net setdomainsid S-1-5-21-x-y-z")
806 : },
807 : { "getdomainsid",
808 : net_getdomainsid,
809 : NET_TRANSPORT_LOCAL,
810 : N_("Get domain SID on member servers"),
811 : N_(" net getdomainsid")
812 : },
813 : { "maxrid",
814 : net_maxrid,
815 : NET_TRANSPORT_LOCAL,
816 : N_("Display the maximum RID currently used"),
817 : N_(" net maxrid")
818 : },
819 : { "idmap",
820 : net_idmap,
821 : NET_TRANSPORT_LOCAL,
822 : N_("IDmap functions"),
823 : N_(" Use 'net help idmap to get more information about 'net "
824 : "idmap' commands.")
825 : },
826 : { "status",
827 : net_status,
828 : NET_TRANSPORT_LOCAL,
829 : N_("Display server status"),
830 : N_(" Use 'net help status' to get more information about 'net "
831 : "status' commands.")
832 : },
833 : { "usershare",
834 : net_usershare,
835 : NET_TRANSPORT_LOCAL,
836 : N_("Manage user-modifiable shares"),
837 : N_(" Use 'net help usershare to get more information about "
838 : "'net usershare' commands.")
839 : },
840 : { "usersidlist",
841 : net_usersidlist,
842 : NET_TRANSPORT_RPC,
843 : N_("Display list of all users with SID"),
844 : N_(" Use 'net help usersidlist' to get more information about "
845 : "'net usersidlist'.")
846 : },
847 : { "conf",
848 : net_conf,
849 : NET_TRANSPORT_LOCAL,
850 : N_("Manage Samba registry based configuration"),
851 : N_(" Use 'net help conf' to get more information about 'net "
852 : "conf' commands.")
853 : },
854 : { "registry",
855 : net_registry,
856 : NET_TRANSPORT_LOCAL,
857 : N_("Manage the Samba registry"),
858 : N_(" Use 'net help registry' to get more information about "
859 : "'net registry' commands.")
860 : },
861 : { "eventlog",
862 : net_eventlog,
863 : NET_TRANSPORT_LOCAL,
864 : N_("Process Win32 *.evt eventlog files"),
865 : N_(" Use 'net help eventlog' to get more information about "
866 : "'net eventlog' commands.")
867 : },
868 : { "printing",
869 : net_printing,
870 : NET_TRANSPORT_LOCAL,
871 : N_("Process tdb printer files"),
872 : N_(" Use 'net help printing' to get more information about "
873 : "'net printing' commands.")
874 : },
875 :
876 : { "serverid",
877 : net_serverid,
878 : NET_TRANSPORT_LOCAL,
879 : N_("Manage the serverid tdb"),
880 : N_(" Use 'net help serverid' to get more information about "
881 : "'net serverid' commands.")
882 : },
883 :
884 : { "notify",
885 : net_notify,
886 : NET_TRANSPORT_LOCAL,
887 : N_("notifyd client code"),
888 : N_(" Use 'net help notify' to get more information about "
889 : "'net notify' commands.")
890 : },
891 :
892 : { "tdb",
893 : net_tdb,
894 : NET_TRANSPORT_LOCAL,
895 : N_("Show information from tdb records"),
896 : N_(" Use 'net help tdb' to get more information about "
897 : "'net tdb' commands.")
898 : },
899 :
900 : { "vfs",
901 : net_vfs,
902 : NET_TRANSPORT_LOCAL,
903 : N_("Filesystem operation through the VFS stack"),
904 : N_(" Use 'net help vfs' to get more information about "
905 : "'net vfs' commands.")
906 : },
907 :
908 : #ifdef WITH_FAKE_KASERVER
909 : { "afs",
910 : net_afs,
911 : NET_TRANSPORT_LOCAL,
912 : N_("Manage AFS tokens"),
913 : N_(" Use 'net help afs' to get more information about 'net "
914 : "afs' commands.")
915 : },
916 : #endif
917 :
918 : { "help",
919 : net_help,
920 : NET_TRANSPORT_LOCAL,
921 : N_("Print usage information"),
922 : N_(" Use 'net help help' to list usage information for 'net' "
923 : "commands.")
924 : },
925 : {NULL, NULL, 0, NULL, NULL}
926 : };
927 :
928 :
929 : /****************************************************************************
930 : main program
931 : ****************************************************************************/
932 3393 : int main(int argc, char **argv)
933 : {
934 5 : int opt,i;
935 3393 : int rc = 0;
936 3393 : int argc_new = 0;
937 5 : const char ** argv_new;
938 3393 : const char **argv_const = discard_const_p(const char *, argv);
939 5 : poptContext pc;
940 3393 : TALLOC_CTX *frame = talloc_stackframe();
941 3393 : struct net_context *c = talloc_zero(frame, struct net_context);
942 5 : bool ok;
943 :
944 20358 : struct poptOption long_options[] = {
945 : {
946 : .longName = "help",
947 : .shortName = 'h',
948 : .argInfo = POPT_ARG_NONE,
949 : .val = 'h',
950 : },
951 : {
952 : .longName = "target-workgroup",
953 : .shortName = 'w',
954 : .argInfo = POPT_ARG_STRING,
955 3393 : .arg = &c->opt_target_workgroup,
956 : },
957 : {
958 : .longName = "ipaddress",
959 : .shortName = 'I',
960 : .argInfo = POPT_ARG_STRING,
961 : .arg = 0,
962 : .val = 'I',
963 : },
964 : {
965 : .longName = "port",
966 : .shortName = 'p',
967 : .argInfo = POPT_ARG_INT,
968 3393 : .arg = &c->opt_port,
969 : },
970 : {
971 : .longName = "myname",
972 : .shortName = 0,
973 : .argInfo = POPT_ARG_STRING,
974 3393 : .arg = &c->opt_requester_name,
975 : },
976 : {
977 : .longName = "server",
978 : .shortName = 'S',
979 : .argInfo = POPT_ARG_STRING,
980 3393 : .arg = &c->opt_host,
981 : },
982 : {
983 : .longName = "container",
984 : .shortName = 'c',
985 : .argInfo = POPT_ARG_STRING,
986 3393 : .arg = &c->opt_container,
987 : },
988 : {
989 : .longName = "comment",
990 : .shortName = 'C',
991 : .argInfo = POPT_ARG_STRING,
992 3393 : .arg = &c->opt_comment,
993 : },
994 : {
995 : .longName = "maxusers",
996 : .shortName = 'M',
997 : .argInfo = POPT_ARG_INT,
998 3393 : .arg = &c->opt_maxusers,
999 : },
1000 : {
1001 : .longName = "flags",
1002 : .shortName = 'F',
1003 : .argInfo = POPT_ARG_INT,
1004 3393 : .arg = &c->opt_flags,
1005 : },
1006 : {
1007 : .longName = "long",
1008 : .argInfo = POPT_ARG_NONE,
1009 3393 : .arg = &c->opt_long_list_entries,
1010 : },
1011 : {
1012 : .longName = "reboot",
1013 : .shortName = 'r',
1014 : .argInfo = POPT_ARG_NONE,
1015 3393 : .arg = &c->opt_reboot,
1016 : },
1017 : {
1018 : .longName = "force",
1019 : .shortName = 'f',
1020 : .argInfo = POPT_ARG_NONE,
1021 3393 : .arg = &c->opt_force,
1022 : },
1023 : {
1024 : .longName = "stdin",
1025 : .shortName = 'i',
1026 : .argInfo = POPT_ARG_NONE,
1027 3393 : .arg = &c->opt_stdin,
1028 : },
1029 : {
1030 : .longName = "timeout",
1031 : .shortName = 't',
1032 : .argInfo = POPT_ARG_INT,
1033 3393 : .arg = &c->opt_timeout,
1034 : },
1035 : {
1036 : .longName = "request-timeout",
1037 : .shortName = 0,
1038 : .argInfo = POPT_ARG_INT,
1039 3393 : .arg = &c->opt_request_timeout,
1040 : },
1041 : {
1042 : .longName = "use-ccache",
1043 : .shortName = 0,
1044 : .argInfo = POPT_ARG_NONE,
1045 3393 : .arg = &c->opt_ccache,
1046 : },
1047 : {
1048 : .longName = "verbose",
1049 : .shortName = 'v',
1050 : .argInfo = POPT_ARG_NONE,
1051 3393 : .arg = &c->opt_verbose,
1052 : },
1053 : {
1054 : .longName = "test",
1055 : .shortName = 'T',
1056 : .argInfo = POPT_ARG_NONE,
1057 3393 : .arg = &c->opt_testmode,
1058 : },
1059 : /* Options for 'net groupmap set' */
1060 : {
1061 : .longName = "local",
1062 : .shortName = 'L',
1063 : .argInfo = POPT_ARG_NONE,
1064 3393 : .arg = &c->opt_localgroup,
1065 : },
1066 : {
1067 : .longName = "domain",
1068 : .shortName = 'D',
1069 : .argInfo = POPT_ARG_NONE,
1070 3393 : .arg = &c->opt_domaingroup,
1071 : },
1072 : {
1073 : .longName = "ntname",
1074 : .shortName = 0,
1075 : .argInfo = POPT_ARG_STRING,
1076 3393 : .arg = &c->opt_newntname,
1077 : },
1078 : {
1079 : .longName = "rid",
1080 : .shortName = 0,
1081 : .argInfo = POPT_ARG_INT,
1082 3393 : .arg = &c->opt_rid,
1083 : },
1084 : /* Options for 'net rpc share migrate' */
1085 : {
1086 : .longName = "acls",
1087 : .shortName = 0,
1088 : .argInfo = POPT_ARG_NONE,
1089 3393 : .arg = &c->opt_acls,
1090 : },
1091 : {
1092 : .longName = "attrs",
1093 : .shortName = 0,
1094 : .argInfo = POPT_ARG_NONE,
1095 3393 : .arg = &c->opt_attrs,
1096 : },
1097 : {
1098 : .longName = "timestamps",
1099 : .shortName = 0,
1100 : .argInfo = POPT_ARG_NONE,
1101 3393 : .arg = &c->opt_timestamps,
1102 : },
1103 : {
1104 : .longName = "exclude",
1105 : .shortName = 'X',
1106 : .argInfo = POPT_ARG_STRING,
1107 3393 : .arg = &c->opt_exclude,
1108 : },
1109 : {
1110 : .longName = "destination",
1111 : .shortName = 0,
1112 : .argInfo = POPT_ARG_STRING,
1113 3393 : .arg = &c->opt_destination,
1114 : },
1115 : {
1116 : .longName = "tallocreport",
1117 : .shortName = 0,
1118 : .argInfo = POPT_ARG_NONE,
1119 3393 : .arg = &c->do_talloc_report,
1120 : },
1121 : /* Options for 'net rpc vampire (keytab)' */
1122 : {
1123 : .longName = "force-full-repl",
1124 : .shortName = 0,
1125 : .argInfo = POPT_ARG_NONE,
1126 3393 : .arg = &c->opt_force_full_repl,
1127 : },
1128 : {
1129 : .longName = "single-obj-repl",
1130 : .shortName = 0,
1131 : .argInfo = POPT_ARG_NONE,
1132 3393 : .arg = &c->opt_single_obj_repl,
1133 : },
1134 : {
1135 : .longName = "clean-old-entries",
1136 : .shortName = 0,
1137 : .argInfo = POPT_ARG_NONE,
1138 3393 : .arg = &c->opt_clean_old_entries,
1139 : },
1140 : /* Options for 'net idmap'*/
1141 : {
1142 : .longName = "db",
1143 : .shortName = 0,
1144 : .argInfo = POPT_ARG_STRING,
1145 3393 : .arg = &c->opt_db,
1146 : },
1147 : {
1148 : .longName = "lock",
1149 : .shortName = 0,
1150 : .argInfo = POPT_ARG_NONE,
1151 3393 : .arg = &c->opt_lock,
1152 : },
1153 : {
1154 : .longName = "auto",
1155 : .shortName = 'a',
1156 : .argInfo = POPT_ARG_NONE,
1157 3393 : .arg = &c->opt_auto,
1158 : },
1159 : {
1160 : .longName = "repair",
1161 : .shortName = 0,
1162 : .argInfo = POPT_ARG_NONE,
1163 3393 : .arg = &c->opt_repair,
1164 : },
1165 : /* Options for 'net registry check'*/
1166 : {
1167 : .longName = "reg-version",
1168 : .shortName = 0,
1169 : .argInfo = POPT_ARG_INT,
1170 3393 : .arg = &c->opt_reg_version,
1171 : },
1172 : {
1173 : .longName = "output",
1174 : .shortName = 'o',
1175 : .argInfo = POPT_ARG_STRING,
1176 3393 : .arg = &c->opt_output,
1177 : },
1178 : {
1179 : .longName = "wipe",
1180 : .shortName = 0,
1181 : .argInfo = POPT_ARG_NONE,
1182 3393 : .arg = &c->opt_wipe,
1183 : },
1184 : /* Options for 'net registry import' */
1185 : {
1186 : .longName = "precheck",
1187 : .shortName = 0,
1188 : .argInfo = POPT_ARG_STRING,
1189 3393 : .arg = &c->opt_precheck,
1190 : },
1191 : /* Options for 'net ads join or leave' */
1192 : {
1193 : .longName = "no-dns-updates",
1194 : .shortName = 0,
1195 : .argInfo = POPT_ARG_NONE,
1196 3393 : .arg = &c->opt_no_dns_updates,
1197 : },
1198 : {
1199 : .longName = "keep-account",
1200 : .shortName = 0,
1201 : .argInfo = POPT_ARG_NONE,
1202 3393 : .arg = &c->opt_keep_account,
1203 : },
1204 : {
1205 : .longName = "json",
1206 : .shortName = 0,
1207 : .argInfo = POPT_ARG_NONE,
1208 3393 : .arg = &c->opt_json,
1209 : },
1210 : /* Options for 'net vfs' */
1211 : {
1212 : .longName = "continue",
1213 : .argInfo = POPT_ARG_NONE,
1214 3393 : .arg = &c->opt_continue_on_error,
1215 : .descrip = "Continue on errors",
1216 : },
1217 : {
1218 : .longName = "recursive",
1219 : .argInfo = POPT_ARG_NONE,
1220 3393 : .arg = &c->opt_recursive,
1221 : .descrip = "Traverse directory hierarchy",
1222 : },
1223 : {
1224 : .longName = "follow-symlinks",
1225 : .argInfo = POPT_ARG_NONE,
1226 3393 : .arg = &c->opt_follow_symlink,
1227 : .descrip = "follow symlinks",
1228 : },
1229 : /* Options for 'net ads dns register' */
1230 : {
1231 : .longName = "dns-ttl",
1232 : .argInfo = POPT_ARG_INT,
1233 3393 : .arg = &c->opt_dns_ttl,
1234 : .descrip = "TTL in seconds of DNS records",
1235 : },
1236 3393 : POPT_COMMON_SAMBA
1237 3393 : POPT_COMMON_CONNECTION
1238 3393 : POPT_COMMON_CREDENTIALS
1239 3393 : POPT_COMMON_VERSION
1240 3393 : POPT_LEGACY_S3
1241 : POPT_TABLEEND
1242 : };
1243 :
1244 : /* Ignore possible SIGPIPE upon ldap_unbind when over TLS */
1245 3393 : BlockSignals(True, SIGPIPE);
1246 :
1247 3393 : zero_sockaddr(&c->opt_dest_ip);
1248 :
1249 3393 : smb_init_locale();
1250 :
1251 3393 : setlocale(LC_ALL, "");
1252 : #if defined(HAVE_BINDTEXTDOMAIN)
1253 3393 : bindtextdomain(MODULE_NAME, get_dyn_LOCALEDIR());
1254 : #endif
1255 : #if defined(HAVE_TEXTDOMAIN)
1256 3393 : textdomain(MODULE_NAME);
1257 : #endif
1258 :
1259 3393 : ok = samba_cmdline_init(frame,
1260 : SAMBA_CMDLINE_CONFIG_CLIENT,
1261 : false /* require_smbconf */);
1262 3393 : if (!ok) {
1263 0 : DBG_ERR("Failed to init cmdline parser!\n");
1264 0 : TALLOC_FREE(frame);
1265 0 : exit(1);
1266 : }
1267 3393 : c->lp_ctx = samba_cmdline_get_lp_ctx();
1268 : /* set default debug level to 0 regardless of what smb.conf sets */
1269 3393 : lpcfg_set_cmdline(c->lp_ctx, "log level", "0");
1270 3393 : c->private_data = net_func;
1271 :
1272 3393 : pc = samba_popt_get_context(getprogname(),
1273 : argc,
1274 : argv_const,
1275 : long_options,
1276 : POPT_CONTEXT_KEEP_FIRST);
1277 3393 : if (pc == NULL) {
1278 0 : DBG_ERR("Failed to setup popt context!\n");
1279 0 : TALLOC_FREE(frame);
1280 0 : exit(1);
1281 : }
1282 :
1283 4097 : while((opt = poptGetNextOpt(pc)) != -1) {
1284 704 : switch (opt) {
1285 0 : case 'h':
1286 0 : c->display_usage = true;
1287 0 : break;
1288 704 : case 'I':
1289 704 : if (!interpret_string_addr(&c->opt_dest_ip,
1290 704 : poptGetOptArg(pc), 0)) {
1291 0 : d_fprintf(stderr, _("\nInvalid ip address specified\n"));
1292 : } else {
1293 704 : c->opt_have_ip = true;
1294 : }
1295 704 : break;
1296 0 : default:
1297 0 : d_fprintf(stderr, _("\nInvalid option %s: %s\n"),
1298 : poptBadOption(pc, 0), poptStrerror(opt));
1299 0 : net_help(c, argc, argv_const);
1300 0 : exit(1);
1301 : }
1302 : }
1303 :
1304 3389 : c->creds = samba_cmdline_get_creds();
1305 :
1306 : {
1307 3389 : enum credentials_obtained username_obtained =
1308 : CRED_UNINITIALISED;
1309 5 : enum smb_encryption_setting encrypt_state =
1310 3389 : cli_credentials_get_smb_encryption(c->creds);
1311 5 : enum credentials_use_kerberos krb5_state =
1312 3389 : cli_credentials_get_kerberos_state(c->creds);
1313 5 : uint32_t gensec_features;
1314 :
1315 3389 : c->opt_user_name = cli_credentials_get_username_and_obtained(
1316 : c->creds,
1317 : &username_obtained);
1318 3389 : c->opt_user_specified = (username_obtained == CRED_SPECIFIED);
1319 :
1320 3389 : c->opt_workgroup = cli_credentials_get_domain(c->creds);
1321 :
1322 3389 : c->smb_encrypt = (encrypt_state == SMB_ENCRYPTION_REQUIRED);
1323 :
1324 3389 : c->opt_kerberos = (krb5_state > CRED_USE_KERBEROS_DESIRED);
1325 :
1326 3389 : gensec_features = cli_credentials_get_gensec_features(c->creds);
1327 3389 : c->opt_ccache = (gensec_features & GENSEC_FEATURE_NTLM_CCACHE);
1328 : }
1329 :
1330 3389 : c->msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());
1331 :
1332 : #if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
1333 : /* Bind our gettext results to 'unix charset'
1334 :
1335 : This ensures that the translations and any embedded strings are in the
1336 : same charset. It won't be the one from the user's locale (we no
1337 : longer auto-detect that), but it will be self-consistent.
1338 : */
1339 3389 : bind_textdomain_codeset(MODULE_NAME, lp_unix_charset());
1340 : #endif
1341 :
1342 3389 : argv_new = (const char **)poptGetArgs(pc);
1343 :
1344 3389 : argc_new = argc;
1345 20106 : for (i=0; i<argc; i++) {
1346 19188 : if (argv_new[i] == NULL) {
1347 2471 : argc_new = i;
1348 2471 : break;
1349 : }
1350 : }
1351 :
1352 3389 : if (c->do_talloc_report) {
1353 0 : talloc_enable_leak_report();
1354 : }
1355 :
1356 3389 : if (c->opt_requester_name) {
1357 0 : lpcfg_set_cmdline(c->lp_ctx, "netbios name", c->opt_requester_name);
1358 : }
1359 :
1360 3389 : if (!c->opt_target_workgroup) {
1361 3389 : c->opt_target_workgroup = talloc_strdup(c, lp_workgroup());
1362 : }
1363 :
1364 3389 : load_interfaces();
1365 :
1366 : /* this makes sure that when we do things like call scripts,
1367 : that it won't assert because we are not root */
1368 3389 : sec_init();
1369 :
1370 3389 : samba_cmdline_burn(argc, argv);
1371 :
1372 3389 : rc = net_run_function(c, argc_new-1, argv_new+1, "net", net_func);
1373 :
1374 3389 : DEBUG(2,("return code = %d\n", rc));
1375 :
1376 3389 : libnetapi_free(c->netapi_ctx);
1377 :
1378 3389 : poptFreeContext(pc);
1379 :
1380 3389 : cmdline_messaging_context_free();
1381 :
1382 3389 : gfree_all();
1383 :
1384 3389 : TALLOC_FREE(frame);
1385 3389 : return rc;
1386 : }
|