-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle binary for shebangs #9
Conversation
Note: the reason dealing with binary in the first place is important is for files that aren't scripts, e.g. |
PRoot, the original c implimentation, is Linux-only; it is written against Linux-specific libraries, etc. That being said, this rust version doesn't seem to be a direct translation of the other program. Therefore, I would try to rewrite the code to be as portable as possible. Can you elaborate more on disallowing non-valid UTF-8? Are there examples for why we wouldn't want this? |
I'm not completely sure of this myself but I'll give it my best shot. On Linux (and I think most Unix platforms), paths can be arbitrary bytes, if you want an executable called If we disallow that, then there will be paths we can't exec. However, in the vast majority of cases, this will be just a nuisance to code for because it's not in the standard library - see how getting and splitting the first line is about 10 lines of code where normally it would be All of this is only an issue for binary file paths, it's not that hard to check if the first two bytes of a file are More info:
|
You mentioned this is a rewrite and should probably be portable - in that case we should get rid of the ASM in |
I'm surprised that the loader was brought over from PRoot. I'm not sure how it should be re-implimented here, but I guess that can go into a separate issue. |
What about this, libpathrs? |
libpathrs looks like it addresses safe path handling. That could be useful as part of the main package for proot, but it's not directly related to parsing the path. |
Closing in favor of #14 |
Addresses #8.
The code here is really not fun, but that's because dealing with binary strings in rust is really not fun.
Note that this introduces a dependency on BString so I didn't have to deal with turning a
Vec<u8>
intoOsString
which appears to be non-trivial.Note that this will crash on windows for binary files, not sure if the project plans to run on windows.
The following tests now pass because of this pull:
test kernel::execve::shebang::tests::test_extract_shebang_not_script
test kernel::execve::shebang::tests::test_expand_shebang_not_script