summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-06-09 22:45:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:14 -0500
commit6250b82014f463c5683e18b0646bcae8da379ecf (patch)
tree518cc4c200aeccc76500ef126f818dee2bbac980 /source3/utils
parent22a7d90bfe94a1bb16c1d3d1070d1aad8dc4803f (diff)
downloadsamba-6250b82014f463c5683e18b0646bcae8da379ecf.tar.gz
samba-6250b82014f463c5683e18b0646bcae8da379ecf.tar.bz2
samba-6250b82014f463c5683e18b0646bcae8da379ecf.zip
r23407: While verifying a bug I found out that for some reason
the code to add a machine was different then the one used to add a user, the old code led to the machine SID not being built out correctly allocationg a new RID out of the passdb but instead by using the old algorithmic method. This may easily end up in creating duplicated SID when the RID counter get close to the values built by the algorithmic method. Simo. (This used to be commit e077142aa39ad927a16e0d04874857bbc171ce07)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/pdbedit.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index a598828d92..5dff7e5a93 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -624,28 +624,25 @@ static int new_machine (struct pdb_methods *in, const char *machine_in)
fstrcpy(machineaccount, machinename);
fstrcat(machineaccount, "$");
- if ((pwd = getpwnam_alloc(NULL, machineaccount))) {
-
- if ( (sam_pwent = samu_new( NULL )) == NULL ) {
- fprintf(stderr, "Memory allocation error!\n");
- TALLOC_FREE(pwd);
- return -1;
- }
+ if ( !(pwd = getpwnam_alloc( NULL, machineaccount )) ) {
+ DEBUG(0,("Cannot locate Unix account for %s\n", machineaccount));
+ return -1;
+ }
- if ( !NT_STATUS_IS_OK(samu_set_unix(sam_pwent, pwd )) ) {
- fprintf(stderr, "Could not init sam from pw\n");
- TALLOC_FREE(pwd);
- return -1;
- }
+ if ( (sam_pwent = samu_new( NULL )) == NULL ) {
+ fprintf(stderr, "Memory allocation error!\n");
+ TALLOC_FREE(pwd);
+ return -1;
+ }
+ if ( !NT_STATUS_IS_OK(samu_alloc_rid_unix(sam_pwent, pwd )) ) {
+ fprintf(stderr, "Could not init sam from pw\n");
TALLOC_FREE(pwd);
- } else {
- if ( (sam_pwent = samu_new( NULL )) == NULL ) {
- fprintf(stderr, "Could not init sam from pw\n");
- return -1;
- }
+ return -1;
}
+ TALLOC_FREE(pwd);
+
pdb_set_plaintext_passwd (sam_pwent, machinename);
pdb_set_username (sam_pwent, machineaccount, PDB_CHANGED);
pdb_set_acct_ctrl (sam_pwent, ACB_WSTRUST, PDB_CHANGED);