summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2003-01-07 10:38:33 +0000
committerVolker Lendecke <vlendec@samba.org>2003-01-07 10:38:33 +0000
commit7b4bf92955ece4b14e333e16e346b3057ab14fe3 (patch)
tree44f9f36b71d365cd0f57b328afaf018e51bc57f0 /source3/utils
parent6693cade73fdbf44392948014acc5d568eaa2c35 (diff)
downloadsamba-7b4bf92955ece4b14e333e16e346b3057ab14fe3.tar.gz
samba-7b4bf92955ece4b14e333e16e346b3057ab14fe3.tar.bz2
samba-7b4bf92955ece4b14e333e16e346b3057ab14fe3.zip
Create a machine account correctly if the unix account exists.
With this, my test for W2kSP3 join after pdbedit -a -m works fine. Volker (This used to be commit c9d0c5254c7d4ddb343f405652c609a0128e60f9)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/pdbedit.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index c229d100ca..8aec35ac39 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -346,12 +346,9 @@ static int new_machine (struct pdb_context *in, const char *machine_in)
{
SAM_ACCOUNT *sam_pwent=NULL;
fstring machinename;
+ struct passwd *pwd = NULL;
char name[16];
- if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
- return -1;
- }
-
fstrcpy(machinename, machine_in);
if (machinename[strlen (machinename) -1] == '$')
@@ -362,6 +359,19 @@ static int new_machine (struct pdb_context *in, const char *machine_in)
safe_strcpy (name, machinename, 16);
safe_strcat (name, "$", 16);
+ if ((pwd = getpwnam_alloc(name))) {
+ if (!NT_STATUS_IS_OK(pdb_init_sam_pw( &sam_pwent, pwd))) {
+ fprintf(stderr, "Could not init sam from pw\n");
+ passwd_free(&pwd);
+ return -1;
+ }
+ } else {
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
+ fprintf(stderr, "Could not init sam from pw\n");
+ return -1;
+ }
+ }
+
pdb_set_plaintext_passwd (sam_pwent, machinename);
pdb_set_username (sam_pwent, name, PDB_CHANGED);