| 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 "utils/net.h"
|
|---|
| 45 |
|
|---|
| 46 | extern bool AllowDebugChange;
|
|---|
| 47 |
|
|---|
| 48 | #ifdef WITH_FAKE_KASERVER
|
|---|
| 49 | #include "utils/net_afs.h"
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | /***********************************************************************/
|
|---|
| 53 | /* end of internationalization section */
|
|---|
| 54 | /***********************************************************************/
|
|---|
| 55 |
|
|---|
| 56 | enum netr_SchannelType get_sec_channel_type(const char *param)
|
|---|
| 57 | {
|
|---|
| 58 | if (!(param && *param)) {
|
|---|
| 59 | return get_default_sec_channel();
|
|---|
| 60 | } else {
|
|---|
| 61 | if (strequal(param, "PDC")) {
|
|---|
| 62 | return SEC_CHAN_BDC;
|
|---|
| 63 | } else if (strequal(param, "BDC")) {
|
|---|
| 64 | return SEC_CHAN_BDC;
|
|---|
| 65 | } else if (strequal(param, "MEMBER")) {
|
|---|
| 66 | return SEC_CHAN_WKSTA;
|
|---|
| 67 | #if 0
|
|---|
| 68 | } else if (strequal(param, "DOMAIN")) {
|
|---|
| 69 | return SEC_CHAN_DOMAIN;
|
|---|
| 70 | #endif
|
|---|
| 71 | } else {
|
|---|
| 72 | return get_default_sec_channel();
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | static int net_changetrustpw(struct net_context *c, int argc, const char **argv)
|
|---|
| 78 | {
|
|---|
| 79 | if (net_ads_check_our_domain(c) == 0)
|
|---|
| 80 | return net_ads_changetrustpw(c, argc, argv);
|
|---|
| 81 |
|
|---|
| 82 | return net_rpc_changetrustpw(c, argc, argv);
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | static void set_line_buffering(FILE *f)
|
|---|
| 86 | {
|
|---|
| 87 | setvbuf(f, NULL, _IOLBF, 0);
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | static int net_changesecretpw(struct net_context *c, int argc,
|
|---|
| 91 | const char **argv)
|
|---|
| 92 | {
|
|---|
| 93 | char *trust_pw;
|
|---|
| 94 | enum netr_SchannelType sec_channel_type = SEC_CHAN_WKSTA;
|
|---|
| 95 |
|
|---|
| 96 | if(c->opt_force) {
|
|---|
| 97 | if (c->opt_stdin) {
|
|---|
| 98 | set_line_buffering(stdin);
|
|---|
| 99 | set_line_buffering(stdout);
|
|---|
| 100 | set_line_buffering(stderr);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | trust_pw = get_pass(_("Enter machine password: "), c->opt_stdin);
|
|---|
| 104 |
|
|---|
| 105 | if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) {
|
|---|
| 106 | d_fprintf(stderr,
|
|---|
| 107 | _("Unable to write the machine account password in the secrets database"));
|
|---|
| 108 | return 1;
|
|---|
| 109 | }
|
|---|
| 110 | else {
|
|---|
| 111 | d_printf(_("Modified trust account password in secrets database\n"));
|
|---|
| 112 | }
|
|---|
| 113 | }
|
|---|
| 114 | else {
|
|---|
| 115 | d_printf(_("Machine account password change requires the -f flag.\n"
|
|---|
| 116 | "Do NOT use this function unless you know what it does!\n"
|
|---|
| 117 | "This function will change the ADS Domain member "
|
|---|
| 118 | "machine account password in the secrets.tdb file!\n"));
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | return 0;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | /**
|
|---|
| 125 | * @brief Set the authorised user for winbindd access in secrets.tdb
|
|---|
| 126 | */
|
|---|
| 127 | static int net_setauthuser(struct net_context *c, int argc, const char **argv)
|
|---|
| 128 | {
|
|---|
| 129 | const char *password = NULL;
|
|---|
| 130 |
|
|---|
| 131 | if (!secrets_init()) {
|
|---|
| 132 | d_fprintf(stderr, _("Failed to open secrets.tdb.\n"));
|
|---|
| 133 | return 1;
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | /* Delete the settings. */
|
|---|
| 137 | if (argc >= 1) {
|
|---|
| 138 | if (strncmp(argv[0], "delete", 6) != 0) {
|
|---|
| 139 | d_fprintf(stderr,_("Usage:\n"));
|
|---|
| 140 | d_fprintf(stderr,
|
|---|
| 141 | _(" net setauthuser -U user[%%password] \n"
|
|---|
| 142 | " Set the auth user account to user"
|
|---|
| 143 | "password. Prompt for password if not "
|
|---|
| 144 | "specified.\n"));
|
|---|
| 145 | d_fprintf(stderr,
|
|---|
| 146 | _(" net setauthuser delete\n"
|
|---|
| 147 | " Delete the auth user setting.\n"));
|
|---|
| 148 | return 1;
|
|---|
| 149 | }
|
|---|
| 150 | secrets_delete(SECRETS_AUTH_USER);
|
|---|
| 151 | secrets_delete(SECRETS_AUTH_DOMAIN);
|
|---|
| 152 | secrets_delete(SECRETS_AUTH_PASSWORD);
|
|---|
| 153 | return 0;
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | if (!c->opt_user_specified) {
|
|---|
| 157 | d_fprintf(stderr, _("Usage:\n"));
|
|---|
| 158 | d_fprintf(stderr,
|
|---|
| 159 | _(" net setauthuser -U user[%%password]\n"
|
|---|
| 160 | " Set the auth user account to user"
|
|---|
| 161 | "password. Prompt for password if not "
|
|---|
| 162 | "specified.\n"));
|
|---|
| 163 | d_fprintf(stderr,
|
|---|
| 164 | _(" net setauthuser delete\n"
|
|---|
| 165 | " Delete the auth user setting.\n"));
|
|---|
| 166 | return 1;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | password = net_prompt_pass(c, _("the auth user"));
|
|---|
| 170 | if (password == NULL) {
|
|---|
| 171 | d_fprintf(stderr,_("Failed to get the auth users password.\n"));
|
|---|
| 172 | return 1;
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | if (!secrets_store(SECRETS_AUTH_USER, c->opt_user_name,
|
|---|
| 176 | strlen(c->opt_user_name) + 1)) {
|
|---|
| 177 | d_fprintf(stderr, _("error storing auth user name\n"));
|
|---|
| 178 | return 1;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | if (!secrets_store(SECRETS_AUTH_DOMAIN, c->opt_workgroup,
|
|---|
| 182 | strlen(c->opt_workgroup) + 1)) {
|
|---|
| 183 | d_fprintf(stderr, _("error storing auth user domain\n"));
|
|---|
| 184 | return 1;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | if (!secrets_store(SECRETS_AUTH_PASSWORD, password,
|
|---|
| 188 | strlen(password) + 1)) {
|
|---|
| 189 | d_fprintf(stderr, _("error storing auth user password\n"));
|
|---|
| 190 | return 1;
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | return 0;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | /**
|
|---|
| 197 | * @brief Get the auth user settings
|
|---|
| 198 | */
|
|---|
| 199 | static int net_getauthuser(struct net_context *c, int argc, const char **argv)
|
|---|
| 200 | {
|
|---|
| 201 | char *user, *domain, *password;
|
|---|
| 202 |
|
|---|
| 203 | /* Lift data from secrets file */
|
|---|
| 204 |
|
|---|
| 205 | secrets_fetch_ipc_userpass(&user, &domain, &password);
|
|---|
| 206 |
|
|---|
| 207 | if ((!user || !*user) && (!domain || !*domain ) &&
|
|---|
| 208 | (!password || !*password)){
|
|---|
| 209 |
|
|---|
| 210 | SAFE_FREE(user);
|
|---|
| 211 | SAFE_FREE(domain);
|
|---|
| 212 | SAFE_FREE(password);
|
|---|
| 213 | d_printf(_("No authorised user configured\n"));
|
|---|
| 214 | return 0;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | /* Pretty print authorised user info */
|
|---|
| 218 |
|
|---|
| 219 | d_printf("%s%s%s%s%s\n", domain ? domain : "",
|
|---|
| 220 | domain ? lp_winbind_separator(): "", user,
|
|---|
| 221 | password ? "%" : "", password ? password : "");
|
|---|
| 222 |
|
|---|
| 223 | SAFE_FREE(user);
|
|---|
| 224 | SAFE_FREE(domain);
|
|---|
| 225 | SAFE_FREE(password);
|
|---|
| 226 |
|
|---|
| 227 | return 0;
|
|---|
| 228 | }
|
|---|
| 229 | /*
|
|---|
| 230 | Retrieve our local SID or the SID for the specified name
|
|---|
| 231 | */
|
|---|
| 232 | static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
|
|---|
| 233 | {
|
|---|
| 234 | DOM_SID sid;
|
|---|
| 235 | const char *name;
|
|---|
| 236 | fstring sid_str;
|
|---|
| 237 |
|
|---|
| 238 | if (argc >= 1) {
|
|---|
| 239 | name = argv[0];
|
|---|
| 240 | }
|
|---|
| 241 | else {
|
|---|
| 242 | name = global_myname();
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | if(!initialize_password_db(false, NULL)) {
|
|---|
| 246 | DEBUG(0, ("WARNING: Could not open passdb - local sid may not reflect passdb\n"
|
|---|
| 247 | "backend knowledge (such as the sid stored in LDAP)\n"));
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | /* first check to see if we can even access secrets, so we don't
|
|---|
| 251 | panic when we can't. */
|
|---|
| 252 |
|
|---|
| 253 | if (!secrets_init()) {
|
|---|
| 254 | d_fprintf(stderr,
|
|---|
| 255 | _("Unable to open secrets.tdb. Can't fetch domain "
|
|---|
| 256 | "SID for name: %s\n"), name);
|
|---|
| 257 | return 1;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | /* Generate one, if it doesn't exist */
|
|---|
| 261 | get_global_sam_sid();
|
|---|
| 262 |
|
|---|
| 263 | if (!secrets_fetch_domain_sid(name, &sid)) {
|
|---|
| 264 | DEBUG(0, ("Can't fetch domain SID for name: %s\n", name));
|
|---|
| 265 | return 1;
|
|---|
| 266 | }
|
|---|
| 267 | sid_to_fstring(sid_str, &sid);
|
|---|
| 268 | d_printf(_("SID for domain %s is: %s\n"), name, sid_str);
|
|---|
| 269 | return 0;
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | static int net_setlocalsid(struct net_context *c, int argc, const char **argv)
|
|---|
| 273 | {
|
|---|
| 274 | DOM_SID sid;
|
|---|
| 275 |
|
|---|
| 276 | if ( (argc != 1)
|
|---|
| 277 | || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
|
|---|
| 278 | || (!string_to_sid(&sid, argv[0]))
|
|---|
| 279 | || (sid.num_auths != 4)) {
|
|---|
| 280 | d_printf(_("Usage:"));
|
|---|
| 281 | d_printf(" net setlocalsid S-1-5-21-x-y-z\n");
|
|---|
| 282 | return 1;
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 | if (!secrets_store_domain_sid(global_myname(), &sid)) {
|
|---|
| 286 | DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
|
|---|
| 287 | return 1;
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 | return 0;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | static int net_setdomainsid(struct net_context *c, int argc, const char **argv)
|
|---|
| 294 | {
|
|---|
| 295 | DOM_SID sid;
|
|---|
| 296 |
|
|---|
| 297 | if ( (argc != 1)
|
|---|
| 298 | || (strncmp(argv[0], "S-1-5-21-", strlen("S-1-5-21-")) != 0)
|
|---|
| 299 | || (!string_to_sid(&sid, argv[0]))
|
|---|
| 300 | || (sid.num_auths != 4)) {
|
|---|
| 301 | d_printf(_("Usage:"));
|
|---|
| 302 | d_printf(" net setdomainsid S-1-5-21-x-y-z\n");
|
|---|
| 303 | return 1;
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | if (!secrets_store_domain_sid(lp_workgroup(), &sid)) {
|
|---|
| 307 | DEBUG(0,("Can't store domain SID.\n"));
|
|---|
| 308 | return 1;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | return 0;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
|
|---|
| 315 | {
|
|---|
| 316 | DOM_SID domain_sid;
|
|---|
| 317 | fstring sid_str;
|
|---|
| 318 |
|
|---|
| 319 | if (argc > 0) {
|
|---|
| 320 | d_printf(_("Usage:"));
|
|---|
| 321 | d_printf(" net getdomainsid\n");
|
|---|
| 322 | return 1;
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | if(!initialize_password_db(false, NULL)) {
|
|---|
| 326 | DEBUG(0, ("WARNING: Could not open passdb - domain SID may "
|
|---|
| 327 | "not reflect passdb\n"
|
|---|
| 328 | "backend knowledge (such as the SID stored in "
|
|---|
| 329 | "LDAP)\n"));
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | /* first check to see if we can even access secrets, so we don't
|
|---|
| 333 | panic when we can't. */
|
|---|
| 334 |
|
|---|
| 335 | if (!secrets_init()) {
|
|---|
| 336 | d_fprintf(stderr, _("Unable to open secrets.tdb. Can't fetch "
|
|---|
| 337 | "domain SID for name: %s\n"),
|
|---|
| 338 | get_global_sam_name());
|
|---|
| 339 | return 1;
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | /* Generate one, if it doesn't exist */
|
|---|
| 343 | get_global_sam_sid();
|
|---|
| 344 |
|
|---|
| 345 | if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) {
|
|---|
| 346 | d_fprintf(stderr, _("Could not fetch local SID\n"));
|
|---|
| 347 | return 1;
|
|---|
| 348 | }
|
|---|
| 349 | sid_to_fstring(sid_str, &domain_sid);
|
|---|
| 350 | d_printf(_("SID for local machine %s is: %s\n"),
|
|---|
| 351 | global_myname(), sid_str);
|
|---|
| 352 |
|
|---|
| 353 | if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) {
|
|---|
| 354 | d_fprintf(stderr, _("Could not fetch domain SID\n"));
|
|---|
| 355 | return 1;
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | sid_to_fstring(sid_str, &domain_sid);
|
|---|
| 359 | d_printf(_("SID for domain %s is: %s\n"), c->opt_workgroup, sid_str);
|
|---|
| 360 |
|
|---|
| 361 | return 0;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | static bool search_maxrid(struct pdb_search *search, const char *type,
|
|---|
| 365 | uint32 *max_rid)
|
|---|
| 366 | {
|
|---|
| 367 | struct samr_displayentry *entries;
|
|---|
| 368 | uint32 i, num_entries;
|
|---|
| 369 |
|
|---|
| 370 | if (search == NULL) {
|
|---|
| 371 | d_fprintf(stderr, _("get_maxrid: Could not search %s\n"), type);
|
|---|
| 372 | return false;
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | num_entries = pdb_search_entries(search, 0, 0xffffffff, &entries);
|
|---|
| 376 | for (i=0; i<num_entries; i++)
|
|---|
| 377 | *max_rid = MAX(*max_rid, entries[i].rid);
|
|---|
| 378 | TALLOC_FREE(search);
|
|---|
| 379 | return true;
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | static uint32 get_maxrid(void)
|
|---|
| 383 | {
|
|---|
| 384 | uint32 max_rid = 0;
|
|---|
| 385 |
|
|---|
| 386 | if (!search_maxrid(pdb_search_users(talloc_tos(), 0), "users", &max_rid))
|
|---|
| 387 | return 0;
|
|---|
| 388 |
|
|---|
| 389 | if (!search_maxrid(pdb_search_groups(talloc_tos()), "groups", &max_rid))
|
|---|
| 390 | return 0;
|
|---|
| 391 |
|
|---|
| 392 | if (!search_maxrid(pdb_search_aliases(talloc_tos(),
|
|---|
| 393 | get_global_sam_sid()),
|
|---|
| 394 | "aliases", &max_rid))
|
|---|
| 395 | return 0;
|
|---|
| 396 |
|
|---|
| 397 | return max_rid;
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | static int net_maxrid(struct net_context *c, int argc, const char **argv)
|
|---|
| 401 | {
|
|---|
| 402 | uint32 rid;
|
|---|
| 403 |
|
|---|
| 404 | if (argc != 0) {
|
|---|
| 405 | d_fprintf(stderr, "%s net maxrid\n", _("Usage:"));
|
|---|
| 406 | return 1;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | if ((rid = get_maxrid()) == 0) {
|
|---|
| 410 | d_fprintf(stderr, _("can't get current maximum rid\n"));
|
|---|
| 411 | return 1;
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | d_printf(_("Currently used maximum rid: %d\n"), rid);
|
|---|
| 415 |
|
|---|
| 416 | return 0;
|
|---|
| 417 | }
|
|---|
| 418 |
|
|---|
| 419 | /* main function table */
|
|---|
| 420 | static struct functable net_func[] = {
|
|---|
| 421 | {
|
|---|
| 422 | "rpc",
|
|---|
| 423 | net_rpc,
|
|---|
| 424 | NET_TRANSPORT_RPC,
|
|---|
| 425 | N_("Run functions using RPC transport"),
|
|---|
| 426 | N_(" Use 'net help rpc' to get more extensive information "
|
|---|
| 427 | "about 'net rpc' commands.")
|
|---|
| 428 | },
|
|---|
| 429 | {
|
|---|
| 430 | "rap",
|
|---|
| 431 | net_rap,
|
|---|
| 432 | NET_TRANSPORT_RAP,
|
|---|
| 433 | N_("Run functions using RAP transport"),
|
|---|
| 434 | N_(" Use 'net help rap' to get more extensive information "
|
|---|
| 435 | "about 'net rap' commands.")
|
|---|
| 436 | },
|
|---|
| 437 | {
|
|---|
| 438 | "ads",
|
|---|
| 439 | net_ads,
|
|---|
| 440 | NET_TRANSPORT_ADS,
|
|---|
| 441 | N_("Run functions using ADS transport"),
|
|---|
| 442 | N_(" Use 'net help ads' to get more extensive information "
|
|---|
| 443 | "about 'net ads' commands.")
|
|---|
| 444 | },
|
|---|
| 445 |
|
|---|
| 446 | /* eventually these should auto-choose the transport ... */
|
|---|
| 447 | {
|
|---|
| 448 | "file",
|
|---|
| 449 | net_file,
|
|---|
| 450 | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
|
|---|
| 451 | N_("Functions on remote opened files"),
|
|---|
| 452 | N_(" Use 'net help file' to get more information about 'net "
|
|---|
| 453 | "file' commands.")
|
|---|
| 454 | },
|
|---|
| 455 | {
|
|---|
| 456 | "share",
|
|---|
| 457 | net_share,
|
|---|
| 458 | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
|
|---|
| 459 | N_("Functions on shares"),
|
|---|
| 460 | N_(" Use 'net help share' to get more information about 'net "
|
|---|
| 461 | "share' commands.")
|
|---|
| 462 | },
|
|---|
| 463 | {
|
|---|
| 464 | "session",
|
|---|
| 465 | net_rap_session,
|
|---|
| 466 | NET_TRANSPORT_RAP,
|
|---|
| 467 | N_("Manage sessions"),
|
|---|
| 468 | N_(" Use 'net help session' to get more information about "
|
|---|
| 469 | "'net session' commands.")
|
|---|
| 470 | },
|
|---|
| 471 | {
|
|---|
| 472 | "server",
|
|---|
| 473 | net_rap_server,
|
|---|
| 474 | NET_TRANSPORT_RAP,
|
|---|
| 475 | N_("List servers in workgroup"),
|
|---|
| 476 | N_(" Use 'net help server' to get more information about 'net "
|
|---|
| 477 | "server' commands.")
|
|---|
| 478 | },
|
|---|
| 479 | {
|
|---|
| 480 | "domain",
|
|---|
| 481 | net_rap_domain,
|
|---|
| 482 | NET_TRANSPORT_RAP,
|
|---|
| 483 | N_("List domains/workgroups on network"),
|
|---|
| 484 | N_(" Use 'net help domain' to get more information about 'net "
|
|---|
| 485 | "domain' commands.")
|
|---|
| 486 | },
|
|---|
| 487 | {
|
|---|
| 488 | "printq",
|
|---|
| 489 | net_rap_printq,
|
|---|
| 490 | NET_TRANSPORT_RAP,
|
|---|
| 491 | N_("Modify printer queue"),
|
|---|
| 492 | N_(" Use 'net help printq' to get more information about 'net "
|
|---|
| 493 | "printq' commands.")
|
|---|
| 494 | },
|
|---|
| 495 | {
|
|---|
| 496 | "user",
|
|---|
| 497 | net_user,
|
|---|
| 498 | NET_TRANSPORT_ADS | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
|
|---|
| 499 | N_("Manage users"),
|
|---|
| 500 | N_(" Use 'net help user' to get more information about 'net "
|
|---|
| 501 | "user' commands.")
|
|---|
| 502 | },
|
|---|
| 503 | {
|
|---|
| 504 | "group",
|
|---|
| 505 | net_group,
|
|---|
| 506 | NET_TRANSPORT_ADS | NET_TRANSPORT_RPC | NET_TRANSPORT_RAP,
|
|---|
| 507 | N_("Manage groups"),
|
|---|
| 508 | N_(" Use 'net help group' to get more information about 'net "
|
|---|
| 509 | "group' commands.")
|
|---|
| 510 | },
|
|---|
| 511 | {
|
|---|
| 512 | "groupmap",
|
|---|
| 513 | net_groupmap,
|
|---|
| 514 | NET_TRANSPORT_LOCAL,
|
|---|
| 515 | N_("Manage group mappings"),
|
|---|
| 516 | N_(" Use 'net help groupmap' to get more information about "
|
|---|
| 517 | "'net groupmap' commands.")
|
|---|
| 518 | },
|
|---|
| 519 | {
|
|---|
| 520 | "sam",
|
|---|
| 521 | net_sam,
|
|---|
| 522 | NET_TRANSPORT_LOCAL,
|
|---|
| 523 | N_("Functions on the SAM database"),
|
|---|
| 524 | N_(" Use 'net help sam' to get more information about 'net "
|
|---|
| 525 | "sam' commands.")
|
|---|
| 526 | },
|
|---|
| 527 | {
|
|---|
| 528 | "validate",
|
|---|
| 529 | net_rap_validate,
|
|---|
| 530 | NET_TRANSPORT_RAP,
|
|---|
| 531 | N_("Validate username and password"),
|
|---|
| 532 | N_(" Use 'net help validate' to get more information about "
|
|---|
| 533 | "'net validate' commands.")
|
|---|
| 534 | },
|
|---|
| 535 | {
|
|---|
| 536 | "groupmember",
|
|---|
| 537 | net_rap_groupmember,
|
|---|
| 538 | NET_TRANSPORT_RAP,
|
|---|
| 539 | N_("Modify group memberships"),
|
|---|
| 540 | N_(" Use 'net help groupmember' to get more information about "
|
|---|
| 541 | "'net groupmember' commands.")
|
|---|
| 542 | },
|
|---|
| 543 | { "admin",
|
|---|
| 544 | net_rap_admin,
|
|---|
| 545 | NET_TRANSPORT_RAP,
|
|---|
| 546 | N_("Execute remote command on a remote OS/2 server"),
|
|---|
| 547 | N_(" Use 'net help admin' to get more information about 'net "
|
|---|
| 548 | "admin' commands.")
|
|---|
| 549 | },
|
|---|
| 550 | { "service",
|
|---|
| 551 | net_rap_service,
|
|---|
| 552 | NET_TRANSPORT_RAP,
|
|---|
| 553 | N_("List/modify running services"),
|
|---|
| 554 | N_(" Use 'net help service' to get more information about "
|
|---|
| 555 | "'net service' commands.")
|
|---|
| 556 | },
|
|---|
| 557 | {
|
|---|
| 558 | "password",
|
|---|
| 559 | net_rap_password,
|
|---|
| 560 | NET_TRANSPORT_RAP,
|
|---|
| 561 | N_("Change user password on target server"),
|
|---|
| 562 | N_(" Use 'net help password' to get more information about "
|
|---|
| 563 | "'net password' commands.")
|
|---|
| 564 | },
|
|---|
| 565 | { "changetrustpw",
|
|---|
| 566 | net_changetrustpw,
|
|---|
| 567 | NET_TRANSPORT_ADS | NET_TRANSPORT_RPC,
|
|---|
| 568 | N_("Change the trust password"),
|
|---|
| 569 | N_(" Use 'net help changetrustpw' to get more information "
|
|---|
| 570 | "about 'net changetrustpw'.")
|
|---|
| 571 | },
|
|---|
| 572 | { "changesecretpw",
|
|---|
| 573 | net_changesecretpw,
|
|---|
| 574 | NET_TRANSPORT_LOCAL,
|
|---|
| 575 | N_("Change the secret password"),
|
|---|
| 576 | N_(" net [options] changesecretpw\n"
|
|---|
| 577 | " Change the ADS domain member machine account password "
|
|---|
| 578 | "in secrets.tdb.\n"
|
|---|
| 579 | " Do NOT use this function unless you know what it does.\n"
|
|---|
| 580 | " Requires the -f flag to work.")
|
|---|
| 581 | },
|
|---|
| 582 | {
|
|---|
| 583 | "setauthuser",
|
|---|
| 584 | net_setauthuser,
|
|---|
| 585 | NET_TRANSPORT_LOCAL,
|
|---|
| 586 | N_("Set the winbind auth user"),
|
|---|
| 587 | N_(" net -U user[%%password] [-W domain] setauthuser\n"
|
|---|
| 588 | " Set the auth user, password (and optionally domain\n"
|
|---|
| 589 | " Will prompt for password if not given.\n"
|
|---|
| 590 | " net setauthuser delete\n"
|
|---|
| 591 | " Delete the existing auth user settings.")
|
|---|
| 592 | },
|
|---|
| 593 | {
|
|---|
| 594 | "getauthuser",
|
|---|
| 595 | net_getauthuser,
|
|---|
| 596 | NET_TRANSPORT_LOCAL,
|
|---|
| 597 | N_("Get the winbind auth user settings"),
|
|---|
| 598 | N_(" net getauthuser\n"
|
|---|
| 599 | " Get the current winbind auth user settings.")
|
|---|
| 600 | },
|
|---|
| 601 | { "time",
|
|---|
| 602 | net_time,
|
|---|
| 603 | NET_TRANSPORT_LOCAL,
|
|---|
| 604 | N_("Show/set time"),
|
|---|
| 605 | N_(" Use 'net help time' to get more information about 'net "
|
|---|
| 606 | "time' commands.")
|
|---|
| 607 | },
|
|---|
| 608 | { "lookup",
|
|---|
| 609 | net_lookup,
|
|---|
| 610 | NET_TRANSPORT_LOCAL,
|
|---|
| 611 | N_("Look up host names/IP addresses"),
|
|---|
| 612 | N_(" Use 'net help lookup' to get more information about 'net "
|
|---|
| 613 | "lookup' commands.")
|
|---|
| 614 | },
|
|---|
| 615 | { "g_lock",
|
|---|
| 616 | net_g_lock,
|
|---|
| 617 | NET_TRANSPORT_LOCAL,
|
|---|
| 618 | N_("Manipulate the global lock table"),
|
|---|
| 619 | N_(" Use 'net help g_lock' to get more information about "
|
|---|
| 620 | "'net g_lock' commands.")
|
|---|
| 621 | },
|
|---|
| 622 | { "join",
|
|---|
| 623 | net_join,
|
|---|
| 624 | NET_TRANSPORT_ADS | NET_TRANSPORT_RPC,
|
|---|
| 625 | N_("Join a domain/AD"),
|
|---|
| 626 | N_(" Use 'net help join' to get more information about 'net "
|
|---|
| 627 | "join'.")
|
|---|
| 628 | },
|
|---|
| 629 | { "dom",
|
|---|
| 630 | net_dom,
|
|---|
| 631 | NET_TRANSPORT_LOCAL,
|
|---|
| 632 | N_("Join/unjoin (remote) machines to/from a domain/AD"),
|
|---|
| 633 | N_(" Use 'net help dom' to get more information about 'net "
|
|---|
| 634 | "dom' commands.")
|
|---|
| 635 | },
|
|---|
| 636 | { "cache",
|
|---|
| 637 | net_cache,
|
|---|
| 638 | NET_TRANSPORT_LOCAL,
|
|---|
| 639 | N_("Operate on the cache tdb file"),
|
|---|
| 640 | N_(" Use 'net help cache' to get more information about 'net "
|
|---|
| 641 | "cache' commands.")
|
|---|
| 642 | },
|
|---|
| 643 | { "getlocalsid",
|
|---|
| 644 | net_getlocalsid,
|
|---|
| 645 | NET_TRANSPORT_LOCAL,
|
|---|
| 646 | N_("Get the SID for the local domain"),
|
|---|
| 647 | N_(" net getlocalsid")
|
|---|
| 648 | },
|
|---|
| 649 | { "setlocalsid",
|
|---|
| 650 | net_setlocalsid,
|
|---|
| 651 | NET_TRANSPORT_LOCAL,
|
|---|
| 652 | N_("Set the SID for the local domain"),
|
|---|
| 653 | N_(" net setlocalsid S-1-5-21-x-y-z")
|
|---|
| 654 | },
|
|---|
| 655 | { "setdomainsid",
|
|---|
| 656 | net_setdomainsid,
|
|---|
| 657 | NET_TRANSPORT_LOCAL,
|
|---|
| 658 | N_("Set domain SID on member servers"),
|
|---|
| 659 | N_(" net setdomainsid S-1-5-21-x-y-z")
|
|---|
| 660 | },
|
|---|
| 661 | { "getdomainsid",
|
|---|
| 662 | net_getdomainsid,
|
|---|
| 663 | NET_TRANSPORT_LOCAL,
|
|---|
| 664 | N_("Get domain SID on member servers"),
|
|---|
| 665 | N_(" net getdomainsid")
|
|---|
| 666 | },
|
|---|
| 667 | { "maxrid",
|
|---|
| 668 | net_maxrid,
|
|---|
| 669 | NET_TRANSPORT_LOCAL,
|
|---|
| 670 | N_("Display the maximul RID currently used"),
|
|---|
| 671 | N_(" net maxrid")
|
|---|
| 672 | },
|
|---|
| 673 | { "idmap",
|
|---|
| 674 | net_idmap,
|
|---|
| 675 | NET_TRANSPORT_LOCAL,
|
|---|
| 676 | N_("IDmap functions"),
|
|---|
| 677 | N_(" Use 'net help idmap to get more information about 'net "
|
|---|
| 678 | "idmap' commands.")
|
|---|
| 679 | },
|
|---|
| 680 | { "status",
|
|---|
| 681 | net_status,
|
|---|
| 682 | NET_TRANSPORT_LOCAL,
|
|---|
| 683 | N_("Display server status"),
|
|---|
| 684 | N_(" Use 'net help status' to get more information about 'net "
|
|---|
| 685 | "status' commands.")
|
|---|
| 686 | },
|
|---|
| 687 | { "usershare",
|
|---|
| 688 | net_usershare,
|
|---|
| 689 | NET_TRANSPORT_LOCAL,
|
|---|
| 690 | N_("Manage user-modifiable shares"),
|
|---|
| 691 | N_(" Use 'net help usershare to get more information about "
|
|---|
| 692 | "'net usershare' commands.")
|
|---|
| 693 | },
|
|---|
| 694 | { "usersidlist",
|
|---|
| 695 | net_usersidlist,
|
|---|
| 696 | NET_TRANSPORT_RPC,
|
|---|
| 697 | N_("Display list of all users with SID"),
|
|---|
| 698 | N_(" Use 'net help usersidlist' to get more information about "
|
|---|
| 699 | "'net usersidlist'.")
|
|---|
| 700 | },
|
|---|
| 701 | { "conf",
|
|---|
| 702 | net_conf,
|
|---|
| 703 | NET_TRANSPORT_LOCAL,
|
|---|
| 704 | N_("Manage Samba registry based configuration"),
|
|---|
| 705 | N_(" Use 'net help conf' to get more information about 'net "
|
|---|
| 706 | "conf' commands.")
|
|---|
| 707 | },
|
|---|
| 708 | { "registry",
|
|---|
| 709 | net_registry,
|
|---|
| 710 | NET_TRANSPORT_LOCAL,
|
|---|
| 711 | N_("Manage the Samba registry"),
|
|---|
| 712 | N_(" Use 'net help registry' to get more information about "
|
|---|
| 713 | "'net registry' commands.")
|
|---|
| 714 | },
|
|---|
| 715 | { "eventlog",
|
|---|
| 716 | net_eventlog,
|
|---|
| 717 | NET_TRANSPORT_LOCAL,
|
|---|
| 718 | N_("Process Win32 *.evt eventlog files"),
|
|---|
| 719 | N_(" Use 'net help eventlog' to get more information about "
|
|---|
| 720 | "'net eventlog' commands.")
|
|---|
| 721 | },
|
|---|
| 722 |
|
|---|
| 723 | #ifdef WITH_FAKE_KASERVER
|
|---|
| 724 | { "afs",
|
|---|
| 725 | net_afs,
|
|---|
| 726 | NET_TRANSPORT_LOCAL,
|
|---|
| 727 | N_("Manage AFS tokens"),
|
|---|
| 728 | N_(" Use 'net help afs' to get more information about 'net "
|
|---|
| 729 | "afs' commands.")
|
|---|
| 730 | },
|
|---|
| 731 | #endif
|
|---|
| 732 |
|
|---|
| 733 | { "help",
|
|---|
| 734 | net_help,
|
|---|
| 735 | NET_TRANSPORT_LOCAL,
|
|---|
| 736 | N_("Print usage information"),
|
|---|
| 737 | N_(" Use 'net help help' to list usage information for 'net' "
|
|---|
| 738 | "commands.")
|
|---|
| 739 | },
|
|---|
| 740 | {NULL, NULL, 0, NULL, NULL}
|
|---|
| 741 | };
|
|---|
| 742 |
|
|---|
| 743 |
|
|---|
| 744 | /****************************************************************************
|
|---|
| 745 | main program
|
|---|
| 746 | ****************************************************************************/
|
|---|
| 747 | int main(int argc, const char **argv)
|
|---|
| 748 | {
|
|---|
| 749 | int opt,i;
|
|---|
| 750 | char *p;
|
|---|
| 751 | int rc = 0;
|
|---|
| 752 | int argc_new = 0;
|
|---|
| 753 | const char ** argv_new;
|
|---|
| 754 | poptContext pc;
|
|---|
| 755 | TALLOC_CTX *frame = talloc_stackframe();
|
|---|
| 756 | struct net_context *c = talloc_zero(frame, struct net_context);
|
|---|
| 757 |
|
|---|
| 758 | struct poptOption long_options[] = {
|
|---|
| 759 | {"help", 'h', POPT_ARG_NONE, 0, 'h'},
|
|---|
| 760 | {"workgroup", 'w', POPT_ARG_STRING, &c->opt_target_workgroup},
|
|---|
| 761 | {"user", 'U', POPT_ARG_STRING, &c->opt_user_name, 'U'},
|
|---|
| 762 | {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'},
|
|---|
| 763 | {"port", 'p', POPT_ARG_INT, &c->opt_port},
|
|---|
| 764 | {"myname", 'n', POPT_ARG_STRING, &c->opt_requester_name},
|
|---|
| 765 | {"server", 'S', POPT_ARG_STRING, &c->opt_host},
|
|---|
| 766 | {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', N_("Encrypt SMB transport (UNIX extended servers only)") },
|
|---|
| 767 | {"container", 'c', POPT_ARG_STRING, &c->opt_container},
|
|---|
| 768 | {"comment", 'C', POPT_ARG_STRING, &c->opt_comment},
|
|---|
| 769 | {"maxusers", 'M', POPT_ARG_INT, &c->opt_maxusers},
|
|---|
| 770 | {"flags", 'F', POPT_ARG_INT, &c->opt_flags},
|
|---|
| 771 | {"long", 'l', POPT_ARG_NONE, &c->opt_long_list_entries},
|
|---|
| 772 | {"reboot", 'r', POPT_ARG_NONE, &c->opt_reboot},
|
|---|
| 773 | {"force", 'f', POPT_ARG_NONE, &c->opt_force},
|
|---|
| 774 | {"stdin", 'i', POPT_ARG_NONE, &c->opt_stdin},
|
|---|
| 775 | {"timeout", 't', POPT_ARG_INT, &c->opt_timeout},
|
|---|
| 776 | {"request-timeout",0,POPT_ARG_INT, &c->opt_request_timeout},
|
|---|
| 777 | {"machine-pass",'P', POPT_ARG_NONE, &c->opt_machine_pass},
|
|---|
| 778 | {"kerberos", 'k', POPT_ARG_NONE, &c->opt_kerberos},
|
|---|
| 779 | {"myworkgroup", 'W', POPT_ARG_STRING, &c->opt_workgroup},
|
|---|
| 780 | {"use-ccache", 0, POPT_ARG_NONE, &c->opt_ccache},
|
|---|
| 781 | {"verbose", 'v', POPT_ARG_NONE, &c->opt_verbose},
|
|---|
| 782 | {"test", 'T', POPT_ARG_NONE, &c->opt_testmode},
|
|---|
| 783 | /* Options for 'net groupmap set' */
|
|---|
| 784 | {"local", 'L', POPT_ARG_NONE, &c->opt_localgroup},
|
|---|
| 785 | {"domain", 'D', POPT_ARG_NONE, &c->opt_domaingroup},
|
|---|
| 786 | {"ntname", 'N', POPT_ARG_STRING, &c->opt_newntname},
|
|---|
| 787 | {"rid", 'R', POPT_ARG_INT, &c->opt_rid},
|
|---|
| 788 | /* Options for 'net rpc share migrate' */
|
|---|
| 789 | {"acls", 0, POPT_ARG_NONE, &c->opt_acls},
|
|---|
| 790 | {"attrs", 0, POPT_ARG_NONE, &c->opt_attrs},
|
|---|
| 791 | {"timestamps", 0, POPT_ARG_NONE, &c->opt_timestamps},
|
|---|
| 792 | {"exclude", 'X', POPT_ARG_STRING, &c->opt_exclude},
|
|---|
| 793 | {"destination", 0, POPT_ARG_STRING, &c->opt_destination},
|
|---|
| 794 | {"tallocreport", 0, POPT_ARG_NONE, &c->do_talloc_report},
|
|---|
| 795 | /* Options for 'net rpc vampire (keytab)' */
|
|---|
| 796 | {"force-full-repl", 0, POPT_ARG_NONE, &c->opt_force_full_repl},
|
|---|
| 797 | {"single-obj-repl", 0, POPT_ARG_NONE, &c->opt_single_obj_repl},
|
|---|
| 798 | {"clean-old-entries", 0, POPT_ARG_NONE, &c->opt_clean_old_entries},
|
|---|
| 799 |
|
|---|
| 800 | POPT_COMMON_SAMBA
|
|---|
| 801 | { 0, 0, 0, 0}
|
|---|
| 802 | };
|
|---|
| 803 |
|
|---|
| 804 | zero_sockaddr(&c->opt_dest_ip);
|
|---|
| 805 |
|
|---|
| 806 | load_case_tables();
|
|---|
| 807 |
|
|---|
| 808 | setlocale(LC_ALL, "");
|
|---|
| 809 | #if defined(HAVE_BINDTEXTDOMAIN)
|
|---|
| 810 | bindtextdomain(MODULE_NAME, dyn_LOCALEDIR);
|
|---|
| 811 | #endif
|
|---|
| 812 | #if defined(HAVE_TEXTDOMAIN)
|
|---|
| 813 | textdomain(MODULE_NAME);
|
|---|
| 814 | #endif
|
|---|
| 815 |
|
|---|
| 816 | /* set default debug level to 0 regardless of what smb.conf sets */
|
|---|
| 817 | DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
|
|---|
| 818 | dbf = x_stderr;
|
|---|
| 819 | c->private_data = net_func;
|
|---|
| 820 |
|
|---|
| 821 | pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
|
|---|
| 822 | POPT_CONTEXT_KEEP_FIRST);
|
|---|
| 823 |
|
|---|
| 824 | while((opt = poptGetNextOpt(pc)) != -1) {
|
|---|
| 825 | switch (opt) {
|
|---|
| 826 | case 'h':
|
|---|
| 827 | c->display_usage = true;
|
|---|
| 828 | break;
|
|---|
| 829 | case 'e':
|
|---|
| 830 | c->smb_encrypt = true;
|
|---|
| 831 | break;
|
|---|
| 832 | case 'I':
|
|---|
| 833 | if (!interpret_string_addr(&c->opt_dest_ip,
|
|---|
| 834 | poptGetOptArg(pc), 0)) {
|
|---|
| 835 | d_fprintf(stderr, _("\nInvalid ip address specified\n"));
|
|---|
| 836 | } else {
|
|---|
| 837 | c->opt_have_ip = true;
|
|---|
| 838 | }
|
|---|
| 839 | break;
|
|---|
| 840 | case 'U':
|
|---|
| 841 | c->opt_user_specified = true;
|
|---|
| 842 | c->opt_user_name = SMB_STRDUP(c->opt_user_name);
|
|---|
| 843 | p = strchr(c->opt_user_name,'%');
|
|---|
| 844 | if (p) {
|
|---|
| 845 | *p = 0;
|
|---|
| 846 | c->opt_password = p+1;
|
|---|
| 847 | }
|
|---|
| 848 | break;
|
|---|
| 849 | default:
|
|---|
| 850 | d_fprintf(stderr, _("\nInvalid option %s: %s\n"),
|
|---|
| 851 | poptBadOption(pc, 0), poptStrerror(opt));
|
|---|
| 852 | net_help(c, argc, argv);
|
|---|
| 853 | exit(1);
|
|---|
| 854 | }
|
|---|
| 855 | }
|
|---|
| 856 |
|
|---|
| 857 | /*
|
|---|
| 858 | * Don't load debug level from smb.conf. It should be
|
|---|
| 859 | * set by cmdline arg or remain default (0)
|
|---|
| 860 | */
|
|---|
| 861 | AllowDebugChange = false;
|
|---|
| 862 | lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
|
|---|
| 863 |
|
|---|
| 864 | argv_new = (const char **)poptGetArgs(pc);
|
|---|
| 865 |
|
|---|
| 866 | argc_new = argc;
|
|---|
| 867 | for (i=0; i<argc; i++) {
|
|---|
| 868 | if (argv_new[i] == NULL) {
|
|---|
| 869 | argc_new = i;
|
|---|
| 870 | break;
|
|---|
| 871 | }
|
|---|
| 872 | }
|
|---|
| 873 |
|
|---|
| 874 | if (c->do_talloc_report) {
|
|---|
| 875 | talloc_enable_leak_report();
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| 878 | if (c->opt_requester_name) {
|
|---|
| 879 | set_global_myname(c->opt_requester_name);
|
|---|
| 880 | }
|
|---|
| 881 |
|
|---|
| 882 | if (!c->opt_user_name && getenv("LOGNAME")) {
|
|---|
| 883 | c->opt_user_name = getenv("LOGNAME");
|
|---|
| 884 | }
|
|---|
| 885 |
|
|---|
| 886 | if (!c->opt_workgroup) {
|
|---|
| 887 | c->opt_workgroup = smb_xstrdup(lp_workgroup());
|
|---|
| 888 | }
|
|---|
| 889 |
|
|---|
| 890 | if (!c->opt_target_workgroup) {
|
|---|
| 891 | c->opt_target_workgroup = smb_xstrdup(lp_workgroup());
|
|---|
| 892 | }
|
|---|
| 893 |
|
|---|
| 894 | if (!init_names())
|
|---|
| 895 | exit(1);
|
|---|
| 896 |
|
|---|
| 897 | load_interfaces();
|
|---|
| 898 |
|
|---|
| 899 | /* this makes sure that when we do things like call scripts,
|
|---|
| 900 | that it won't assert becouse we are not root */
|
|---|
| 901 | sec_init();
|
|---|
| 902 |
|
|---|
| 903 | if (c->opt_machine_pass) {
|
|---|
| 904 | /* it is very useful to be able to make ads queries as the
|
|---|
| 905 | machine account for testing purposes and for domain leave */
|
|---|
| 906 |
|
|---|
| 907 | net_use_krb_machine_account(c);
|
|---|
| 908 | }
|
|---|
| 909 |
|
|---|
| 910 | if (!c->opt_password) {
|
|---|
| 911 | c->opt_password = getenv("PASSWD");
|
|---|
| 912 | }
|
|---|
| 913 |
|
|---|
| 914 | rc = net_run_function(c, argc_new-1, argv_new+1, "net", net_func);
|
|---|
| 915 |
|
|---|
| 916 | DEBUG(2,("return code = %d\n", rc));
|
|---|
| 917 |
|
|---|
| 918 | gencache_stabilize();
|
|---|
| 919 |
|
|---|
| 920 | libnetapi_free(c->netapi_ctx);
|
|---|
| 921 |
|
|---|
| 922 | poptFreeContext(pc);
|
|---|
| 923 |
|
|---|
| 924 | TALLOC_FREE(frame);
|
|---|
| 925 | return rc;
|
|---|
| 926 | }
|
|---|