Annotation of pkgsrc/databases/phpldapadmin/patches/patch-lib_functions.php, revision 1.1

1.1     ! taca        1: $NetBSD$
        !             2: 
        !             3: * Add support for SHA512 with OpenLDAP from repository,
        !             4:        21959715c3d6f204dd6c35b2e313eb2d4a01d22a.
        !             5: 
        !             6: --- lib/functions.php.orig     2011-10-27 02:07:09.000000000 +0000
        !             7: +++ lib/functions.php
        !             8: @@ -1471,10 +1471,10 @@ function get_next_number($base,$attr,$in
        !             9:                        for ($i=0;$i<count($autonum);$i++) {
        !            10:                                $num = $autonum[$i] < $minNumber ? $minNumber : $autonum[$i];
        !            11:  
        !            12: -                              /* If we're at the end of the list, or we've found a gap between this number and the 
        !            13: -                                 following, use the next available number in the gap. */ 
        !            14: -                              if ($i+1 == count($autonum) || $autonum[$i+1] > $num+1) 
        !            15: -                                      return $autonum[$i] >= $num ? $num+1 : $num; 
        !            16: +                              /* If we're at the end of the list, or we've found a gap between this number and the
        !            17: +                                 following, use the next available number in the gap. */
        !            18: +                              if ($i+1 == count($autonum) || $autonum[$i+1] > $num+1)
        !            19: +                                      return $autonum[$i] >= $num ? $num+1 : $num;
        !            20:                        }
        !            21:  
        !            22:                        # If we didnt find a suitable gap and are all above the minNumber, we'll just return the $minNumber
        !            23: @@ -2114,7 +2114,7 @@ function password_types() {
        !            24:                'md5crypt'=>'md5crypt',
        !            25:                'sha'=>'sha',
        !            26:                'smd5'=>'smd5',
        !            27: -              'ssha'=>'ssha'
        !            28: +              'ssh512'=>'ssh512'
        !            29:        );
        !            30:  }
        !            31:  
        !            32: @@ -2123,7 +2123,7 @@ function password_types() {
        !            33:   *
        !            34:   * @param string The password to hash in clear text.
        !            35:   * @param string Standard LDAP encryption type which must be one of
        !            36: - *        crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear.
        !            37: + *        crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, sha512, or clear.
        !            38:   * @return string The hashed password.
        !            39:   */
        !            40:  function password_hash($password_clear,$enc_type) {
        !            41: @@ -2216,6 +2216,16 @@ function password_hash($password_clear,$
        !            42:  
        !            43:                        break;
        !            44:  
        !            45: +              case 'sha512':
        !            46: +                      if (function_exists('openssl_digest') && function_exists('base64_encode')) {
        !            47: +                              $new_value = sprintf('{SHA512}%s', base64_encode(openssl_digest($password_clear, 'sha512', true)));
        !            48: +
        !            49: +                      } else {
        !            50: +                              error(_('Your PHP install doest not have the openssl_digest() or base64_encode() function. Cannot do SHA512 hashes. '),'error','index.php');
        !            51: +                      }
        !            52: +
        !            53: +            break;
        !            54: +
        !            55:                case 'clear':
        !            56:                default:
        !            57:                        $new_value = $password_clear;
        !            58: @@ -2379,6 +2389,15 @@ function password_check($cryptedpassword
        !            59:  
        !            60:                        break;
        !            61:  
        !            62: +                      # SHA512 crypted passwords
        !            63: +              case 'sha512':
        !            64: +                      if (strcasecmp(password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
        !            65: +                              return true;
        !            66: +                      else
        !            67: +                              return false;
        !            68: +
        !            69: +                      break;
        !            70: +
        !            71:                # No crypt is given assume plaintext passwords are used
        !            72:                default:
        !            73:                        if ($plainpassword == $cryptedpassword)
        !            74: @@ -2782,7 +2801,7 @@ function draw_formatted_dn($server,$entr
        !            75:  
        !            76:        $formats = $_SESSION[APPCONFIG]->getValue('appearance','tree_display_format');
        !            77:  
        !            78: -      foreach ($formats as $format) { 
        !            79: +      foreach ($formats as $format) {
        !            80:                $has_none = false;
        !            81:                preg_match_all('/%[a-zA-Z_0-9]+/',$format,$tokens);
        !            82:                $tokens = $tokens[0];

CVSweb <webmaster@jp.NetBSD.org>