Changeset: 4d6bfc57f81e for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4d6bfc57f81e Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out monetdb5/ChangeLog monetdb5/mal/Tests/tst830.mal monetdb5/mal/Tests/tst830.stable.out monetdb5/mal/mal_authorize.c monetdb5/mal/mal_authorize.h monetdb5/mal/mal_private.h monetdb5/mal/mal_session.c monetdb5/modules/mal/Tests/remote03.stable.out monetdb5/modules/mal/Tests/remote88.mal monetdb5/modules/mal/clients.c monetdb5/modules/mal/clients.mal monetdb5/modules/mal/sysmon.c sql/backends/monet5/sql_user.c Branch: default Log Message:
Changed client.getUsers to return two dense-headed bats. Splitting the old bat with user ids in the head and names in the tail into two aligned bats. diffs (truncated from 759 to 300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -37591,9 +37591,9 @@ pattern clients.changeUsername(old:str,n address CLTchangeUsername; comment Change the username of the user into the new string -pattern clients.getUsers():bat[:oid,:str] +pattern clients.getUsers() (X_1:bat[:oid,:oid],X_2:bat[:oid,:str]) address CLTgetUsers; -comment return a BAT with user id and name available in the system +comment return a BAT with user id and one with name available in the system pattern clients.getPasswordHash(user:str):str address CLTgetPasswordHash; diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -48474,9 +48474,9 @@ pattern clients.changeUsername(old:str,n address CLTchangeUsername; comment Change the username of the user into the new string -pattern clients.getUsers():bat[:oid,:str] +pattern clients.getUsers() (X_1:bat[:oid,:oid],X_2:bat[:oid,:str]) address CLTgetUsers; -comment return a BAT with user id and name available in the system +comment return a BAT with user id and one with name available in the system pattern clients.getPasswordHash(user:str):str address CLTgetPasswordHash; diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -807,18 +807,17 @@ str ALGtsort(bat *result, const bat *bid str ALGtsort_rev(bat *result, const bat *bid); str ALGvariance(dbl *res, const bat *bid); str ALGvariancep(dbl *res, const bat *bid); -str AUTHaddUser(oid *ret, Client *c, str *user, str *pass); -str AUTHchangePassword(Client *c, str *oldpass, str *passwd); -str AUTHchangeUsername(Client *c, str *olduser, str *newuser); -str AUTHcheckCredentials(oid *ret, Client *c, str *user, str *passwd, str *challenge, str *algo); -str AUTHgetPasswordHash(str *ret, Client *c, str *username); -str AUTHgetUsername(str *ret, Client *c); -str AUTHgetUsers(BAT **ret, Client *c); +str AUTHaddUser(oid *ret, Client c, str *user, str *pass); +str AUTHchangePassword(Client c, str *oldpass, str *passwd); +str AUTHchangeUsername(Client c, str *olduser, str *newuser); +str AUTHcheckCredentials(oid *ret, Client c, str *user, str *passwd, str *challenge, str *algo); +str AUTHgetPasswordHash(str *ret, Client c, str *username); +str AUTHgetUsername(str *ret, Client c); +str AUTHgetUsers(BAT **ret1, BAT **ret2, Client c); str AUTHinitTables(str *passwd); -str AUTHremoveUser(Client *c, str *username); -str AUTHrequireAdmin(Client *c); +str AUTHremoveUser(Client c, str *username); str AUTHresolveUser(str *ret, oid *uid); -str AUTHsetPassword(Client *c, str *username, str *passwd); +str AUTHsetPassword(Client c, str *username, str *passwd); str AUTHunlockVault(str *password); str BATPCREilike(bat *ret, const bat *b, const str *pat, const str *esc); str BATPCREilike2(bat *ret, const bat *b, const str *pat); diff --git a/monetdb5/ChangeLog b/monetdb5/ChangeLog --- a/monetdb5/ChangeLog +++ b/monetdb5/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog file for MonetDB5 # This file is updated with Maddlog +* Mon Sep 7 2015 Sjoerd Mullender <[email protected]> +- Changed client.getUsers to return two bats, one with the user id + and one with the user name. + * Sun Sep 6 2015 Sjoerd Mullender <[email protected]> - Implemented algebra.subdiff and algebra.subinter. The old functions algegra.tdiff and algebra.tinter are now officially deprecated. diff --git a/monetdb5/mal/Tests/tst830.mal b/monetdb5/mal/Tests/tst830.mal --- a/monetdb5/mal/Tests/tst830.mal +++ b/monetdb5/mal/Tests/tst830.mal @@ -16,15 +16,15 @@ exit MALException; io.print(id); # do a simple listing of users known - u := clients.getUsers(); - io.print(u); + (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 := clients.getUsers(); - io.print(u); + (u,n) := clients.getUsers(); + io.print(u,n); # forcefully set the password of the user test clients.setPassword("test", pw); diff --git a/monetdb5/mal/Tests/tst830.stable.out b/monetdb5/mal/Tests/tst830.stable.out --- a/monetdb5/mal/Tests/tst830.stable.out +++ b/monetdb5/mal/Tests/tst830.stable.out @@ -27,13 +27,13 @@ exit MALException:str; id := clients.addUser("checkpoint",pw); io.print(id); # do a simple listing of users known - u := clients.getUsers(); - io.print(u); + (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 := clients.getUsers(); - io.print(u); + (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 @@ -70,19 +70,19 @@ end user.main; MALException:addUser:user 'monetdb' already exists [ 1@0 ] [ 2@0 ] -#-------------------------# -# h t # name -# oid str # type -#-------------------------# -[ 0@0, "monetdb" ] -[ 1@0, "test" ] -[ 2@0, "checkpoint" ] -#-------------------------# -# h t # name -# oid str # type -#-------------------------# -[ 0@0, "monetdb" ] -[ 1@0, "test" ] +#--------------------------# +# h t t # name +# void void str # type +#--------------------------# +[ 0@0, 0@0, "monetdb" ] +[ 1@0, 1@0, "test" ] +[ 2@0, 2@0, "checkpoint" ] +#--------------------------# +# h t t # name +# void void str # type +#--------------------------# +[ 0@0, 0@0, "monetdb" ] +[ 1@0, 1@0, "test" ] InvalidCredentialsException:setPassword:The administrator cannot set its own password, use changePassword instead InvalidCredentialsException:changePassword:Access denied InvalidCredentialsException:checkCredentials:invalid credentials for user 'monetdb' 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 @@ -30,14 +30,14 @@ static str AUTHdecypherValue(str *ret, str *value); static str AUTHcypherValue(str *ret, str *value); -static str AUTHverifyPassword(int *ret, str *passwd); +static str AUTHverifyPassword(str *passwd); static BAT *user = NULL; static BAT *pass = NULL; static BAT *duser = NULL; static BUN -AUTHfindUser(str username) +AUTHfindUser(const char *username) { BATiter cni = bat_iterator(user); BUN p; @@ -56,10 +56,9 @@ AUTHfindUser(str username) * Requires the current client to be the admin user thread. If not the case, * this function returns an InvalidCredentialsException. */ -str -AUTHrequireAdmin(Client *c) { +static str +AUTHrequireAdmin(Client cntxt) { oid id; - Client cntxt = *c; if (cntxt == NULL) return(MAL_SUCCEED); @@ -82,9 +81,9 @@ AUTHrequireAdmin(Client *c) { * the given username. If not the case, this function returns an * InvalidCredentialsException. */ -str -AUTHrequireAdminOrUser(Client *c, str *username) { - oid id = (*c)->user; +static str +AUTHrequireAdminOrUser(Client cntxt, str *username) { + oid id = cntxt->user; char u[BUFSIZ] = ""; str user = u; str tmp = MAL_SUCCEED; @@ -202,7 +201,7 @@ AUTHinitTables(str *passwd) { if (passwd != NULL && *passwd != NULL) pw = *passwd; pw = mcrypt_BackendSum(pw, strlen(pw)); - msg = AUTHaddUser(&uid, &c, &user, &pw); + msg = AUTHaddUser(&uid, c, &user, &pw); free(pw); if (msg) return msg; @@ -221,7 +220,7 @@ AUTHinitTables(str *passwd) { str AUTHcheckCredentials( oid *uid, - Client *c, + Client cntxt, str *username, str *passwd, str *challenge, @@ -233,7 +232,7 @@ AUTHcheckCredentials( BUN p; BATiter passi; - rethrow("checkCredentials", tmp, AUTHrequireAdminOrUser(c, username)); + rethrow("checkCredentials", tmp, AUTHrequireAdminOrUser(cntxt, username)); assert(user); assert(pass); @@ -280,13 +279,13 @@ AUTHcheckCredentials( * return value of this function is the user id of the added user. */ str -AUTHaddUser(oid *uid, Client *c, str *username, str *passwd) +AUTHaddUser(oid *uid, Client cntxt, str *username, str *passwd) { BUN p; str tmp; str hash = NULL; - rethrow("addUser", tmp, AUTHrequireAdmin(c)); + rethrow("addUser", tmp, AUTHrequireAdmin(cntxt)); assert(user); assert(pass); @@ -295,7 +294,7 @@ AUTHaddUser(oid *uid, Client *c, str *us throw(ILLARG, "addUser", "username should not be nil"); if (*passwd == NULL || strNil(*passwd)) throw(ILLARG, "addUser", "password should not be nil"); - rethrow("addUser", tmp, AUTHverifyPassword(NULL, passwd)); + rethrow("addUser", tmp, AUTHverifyPassword(passwd)); /* ensure that the username is not already there */ p = AUTHfindUser(*username); @@ -322,13 +321,13 @@ AUTHaddUser(oid *uid, Client *c, str *us * Removes the given user from the administration. */ str -AUTHremoveUser(Client *c, str *username) +AUTHremoveUser(Client cntxt, str *username) { BUN p; oid id; str tmp; - rethrow("removeUser", tmp, AUTHrequireAdmin(c)); + rethrow("removeUser", tmp, AUTHrequireAdmin(cntxt)); assert(user); assert(pass); @@ -343,7 +342,7 @@ AUTHremoveUser(Client *c, str *username) id = p; /* find the name of the administrator and see if it equals username */ - if (id == (*c)->user) + if (id == cntxt->user) throw(MAL, "removeUser", "cannot remove yourself"); /* now, we got the oid, start removing the related tuples */ @@ -360,13 +359,13 @@ AUTHremoveUser(Client *c, str *username) * is modified. */ str -AUTHchangeUsername(Client *c, str *olduser, str *newuser) +AUTHchangeUsername(Client cntxt, str *olduser, str *newuser) { BUN p, q; str tmp; oid id; - rethrow("addUser", tmp, AUTHrequireAdminOrUser(c, olduser)); + rethrow("addUser", tmp, AUTHrequireAdminOrUser(cntxt, olduser)); /* precondition checks */ if (*olduser == NULL || strNil(*olduser)) @@ -397,7 +396,7 @@ AUTHchangeUsername(Client *c, str *oldus * set. */ str -AUTHchangePassword(Client *c, str *oldpass, str *passwd) +AUTHchangePassword(Client cntxt, str *oldpass, str *passwd) { BUN p; str tmp= NULL; _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
