Changeset: 6a2f27aa45e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6a2f27aa45e8
Modified Files:
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_client.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_user.c
Branch: resource_management
Log Message:
pass allocator explicitly
diffs (149 lines):
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -40,7 +40,7 @@ static str vaultKey = NULL;
/* lock to protect the above */
static MT_RWLock rt_lock = MT_RWLOCK_INITIALIZER(rt_lock);
-static str AUTHdecypherValueLocked(str *ret, const char *value);
+static str AUTHdecypherValueLocked(allocator *, str *ret, const char *value);
void
AUTHreset(void)
@@ -103,7 +103,7 @@ AUTHunlockVault(const char *password)
* by the caller.
*/
static str
-AUTHdecypherValueLocked(str *ret, const char *value)
+AUTHdecypherValueLocked(allocator *ma, str *ret, const char *value)
{
/* Cyphering and decyphering can be done using many algorithms.
* Future requirements might want a stronger cypher than the XOR
@@ -116,6 +116,7 @@ AUTHdecypherValueLocked(str *ret, const
*/
/* this is the XOR decypher implementation */
+ assert(ma);
str r, w;
const char *s = value;
char t = '\0';
@@ -126,8 +127,6 @@ AUTHdecypherValueLocked(str *ret, const
if (vaultKey == NULL)
throw(MAL, "decypherValue", "The vault is still locked!");
- allocator *ma = MT_thread_getallocator();
- assert(ma);
w = r = ma_alloc(ma, sizeof(char) * (strlen(value) + 1));
if (r == NULL)
throw(MAL, "decypherValue", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -159,10 +158,10 @@ AUTHdecypherValueLocked(str *ret, const
}
str
-AUTHdecypherValue(str *ret, const char *value)
+AUTHdecypherValue(allocator *ma, str *ret, const char *value)
{
MT_rwlock_rdlock(&rt_lock);
- str err = AUTHdecypherValueLocked(ret, value);
+ str err = AUTHdecypherValueLocked(ma, ret, value);
MT_rwlock_rdunlock(&rt_lock);
return err;
}
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -268,9 +268,9 @@ MCinitClientRecord(Client c, oid user, b
c->filetrans = false;
c->handshake_options = NULL;
c->query = NULL;
- c->ma = create_allocator(NULL, "MA_Client", true);
- c->ta = create_allocator(c->ma, "TA_Client", false);
- sa_set_ta(c->ma, c->ta);
+ c->ma = create_allocator(NULL, "MA_Client", false);
+ //c->ta = create_allocator(c->ma, "TA_Client", false);
+ //sa_set_ta(c->ma, c->ta);
char name[MT_NAME_LEN];
snprintf(name, sizeof(name), "Client%d->s", (int) (c - mal_clients));
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -5495,7 +5495,7 @@ SQLdecypher(Client cntxt, MalBlkPtr mb,
return msg;
if ((msg = checkSQLContext(cntxt)) != NULL)
return msg;
- return AUTHdecypherValue(pwhash, cypher);
+ return AUTHdecypherValue(mb->ma, pwhash, cypher);
}
static str
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -430,7 +430,7 @@ userCheckCredentials( mvc *m, Client c,
/* find the corresponding password to the user */
str pwd = NULL;
- str msg = AUTHdecypherValue(&pwd, passValue);
+ str msg = AUTHdecypherValue(c->ma, &pwd, passValue);
GDKfree(passValue);
if (msg)
return msg;
diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -123,7 +123,7 @@ changeUserPassword(mvc *m, oid rid, str
}
if (oldpass) {
// validate old password match
- if ((err = AUTHdecypherValue(&hash,
passValue=getUserPassword(m, rid))) != MAL_SUCCEED) {
+ if ((err = AUTHdecypherValue(m->sa, &hash,
passValue=getUserPassword(m, rid))) != MAL_SUCCEED) {
(void) sql_error(m, 02, SQLSTATE(42000)
"changeUserPassword: %s", getExceptionMessage(err));
freeException(err);
GDKfree(passValue);
@@ -389,7 +389,7 @@ monet5_password_hash(mvc *m, const char
oid rid = getUserOIDByName(m, username);
str password = getUserPassword(m, rid);
if (password) {
- msg = AUTHdecypherValue(&hash, password);
+ msg = AUTHdecypherValue(m->sa, &hash, password);
GDKfree(password);
if (msg) {
(void) sql_error(m, 02, SQLSTATE(42000)
"monet5_password_hash: %s", getExceptionMessage(msg));
@@ -943,7 +943,7 @@ remote_create(mvc *m, sqlid id, const ch
if (strNil(password)) {
oid rid = getUserOIDByName(m, username);
str cypher = getUserPassword(m, rid);
- str err = AUTHdecypherValue(&pwhash, cypher);
+ str err = AUTHdecypherValue(m->sa, &pwhash, cypher);
GDKfree(cypher);
if (err) {
GDKfree(err);
@@ -951,12 +951,12 @@ remote_create(mvc *m, sqlid id, const ch
}
}
str msg = AUTHcypherValue(&cypher, pwhash ? pwhash : password);
- if (pwhash != NULL) {
- if (!pw_encrypted)
- free(pwhash);
- //else
- // GDKfree(pwhash);
- }
+ //if (pwhash != NULL) {
+ // if (!pw_encrypted)
+ // free(pwhash);
+ // //else
+ // // GDKfree(pwhash);
+ //}
if (msg != MAL_SUCCEED)
return msg;
log_res = store->table_api.table_insert(m->session->tr,
remote_user_info, &id, &username, &cypher, NULL);
@@ -984,7 +984,7 @@ remote_get(mvc *m, sqlid id, str *userna
*username = GDKstrdup("");
}
str cypher = store->table_api.column_find_value(tr,
find_sql_column(remote_user_info, "password"), rid);
- str err = AUTHdecypherValue(pwhash, cypher);
+ str err = AUTHdecypherValue(m->sa, pwhash, cypher);
GDKfree(cypher);
if (err)
return err;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]