This file is indexed.

/usr/lib/nanoweb/modules/mod_auth_pgsql.php is in nanoweb 2.2.9-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php

/*

Nanoweb PostgreSQL Auth Module
==============================

Copyright (C) 2002 Szilveszter Farkas aka. Phanatic <linux@psoftwares.hu>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Usage
=====

Use these directives in a conf/vhost/access file to use mod_auth_pgsql

AuthRealm      = your auth realm name here
AuthRequire    = PGSQL
AuthPgsqlHost  = localhost
AuthPgsqlUser  = db_user
AuthPgsqlPass  = db_pass
AuthPgsqlDB    = db_name
AuthPgsqlTable = table_name
AuthPgsqlPassType = plain | md5
AuthPgsqlLoginColumn = login_field_name
AuthPgsqlPassColumn  = password_field_name

Password types are 

plain : password is plaintext
md5   : password is hashed using the md5 algorithm

*/

class mod_auth_pgsql {

	function mod_auth_pgsql() {

		$this->modtype="auth_pgsql";
		$this->modname="PostgreSQL authentication";

	}

	function auth($user, $pass, $args) {

		$host=access_query("authpgsqlhost", 0);
		$dbuser=access_query("authpgsqluser", 0);
		$dbpass=access_query("authpgsqlpass", 0);
		$dbname=access_query("authpgsqldb", 0);
		$tbname=access_query("authpgsqltable", 0);
		$lname=access_query("authpgsqllogincolumn", 0);
		$pname=access_query("authpgsqlpasscolumn", 0);
		
		$ps=trim($pass);
		
		switch (strtolower(access_query("authpgsqlpasstype", 0))) {

			case "md5":
			$pstr=md5($ps); 
			break;

			case "plain":
			default:
			$pstr=$ps;
		
		}
		
		if (is_callable("pg_connect")) {
		
			if ($cid=@pg_connect("host=$host user=$dbuser password=$dbpass dbname=$dbname")) {

				if ($q=@pg_query($cid, "SELECT * FROM $tbname WHERE $lname = '$user' AND $pname = '$pstr'")) {
					$r=pg_num_rows($q);
					pg_free_result($q);

					$auth=($r>0);
					
				} else {

					techo("WARN: mod_auth_pgsql could not fetch '$lname' and '$pname' from table '$tbname'", NW_EL_WARNING);
				
				}

			} else {

				techo("WARN: mod_auth_pgsql could not connect to database '$dbname@$host'", NW_EL_WARNING);
			
			}

		} else {

			techo("WARN: postgresql extension not built in your PHP binary", NW_EL_WARNING);
		
		}
		
		return($auth);
	
	}

}

?>