Change in pysim[master]: pySim-shell: be sure that startup script file exists

laforge gerrit-no-reply at lists.osmocom.org
Fri Apr 9 16:13:10 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23680 )

Change subject: pySim-shell: be sure that startup script file exists
......................................................................

pySim-shell: be sure that startup script file exists

When a startup script file is specified that does not exists pySim-shell
skips the script and starts normally. This is dangerous because if
pySim-shell is called by a shellscript with a nonexisting script file
the shellscript may hang forever because there is no script that exists
pySim-shell again

Change-Id: I4ff2226c8852727aa23357aa54d1e2d480bfaf2d
Related: OS#4963
---
M pySim-shell.py
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim-shell.py b/pySim-shell.py
index f1060de..3059f3f 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -450,6 +450,12 @@
 	rs.mf.add_file(DF_TELECOM())
 	rs.mf.add_file(DF_GSM())
 
+	# If a script file is specified, be sure that it actually exists
+	if opts.script:
+		if not os.access(opts.script, os.R_OK):
+			print("Invalid script file!")
+			sys.exit(2)
+
 	app = PysimApp(card, rs, opts.script)
 	rs.select('MF', app)
 

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23680
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4ff2226c8852727aa23357aa54d1e2d480bfaf2d
Gerrit-Change-Number: 23680
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210409/29c15bd0/attachment.htm>


More information about the gerrit-log mailing list