Changeset 124 for branches/samba-3.0/source/utils
- Timestamp:
- Mar 12, 2008, 9:08:18 AM (17 years ago)
- Location:
- branches/samba-3.0/source/utils
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/utils/net.c
r62 r124 676 676 DEBUG(0, ("WARNING: Could not open passdb - domain sid may not reflect passdb\n" 677 677 "backend knowlege (such as the sid stored in LDAP)\n")); 678 } 679 680 /* first check to see if we can even access secrets, so we don't 681 panic when we can't. */ 682 683 if (!secrets_init()) { 684 d_fprintf(stderr, "Unable to open secrets.tdb. " 685 "Can't fetch domainSID for name: %s\n", 686 get_global_sam_name()); 687 return 1; 678 688 } 679 689 -
branches/samba-3.0/source/utils/net_domain.c
r1 r124 210 210 uint32 flags = 0x3e8; 211 211 uint32 acb_info = ACB_WSTRUST; 212 uchar pwbuf[516]; 212 uint32 acct_flags=0; 213 uint32 fields_present; 214 uchar pwbuf[532]; 213 215 SAM_USERINFO_CTR ctr; 214 SAM_USER_INFO_24 p24; 215 SAM_USER_INFO_16 p16; 216 SAM_USER_INFO_25 p25; 217 const int infolevel = 25; 218 struct MD5Context md5ctx; 219 uchar md5buffer[16]; 220 DATA_BLOB digested_session_key; 216 221 uchar md4_trust_password[16]; 217 222 … … 243 248 /* Don't try to set any acb_info flags other than ACB_WSTRUST */ 244 249 250 acct_flags = SAMR_GENERIC_READ | SAMR_GENERIC_WRITE | 251 SAMR_GENERIC_EXECUTE | SAMR_STANDARD_WRITEDAC | 252 SAMR_STANDARD_DELETE | SAMR_USER_SETPASS | SAMR_USER_GETATTR | 253 SAMR_USER_SETATTR; 254 DEBUG(10, ("Creating account with flags: %d\n",acct_flags)); 245 255 status = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol, 246 acct_name, acb_info, 0xe005000b, &user_pol, &user_rid);256 acct_name, acb_info, acct_flags, &user_pol, &user_rid); 247 257 248 258 if ( !NT_STATUS_IS_OK(status) … … 284 294 status = rpccli_samr_open_user(pipe_hnd, mem_ctx, &domain_pol, 285 295 SEC_RIGHTS_MAXIMUM_ALLOWED, user_rid, &user_pol); 286 287 /* Create a random machine account password */ 288 289 E_md4hash( clear_pw, md4_trust_password); 296 if (!NT_STATUS_IS_OK(status)) { 297 return status; 298 } 299 300 /* Create a random machine account password and generate the hash */ 301 302 E_md4hash(clear_pw, md4_trust_password); 290 303 encode_pw_buffer(pwbuf, clear_pw, STR_UNICODE); 291 292 /* Set password on machine account */ 293 294 ZERO_STRUCT(ctr); 295 ZERO_STRUCT(p24); 296 297 init_sam_user_info24(&p24, (char *)pwbuf,24); 298 299 ctr.switch_value = 24; 300 ctr.info.id24 = &p24; 301 302 status = rpccli_samr_set_userinfo(pipe_hnd, mem_ctx, &user_pol, 303 24, &cli->user_session_key, &ctr); 304 305 if ( !NT_STATUS_IS_OK(status) ) { 306 d_fprintf( stderr, "Failed to set password for machine account (%s)\n", 307 nt_errstr(status)); 308 return status; 309 } 310 311 312 /* Why do we have to try to (re-)set the ACB to be the same as what 313 we passed in the samr_create_dom_user() call? When a NT 314 workstation is joined to a domain by an administrator the 315 acb_info is set to 0x80. For a normal user with "Add 316 workstations to the domain" rights the acb_info is 0x84. I'm 317 not sure whether it is supposed to make a difference or not. NT 318 seems to cope with either value so don't bomb out if the set 319 userinfo2 level 0x10 fails. -tpot */ 320 321 ZERO_STRUCT(ctr); 322 ctr.switch_value = 16; 323 ctr.info.id16 = &p16; 304 305 generate_random_buffer((uint8*)md5buffer, sizeof(md5buffer)); 306 digested_session_key = data_blob_talloc(mem_ctx, 0, 16); 307 308 MD5Init(&md5ctx); 309 MD5Update(&md5ctx, md5buffer, sizeof(md5buffer)); 310 MD5Update(&md5ctx, cli->user_session_key.data, cli->user_session_key.length); 311 MD5Final(digested_session_key.data, &md5ctx); 312 313 SamOEMhashBlob(pwbuf, sizeof(pwbuf), &digested_session_key); 314 memcpy(&pwbuf[516], md5buffer, sizeof(md5buffer)); 324 315 325 316 /* Fill in the additional account flags now */ … … 333 324 } 334 325 335 init_sam_user_info16(&p16, acb_info); 336 337 status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, 16, 338 &cli->user_session_key, &ctr); 326 /* Set password and account flags on machine account */ 327 328 ZERO_STRUCT(ctr); 329 ZERO_STRUCT(p25); 330 331 fields_present = ACCT_NT_PWD_SET | ACCT_LM_PWD_SET | ACCT_FLAGS; 332 init_sam_user_info25P(&p25, fields_present, acb_info, (char *)pwbuf); 333 334 ctr.switch_value = infolevel; 335 ctr.info.id25 = &p25; 336 337 status = rpccli_samr_set_userinfo2(pipe_hnd, mem_ctx, &user_pol, 338 infolevel, &cli->user_session_key, &ctr); 339 340 if ( !NT_STATUS_IS_OK(status) ) { 341 d_fprintf( stderr, "Failed to set password for machine account (%s)\n", 342 nt_errstr(status)); 343 return status; 344 } 339 345 340 346 rpccli_samr_close(pipe_hnd, mem_ctx, &user_pol); -
branches/samba-3.0/source/utils/net_rpc.c
r62 r124 382 382 * stripped 383 383 * 384 * Main 'net_rpc_join()' (where the adm ain username/password is used) is384 * Main 'net_rpc_join()' (where the admin username/password is used) is 385 385 * in net_rpc_join.c 386 386 * Try to just change the password, but if that doesn't work, use/prompt … … 582 582 const char *acct_name; 583 583 uint32 acb_info; 584 uint32 unknown, user_rid; 584 uint32 acct_flags=0; 585 uint32 user_rid; 585 586 586 587 if (argc < 1) { … … 612 613 613 614 acb_info = ACB_NORMAL; 614 unknown = 0xe005000b; /* No idea what this is - a permission mask? */ 615 acct_flags = SAMR_GENERIC_READ | SAMR_GENERIC_WRITE | 616 SAMR_GENERIC_EXECUTE | SAMR_STANDARD_WRITEDAC | 617 SAMR_STANDARD_DELETE | SAMR_USER_SETPASS | SAMR_USER_GETATTR | 618 SAMR_USER_SETATTR; 619 DEBUG(10, ("Creating account with flags: %d\n",acct_flags)); 615 620 616 621 result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol, 617 acct_name, acb_info, unknown,622 acct_name, acb_info, acct_flags, 618 623 &user_pol, &user_rid); 619 624 if (!NT_STATUS_IS_OK(result)) { … … 5336 5341 char *acct_name; 5337 5342 uint32 acb_info; 5338 uint32 unknown, user_rid; 5343 uint32 user_rid; 5344 uint32 acct_flags=0; 5339 5345 5340 5346 if (argc != 2) { … … 5370 5376 /* Create trusting domain's account */ 5371 5377 acb_info = ACB_NORMAL; 5372 unknown = 0xe00500b0; /* No idea what this is - a permission mask? 5373 mimir: yes, most probably it is */ 5378 acct_flags = SAMR_GENERIC_READ | SAMR_GENERIC_WRITE | 5379 SAMR_GENERIC_EXECUTE | SAMR_STANDARD_WRITEDAC | 5380 SAMR_STANDARD_DELETE | SAMR_USER_SETPASS | SAMR_USER_GETATTR | 5381 SAMR_USER_SETATTR; 5374 5382 5375 5383 result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol, 5376 acct_name, acb_info, unknown,5384 acct_name, acb_info, acct_flags, 5377 5385 &user_pol, &user_rid); 5378 5386 if (!NT_STATUS_IS_OK(result)) { -
branches/samba-3.0/source/utils/net_rpc_join.c
r1 r124 44 44 int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip ) 45 45 { 46 uint32 neg_flags = NETLOGON_NEG_ AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL;46 uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; 47 47 struct cli_state *cli = NULL; 48 48 struct rpc_pipe_client *pipe_hnd = NULL; … … 115 115 TALLOC_CTX *mem_ctx; 116 116 uint32 acb_info = ACB_WSTRUST; 117 uint32 neg_flags = NETLOGON_NEG_ AUTH2_FLAGS|(lp_client_schannel() ? NETLOGON_NEG_SCHANNEL : 0);117 uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS|(lp_client_schannel() ? NETLOGON_NEG_SCHANNEL : 0); 118 118 uint32 sec_channel_type; 119 119 struct rpc_pipe_client *pipe_hnd = NULL; … … 143 143 char *acct_name; 144 144 const char *const_acct_name; 145 uint32 acct_flags=0; 145 146 146 147 /* check what type of join */ … … 230 231 const_acct_name = acct_name; 231 232 233 acct_flags = SAMR_GENERIC_READ | SAMR_GENERIC_WRITE | 234 SAMR_GENERIC_EXECUTE | SAMR_STANDARD_WRITEDAC | 235 SAMR_STANDARD_DELETE | SAMR_USER_SETPASS | SAMR_USER_GETATTR | 236 SAMR_USER_SETATTR; 237 DEBUG(10, ("Creating account with flags: %d\n",acct_flags)); 232 238 result = rpccli_samr_create_dom_user(pipe_hnd, mem_ctx, &domain_pol, 233 239 acct_name, acb_info, 234 0xe005000b, &user_pol,240 acct_flags, &user_pol, 235 241 &user_rid); 236 242 -
branches/samba-3.0/source/utils/net_rpc_samsync.c
r39 r124 239 239 NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; 240 240 uchar trust_password[16]; 241 uint32 neg_flags = NETLOGON_NEG_ AUTH2_FLAGS;241 uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS; 242 242 uint32 sec_channel_type = 0; 243 243 -
branches/samba-3.0/source/utils/net_sam.c
r22 r124 43 43 } 44 44 45 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,45 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 46 46 &dom, &name, &sid, &type)) { 47 47 d_fprintf(stderr, "Could not find name %s\n", argv[0]); … … 140 140 } 141 141 142 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,142 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 143 143 &dom, &name, &sid, &type)) { 144 144 d_fprintf(stderr, "Could not find name %s\n", argv[0]); … … 224 224 } 225 225 226 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,226 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 227 227 &dom, &name, &sid, &type)) { 228 228 d_fprintf(stderr, "Could not find name %s\n", argv[0]); … … 285 285 } 286 286 287 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,287 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 288 288 &dom, &name, &sid, &type)) { 289 289 d_fprintf(stderr, "Could not find name %s\n", argv[0]); … … 640 640 } 641 641 642 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,642 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 643 643 &groupdomain, &groupname, &group, &grouptype)) { 644 644 d_fprintf(stderr, "Could not find group %s\n", argv[0]); … … 648 648 /* check to see if the member to be added is a name or a SID */ 649 649 650 if (!lookup_name(tmp_talloc_ctx(), argv[1], LOOKUP_NAME_ ISOLATED,650 if (!lookup_name(tmp_talloc_ctx(), argv[1], LOOKUP_NAME_LOCAL, 651 651 &memberdomain, &membername, &member, &membertype)) 652 652 { … … 713 713 } 714 714 715 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,715 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 716 716 &groupdomain, &groupname, &group, &grouptype)) { 717 717 d_fprintf(stderr, "Could not find group %s\n", argv[0]); … … 719 719 } 720 720 721 if (!lookup_name(tmp_talloc_ctx(), argv[1], LOOKUP_NAME_ ISOLATED,721 if (!lookup_name(tmp_talloc_ctx(), argv[1], LOOKUP_NAME_LOCAL, 722 722 &memberdomain, &membername, &member, NULL)) { 723 723 if (!string_to_sid(&member, argv[1])) { … … 771 771 } 772 772 773 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,773 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 774 774 &groupdomain, &groupname, &group, &grouptype)) { 775 775 d_fprintf(stderr, "Could not find group %s\n", argv[0]); … … 919 919 } 920 920 921 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_ ISOLATED,921 if (!lookup_name(tmp_talloc_ctx(), argv[0], LOOKUP_NAME_LOCAL, 922 922 &dom, &name, &sid, &type)) { 923 923 d_fprintf(stderr, "Could not find name %s\n", argv[0]); -
branches/samba-3.0/source/utils/smbcacls.c
r1 r124 789 789 share, "?????", 790 790 cmdline_auth_info.username, lp_workgroup(), 791 cmdline_auth_info.password, 0, 791 cmdline_auth_info.password, 792 cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, 792 793 cmdline_auth_info.signing_state, NULL))) { 793 794 return c; -
branches/samba-3.0/source/utils/smbpasswd.c
r30 r124 97 97 switch(ch) { 98 98 case 'L': 99 #if !defined(DEVELOPER) 100 if (getuid() != 0) { 101 fprintf(stderr, "smbpasswd -L can only be used by root.\n"); 102 exit(1); 103 } 104 #endif 99 105 local_flags |= LOCAL_AM_ROOT; 100 106 break; -
branches/samba-3.0/source/utils/status.c
r30 r124 368 368 int ret; 369 369 370 tdb = tdb_open_log(lock_path("locking.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0); 371 372 if (!tdb) { 373 d_printf("%s not initialised\n", lock_path("locking.tdb")); 374 d_printf("This is normal if an SMB client has never connected to your server.\n"); 375 exit(0); 376 } else { 377 tdb_close(tdb); 378 } 379 370 380 if (!locking_init(1)) { 371 381 d_printf("Can't initialise locking module - exiting\n");
Note:
See TracChangeset
for help on using the changeset viewer.