summaryrefslogtreecommitdiff
path: root/source3/utils/pdbedit.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2003-01-07 10:39:23 +0000
committerVolker Lendecke <vlendec@samba.org>2003-01-07 10:39:23 +0000
commitb59dc9ee58f2a496aa82b52ae6e89abbb44648de (patch)
treeb88cdbd078aba7d2f6aae2886098df12e0435f84 /source3/utils/pdbedit.c
parente8a70338d94810871a117d3f96e6cc1f13e8d3a9 (diff)
downloadsamba-b59dc9ee58f2a496aa82b52ae6e89abbb44648de.tar.gz
samba-b59dc9ee58f2a496aa82b52ae6e89abbb44648de.tar.bz2
samba-b59dc9ee58f2a496aa82b52ae6e89abbb44648de.zip
Merge from HEAD.
Volker (This used to be commit 7977a025ae698fb91694e3809985b14e35693e92)
Diffstat (limited to 'source3/utils/pdbedit.c')
-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 3904f25154..60022d007d 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);