summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
commite5a951325a6cac8567af3a66de6d2df577508ae4 (patch)
tree34da9fe59f3c2d7f8edb072144443a9704197831 /source3/passdb
parent57482469b32645250e92a7ffd003aeeb4a42235e (diff)
downloadsamba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.gz
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.bz2
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.zip
[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
(This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_ldap.c2
-rw-r--r--source3/passdb/secrets.c87
2 files changed, 37 insertions, 52 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index cc123bff22..a945867967 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
LDAP protocol helper functions for SAMBA
- Copyright (C) Jean François Micouleau 1998
+ Copyright (C) Jean François Micouleau 1998
Copyright (C) Gerald Carter 2001-2003
Copyright (C) Shahms King 2001
Copyright (C) Andrew Bartlett 2002-2003
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index c5c1e29ecf..771adb96e3 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -104,7 +104,7 @@ BOOL secrets_store(const char *key, const void *data, size_t size)
if (!tdb)
return False;
return tdb_trans_store(tdb, string_tdb_data(key),
- make_tdb_data((uint8 *)data, size),
+ make_tdb_data((const uint8 *)data, size),
TDB_REPLACE) == 0;
}
@@ -499,6 +499,20 @@ BOOL secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
return True;
}
+/************************************************************************
+ Routine to set the trust account password for a domain.
+************************************************************************/
+
+BOOL secrets_store_trust_account_password(const char *domain, uint8 new_pwd[16])
+{
+ struct machine_acct_pass pass;
+
+ pass.mod_time = time(NULL);
+ memcpy(pass.hash, new_pwd, 16);
+
+ return secrets_store(trust_keystr(domain), (void *)&pass, sizeof(pass));
+}
+
/**
* Routine to store the password for trusted domain
*
@@ -555,78 +569,40 @@ the password is assumed to be a null terminated ascii string
BOOL secrets_store_machine_password(const char *pass, const char *domain, uint32 sec_channel)
{
char *key = NULL;
- BOOL ret = False;
+ BOOL ret;
uint32 last_change_time;
uint32 sec_channel_type;
- if (tdb_transaction_start(tdb) == -1) {
- DEBUG(5, ("tdb_transaction_start failed: %s\n",
- tdb_errorstr(tdb)));
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_PASSWORD, domain);
+ if (!key)
return False;
- }
-
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_PASSWORD, domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
strupper_m(key);
ret = secrets_store(key, pass, strlen(pass)+1);
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
+ if (!ret)
+ return ret;
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME,
- domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME, domain);
+ if (!key)
+ return False;
strupper_m(key);
SIVAL(&last_change_time, 0, time(NULL));
ret = secrets_store(key, &last_change_time, sizeof(last_change_time));
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
-
- if (asprintf(&key, "%s/%s", SECRETS_MACHINE_SEC_CHANNEL_TYPE,
- domain) == -1) {
- DEBUG(5, ("asprintf failed\n"));
- goto fail;
- }
+ asprintf(&key, "%s/%s", SECRETS_MACHINE_SEC_CHANNEL_TYPE, domain);
+ if (!key)
+ return False;
strupper_m(key);
SIVAL(&sec_channel_type, 0, sec_channel);
ret = secrets_store(key, &sec_channel_type, sizeof(sec_channel_type));
SAFE_FREE(key);
- if (!ret) {
- DEBUG(5, ("secrets_store failed: %s\n",
- tdb_errorstr(tdb)));
- goto fail;
- }
-
- if (tdb_transaction_commit(tdb) != 0) {
- DEBUG(5, ("tdb_transaction_commit failed: %s\n",
- tdb_errorstr(tdb)));
- return False;
- }
-
- return True;
-
- fail:
- if (tdb_transaction_cancel(tdb) != 0) {
- smb_panic("tdb_transaction_cancel failed!\n");
- }
- return False;
+ return ret;
}
/************************************************************************
@@ -679,6 +655,15 @@ char *secrets_fetch_machine_password(const char *domain,
}
/************************************************************************
+ Routine to delete the machine trust account password file for a domain.
+************************************************************************/
+
+BOOL trust_password_delete(const char *domain)
+{
+ return secrets_delete(trust_keystr(domain));
+}
+
+/************************************************************************
Routine to delete the password for trusted domain
************************************************************************/