Пример #1
0
include_once dirname(__FILE__) . '/ressources/class.ini.inc';
if (posix_getuid() != 0) {
    die("Cannot be used in web server mode\n\n");
}
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . "/framework/frame.class.inc";
include_once dirname(__FILE__) . "/ressources/class.user.inc";
include_once dirname(__FILE__) . "/ressources/class.ldap.inc";
$ldap = new clladp();
$conf[] = "ldap_servers: ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/";
$conf[] = "ldap_version: 3";
$conf[] = "ldap_search_base: dc=organizations,{$ldap->suffix}";
$conf[] = "ldap_scope: sub";
$conf[] = "ldap_filter: uid=%u";
$conf[] = "ldap_auth_method: bind";
$conf[] = "ldap_bind_dn: cn={$ldap->ldap_admin},{$ldap->suffix}";
$conf[] = "ldap_password: {$ldap->ldap_password}";
$conf[] = "ldap_timeout: 10";
$conf[] = "";
echo "Starting......: saslauthd ldap:/{$ldap->ldap_host}:{$ldap->ldap_port}\n";
@file_put_contents(saslauthd_conf(), @implode("\n", $conf));
function saslauthd_conf()
{
    if (is_file("/etc/saslauthd.conf")) {
        return "/etc/saslauthd.conf";
    }
    if (is_file("/usr/local/etc/saslauthd.conf")) {
        return "/usr/local/etc/saslauthd.conf";
    }
    return "/etc/saslauthd.conf";
}
Пример #2
0
function build()
{
    $sock = new sockets();
    $unix = new unix();
    $EnableMechLogin = $sock->GET_INFO("EnableMechLogin");
    $EnableMechPlain = $sock->GET_INFO("EnableMechPlain");
    $EnableMechDigestMD5 = $sock->GET_INFO("EnableMechDigestMD5");
    $EnableMechCramMD5 = $sock->GET_INFO("EnableMechCramMD5");
    if (!is_numeric($EnableMechLogin)) {
        $EnableMechLogin = 1;
    }
    if (!is_numeric($EnableMechPlain)) {
        $EnableMechPlain = 1;
    }
    if (!is_numeric($EnableMechDigestMD5)) {
        $EnableMechDigestMD5 = 0;
    }
    if (!is_numeric($EnableMechCramMD5)) {
        $EnableMechCramMD5 = 0;
    }
    if ($EnableMechLogin == 1) {
        $mech_list[] = "LOGIN";
    }
    if ($EnableMechPlain == 1) {
        $mech_list[] = "PLAIN";
    }
    if ($EnableMechDigestMD5 == 1) {
        $mech_list[] = "DIGEST-MD5";
    }
    if ($EnableMechCramMD5 == 1) {
        $mech_list[] = "CRAM-MD5";
    }
    $ldap = new clladp();
    $conf[] = "ldap_servers: ldap://{$ldap->ldap_host}:{$ldap->ldap_port}/";
    $conf[] = "ldap_version: 3";
    $conf[] = "ldap_search_base: dc=organizations,{$ldap->suffix}";
    $conf[] = "ldap_scope: sub";
    $conf[] = "ldap_filter: uid=%u";
    $conf[] = "ldap_auth_method: bind";
    $conf[] = "ldap_bind_dn: cn={$ldap->ldap_admin},{$ldap->suffix}";
    $conf[] = "ldap_password: {$ldap->ldap_password}";
    $conf[] = "ldap_timeout: 10";
    $conf[] = "";
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} ldap://{$ldap->ldap_host}:{$ldap->ldap_port}\n";
    }
    @file_put_contents(saslauthd_conf(), @implode("\n", $conf));
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}  " . @implode(" ", $mech_list) . "\n";
    }
    $f[] = "pwcheck_method: saslauthd";
    $f[] = "mech_list: " . @implode(" ", $mech_list);
    $f[] = "minimum_layer: 0";
    $f[] = "log_level: 5";
    @mkdir('/etc/postfix/sasl', 0755);
    @file_put_contents('/etc/postfix/sasl/smtpd.conf', @implode("\n", $f));
    if (!is_file("/usr/lib/sasl2/smtpd.conf")) {
        $ln = $unix->find_program("ln");
        shell_exec("{$ln} -s /etc/postfix/sasl/smtpd.conf  /usr/lib/sasl2/smtpd.conf >/dev/null 2>&1");
    }
}