aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-shell.py
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-07-04 21:14:23 +0200
committerHarald Welte <laforge@osmocom.org>2023-07-04 21:17:19 +0200
commitf4a01472bf1a5cad38c7db1fd46666a8adfa0b96 (patch)
treeda6b8161d7a18c314b733b19818b6ec3d9a51b16 /pySim-shell.py
parentfa9f348180ee3bb98edee38ec0209d3989ebe42e (diff)
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
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-xpySim-shell.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index e5cc0c3..3161844 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)