svn commit: samba r23407 - in branches: SAMBA_3_0/source/utils
SAMBA_3_0_25/source/utils SAMBA_3_0_26/source/utils
idra at samba.org
idra at samba.org
Sat Jun 9 22:45:22 GMT 2007
Author: idra
Date: 2007-06-09 22:45:21 +0000 (Sat, 09 Jun 2007)
New Revision: 23407
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23407
Log:
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.
Modified:
branches/SAMBA_3_0/source/utils/pdbedit.c
branches/SAMBA_3_0_25/source/utils/pdbedit.c
branches/SAMBA_3_0_26/source/utils/pdbedit.c
Changeset:
Modified: branches/SAMBA_3_0/source/utils/pdbedit.c
===================================================================
--- branches/SAMBA_3_0/source/utils/pdbedit.c 2007-06-09 19:29:35 UTC (rev 23406)
+++ branches/SAMBA_3_0/source/utils/pdbedit.c 2007-06-09 22:45:21 UTC (rev 23407)
@@ -624,28 +624,25 @@
fstrcpy(machineaccount, machinename);
fstrcat(machineaccount, "$");
- if ((pwd = getpwnam_alloc(NULL, machineaccount))) {
+ if ( !(pwd = getpwnam_alloc( NULL, machineaccount )) ) {
+ DEBUG(0,("Cannot locate Unix account for %s\n", machineaccount));
+ return -1;
+ }
- if ( (sam_pwent = samu_new( NULL )) == NULL ) {
- fprintf(stderr, "Memory allocation error!\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_set_unix(sam_pwent, pwd )) ) {
- fprintf(stderr, "Could not init sam from pw\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);
Modified: branches/SAMBA_3_0_25/source/utils/pdbedit.c
===================================================================
--- branches/SAMBA_3_0_25/source/utils/pdbedit.c 2007-06-09 19:29:35 UTC (rev 23406)
+++ branches/SAMBA_3_0_25/source/utils/pdbedit.c 2007-06-09 22:45:21 UTC (rev 23407)
@@ -624,28 +624,25 @@
fstrcpy(machineaccount, machinename);
fstrcat(machineaccount, "$");
- if ((pwd = getpwnam_alloc(NULL, machineaccount))) {
+ if ( !(pwd = getpwnam_alloc( NULL, machineaccount )) ) {
+ DEBUG(0,("Cannot locate Unix account for %s\n", machineaccount));
+ return -1;
+ }
- if ( (sam_pwent = samu_new( NULL )) == NULL ) {
- fprintf(stderr, "Memory allocation error!\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_set_unix(sam_pwent, pwd )) ) {
- fprintf(stderr, "Could not init sam from pw\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);
Modified: branches/SAMBA_3_0_26/source/utils/pdbedit.c
===================================================================
--- branches/SAMBA_3_0_26/source/utils/pdbedit.c 2007-06-09 19:29:35 UTC (rev 23406)
+++ branches/SAMBA_3_0_26/source/utils/pdbedit.c 2007-06-09 22:45:21 UTC (rev 23407)
@@ -624,28 +624,25 @@
fstrcpy(machineaccount, machinename);
fstrcat(machineaccount, "$");
- if ((pwd = getpwnam_alloc(NULL, machineaccount))) {
+ if ( !(pwd = getpwnam_alloc( NULL, machineaccount )) ) {
+ DEBUG(0,("Cannot locate Unix account for %s\n", machineaccount));
+ return -1;
+ }
- if ( (sam_pwent = samu_new( NULL )) == NULL ) {
- fprintf(stderr, "Memory allocation error!\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_set_unix(sam_pwent, pwd )) ) {
- fprintf(stderr, "Could not init sam from pw\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);
More information about the samba-cvs
mailing list