Reorder parameters on the sqlite3_user_*() interfaces for consistency.

Add the first TCL test cases.

FossilOrigin-Name: 2f6d8f32eef526b5912f42ab467e3c7812480d8b
This commit is contained in:
drh
2014-09-11 00:27:53 +00:00
parent 09e60541ae
commit d39c40ff5e
8 changed files with 257 additions and 43 deletions
+6 -6
View File
@@ -36,8 +36,8 @@
int sqlite3_user_authenticate(
sqlite3 *db, /* The database connection */
const char *zUsername, /* Username */
int nPW, /* Number of bytes in aPW[] */
const char *aPW /* Password or credentials */
const char *aPW, /* Password or credentials */
int nPW /* Number of bytes in aPW[] */
);
/*
@@ -53,9 +53,9 @@ int sqlite3_user_authenticate(
int sqlite3_user_add(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to be added */
int isAdmin, /* True to give new user admin privilege */
const char *aPW, /* Password or credentials */
int nPW, /* Number of bytes in aPW[] */
const char *aPW /* Password or credentials */
int isAdmin /* True to give new user admin privilege */
);
/*
@@ -68,9 +68,9 @@ int sqlite3_user_add(
int sqlite3_user_change(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to change */
int isAdmin, /* Modified admin privilege for the user */
const char *aPW, /* New password or credentials */
int nPW, /* Number of bytes in aPW[] */
const char *aPW /* Modified password or credentials */
int isAdmin /* Modified admin privilege for the user */
);
/*
+15 -12
View File
@@ -7,24 +7,24 @@ activated:
int sqlite3_user_authenticate(
sqlite3 *db, /* The database connection */
const char *zUsername, /* Username */
int nPW, /* Number of bytes in aPW[] */
const void *aPW /* Password or credentials */
const char *aPW, /* Password or credentials */
int nPW /* Number of bytes in aPW[] */
);
int sqlite3_user_add(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to be added */
int isAdmin, /* True to give new user admin privilege */
const char *aPW, /* Password or credentials */
int nPW, /* Number of bytes in aPW[] */
const void *aPW /* Password or credentials */
int isAdmin /* True to give new user admin privilege */
);
int sqlite3_user_change(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to change */
int isAdmin, /* Modified admin privilege for the user */
const void *aPW, /* Modified password or credentials */
int nPW, /* Number of bytes in aPW[] */
const void *aPW /* Modified password or credentials */
int isAdmin /* Modified admin privilege for the user */
);
int sqlite3_user_delete(
@@ -71,12 +71,15 @@ check fails, then the ATTACH-ed database is unreadable [1g].
The sqlite3_user_add() interface can be used (by an admin user only)
to create a new user. When called on a no-authentication-required
database, this routine converts the database into an authentication-
required database [3], automatically makes the added user an
administrator [1b], and logs in the current connection as that user [1a].
The sqlite3_user_add() interface only works for the "main" database, not
for any ATTACH-ed databases. Any call to sqlite3_user_add() by a
non-admin user results in an error.
database and when A is true, the sqlite3_user_add(D,U,P,N,A) routine
converts the database into an authentication-required database and
logs the database connection D in using user U with password P,N.
To convert a no-authentication-required database into an authentication-
required database, the isAdmin parameter must be true. If
sqlite3_user_add(D,U,P,N,A) is called on a no-authentication-required
database and A is false, then the call fails with an SQLITE_AUTH error.
Any call to sqlite3_user_add() by a non-admin user results in an error.
Hence, to create a new, unencrypted, authentication-required database,
the call sequence is:
+7 -7
View File
@@ -177,8 +177,8 @@ void sqlite3CryptFunc(
int sqlite3_user_authenticate(
sqlite3 *db, /* The database connection */
const char *zUsername, /* Username */
int nPW, /* Number of bytes in aPW[] */
const char *zPW /* Password or credentials */
const char *zPW, /* Password or credentials */
int nPW /* Number of bytes in aPW[] */
){
int rc;
u8 authLevel = UAUTH_Fail;
@@ -217,9 +217,9 @@ int sqlite3_user_authenticate(
int sqlite3_user_add(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to be added */
int isAdmin, /* True to give new user admin privilege */
const char *aPW, /* Password or credentials */
int nPW, /* Number of bytes in aPW[] */
const char *aPW /* Password or credentials */
int isAdmin /* True to give new user admin privilege */
){
sqlite3_stmt *pStmt;
int rc;
@@ -248,7 +248,7 @@ int sqlite3_user_add(
if( rc ) return rc;
if( db->auth.zAuthUser==0 ){
assert( isAdmin!=0 );
sqlite3_user_authenticate(db, zUsername, nPW, aPW);
sqlite3_user_authenticate(db, zUsername, aPW, nPW);
}
return SQLITE_OK;
}
@@ -263,9 +263,9 @@ int sqlite3_user_add(
int sqlite3_user_change(
sqlite3 *db, /* Database connection */
const char *zUsername, /* Username to change */
int isAdmin, /* Modified admin privilege for the user */
const char *aPW, /* Modified password or credentials */
int nPW, /* Number of bytes in aPW[] */
const char *aPW /* Modified password or credentials */
int isAdmin /* Modified admin privilege for the user */
){
sqlite3_stmt *pStmt;
if( db->auth.authLevel<UAUTH_User ){