From 77dc3b52ab931cdbed0b35c1f03c44ee24ebb13e Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Thu, 10 May 2012 17:51:08 -0700 Subject: [PATCH 1/4] Catching exceptions from M2Crypto.RSA. Otherwise queue workers can die mysterious deaths when rogue bits float around. --- salt/master.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/salt/master.py b/salt/master.py index 0241e6ce91..9b420a3539 100644 --- a/salt/master.py +++ b/salt/master.py @@ -440,10 +440,20 @@ class AESFuncs(object): os.close(fd_) with open(tmp_pub, 'w+') as fp_: fp_.write(minion_pub) - pub = RSA.load_pub_key(tmp_pub) - os.remove(tmp_pub) - if pub.public_decrypt(token, 5) == 'salt': - return True + + pub = None + try: + pub = RSA.load_pub_key(tmp_pub) + except RSA.RSAError, e: + log.error('Unable to load temporary public key "{0}": {1}' + .format(tmp_pub, e)) + try: + os.remove(tmp_pub) + if pub.public_decrypt(token, 5) == 'salt': + return True + except RSA.RSAError, e: + log.error('Unable to decrypt token: {0}'.format(e)) + log.error('Salt minion claiming to be {0} has attempted to' 'communicate with the master and could not be verified' .format(id_)) @@ -966,7 +976,17 @@ class ClearFuncs(object): log.info('Authentication accepted from %(id)s', load) with open(pubfn, 'w+') as fp_: fp_.write(load['pub']) - pub = RSA.load_pub_key(pubfn) + pub = None + + # The key payload may sometimes be corrupt when using auto-accept + # and an empty request comes in + try: + pub = RSA.load_pub_key(pubfn) + except RSA.RSAError, e: + log.error('Corrupt public key "{0}": {1}'.format(pubfn, e)) + return {'enc': 'clear', + 'load': {'ret': False}} + ret = {'enc': 'pub', 'pub_key': self.master_key.get_pub_str(), 'token': self.master_key.token, From 179c0df614c56255ba99f2d58b5c45c4ccf35a1b Mon Sep 17 00:00:00 2001 From: Jeff Hutchins Date: Tue, 19 Jun 2012 13:52:06 -0600 Subject: [PATCH 2/4] Fix the mount module in certain cases It is possible that the minion may not have /proc/self/mountinfo (our virtualized CentOS 5 boxes don't). This provides a fallback on /proc/self/mounts in the case that mountinfo doesn't exist or can't be read. --- salt/modules/mount.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/salt/modules/mount.py b/salt/modules/mount.py index d847cae3d3..4c9fa698aa 100644 --- a/salt/modules/mount.py +++ b/salt/modules/mount.py @@ -12,15 +12,7 @@ from salt._compat import string_types log = logging.getLogger(__name__) -def active(): - ''' - List the active mounts. - - CLI Example:: - - salt '*' mount.active - ''' - ret = {} +def _active_mountinfo(ret): with open('/proc/self/mountinfo') as fh: for line in fh: comps = line.split() @@ -37,6 +29,32 @@ def active(): return ret +def _active_mounts(ret): + with open('/proc/self/mounts') as fh: + for line in fh: + comps.split() + ret[comps[1]] = {'device': comps[0], + 'fstype': comps[2], + 'opts': comps[3].split(',')} + return ret + + +def active(): + ''' + List the active mounts. + + CLI Example:: + + salt '*' mount.active + ''' + ret = {} + try: + _active_mountinfo(ret) + except IOError: + _active_mounts(ret) + return ret + + def fstab(config='/etc/fstab'): ''' List the contents of the fstab From 90ad340a47af2083db35028150bc91589ab692f1 Mon Sep 17 00:00:00 2001 From: Anders Bruun Olsen Date: Tue, 19 Jun 2012 22:03:01 +0200 Subject: [PATCH 3/4] Updated docstring for network module to specify that only Redhat-style networking is supported. --- salt/states/network.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/states/network.py b/salt/states/network.py index e979718684..907da729c2 100644 --- a/salt/states/network.py +++ b/salt/states/network.py @@ -6,6 +6,9 @@ The network module is used to create and manage network settings, interfaces can be set as either managed or ignored. By default all interfaces are ignored unless specified. +Please note that only Redhat-style networking is currently +supported. This module will therefore only work on RH/CentOS/Fedora. + .. code-block:: yaml eth0: From 835600db1c3a8c4490c9110e10955cf83f9b6554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81ophile=20Studer?= Date: Tue, 19 Jun 2012 23:03:07 +0200 Subject: [PATCH 4/4] Fix pacman list_upgrades --- salt/modules/pacman.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/pacman.py b/salt/modules/pacman.py index 65ac19f468..9fad42bb75 100644 --- a/salt/modules/pacman.py +++ b/salt/modules/pacman.py @@ -58,7 +58,7 @@ def list_upgrades(): 'pacman -Sypu --print-format "%n %v" | egrep -v "^\s|^:"' ).split('\n') for line in lines: - comps = lines.split(' ') + comps = line.split(' ') if len(comps) < 2: continue upgrades[comps[0]] = comps[1]