Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/python-bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobborisov <jacobborisov@users.noreply.github.com>2016-10-18 12:23:05 +0300
committerjacobborisov <jacobborisov@users.noreply.github.com>2016-10-18 12:23:05 +0300
commit188d3507f85e708e01f00bef7c0b83cc62a774ed (patch)
tree719148f0666760e6ed5e6b7db315b7cfda1c5418
parent9c22f56027b8b86f90a538a956d58588cfaa5166 (diff)
appropriate handling of '1999 You are not authorized.' dir response
-rw-r--r--bareos/bsock/lowlevel.py7
-rw-r--r--bareos/bsock/protocolmessages.py8
2 files changed, 15 insertions, 0 deletions
diff --git a/bareos/bsock/lowlevel.py b/bareos/bsock/lowlevel.py
index 5e5fd38..042fa68 100644
--- a/bareos/bsock/lowlevel.py
+++ b/bareos/bsock/lowlevel.py
@@ -346,8 +346,15 @@ class LowLevel(object):
except RuntimeError:
self.logger.error("RuntimeError exception in recv")
return (0, True, False)
+
+ # invalid username
+ if ProtocolMessages.is_not_authorized(msg):
+ self.logger.error("failed: " + str(msg))
+ return (0, True, False)
+
# check the receive message
self.logger.debug("(recv): " + str(msg))
+
msg_list = msg.split(b" ")
chal = msg_list[2]
# get th timestamp and the tle info from director response
diff --git a/bareos/bsock/protocolmessages.py b/bareos/bsock/protocolmessages.py
index 78fb3a9..0db3642 100644
--- a/bareos/bsock/protocolmessages.py
+++ b/bareos/bsock/protocolmessages.py
@@ -28,5 +28,13 @@ class ProtocolMessages():
return b"1999 Authorization failed.\n"
@staticmethod
+ def not_authorized():
+ return b"1999 You are not authorized.\n"
+
+ @staticmethod
def is_auth_ok(msg):
return msg == ProtocolMessages.auth_ok()
+
+ @staticmethod
+ def is_not_authorized(msg):
+ return msg == ProtocolMessages.not_authorized() \ No newline at end of file