dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/pysim/+/34884?usp=email )
Change subject: pySim-shell: don't get trapped in applications without file system
......................................................................
pySim-shell: don't get trapped in applications without file system
When we traverse the file system, we may also end up selecting
applications (ADF), which do not support an USIM/ISIM like file system.
This will leave us without the ability to select the MF (or any other
file) again. The only way out is to select the ISIM or USIM application
again to get the access to the file system again.
Related: OS#5418
Change-Id: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0
---
M pySim-shell.py
1 file changed, 42 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/84/34884/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 8a1ad01..2368f95 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -55,7 +55,7 @@
from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr,
dec_iccid
from pySim.card_handler import CardHandler, CardHandlerAuto
-from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication
+from pySim.filesystem import CardMF, CardDF, CardADF, CardModel, CardApplication
from pySim.runtime import RuntimeState
from pySim.profile import CardProfile
from pySim.cdma_ruim import CardProfileRUIM
@@ -599,7 +599,31 @@
# below, so we must not move up.
if skip_df == False:
self.walk(indent + 1, action_ef, action_df, context, **kwargs)
- fcp_dec = self._cmd.lchan.select("..", self._cmd)
+
+ parent =
self._cmd.lchan.selected_file.get_selectables()[".."]
+ df = self._cmd.lchan.selected_file
+ if isinstance(parent, CardMF) and (df.name not in [
"ADF.USIM", "ADF.ISIM"]):
+ # Not every application that may be present on a GlobalPlatform
card will support the SELECT
+ # command as we know it from ETSI TS 102 221, section 11.1.1. In
fact the only subset of
+ # SELECT we may rely on is the OPEN SELECT command as specified
in GlobalPlatform Card
+ # Specification, section 11.9. Unfortunately the OPEN SELECT
command only supports the
+ # "select by name" method, which means we can only
select an application and not a file.
+ # The consequence of this is that we may get trapped in an
application that does not have
+ # ISIM/USIM like file system support and the only way to leave
that application is to select
+ # an ISIM/USIM application in order to get the file system access
back.
+ #
+ # To automatize this escape-route while traversing the file
system we will check whether
+ # the parent file is the MF. When this is the case and the
selected ADF is not ADF.ISIM or
+ # ADF.USIM, we will select ADF.USIM or ADF.ISIM (depending on
what is available) and from
+ # from there we will then select the MF.
+ for app in parent.applications:
+ if app in [ "a0000000871002",
"a0000000871004"]:
+ adf_xsim = app
+ self._cmd.lchan.select(adf_xsim, self._cmd)
+ self._cmd.lchan.select("MF", self._cmd)
+ else:
+ # Normal DF/ADF selection
+ fcp_dec = self._cmd.lchan.select("..", self._cmd)
elif action_ef:
df_before_action = self._cmd.lchan.selected_file
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/34884?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0
Gerrit-Change-Number: 34884
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange