travis-ci/travis-cookbooks — pull request #154 by gildegoma (2013-02-13 15:18:46+00:00)
Title: Clean up around management of PATH environment variable

While working on #153, I realized that `/home/travis/.bashrc` is tuned to explicitly sources `/etc/profile`.

It is actually not (anymore) necessary (at least with the current environment: ubuntu 12.04), because `/etc/profile` is automatically loaded when a new shell starts. Sourcing twice `/etc/profile` leads to duplicate the `PATH` environment variable definition, as shown here: https://travis-ci.org/gildegoma/travis-ci-inspector/builds/4766834/#L45.
It is more a cosmetic thing, because `PATH` is logically equivalent to `$PATH:$PATH`

### Proposed Changes

Remove useless or unused stuff around .bashrc files and templates
* .bashrc of 'travis' user explicitly loaded /etc/profile
definitions, but /etc/profile.d mechanism is applied by default in
travis shell.
* .bashrc of 'root' user is managed with a template, not anymore with a
cookbook file.

**not implented yet / to be discussed:** At the moment, there are some `export PATH=…` definitions in travis cookbooks that are prepending default system paths (like `/usr/bin`) with custom paths (like `/node_modules/.bin":$PATH`). I think it would be better to always append custom paths at the end of PATH variable. This way there is no risk of shadowing standard binaries. (See for instance in node_js cookbook: `nvm.sh.erb:export PATH="./node_modules/.bin":$PATH`). I'm thinking about change it in the scope of this pull request. Any opinion?

### Open Questions

* What was exactly the reason to source it from `.bashrc` ? Could you @michaelklishin remember? Previous ubuntu version may not auto-loaded `/etc/profile` ? Cookbook integration problem ?
* I ran some chef tests without problems, but I won't merge this change before receiving the confirmation that all kinds of `ci_environment` worker machines still can be provisioned without any problem. Maybe some cookbook/recipes will need to be modified, and I would propose to directly add these fixes to this pull-request branch. @joshk could you please validate this fix on real provisioning cases?
* About the root access an the ability to run anything with a travis worker, I'm just now trying to figure out the potential hijacking weaknesses (e.g. Execute network attacks from a travis worker, take advantage of root access to dig into travis infrastructure). Is there critical security issue, or am I wrongly paranoid ?

### Notes and References

* related previous commits: b6e13dd102256c4d4474bd187f435b729343091c and 7fed0ec6ca0ff405de3f3a28570dace245a2da7d.
* Caution: `/etc/profile`and `/etc/profile.d/...` are not handled the same in all Linux distros and other Unix-like operating systems.
* http://askubuntu.com/questions/40287/etc-profile-not-being-sourced