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

config: make user-config world readable #2804

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions debian/ubuntu-advantage-tools.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ case "$1" in
chmod 0700 "$private_dir"
fi

if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "30~"; then
if [ -f /var/lib/ubuntu-advantage/user-config.json ]; then
chmod 0644 /var/lib/ubuntu-advantage/user-config.json
fi
fi
Comment on lines +432 to +436
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to continue the pattern of keeping the version migrations in order, so can you move this down after the if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "29~"; block?


if [ "$VERSION_ID" = "16.04" ]; then
if echo "$PREVIOUS_PKG_VER" | grep -q "14.04"; then
mark_reboot_cmds_as_needed
Expand Down
34 changes: 34 additions & 0 deletions features/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,40 @@ Feature: pro config sub-command
Then I will see the following on stderr:
"""
"""
When I run `pro config set metering_timer=2000` with sudo
And I run `pro config show` with sudo
Then I will see the following on stdout:
"""
http_proxy None
https_proxy None
apt_http_proxy None
apt_https_proxy None
ua_apt_http_proxy None
ua_apt_https_proxy None
global_apt_http_proxy None
global_apt_https_proxy None
update_messaging_timer 21600
metering_timer 2000
apt_news False
apt_news_url https://motd.ubuntu.com/aptnews.json
"""
When I run `pro config show` as non-root
Then I will see the following on stdout:
"""
http_proxy None
https_proxy None
apt_http_proxy None
apt_https_proxy None
ua_apt_http_proxy None
ua_apt_https_proxy None
global_apt_http_proxy None
global_apt_https_proxy None
update_messaging_timer 21600
metering_timer 2000
apt_news False
apt_news_url https://motd.ubuntu.com/aptnews.json
"""

Examples: ubuntu release
| release |
| xenial |
Expand Down
70 changes: 70 additions & 0 deletions sru/release-30/test-user-config-nonroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
set -e

series=$1
install_from=$2 # either path to a .deb, or 'staging', or 'proposed'

name=$series-dev

function cleanup {
lxc delete $name --force
}

function on_err {
echo -e "Test Failed"
cleanup
exit 1
}
trap on_err ERR


lxc launch ubuntu-daily:$series $name
sleep 5

# Install latest ubuntu-advantage-tools
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install -y ubuntu-advantage-tools > /dev/null
echo -e "\n* Latest u-a-t is installed"
echo "###########################################"
lxc exec $name -- apt-cache policy ubuntu-advantage-tools
echo -e "###########################################\n"

echo -e "\n* Modify metering job"
echo "###########################################"
lxc exec $name -- pro config set metering_timer=2000
lxc exec $name -- pro config show
echo -e "###########################################\n"

echo -e "\n* Show that non-root user cannot see the modification"
echo "###########################################"
lxc exec --user 1000 $name -- pro config show
echo -e "###########################################\n"


# Upgrade u-a-t to new version
# ----------------------------------------------------------------
if [ $install_from == 'staging' ]; then
lxc exec $name -- sudo add-apt-repository ppa:ua-client/staging -y > /dev/null
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install ubuntu-advantage-tools -y > /dev/null
elif [ $install_from == 'proposed' ]; then
lxc exec $name -- sh -c "echo \"deb http://archive.ubuntu.com/ubuntu $series-proposed main\" | tee /etc/apt/sources.list.d/proposed.list"
lxc exec $name -- apt-get update > /dev/null
lxc exec $name -- apt-get install ubuntu-advantage-tools -y > /dev/null
else
lxc file push $install_from $name/new-ua.deb
lxc exec $name -- dpkg -i /new-ua.deb > /dev/null
fi
# ----------------------------------------------------------------

echo -e "\n* Show that non-root user now can see the modification"
echo "###########################################"
lxc exec --user 1000 $name -- pro config show
echo -e "###########################################\n"

echo -e "\n* notice that user-config is now world-readable"
echo "###########################################"
lxc exec $name -- ls -la /var/lib/ubuntu-advantage/user-config.json
echo -e "###########################################\n"

cleanup
2 changes: 1 addition & 1 deletion uaclient/files/state_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __init__(

user_config_file = DataObjectFile(
UserConfigData,
UAFile("user-config.json", private=True),
UAFile("user-config.json", private=False),
DataObjectFileFormat.JSON,
optional_type_errors_become_null=True,
)
Expand Down
Loading