laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37778?usp=email ) Change subject: pySim.cards: Make file_exists() check for activated/deactivated ...................................................................... pySim.cards: Make file_exists() check for activated/deactivated The Card.file_exists() method is only called by legacy pySim-{read,prog} when it wants to determine if it can read/write a file. Therefore it actually doesn't only want to know if the file exists, but also if it's not deactivated. Change-Id: I73bd1ab3780e475c96a10cd5dbdd45b829c67335 Closes: OS#6530 --- M pySim/cards.py 1 file changed, 8 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve diff --git a/pySim/cards.py b/pySim/cards.py index 802c921..65aef98 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -23,7 +23,7 @@ # from typing import Optional, Tuple -from pySim.ts_102_221 import EF_DIR +from pySim.ts_102_221 import EF_DIR, CardProfileUICC from pySim.ts_51_011 import DF_GSM from pySim.utils import * @@ -54,10 +54,17 @@ print("warning: erasing is not supported for specified card type!") def file_exists(self, fid: Path) -> bool: + """Determine if the file exists (and is not deactivated).""" res_arr = self._scc.try_select_path(fid) for res in res_arr: if res[1] != '9000': return False + try: + d = CardProfileUICC.decode_select_response(res_arr[-1][0]) + if d.get('life_cycle_status_integer', 'operational_activated') != 'operational_activated': + return False + except: + pass return True def read_aids(self) -> List[Hexstr]: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37778?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I73bd1ab3780e475c96a10cd5dbdd45b829c67335 Gerrit-Change-Number: 37778 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge@osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org>