This file is indexed.

/usr/share/phamm/lib/login.php is in phamm 0.5.18-3.1.

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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/*
* Autentication functions
*
* @package Phamm
*/

/*
* Phamm - http://www.phamm.org - <team@phamm.org>
* Copyright (C) 2004,2008 Alessandro De Zorzi and Mirko Grava
*
* This file is part of Phamm.
*  
* 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 of the License, 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
*/

/**
* Try to generate DN from $login_username
*
* @author Alessandro De Zorzi <adezorzi AT rhx DOT it>
*
* @param string $login_username
* @return string $dn
**/

function login_dn_costructor($login_username)
{
    // @todo $proposed will be real DN and level
    if (strpos($login_username, '=') && strpos($login_username, ','))
    {
        $proposed["dn"] = $login_username;
	$proposed["login_username"] = $login_username;
    }

    elseif (strpos($login_username, '@'))
    {
        $login = explode ('@',$login_username);

	// Postmaster
        if ( $login[0] == PHAMM_DOMAIN_ADMIN_NAME )
        {
            $proposed["dn"] = 'cn='.$login[0].',vd='.$login[1].','.LDAP_BASE;
            $proposed["level"] = 4;
	    $proposed["domain"] = $login[1];
	    $proposed["login_username"] = $login_username;
        }

	// User
        else
        {
            $proposed["dn"] = 'mail='.$login_username.',vd='.$login[1].','.LDAP_BASE;
            $proposed["level"] = 2;
	    $proposed["domain"] = $login[1];
	    $proposed["login_username"] = $login_username;
        }
    }

    // Manager
    elseif ('cn='.$login_username.','.SUFFIX == BINDDN)
    {
        $proposed["dn"] = 'cn='.$login_username.','.SUFFIX;
        $proposed["level"] = 10;
	$proposed["domain"] = '';
	$proposed["login_username"] = $login_username;
    }
    
    // Login user without @DOMAIN
    elseif (defined('DEFAULT_DOMAIN'))
    {
        $proposed["dn"] = 'mail='.$login_username.'@'.DEFAULT_DOMAIN.',vd='.DEFAULT_DOMAIN.','.LDAP_BASE;
	$proposed["level"] = 2;
	$proposed["domain"] = DEFAULT_DOMAIN;
	$proposed["login_username"] = $login_username.'@'.DEFAULT_DOMAIN;
    }

    // Postmaster without postmaster@
    else
    {
	$proposed["dn"] = 'cn=postmaster,vd='.$login_username.','.LDAP_BASE;
	$proposed["level"] = 4;
	$proposed["domain"] = $login_username;
	$proposed["login_username"] = 'postmaster@'.$login_username;
    }

    return $proposed;
}


/**
* Try login
*
* @todo Clean values with special functions
*
* @param string $dn
* @param string $login_password
* @return mixed
**/

function login_try($connect, $proposed, $login_password,$login_username)
{
    $r = ldap_bind($connect, $proposed["dn"], $login_password);

    if ($r)
    {
        $_SESSION["login"]["dn"] = strtolower($proposed["dn"]);
        $_SESSION["phamm"]["domain"] = strtolower($proposed["domain"]);
        $_SESSION["login"]["username"] = strtolower($proposed["login_username"]);
        
	$_SESSION["login"]["level"] = $proposed["level"];
        $_SESSION["login"]["password"] = $login_password; // @todo crypt it

        return true;
    }

    return false;
}

/**
* Try bind
*
* @todo Clean values with special functions
*
* @param string $dn
* @param string $password
* @return bool $r
**/

function bind_try($connect, $dn, $password)
{
    //$r = @ldap_bind($connect, $proposed["dn"], $login_password);
    $r = ldap_bind($connect, $dn, $password);

    return $r;
}


/**
* Check if user are logged
*
* @return mixed
**/

function login_check()
{
    if (isset($_SESSION["login"]["dn"]))
        return true;

    else
        return false;
}


/**
* Destroy user session
*
* @return mixed
**/

function logout()
{
    session_destroy();
}

?>