dkim / exec im Interface vermeiden

X-Coder

New Member
Hi, auf meinem Server hatte ich das Problem dass exec aus Sicherheitsgründen gesperrt ist und ich es eigentlich nicht aktivieren will wenn es nicht unbedingt nötig ist. Daher kann so im Interface kein private key generiert werden. Es gibt auch keine Fehlermeldung im Interface, sondern nur im php-error log.

Daher habe ich in der Datei interface/web/mail/mail_domain_dkim_create.php das openssl php modul genutzt anstelle des exec-Befehls.
aus:
PHP:
    exec('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2> /dev/null', $output, $result);
    exec('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2> /dev/null', $privkey, $result);
    unlink("../../temp/random-data.bin");

wird:
PHP:
if(function_exists('openssl_pkey_new')){ //* use php's openssl lib if available
    $config = array(
        "private_key_bits" => $dkim_strength,
        "private_key_type" => OPENSSL_KEYTYPE_RSA,
    );

    $res = openssl_pkey_new($config);
    openssl_pkey_export($res, $privkey);
    if(!is_array($privkey)) $privkey = [$privkey];
    $public_key = openssl_pkey_get_details($res);
    $public_key = $public_key["key"];
}
else{ //* try it using exec (which might be blocked for security reasons!)
    exec('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2> /dev/null', $output, $result);
    exec('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2> /dev/null', $privkey, $result);
    unlink("../../temp/random-data.bin");
}

Da fehlt eigentlich nur noch eine Prüfung ob exec nutzbar ist. Oder ein Hinweis das openssl-Modul für php zu aktivieren.

Vielleicht kann dieser Patch in zukünftige ispconfig-Versionen?
 

Till

Administrator
Das ist sicherlich eine gute Ergänzung. Magst Du es vielleicht im ISPconfig Bugtracker posten?
 

Werbung

Top