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
This commit is contained in:
Philipp Maier 2021-04-08 17:48:49 +02:00
parent 1bd664da9e
commit 13e258dc85
1 changed files with 6 additions and 0 deletions

View File

@ -450,6 +450,12 @@ if __name__ == '__main__':
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)