Allow null passphrase for MASTER logins

New config options for this in GLOBAL config section

If pashphrase is null and this option is set, login will always succeed
pypy
Simon 5 years ago
parent f300e61192
commit f8bd5b00df

@ -122,7 +122,9 @@ def build_config(_config_file):
'SUB_ACL': config.get(section, 'SUB_ACL'), 'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'), 'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),
'TG2_ACL': config.get(section, 'TGID_TS2_ACL'), 'TG2_ACL': config.get(section, 'TGID_TS2_ACL'),
'GEN_STAT_BRIDGES': config.getboolean(section, 'GEN_STAT_BRIDGES') 'GEN_STAT_BRIDGES': config.getboolean(section, 'GEN_STAT_BRIDGES'),
'ALLOW_NULL_PASSPHRASE': config.getboolean(section, 'ALLOW_NULL_PASSPHRASE')
}) })
elif section == 'REPORTS': elif section == 'REPORTS':

@ -465,17 +465,22 @@ class HBSYSTEM(DatagramProtocol):
self._peer_sema.release() self._peer_sema.release()
_sent_hash = _data[8:] _sent_hash = _data[8:]
_salt_str = bytes_4(_this_peer['SALT']) _salt_str = bytes_4(_this_peer['SALT'])
_calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest()) if self._CONFIG['GLOBAL']['ALLOW_NULL_PASSPHRASE'] and len(self._config['PASSPHRASE']) == 0:
if _sent_hash == _calc_hash:
_this_peer['CONNECTION'] = 'WAITING_CONFIG' _this_peer['CONNECTION'] = 'WAITING_CONFIG'
self.send_peer(_peer_id, b''.join([RPTACK, _peer_id])) self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
logger.info('(%s) Peer %s has completed the login exchange successfully', self._system, _this_peer['RADIO_ID']) logger.info('(%s) Peer %s has completed the login exchange successfully', self._system, _this_peer['RADIO_ID'])
else: else:
logger.info('(%s) Peer %s has FAILED the login exchange successfully', self._system, _this_peer['RADIO_ID']) _calc_hash = bhex(sha256(_salt_str+self._config['PASSPHRASE']).hexdigest())
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr) if _sent_hash == _calc_hash:
self._peer_sema.acquire(blocking=True) _this_peer['CONNECTION'] = 'WAITING_CONFIG'
del self._peers[_peer_id] self.send_peer(_peer_id, b''.join([RPTACK, _peer_id]))
self._peer_sema.release() logger.info('(%s) Peer %s has completed the login exchange successfully', self._system, _this_peer['RADIO_ID'])
else:
logger.info('(%s) Peer %s has FAILED the login exchange successfully', self._system, _this_peer['RADIO_ID'])
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
self._peer_sema.acquire(blocking=True)
del self._peers[_peer_id]
self._peer_sema.release()
else: else:
self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr) self.transport.write(b''.join([MSTNAK, _peer_id]), _sockaddr)
logger.warning('(%s) Login challenge from Radio ID that has not logged in: %s', self._system, int_id(_peer_id)) logger.warning('(%s) Login challenge from Radio ID that has not logged in: %s', self._system, int_id(_peer_id))

Loading…
Cancel
Save

Powered by TurnKey Linux.