DKIM generate problem (app exec_safe )

Discussion in 'Developers' Forum' started by zsirmo, Aug 2, 2019.

Tags:
  1. zsirmo

    zsirmo New Member

    Hello,

    I found a problem with ispconfig git (ispconfig3-stable-3.1-8f1357074fec6a5a74bd3531a38a581cad8550ab)

    When call ajax:
    https://foobar:8080/mail/ajax_get_j...blic=ul&dkim_selector=server&type=create_dkim

    the system make two app->system->exec_safe (interface/web/mail/ajax_get_json.php line 56 and 57) :
    $app->system->exec_safe('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2> /dev/null', $output, $result);
    $app->system->exec_safe('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2> /dev/null', $privkey, $result);

    But a problem with in interface/lib/classes/system.inc.php, where check $arg_count = func_num_args(); and substr_count($cmd, '?')

    Original calls with 3 parameters, but this "old" call, no placeholders used, but require output return.

    Error log:
    PHP Warning: Placeholder count not matching argument list. in /usr/local/ispconfig/interface/lib/classes/system.inc.php on line 69

    I create workaround patch:

    Code:
    --- ajax_get_json.php   2019-08-01 19:20:52.000000000 +0200
    +++ /usr/local/ispconfig/interface/web/mail/ajax_get_json.php   2019-08-02 13:34:38.996467996 +0200
    @@ -54,11 +54,15 @@
         if ($dkim_strength=='') $dkim_strength = 2048;
         
         $rnd_val = $dkim_strength * 10;
    -   $app->system->exec_safe('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2> /dev/null', $output, $result);
    -   $app->system->exec_safe('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2> /dev/null', $privkey, $result);
    -   unlink("../../temp/random-data.bin");
    -   $dkim_private='';
    -   foreach($privkey as $values) $dkim_private=$dkim_private.$values."\n";
    +   $app->system->exec_safe('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2>/dev/null');
    +   $app->system->exec_safe('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2>/dev/null >../../temp/privkey.bin');
    +   $f = fopen("../../temp/privkey.bin", "r");
    +   $dkim_private = fread($f,8192);
    +   fclose($f);
    +//   unlink("../../temp/random-data.bin");
    +//   unlink("../../temp/privkey.bin");
    +//   $dkim_private='';
    +//   foreach($privkey as $values) $dkim_private=$dkim_private.$values."\n";
         if ($dkim_public != '' && $maildomain != '') {
             if (validate_domain($domain) && validate_selector($dkim_selector) ) {
    
     
    till likes this.
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Thank you for your report. Just uploaded the fix to git stable branch.
     
  3. zsirmo

    zsirmo New Member

    Welcome!

    But patch no check file exists, and no error handling!
     

Share This Page