Back to index

php5  5.3.10
Functions
auth.c File Reference
#include "sqliteInt.h"

Go to the source code of this file.

Functions

int sqlite_set_authorizer (sqlite *db, int(*xAuth)(void *, int, const char *, const char *, const char *, const char *), void *pArg)
static void sqliteAuthBadReturnCode (Parse *pParse, int rc)
void sqliteAuthRead (Parse *pParse, Expr *pExpr, SrcList *pTabList)
int sqliteAuthCheck (Parse *pParse, int code, const char *zArg1, const char *zArg2, const char *zArg3)
void sqliteAuthContextPush (Parse *pParse, AuthContext *pContext, const char *zContext)
void sqliteAuthContextPop (AuthContext *pContext)

Function Documentation

int sqlite_set_authorizer ( sqlite db,
int(*)(void *, int, const char *, const char *, const char *, const char *)  xAuth,
void *  pArg 
)

Definition at line 73 of file auth.c.

 {
  db->xAuth = xAuth;
  db->pAuthArg = pArg;
  return SQLITE_OK;
}

Here is the caller graph for this function:

static void sqliteAuthBadReturnCode ( Parse pParse,
int  rc 
) [static]

Definition at line 87 of file auth.c.

                                                          {
  sqliteErrorMsg(pParse, "illegal return value (%d) from the "
    "authorization function - should be SQLITE_OK, SQLITE_IGNORE, "
    "or SQLITE_DENY", rc);
  pParse->rc = SQLITE_MISUSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqliteAuthCheck ( Parse pParse,
int  code,
const char *  zArg1,
const char *  zArg2,
const char *  zArg3 
)

Definition at line 167 of file auth.c.

 {
  sqlite *db = pParse->db;
  int rc;

  if( db->init.busy || db->xAuth==0 ){
    return SQLITE_OK;
  }
  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);
  if( rc==SQLITE_DENY ){
    sqliteErrorMsg(pParse, "not authorized");
    pParse->rc = SQLITE_AUTH;
  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
    rc = SQLITE_DENY;
    sqliteAuthBadReturnCode(pParse, rc);
  }
  return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqliteAuthContextPop ( AuthContext pContext)

Definition at line 212 of file auth.c.

                                                {
  if( pContext->pParse ){
    pContext->pParse->zAuthContext = pContext->zAuthContext;
    pContext->pParse = 0;
  }
}

Here is the caller graph for this function:

void sqliteAuthContextPush ( Parse pParse,
AuthContext pContext,
const char *  zContext 
)

Definition at line 196 of file auth.c.

 {
  pContext->pParse = pParse;
  if( pParse ){
    pContext->zAuthContext = pParse->zAuthContext;
    pParse->zAuthContext = zContext;
  }
}

Here is the caller graph for this function:

void sqliteAuthRead ( Parse pParse,
Expr pExpr,
SrcList pTabList 
)

Definition at line 103 of file auth.c.

 {
  sqlite *db = pParse->db;
  int rc;
  Table *pTab;          /* The table being read */
  const char *zCol;     /* Name of the column of the table */
  int iSrc;             /* Index in pTabList->a[] of table being read */
  const char *zDBase;   /* Name of database being accessed */
  TriggerStack *pStack; /* The stack of current triggers */

  if( db->xAuth==0 ) return;
  assert( pExpr->op==TK_COLUMN );
  for(iSrc=0; iSrc<pTabList->nSrc; iSrc++){
    if( pExpr->iTable==pTabList->a[iSrc].iCursor ) break;
  }
  if( iSrc>=0 && iSrc<pTabList->nSrc ){
    pTab = pTabList->a[iSrc].pTab;
  }else if( (pStack = pParse->trigStack)!=0 ){
    /* This must be an attempt to read the NEW or OLD pseudo-tables
    ** of a trigger.
    */
    assert( pExpr->iTable==pStack->newIdx || pExpr->iTable==pStack->oldIdx );
    pTab = pStack->pTab;
  }else{
    return;
  }
  if( pTab==0 ) return;
  if( pExpr->iColumn>=0 ){
    assert( pExpr->iColumn<pTab->nCol );
    zCol = pTab->aCol[pExpr->iColumn].zName;
  }else if( pTab->iPKey>=0 ){
    assert( pTab->iPKey<pTab->nCol );
    zCol = pTab->aCol[pTab->iPKey].zName;
  }else{
    zCol = "ROWID";
  }
  assert( pExpr->iDb<db->nDb );
  zDBase = db->aDb[pExpr->iDb].zName;
  rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, 
                 pParse->zAuthContext);
  if( rc==SQLITE_IGNORE ){
    pExpr->op = TK_NULL;
  }else if( rc==SQLITE_DENY ){
    if( db->nDb>2 || pExpr->iDb!=0 ){
      sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited", 
         zDBase, pTab->zName, zCol);
    }else{
      sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
    }
    pParse->rc = SQLITE_AUTH;
  }else if( rc!=SQLITE_OK ){
    sqliteAuthBadReturnCode(pParse, rc);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: