backend_pgsql.h File Reference

#include "/usr/include/postgresql/libpq-fe.h"
#include <security/pam_modules.h>
#include "pam_kmux_options.h"
Include dependency graph for backend_pgsql.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * pgsql_db_connect (const modopt_t *options)
 Connect to postgres database.
void pgsql_db_disconnect (void *vconn)
 Terminate database connection.
int pgsql_expand_query (char **command, const char **values, const char *query, const char *service, const char *user, const char *passwd, const char *rhost, const char *raddr, const modopt_t *options)
 Build a SQL-query. This function build a valid SQL-query. Some variables like u for user or c for column_password are substitutet by their meaning.
int pgsql_exec_param (void *vconn, void **vres, const char *query, const char *service, const char *user, const char *passwd, const char *rhost, const modopt_t *options)
 Execute a query on the postgres database.
int pgsql_backend_authenticate (const char *service, const char *user, const char *passwd, const char *rhost, const modopt_t *options)
 Authenticate against postgres backend.

Detailed Description

pam_kmux-postgres-API In this file all pam-kmux-postgres-backend-API-functions are defined. This is based on the pam_pgsql-Module programmed by William Grzybowski <william@agencialivre.com.br>

Author:
Julian Thome
Date:
2009-11-09

Function Documentation

int pgsql_backend_authenticate ( const char *  service,
const char *  user,
const char *  passwd,
const char *  rhost,
const modopt_t options 
)

Authenticate against postgres backend.

This function tries to finds out the database type given by the modopt_t *options object and run a authentification query on it.

Parameters:
service Service character array.
user Character array contains username/uid of the user that tries to change password.
passwd Character array contains the password of the user.
rhost Character array contains the value of PAM_RHOST. This is only needed if you need something like this in your defined queries.
options Struct which represents exactly one database connection.
Return values:
PAM_SUCCESS Successfully authenticate against backend.
PAM_AUTH_ERR Malformed options (passwd, options or user = NULL), connection error during dial-up, password comarison between database-stored-password and entered password fails, or query expandation fails.
PAM_AUTHINFO_UNAVAIL Fetched no valid result.
void* pgsql_db_connect ( const modopt_t options  ) 

Connect to postgres database.

This functinos establish a postgres database connection and returns a database handle.

Parameters:
options A modopt_t struct, which contains the database information will be used establish a database connection.
Returns:
A PGconn-pgsql-database-handle if everything is ok, NULL if something went wrong trying to establish a connection.
void pgsql_db_disconnect ( void *  vconn  ) 

Terminate database connection.

This function takes a PGconn-postgres-handle-firebird-database-handle an release it properly.

Parameters:
vconn A connection handle to a postgres database.
Returns:
Nothing to return.
int pgsql_exec_param ( void *  vconn,
void **  vres,
const char *  query,
const char *  service,
const char *  user,
const char *  passwd,
const char *  rhost,
const modopt_t options 
)

Execute a query on the postgres database.

This function tries to find out the database type given by the modopt_t *options object and run a query on it.

Parameters:
vconn Postgres database connection handle.
vres PGresult query result.
query Contains the unhandled SQL-query (still contains variables like u or c, ...).
service Service name character array.
user Character array which contains username/uid of the user that tries to change password.
passwd The probably hashified password which should be entered into database.
rhost Character array contains the value of PAM_RHOST. This is only needed if you need something like this in your defined queries.
options Struct which represents exactly one database connection.
Return values:
PAM_SUCCESS Successfully executed query.
PAM_AUTH_ERR Failure durin password encryption.
int pgsql_expand_query ( char **  command,
const char **  values,
const char *  query,
const char *  service,
const char *  user,
const char *  passwd,
const char *  rhost,
const char *  raddr,
const modopt_t options 
)

Build a SQL-query. This function build a valid SQL-query. Some variables like u for user or c for column_password are substitutet by their meaning.

Parameters:
command In this char arry the resulting query will be store.
values This array will be filled with variable-values where value[0] corresponds to the first variable in the query($1), value[1] corresponds to the second variable in the query ($2) ... and so on.
query Contains the unhandled SQL-query (still contains variables like u or c, ...).
service Service name character array.
user Character array which contains username/uid of the user that tries to change password.
passwd The probably hashified password which should be entered into database.
rhost Character array contains the value of PAM_RHOST. This is only needed if you need something like this in your defined queries.
raddr Contains the address of rhost
options Struct which represents exactly one database connection.
Returns:
This function returns the length of the expanded query. So the returnvalue '0' indicated the occurrence of an error.
Generated on Mon Apr 5 22:28:46 2010 for pam_kmux by  doxygen 1.6.3