Changing default hash in file.py

Changed default hashtype in file.py to sha256.  This was not reading
the hash_type from the minion config.  FIPS doesnt allow md5 as a valid
hash type.

          ID: /etc/snmp/snmpd.conf
    Function: file.managed
      Result: False
     Comment: An exception occurred in this state: Traceback (most
recent call last):
                File "/usr/lib/python2.6/site-packages/salt/state.py",
line 1379, in call
                  **cdata['kwargs'])
                File
"/usr/lib/python2.6/site-packages/salt/states/file.py", line 1246, in
managed
                  **kwargs
                File
"/usr/lib/python2.6/site-packages/salt/modules/file.py", line 2363, in
check_managed
                  **kwargs)
                File
"/usr/lib/python2.6/site-packages/salt/modules/file.py", line 2106, in
get_managed
                  hsum = get_hash(sfn)
                File
"/usr/lib/python2.6/site-packages/salt/modules/file.py", line 424, in
get_hash
                  return salt.utils.get_hash(path, form, chunk_size)
                File
"/usr/lib/python2.6/site-packages/salt/utils/__init__.py", line 1468,
in get_hash
                  hash_obj = hash_type()
              ValueError: error:060800A3:digital envelope
routines:EVP_DigestInit_ex:disabled for fips
This commit is contained in:
cingeyedog 2014-08-22 11:17:53 -04:00
parent 4b785ea32b
commit e1e902bacc

View File

@ -457,7 +457,7 @@ def chgrp(path, group):
return chown(path, user, group) return chown(path, user, group)
def get_sum(path, form='md5'): def get_sum(path, form='sha256'):
''' '''
Return the sum for the given file, default is md5, sha1, sha224, sha256, Return the sum for the given file, default is md5, sha1, sha224, sha256,
sha384, sha512 are supported sha384, sha512 are supported
@ -479,7 +479,7 @@ def get_sum(path, form='md5'):
return salt.utils.get_hash(path, form, 4096) return salt.utils.get_hash(path, form, 4096)
def get_hash(path, form='md5', chunk_size=65536): def get_hash(path, form='sha256', chunk_size=65536):
''' '''
Get the hash sum of a file Get the hash sum of a file
@ -2516,7 +2516,7 @@ def get_managed(
if data['result']: if data['result']:
sfn = data['data'] sfn = data['data']
hsum = get_hash(sfn) hsum = get_hash(sfn)
source_sum = {'hash_type': 'md5', source_sum = {'hash_type': 'sha256',
'hsum': hsum} 'hsum': hsum}
else: else:
__clean_tmp(sfn) __clean_tmp(sfn)
@ -2558,7 +2558,7 @@ def get_managed(
return sfn, source_sum, '' return sfn, source_sum, ''
def extract_hash(hash_fn, hash_type='md5', file_name=''): def extract_hash(hash_fn, hash_type='sha256', file_name=''):
''' '''
This routine is called from the :mod:`file.managed This routine is called from the :mod:`file.managed
<salt.states.file.managed>` state to pull a hash from a remote file. <salt.states.file.managed>` state to pull a hash from a remote file.