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

Use Downloads folder of the user who launched the chroot #3531

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion host-bin/enter-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,21 @@ elif [ ! -f "$shares" ]; then
downloads ~/Downloads
EOF
fi

# Bind-mount the stuff in $CHROOT/etc/crouton/shares, unless NOLOGIN is set
if [ -z "$NOLOGIN" -a -f "$shares" ]; then
localdownloads='/home/chronos/user/Downloads'
activeuser=''
if [ -x "/usr/bin/jq" ]; then
activeuser="$(jq -r .LastActiveUser '/home/chronos/Local State')"
Copy link
Owner

Choose a reason for hiding this comment

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

activeuser="$(sed -n 's/.*"LastActiveUser":\s*"\([^"]*\)".*/\1/p' '/home/chronos/Local State')"

fi
if [ -n "$activeuser" ]; then
localdownloads="$(jq -r '.profile.info_cache | to_entries[]
| select(.value.user_name == "'$activeuser'")
| "/home/chronos/\(.key)/Downloads"' '/home/chronos/Local State')"
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not convinced this is better (also not certain it is the correct way of doing it), but if we want to get rid of the jq dependency:

localdownloads="$(grep -l '"account_id":\s*"'"$activeuser"'"' /home/chronos/u-*/Preferences | sed 's/Preferences$/Downloads/;q')"

fi
if [ -z "$localdownloads" ]; then
localdownloads='/home/chronos/user/Downloads'
fi
if [ ! -d "$localdownloads" ]; then
localdownloads=''
fi
Expand Down