Changeset: 0b7fb3a2229c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0b7fb3a2229c
Removed Files:
monetdb5/mal/Tests/tst830.maltest
monetdb5/modules/mal/Tests/clients-getpasswd.maltest
Modified Files:
monetdb5/mal/Tests/All
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_authorize.h
monetdb5/mal/mal_client.c
monetdb5/modules/mal/Tests/All
monetdb5/modules/mal/clients.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_user.c
sql/backends/monet5/sql_user.h
Branch: userprofile
Log Message:
Remove commented code and tests.
diffs (truncated from 1058 to 300 lines):
diff --git a/monetdb5/mal/Tests/All b/monetdb5/mal/Tests/All
--- a/monetdb5/mal/Tests/All
+++ b/monetdb5/mal/Tests/All
@@ -170,7 +170,6 @@ tst802
tst804
tst810
tst819
-#tst830 removed API
tst840
tst850
tst866
diff --git a/monetdb5/mal/Tests/tst830.maltest
b/monetdb5/mal/Tests/tst830.maltest
deleted file mode 100644
--- a/monetdb5/mal/Tests/tst830.maltest
+++ /dev/null
@@ -1,61 +0,0 @@
-statement ok
-function foo();
- pw := clients.backendsum("Pmonetdb");
- id := clients.addUser("monetdb", pw);
-catch MALException:str;
- io.printf("0: %s\n",MALException);
-exit MALException;
- # should print 1@0 or something
- id := clients.addUser("test", pw);
- io.print(id);
- # this should work also
- id := clients.addUser("checkpoint", pw);
- io.print(id);
- # do a simple listing of users known
- (u,n) := clients.getUsers();
- io.print(u,n);
- # should work, we're the admin here
- clients.removeUser("checkpoint");
- # do a simple listing of users known
- (u,n) := clients.getUsers();
- io.print(u,n);
- # forcefully set the password of the user test
- clients.setPassword("test", pw);
- # now try to set the password for ourself, should fail
- clients.setPassword("monetdb", pw);
-catch InvalidCredentialsException:str;
- io.printf("1: %s\n", InvalidCredentialsException);
-exit InvalidCredentialsException;
-#
-# # change our own password,
-# mypw := clients.backendsum("monetdb");
-# clients.changePassword(mypw, pw);
-# # try it again, should fail...
-# clients.changePassword(mypw, pw);
-#catch InvalidCredentialsException:str;
-# io.printf("2: %s\n",InvalidCredentialsException);
-# InvalidCredentialsException:= nil:str;
-#exit InvalidCredentialsException;
- # all should fail
- clients.checkPermission("monetdb","Pmonetdb");
-catch InvalidCredentialsException:str;
- io.printf("3: %s\n",InvalidCredentialsException);
- InvalidCredentialsException:= nil:str;
-exit InvalidCredentialsException;
- clients.checkPermission("monetdb","x");
-catch InvalidCredentialsException:str;
- io.printf("4: %s\n",InvalidCredentialsException);
- InvalidCredentialsException:= nil:str;
-exit InvalidCredentialsException;
- clients.checkPermission("x","Pmonetdb");
-catch InvalidCredentialsException:str;
- io.printf("5: %s\n",InvalidCredentialsException);
- InvalidCredentialsException:= nil:str;
-exit InvalidCredentialsException;
-end;
-
-query T rowsort
-user.foo();
-----
-5: InvalidCredentialsException:checkCredentials:invalid credentials for user
'x'
-
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
@@ -33,10 +33,6 @@
static BUN lookupRemoteTableKey(const char *key);
-// static BAT *user = NULL;
-// static BAT *pass = NULL;
-// static BAT *duser = NULL;
-
/* Remote table bats */
static BAT *rt_key = NULL;
static BAT *rt_uri = NULL;
@@ -54,39 +50,11 @@ static AUTHCallbackCntx authCallbackCntx
void AUTHreset(void)
{
- //if( user) BBPunfix(user->batCacheid);
- // user = NULL;
- //if( pass) BBPunfix(pass->batCacheid);
- // pass = NULL;
- //if( duser) BBPunfix(duser->batCacheid);
- // duser = NULL;
if (vaultKey != NULL)
GDKfree(vaultKey);
vaultKey = NULL;
}
-// static BUN
-// AUTHfindUser(const char *username)
-// {
-// BATiter cni = bat_iterator(user);
-// BUN p;
-//
-// if (BAThash(user) == GDK_SUCCEED) {
-// MT_rwlock_rdlock(&user->thashlock);
-// HASHloop_str(cni, user->thash, p, username) {
-// oid pos = p;
-// if (BUNfnd(duser, &pos) == BUN_NONE) {
-// MT_rwlock_rdunlock(&user->thashlock);
-// bat_iterator_end(&cni);
-// return p;
-// }
-// }
-// MT_rwlock_rdunlock(&user->thashlock);
-// }
-// bat_iterator_end(&cni);
-// return BUN_NONE;
-// }
-
/**
* Requires the current client to be the admin user thread. If not the case,
* this function returns an InvalidCredentialsException.
@@ -98,50 +66,8 @@ AUTHrequireAdmin(Client cntxt) {
if (cntxt->user != MAL_ADMIN)
throw(MAL, "AUTHrequireAdmin", INVCRED_ACCESS_DENIED);
return(MAL_SUCCEED);
-
- // oid id;
-
- // if (cntxt == NULL)
- // return(MAL_SUCCEED);
- // id = cntxt->user;
-
- // if (id != MAL_ADMIN) {
- // str user = NULL;
- // str tmp;
-
- // rethrow("requireAdmin", tmp, AUTHresolveUser(&user, id));
- // tmp = createException(INVCRED, "requireAdmin",
INVCRED_ACCESS_DENIED " '%s'", user);
- // GDKfree(user);
- // return tmp;
- // }
-
- // return(MAL_SUCCEED);
}
-/**
- * Requires the current client to be the admin user, or the user with
- * the given username. If not the case, this function returns an
- * InvalidCredentialsException.
- */
-// static str
-// AUTHrequireAdminOrUser(Client cntxt, const char *username) {
-// oid id = cntxt->user;
-// str user = NULL;
-// str tmp = MAL_SUCCEED;
-//
-// /* MAL_ADMIN then all is well */
-// if (id == MAL_ADMIN)
-// return(MAL_SUCCEED);
-//
-// rethrow("requireAdminOrUser", tmp, AUTHresolveUser(&user, id));
-// if (username == NULL || strcmp(username, user) != 0)
-// tmp = createException(INVCRED, "requireAdminOrUser",
-// INVCRED_ACCESS_DENIED
" '%s'", user);
-//
-// GDKfree(user);
-// return tmp;
-// }
-
static void
AUTHcommit(void)
{
@@ -149,12 +75,6 @@ AUTHcommit(void)
blist[0] = 0;
- // assert(user);
- // blist[1] = user->batCacheid;
- // assert(pass);
- // blist[2] = pass->batCacheid;
- // assert(duser);
- // blist[3] = duser->batCacheid;
assert(rt_key);
blist[1] = rt_key->batCacheid;
assert(rt_uri);
@@ -186,78 +106,8 @@ AUTHinitTables(const char *passwd) {
(void) passwd;
/* skip loading if already loaded */
- //if (user != NULL && pass != NULL)
- // return(MAL_SUCCEED);
-
- /* if one is not NULL here, something is seriously screwed up */
- // assert (user == NULL);
- // assert (pass == NULL);
-
- /* load/create users BAT */
- // bid = BBPindex("M5system_auth_user");
- // if (!bid) {
- // user = COLnew(0, TYPE_str, 256, PERSISTENT);
- // if (user == NULL)
- // throw(MAL, "initTables.user", SQLSTATE(HY013)
MAL_MALLOC_FAIL " user table");
-
- // if (BATkey(user, true) != GDK_SUCCEED ||
- // BBPrename(user, "M5system_auth_user") != 0 ||
- // BATmode(user, false) != GDK_SUCCEED) {
- // throw(MAL, "initTables.user", GDK_EXCEPTION);
- // }
- // } else {
- // int dbg = GDKdebug;
- // /* don't check this bat since we'll fix it below */
- // GDKdebug &= ~CHECKMASK;
- // user = BATdescriptor(bid);
- // GDKdebug = dbg;
- // if (user == NULL)
- // throw(MAL, "initTables.user", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- // isNew = 0;
- // }
- // assert(user);
-
- /* load/create password BAT */
- // bid = BBPindex("M5system_auth_passwd_v2");
- // if (!bid) {
- // pass = COLnew(0, TYPE_str, 256, PERSISTENT);
- // if (pass == NULL)
- // throw(MAL, "initTables.passwd", SQLSTATE(HY013)
MAL_MALLOC_FAIL " password table");
-
- // if (BBPrename(pass, "M5system_auth_passwd_v2") != 0 ||
- // BATmode(pass, false) != GDK_SUCCEED) {
- // throw(MAL, "initTables.user", GDK_EXCEPTION);
- // }
- // } else {
- // int dbg = GDKdebug;
- // /* don't check this bat since we'll fix it below */
- // GDKdebug &= ~CHECKMASK;
- // pass = BATdescriptor(bid);
- // GDKdebug = dbg;
- // if (pass == NULL)
- // throw(MAL, "initTables.passwd", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- // isNew = 0;
- // }
- // assert(pass);
-
- /* load/create deleted BAT */
- // bid = BBPindex("M5system_auth_deleted");
- // if (!bid) {
- // duser = COLnew(0, TYPE_oid, 256, PERSISTENT);
- // if (duser == NULL)
- // throw(MAL, "initTables.duser", SQLSTATE(HY013)
MAL_MALLOC_FAIL " deleted user table");
-
- // if (BBPrename(duser, "M5system_auth_deleted") != 0 ||
- // BATmode(duser, false) != GDK_SUCCEED) {
- // throw(MAL, "initTables.user", GDK_EXCEPTION);
- // }
- // } else {
- // duser = BATdescriptor(bid);
- // if (duser == NULL)
- // throw(MAL, "initTables.duser", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- // isNew = 0;
- // }
- // assert(duser);
+ if (rt_key != NULL && rt_deleted != NULL)
+ return(MAL_SUCCEED);
/* Remote table authorization table.
*
@@ -386,30 +236,6 @@ AUTHinitTables(const char *passwd) {
}
assert(rt_deleted);
- //if (isNew == 1) {
- // /* insert the monetdb/monetdb administrator account on a
- // * complete fresh and new auth tables system */
- // char *pw;
- // oid uid;
-
- // if (passwd == NULL)
- // passwd = "monetdb"; /* default password */
- // pw = mcrypt_BackendSum(passwd, strlen(passwd));
- // if(!pw) {
- // if (!GDKembedded())
- // throw(MAL, "initTables", SQLSTATE(42000) "Crypt
backend hash not found");
- // else
- // pw = strdup(passwd);
- // }
- // msg = AUTHaddUser(&uid, NULL, "monetdb", pw);
- // free(pw);
- // if (msg)
- // return msg;
- // if (uid != MAL_ADMIN)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]