-
Notifications
You must be signed in to change notification settings - Fork 255
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
-extpass option does not support arguments containing space #289
Comments
You mean somethink like -extpass "cat "my password.txt"" ? |
Bad example as this can be done with -passfile... |
Yes, something like this, but let's assume its a different program than
|
What if it contains a quote character? |
For a shell-like syntax, normal quotes would have to be escaped. As a result, the escape character itself also has to be escaped. Adding code for that will certainly make the code more complicated. If we want to avoid the complexity, we could either use the version where the command is passed as separate arguments (cf. |
I've thought about this a bit more. Although I'm not really sure how many people are using The idea with using Considering all options, I think the best one is to add support for shell quotes. There are also existing projects we could use, e.g., https://github.com/kballard/go-shellquote. (Note that this is just one of the first search results, maybe there are also other / better projects out there.) What is your opinion on this direction? |
I think the use case is valid, people use spaces in file names, and we should support that. Passing a user-controlled string to the shell for interpretation is super scary. We would place the burden of sanitising the string on the caller, and that's a ticking time bomb, because it is so hard to get right. The shellquote thing could work, i guess, but i think i would prefer an even simpler solution: have a new flag, "-extpass-raw", that can be specified multiple times. For example, gocryptfs -extpass-raw sha256sum -extpass-raw "my file.doc" |
While this should work, I think it would be better to have a bit shorter name, so we can deprecate the old What about allowing |
Hmm this can lead to unexpected results when the "executable name" may contain spaces: -extpass "userpassword.py" -extpass "rm -rf /" |
Based on my understanding this issue already exists right now. By implementing some legacy logic to split parameters we could ensure that existing scripts continue working during the transition, and then remove the fallback logic in one or two versions. But I agree, its not that easy to check if the parameter is a valid program - we would also have to take into account the PATH environment variable, for example. BTW: While we probably still shouldn't do this, |
To support arguments containing spaces, -extpass can now be passed multiple times. #289
Implemented in cf27037 . I have added guidance for how to use -extpass correctly to the man page. |
Thanks! I think this is a good compromise. |
As the title says, currently
-extpass
does not support arguments containing spaces. This limits the flexibility quite a bit, since its not possible to pass any untrusted user arguments. Extpass should either understand quotes, or support a syntax similar tofind -exec
, e.g.,gocryptfs -extpass arg1 arg2 \;
The text was updated successfully, but these errors were encountered: