laforge has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/38884?usp=email
)
Change subject: pySim-shell: change Prompt character to "#" after
"verify_adm"
......................................................................
pySim-shell: change Prompt character to "#" after "verify_adm"
Let's change the prompt from ">" to "#" when the user gains
admin
privilegs using verify_adm.
Related: OS#6640
Change-Id: I957b9df7b5069b6fce5bf958c94e8ffda833c77f
---
M pySim-shell.py
M pySim/runtime.py
2 files changed, 13 insertions(+), 4 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
diff --git a/pySim-shell.py b/pySim-shell.py
index f2b3ad2..d08dc21 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -219,18 +219,23 @@
self.cmd2.poutput("<- %s: %s" % (sw, resp))
def update_prompt(self):
+ if self.rs and self.rs.adm_verified:
+ prompt_char = '#'
+ else:
+ prompt_char = '>'
+
if self.lchan:
path_str = self.lchan.selected_file.fully_qualified_path_str(not
self.numeric_path)
scp = self.lchan.scc.scp
if scp:
- self.prompt = 'pySIM-shell (%s:%02u:%s)> ' % (str(scp),
self.lchan.lchan_nr, path_str)
+ self.prompt = 'pySIM-shell (%s:%02u:%s)%c ' % (str(scp),
self.lchan.lchan_nr, path_str, prompt_char)
else:
- self.prompt = 'pySIM-shell (%02u:%s)> ' %
(self.lchan.lchan_nr, path_str)
+ self.prompt = 'pySIM-shell (%02u:%s)%c ' % (self.lchan.lchan_nr,
path_str, prompt_char)
else:
if self.card:
- self.prompt = 'pySIM-shell (no card profile)> '
+ self.prompt = 'pySIM-shell (no card profile)%c ' % prompt_char
else:
- self.prompt = 'pySIM-shell (no card)> '
+ self.prompt = 'pySIM-shell (no card)%c ' % prompt_char
@cmd2.with_category(CUSTOM_CATEGORY)
def do_intro(self, _):
@@ -855,6 +860,8 @@
self._cmd.lchan.scc.verify_chv(adm_chv_num, h2b(pin_adm))
else:
raise ValueError("error: cannot authenticate, no adm-pin!")
+ self._cmd.rs.adm_verified = True
+ self._cmd.update_prompt()
def do_cardinfo(self, opts):
"""Display information about the currently inserted
card"""
diff --git a/pySim/runtime.py b/pySim/runtime.py
index 0ee15d0..3e48f75 100644
--- a/pySim/runtime.py
+++ b/pySim/runtime.py
@@ -53,6 +53,7 @@
# this is a dict of card identities which different parts of the code might
populate,
# typically with something like ICCID, EID, ATR, ...
self.identity = {}
+ self.adm_verified = False
# make sure the class and selection control bytes, which are specified
# by the card profile are used
@@ -139,6 +140,7 @@
if lchan_nr == 0:
continue
del self.lchan[lchan_nr]
+ self.adm_verified = False
atr = i2h(self.card.reset())
if cmd_app:
cmd_app.lchan = self.lchan[0]
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/38884?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: I957b9df7b5069b6fce5bf958c94e8ffda833c77f
Gerrit-Change-Number: 38884
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>