Skip to content
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

Cleanup tahoe module #25271

Closed
wants to merge 5 commits into from
Closed

Cleanup tahoe module #25271

wants to merge 5 commits into from

Conversation

0xABAB
Copy link
Contributor

@0xABAB 0xABAB commented Apr 27, 2017

Motivation for this change
  • Remove useless escape of question mark
  • Add proper escaping for correctness
Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • [x ] NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • [x ] Tested execution of all binary files (usually in ./result/bin/)
  • [ x] Fits CONTRIBUTING.md.

- Remove useless escape of question mark
- Fix and quoting
- Add some '&&s' for correctness
@mention-bot
Copy link

@0xABAB, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MostAwesomeDude, @ericsagnes and @fpletz to be potential reviewers.

@joachifm
Copy link
Contributor

Can you elaborate on how && improves correctness?

@0xABAB
Copy link
Contributor Author

0xABAB commented Apr 27, 2017

@joachifm Using && makes it orders of magnitude more likely that the directory exists before the tahoe commands try to access it. I.e. mkdir can fail.

@joachifm
Copy link
Contributor

The preStart script should be executed with set -o errexit, is that insufficient?

@0xABAB
Copy link
Contributor Author

0xABAB commented Apr 27, 2017

@joachifm I was not aware of that, but I also don't want to be aware of that. Global assumptions are bad. I consider running with errexit a huge mistake, but I am sure you have no interest in discussing that here.

@0xABAB
Copy link
Contributor Author

0xABAB commented Apr 29, 2017

@vcunat Can you just commit the above? The comments by @joachifm are talking mostly about the color of the bikeshed.

Copy link
Contributor

@MostAwesomeDude MostAwesomeDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -237,22 +237,22 @@ in
# arguments to $(tahoe start). The node directory must come first,
# and arguments which alter Twisted's behavior come afterwards.
ExecStart = ''
${settings.package}/bin/tahoe start ${nodedir} -n -l- --pidfile=${pidfile}
${settings.package}/bin/tahoe start "${nodedir}" -n -l- --pidfile="${pidfile}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nodedir or pidfile include " or $, this still won't be interpreted correctly. If we really want to fix this properly, I think it would be better to use escapeShellArg in the Nix interpolation, e.g.:
${lib.escapeShellArg pidfile} (without double-quotes around it, and assuming lib is in scope). I'm not sure if it's worth the verbosity, but that would be the most solid way to do it.

Make sure people can't inject shell code by accident.
@0xABAB
Copy link
Contributor Author

0xABAB commented Jun 28, 2017

@ryantrinkle Thanks for your contribution.

@0xABAB
Copy link
Contributor Author

0xABAB commented Jul 9, 2017

@joachifm I made the requested changes and then some. Please merge.

Copy link
Contributor

@MostAwesomeDude MostAwesomeDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found a typo.

mkdir -p /var/db/tahoe-lafs
tahoe create-introducer ${nodedir}
tahoe create-introducer "{lib.escapeShellArg nodedir}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

@grahamc
Copy link
Member

grahamc commented Jul 26, 2017

Applied with a patch in 90acbe5

@joachifm joachifm closed this Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants