backend_pgsql.c File Reference

#include "common.h"
#include "backend_common.h"
#include <postgresql/libpq-fe.h>
#include "backend_pgsql.h"
Include dependency graph for backend_pgsql.c:

Functions

char * build_conninfo (modopt_t *options)
 Build connection query This function buils a connection query from the options contained by the modopt_t struct. The result is needed to establish a connection to postgres database.
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.

Variables

pam_modopt_t pamod_options

Detailed Description

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

Author:
Julian Thome
Date:
2009-11-11

Function Documentation

char* build_conninfo ( modopt_t options  ) 

Build connection query This function buils a connection query from the options contained by the modopt_t struct. The result is needed to establish a connection to postgres database.

Parameters:
options modopt_t struct which contains connection informations.
Returns:
NULL Something went wrong.
char* A connection query was builded.
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.

Variable Documentation

C-Structure which contains pam-module options. In this global variable the pam-module options like debug level or the path of the configuration file are stored.

Generated on Mon Apr 5 22:28:45 2010 for pam_kmux by  doxygen 1.6.3