-
Notifications
You must be signed in to change notification settings - Fork 168
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
pkg installer: Fix ownership of files installed into $HOME #784
Conversation
# install location, the permissions will default to root unless this is done. | ||
chown -R "$USER" "$PREFIX" | ||
chown -R "$USER" "${HOME}/.conda" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might also leave a .condarc
somewhere if the config file asked for that option. Should we add it here too? e.g.
chown -R "$USER" "${HOME}/.conda" | |
test -f "${HOME}/.condarc" && chown "$USER" "${HOME}/.condarc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I tested it, .condarc
had the correct ownership, but better safe than sorry.
constructor/osx/update_path.sh
Outdated
if [[ "${USER}" != "root" ]]; then | ||
echo "Fixing permissions..." | ||
read -r -a MODIFIED_FILES <<< "$(\ | ||
echo "${INIT_FILES}" |\ | ||
grep modified |\ | ||
awk '{print $2}' |\ | ||
# Only grab files inside $HOME or $PREFIX. | ||
# All init files should be there, but that may change, and it | ||
# is better to miss files than to have an infinite loop below. | ||
grep -E "^(${HOME}|${PREFIX})"\ | ||
)" | ||
for file in "${MODIFIED_FILES[@]}"; do | ||
while [[ "${file}" != "${HOME}" ]] && [[ "${file}" != "${PREFIX}" ]]; do | ||
# Check just in case the file wasn't created due to flaky conda init | ||
if [[ -f "${file}" ]] || [[ -d "${file}" ]]; then | ||
OWNER=$(stat -f "%u" "${file}" | id -un) | ||
if [[ "${OWNER}" == "root" ]]; then | ||
chown "${USER}" "${file}" | ||
fi | ||
fi | ||
file="${file%/*}" | ||
done | ||
done | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome shell skills here! This script is called with sh
though, so I think we need to either:
- Change the shebang to bash
- Make sure we only use strict POSIX (e.g. no
[[ ]]
ifs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't sh
link to bash
on MacOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it does, I think it's better to be explicit. I changed the shell to bash since that's what we're using in the other scripts as well.
Let's double check SH vs BASH vs POSIX for that nice chunk of shell code :) |
Co-authored-by: jaimergp <[email protected]>
Co-authored-by: jaimergp <[email protected]>
…ctor into pkg-file-permissions
Description
When installing outside
$HOME
, the pkg installer installs asroot
. Constructor changes the ownership of the$PREFIX
directory to$USER
:constructor/constructor/osx/run_installation.sh
Line 115 in 58385ee
However, the installer creates additional files and directories outside of
$PREFIX
:${HOME}/.conda
conda init
, e.g.,${HOME}/.bash_profile
or${HOME}/.config/powershell
This PR fixes the ownership of those files and directories as well.
Checklist - did you ...
news
directory (using the template) for the next release's release notes?