~ubuntu-branches/ubuntu/dapper/freeradius/dapper-updates

« back to all changes in this revision

Viewing changes to src/modules/rlm_sql/drivers/rlm_sql_postgresql/sql_postgresql.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Hampson
  • Date: 2004-12-29 20:19:42 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041229201942-uj2e95la965uthc7
Tags: 1.0.1-2
* freeradius-dialupadmin Suggests php4-mysql | php4-pgsql
   Closes: #279419
* Added a two-second pause to restart in init.d script
   Closes: #262635
* FreeRADIUS module packages now depend on the same source
  version of the main FreeRADIUS package.
   Closes: #284353
* FreeRADIUS-dialupadmin's default paths in admin.conf are
  now correct.
   Closes: #280942
* FreeRADIUS-dialupadmin's help.php3 can now find README.
   Closes: #280941
* Fixes stolen from 1.0.2 CVS:
  - Bug fix to make udpfromto code work
  - radrelay shouldn't dump core if it can't read a VP from the
    detail file.
  - Only initialize the random pool once.
  - In rlm_sql, don't escape characters twice.
  - In rlm_ldap, only claim Auth-Type if a plain text password is present.
  - Locking fixes in threading code
  - Fix building on gcc-4.0 by not trying to access static auth_port from
    other files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * sql_postgresql.c             Postgresql rlm_sql driver
3
3
 *
4
 
 * Version:     $Id: sql_postgresql.c,v 1.30.2.2 2003/08/28 11:30:12 pnixon Exp $
 
4
 * Version:     $Id: sql_postgresql.c,v 1.38 2004/02/26 19:04:36 aland Exp $
5
5
 *
6
6
 *   This program is free software; you can redistribute it and/or modify
7
7
 *   it under the terms of the GNU General Public License as published by
159
159
                port = "";
160
160
        }
161
161
 
162
 
        sqlsocket->conn = (rlm_sql_postgres_sock *)rad_malloc(sizeof(rlm_sql_postgres_sock));
 
162
        if (!sqlsocket->conn) {
 
163
                sqlsocket->conn = (rlm_sql_postgres_sock *)rad_malloc(sizeof(rlm_sql_postgres_sock));
 
164
                if (!sqlsocket->conn) {
 
165
                        return -1;
 
166
                }
 
167
        }
163
168
 
164
169
        pg_sock = sqlsocket->conn;
 
170
        memset(pg_sock, 0, sizeof(*pg_sock));
165
171
 
166
172
        snprintf(connstring, sizeof(connstring),
167
173
                        "dbname=%s%s%s%s%s user=%s password=%s",
202
208
        }
203
209
 
204
210
        pg_sock->result = PQexec(pg_sock->conn, querystr);
205
 
                /* Returns a result pointer or possibly a NULL pointer. 
 
211
                /* Returns a result pointer or possibly a NULL pointer.
206
212
                 * A non-NULL pointer will generally be returned except in
207
213
                 * out-of-memory conditions or serious errors such as inability
208
214
                 * to send the command to the backend. If a NULL is returned,
211
217
                 */
212
218
        if (!pg_sock->result)
213
219
        {
214
 
                radlog(L_ERR, "rlm_sql_postgresql: PostgreSQL Query failed Error: %s", 
 
220
                radlog(L_ERR, "rlm_sql_postgresql: PostgreSQL Query failed Error: %s",
215
221
                                PQerrorMessage(pg_sock->conn));
216
222
                return  SQL_DOWN;
217
223
        } else {
280
286
 *************************************************************************/
281
287
static int sql_destroy_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
282
288
{
283
 
        rlm_sql_postgres_sock *pg_sock = sqlsocket->conn;
284
 
 
285
 
        free(pg_sock);
 
289
        free(sqlsocket->conn);
 
290
        sqlsocket->conn = NULL;
286
291
        return 0;
287
292
}
288
293