From f4a01472bf1a5cad38c7db1fd46666a8adfa0b96 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 4 Jul 2023 21:14:23 +0200 Subject: [PATCH] pySim-shell: Support USIM specific methods/commands on unknown UICC So far, if no known programmable card (like sysmoISIM) has been found, we were using the SimCard base class. However, once we detect an UICC, we should have switched to the UsimCard class, as otherwise the various methods called by USIM/ISIM specific commands don't exist and we get weird 'SimCard' object has no attribute 'update_ust' execptions. The entire auto-detection and the legacy SimCard / UsimCard classes are showing the legacy of the code base and should probably be re-architected. However, let's fix the apparent bug for now. Change-Id: I5a863198084250458693f060ca10b268a58550a1 Closes: OS#6055 --- pySim-shell.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pySim-shell.py b/pySim-shell.py index e5cc0c3b..31618446 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -49,7 +49,7 @@ from pprint import pprint as pp from pySim.exceptions import * from pySim.commands import SimCardCommands from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, ProactiveHandler -from pySim.cards import card_detect, SimCard +from pySim.cards import card_detect, SimCard, UsimCard from pySim.utils import h2b, b2h, i2h, swap_nibbles, rpad, JsonEncoder, bertlv_parse_one, sw_match from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr from pySim.card_handler import CardHandler, CardHandlerAuto @@ -127,6 +127,12 @@ def init_card(sl): profile.add_application(CardApplicationHPSIM()) profile.add_application(CardApplicationARAM()) profile.add_application(CardApplicationISD()) + # We have chosen SimCard() above, but we now know it actually is an UICC + # so it's safe to assume it supports USIM application (which we're adding above). + # IF we don't do this, we will have a SimCard but try USIM specific commands like + # the update_ust method (see https://osmocom.org/issues/6055) + if generic_card: + card = UsimCard(scc) # Create runtime state with card profile rs = RuntimeState(card, profile)