svn commit: samba r21819 - in branches/SAMBA_3_0/source/passdb: .
vlendec at samba.org
vlendec at samba.org
Tue Mar 13 14:05:38 GMT 2007
Author: vlendec
Date: 2007-03-13 14:05:38 +0000 (Tue, 13 Mar 2007)
New Revision: 21819
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21819
Log:
Wrap all steps in secrets_store_machine_password into one single
transaction. Succeed all or store nothing.
Volker
Modified:
branches/SAMBA_3_0/source/passdb/secrets.c
Changeset:
Modified: branches/SAMBA_3_0/source/passdb/secrets.c
===================================================================
--- branches/SAMBA_3_0/source/passdb/secrets.c 2007-03-13 12:45:20 UTC (rev 21818)
+++ branches/SAMBA_3_0/source/passdb/secrets.c 2007-03-13 14:05:38 UTC (rev 21819)
@@ -556,40 +556,78 @@
BOOL secrets_store_machine_password(const char *pass, const char *domain, uint32 sec_channel)
{
char *key = NULL;
- BOOL ret;
+ BOOL ret = False;
uint32 last_change_time;
uint32 sec_channel_type;
- asprintf(&key, "%s/%s", SECRETS_MACHINE_PASSWORD, domain);
- if (!key)
+ if (tdb_transaction_start(tdb) == -1) {
+ DEBUG(5, ("tdb_transaction_start failed: %s\n",
+ tdb_errorstr(tdb)));
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)
- return ret;
+ if (!ret) {
+ DEBUG(5, ("secrets_store failed: %s\n",
+ tdb_errorstr(tdb)));
+ goto fail;
+ }
- asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME, domain);
- if (!key)
- return False;
+ if (asprintf(&key, "%s/%s", SECRETS_MACHINE_LAST_CHANGE_TIME,
+ domain) == -1) {
+ DEBUG(5, ("asprintf failed\n"));
+ goto fail;
+ }
strupper_m(key);
SIVAL(&last_change_time, 0, time(NULL));
ret = secrets_store(key, &last_change_time, sizeof(last_change_time));
SAFE_FREE(key);
- asprintf(&key, "%s/%s", SECRETS_MACHINE_SEC_CHANNEL_TYPE, domain);
- if (!key)
- return False;
+ 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;
+ }
strupper_m(key);
SIVAL(&sec_channel_type, 0, sec_channel);
ret = secrets_store(key, &sec_channel_type, sizeof(sec_channel_type));
SAFE_FREE(key);
- return ret;
+ 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;
}
/************************************************************************
More information about the samba-cvs
mailing list