vicc: use logging.critical if vicc needs exit()

This commit is contained in:
Frank Morgner
2022-05-06 11:57:23 +02:00
parent 1e5731fb0e
commit fe5977bc39
2 changed files with 11 additions and 10 deletions

View File

@@ -476,8 +476,8 @@ class VirtualICC(object):
self.sock.settimeout(None) self.sock.settimeout(None)
self.server_sock = None self.server_sock = None
except socket.error as e: except socket.error as e:
logging.error("Failed to open socket: %s", str(e)) logging.critical("Failed to open socket: %s", str(e))
logging.error("Is pcscd running at %s? Is vpcd loaded? Is a \ logging.critical("Is pcscd running at %s? Is vpcd loaded? Is a \
firewall blocking port %u?", host, port) firewall blocking port %u?", host, port)
sys.exit() sys.exit()
else: else:
@@ -498,8 +498,8 @@ class VirtualICC(object):
(self.sock, self.server_sock, host) = self.openPort(port) (self.sock, self.server_sock, host) = self.openPort(port)
self.sock.settimeout(None) self.sock.settimeout(None)
except socket.error as e: except socket.error as e:
logging.error("Failed to open socket: %s", str(e)) logging.critical("Failed to open socket: %s", str(e))
logging.error("Is pcscd running? Is vpcd loaded and in \ logging.critical("Is pcscd running? Is vpcd loaded and in \
reversed connection mode? Is a firewall \ reversed connection mode? Is a firewall \
blocking port %u?", port) blocking port %u?", port)
sys.exit() sys.exit()
@@ -581,6 +581,7 @@ class VirtualICC(object):
(self.sock, address) = self.server_sock.accept() (self.sock, address) = self.server_sock.accept()
continue continue
else: else:
logging.critical(str(e))
sys.exit() sys.exit()
if not size: if not size:

View File

@@ -41,7 +41,7 @@ class RelayOS(SmartcardOS):
# See which readers are available # See which readers are available
readers = smartcard.System.listReaders() readers = smartcard.System.listReaders()
if len(readers) <= readernum: if len(readers) <= readernum:
logging.error("Invalid number of reader '%u' (only %u available)", logging.critical("Invalid number of reader '%u' (only %u available)",
readernum, len(readers)) readernum, len(readers))
sys.exit() sys.exit()
@@ -53,7 +53,7 @@ class RelayOS(SmartcardOS):
try: try:
self.session = smartcard.Session(self.reader) self.session = smartcard.Session(self.reader)
except smartcard.Exceptions.CardConnectionException as e: except smartcard.Exceptions.CardConnectionException as e:
logging.error("Error connecting to card: %s", e.message) logging.critical("Error connecting to card: %s", e.message)
sys.exit() sys.exit()
logging.info("Connected to card in '%s'", self.reader) logging.info("Connected to card in '%s'", self.reader)
@@ -83,7 +83,7 @@ class RelayOS(SmartcardOS):
self.session = smartcard.Session(self.reader) self.session = smartcard.Session(self.reader)
atr = self.session.getATR() atr = self.session.getATR()
except smartcard.Exceptions.CardConnectionException as e: except smartcard.Exceptions.CardConnectionException as e:
logging.error("Error getting ATR: %s", e.message) logging.critical("Error getting ATR: %s", e.message)
sys.exit() sys.exit()
return "".join([chr(b) for b in atr]) return "".join([chr(b) for b in atr])
@@ -99,7 +99,7 @@ class RelayOS(SmartcardOS):
try: try:
self.session = smartcard.Session(self.reader) self.session = smartcard.Session(self.reader)
except smartcard.Exceptions.CardConnectionException as e: except smartcard.Exceptions.CardConnectionException as e:
logging.error("Error connecting to card: %s", e.message) logging.critical("Error connecting to card: %s", e.message)
sys.exit() sys.exit()
def powerDown(self): def powerDown(self):
@@ -108,7 +108,7 @@ class RelayOS(SmartcardOS):
try: try:
self.session.close() self.session.close()
except smartcard.Exceptions.CardConnectionException as e: except smartcard.Exceptions.CardConnectionException as e:
logging.error("Error disconnecting from card: %s", str(e)) logging.critical("Error disconnecting from card: %s", str(e))
sys.exit() sys.exit()
def reset(self): def reset(self):
@@ -127,7 +127,7 @@ class RelayOS(SmartcardOS):
try: try:
rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu) rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu)
except smartcard.Exceptions.CardConnectionException as e: except smartcard.Exceptions.CardConnectionException as e:
logging.error("Error transmitting APDU: %s", str(e)) logging.critical("Error transmitting APDU: %s", str(e))
sys.exit() sys.exit()
# XXX this is a workaround, see on sourceforge bug #3083586 # XXX this is a workaround, see on sourceforge bug #3083586