openterm
openterm copied to clipboard
Limit commands to Documents folder
Currently it's possible to "escape" the documents folder and peek at the system hierarchy (e.g. cd /
will bring you to the root of iOS). Apple may find this reason to remove the app from the App Store. Therefore, I was wondering if there's any way to easily limit all commands to a certain folder scope.
@holzschu Do you have any ideas or thoughts about this?
Another thing we might need to limit (to please Apple) is the paths that are displayed in command results. For example, pwd
will currently print the full path (/private/var/mobile/...
). It might be necessary to treat the app as the root of the file system. So pwd
would print /Documents
if you're in the documents folder.
I have no idea on how to do the first one. There are already strong protections in place: you can cd /
, but you can't list or enter any of the directories under it. Likewise, you can cd ~/..
but not list its content.
For the second, an automatic replacement on the string returned by process()
, scanning all occurences of the string that is the result of getenv($HOME)
and replacing them with ~
would be a simple solution. Using stringByReplacingOccurrencesOfString
. It would actually improve readability.
Going back to the first question: it would be easy to place a restriction in cd
, to verify that the directory you're going to has either $HOME
or $CLOUDHOME
as a prefix, because cd
is a simple command (and the entire source is in ios_system).
It would be harder to place the same restriction on all commands, because we don't know in advance if an argument is a directory or just text.
Also, I'm not sure I can detect a user typing cd $HOME/../..
, but that is starting to be sophisticated.