Changeset 988 for vendor/current/source3/utils/smbpasswd.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/smbpasswd.c
r740 r988 98 98 switch(ch) { 99 99 case 'L': 100 #if !defined(NSS_WRAPPER)101 100 if (getuid() != 0) { 102 101 fprintf(stderr, "smbpasswd -L can only be used by root.\n"); 103 102 exit(1); 104 103 } 105 #endif106 104 local_flags |= LOCAL_AM_ROOT; 107 105 break; 108 106 case 'c': 109 107 configfile = optarg; 108 set_dyn_CONFIGFILE(optarg); 110 109 break; 111 110 case 'a': … … 137 136 local_flags |= LOCAL_SET_NO_PASSWORD; 138 137 local_flags &= ~LOCAL_SET_PASSWORD; 138 SAFE_FREE(new_passwd); 139 139 new_passwd = smb_xstrdup("NO PASSWORD"); 140 140 break; … … 153 153 break; 154 154 case 'R': 155 lp_set_ name_resolve_order(optarg);155 lp_set_cmdline("name resolve order", optarg); 156 156 break; 157 157 case 'D': … … 196 196 } 197 197 198 if (!lp_load (configfile,True,False,False,True)) {198 if (!lp_load_global(configfile)) { 199 199 fprintf(stderr, "Can't load %s - run testparm to debug it\n", 200 200 configfile); … … 216 216 217 217 p = get_pass("New SMB password:", stdin_get); 218 if (p == NULL) { 219 return NULL; 220 } 218 221 219 222 fstrcpy(new_pw, p); … … 221 224 222 225 p = get_pass("Retype new SMB password:", stdin_get); 226 if (p == NULL) { 227 return NULL; 228 } 223 229 224 230 if (strcmp(p, new_pw)) { … … 286 292 return False; 287 293 288 return secrets_store_ldap_pw(lp_ldap_admin_dn( ), pw);294 return secrets_store_ldap_pw(lp_ldap_admin_dn(talloc_tos()), pw); 289 295 } 290 296 … … 301 307 302 308 if (local_flags & LOCAL_SET_LDAP_ADMIN_PW) { 303 char *ldap_admin_dn = lp_ldap_admin_dn( );309 char *ldap_admin_dn = lp_ldap_admin_dn(talloc_tos()); 304 310 if ( ! *ldap_admin_dn ) { 305 311 DEBUG(0,("ERROR: 'ldap admin dn' not defined! Please check your smb.conf\n")); … … 310 316 if ( ! *ldap_secret ) { 311 317 new_passwd = prompt_for_new_password(stdin_passwd_get); 318 if (new_passwd == NULL) { 319 fprintf(stderr, "Failed to read new password!\n"); 320 exit(1); 321 } 312 322 fstrcpy(ldap_secret, new_passwd); 313 323 } … … 370 380 SAFE_FREE(new_passwd); 371 381 new_passwd = smb_xstrdup(user_name); 372 strlower_m(new_passwd); 382 if (!strlower_m(new_passwd)) { 383 fprintf(stderr, "strlower_m %s failed\n", 384 new_passwd); 385 exit(1); 386 } 373 387 } 374 388 … … 379 393 380 394 slprintf(buf, sizeof(buf)-1, "%s$", user_name); 381 fstrcpy(user_name, buf);395 strlcpy(user_name, buf, sizeof(user_name)); 382 396 } else if (local_flags & LOCAL_INTERDOM_ACCOUNT) { 383 397 static fstring buf; … … 396 410 /* prepare uppercased and '$' terminated username */ 397 411 slprintf(buf, sizeof(buf) - 1, "%s$", user_name); 398 fstrcpy(user_name, buf);412 strlcpy(user_name, buf, sizeof(user_name)); 399 413 400 414 } else { … … 533 547 if (remote_machine != NULL) { 534 548 old_pw = get_pass("Old SMB password:",stdin_passwd_get); 549 if (old_pw == NULL) { 550 fprintf(stderr, "Unable to get old password.\n"); 551 exit(1); 552 } 535 553 } 536 554 … … 580 598 } 581 599 582 load_case_tables();600 smb_init_locale(); 583 601 584 602 local_flags = process_options(argc, argv, local_flags); … … 601 619 602 620 if (local_flags & LOCAL_AM_ROOT) { 603 secrets_init(); 604 return process_root(local_flags); 605 } 606 607 ret = process_nonroot(local_flags); 621 bool ok; 622 623 ok = secrets_init(); 624 if (!ok) { 625 return 1; 626 } 627 ret = process_root(local_flags); 628 } else { 629 ret = process_nonroot(local_flags); 630 } 608 631 TALLOC_FREE(frame); 609 632 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.