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

[Error] /etc/localtime integration with the host failed, runtime sync for /etc/localtime disabled. Error: An error occurred #1624

Open
shocklateboy92 opened this issue Dec 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@shocklateboy92
Copy link

Describe the bug
Fails to create an ubuntu 22.04 container after failing to bind mount /etc/localtime

To Reproduce

  1. distrobox create -i ubuntu:22.04 -n ubuntu-test --init --home $HOME/containers/ubuntu-test
  2. distrobox enter ubuntu-test

Expected behavior
Container is successfully created

Logs

+ mount_bind /run/host/etc/localtime /etc/localtime ro
+ source_dir=/run/host/etc/localtime
+ target_dir=/etc/localtime
+ mount_flags=
+ [ 3 -gt 2 ]
+ mount_flags=ro
+ [ -L /run/host/etc/localtime ]
+ init_readlink /run/host/etc/localtime
+ ls -l /run/host/etc/localtime
+ grep -Eo \->.*
+ cut -d  -f2-
+ sed s|\.\./|/|g
+ source_dir=/usr/share/zoneinfo/America/Chicago
+ printf %s /usr/share/zoneinfo/America/Chicago
+ grep -q /run/host
+ source_dir=/run/host/usr/share/zoneinfo/America/Chicago
+ [ ! -d /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ ! -f /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ -e /etc/localtime ]
+ findmnt /etc/localtime
+ [ -L /etc/localtime ]
+ rm -f /etc/localtime
+ [ -d /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ -f /run/host/usr/share/zoneinfo/America/Chicago ]
+ dirname /etc/localtime
+ [ ! -d /etc ]
+ touch /etc/localtime
+ [ ro =  ]
+ mount --rbind -o ro /run/host/usr/share/zoneinfo/America/Chicago /etc/localtime
mount: /etc/localtime: filesystem was mounted, but any subsequent operation failed: Unknown error 5005.
+ printf Warning: failed to bind mount %s to %s using option %s\n /run/host/usr/share/zoneinfo/America/Chicago /etc/localtime ro
Warning: failed to bind mount /run/host/usr/share/zoneinfo/America/Chicago to /etc/localtime using option ro
+ return 1
+ printf Warning: %s integration with the host failed, runtime sync for %s disabled.\n /etc/localtime /etc/localtime
Warning: /etc/localtime integration with the host failed, runtime sync for /etc/localtime disabled.
+ [ -f /run/host/etc/localtime ]
+ rm -f /etc/localtime
rm: cannot remove '/etc/localtime': Device or resource busy
+ [ 1 -ne 0 ]
+ printf Error: An error occurred\n
Error: An error occurred
time="2024-12-01T23:52:32-06:00" level=debug msg="Called logs.PersistentPostRunE(podman --log-level debug logs ubuntu-intune)"
time="2024-12-01T23:52:32-06:00" level=debug msg="Shutting down engines"
time="2024-12-01T23:52:32-06:00" level=info msg="Received shutdown.Stop(), terminating!" PID=47893

Full log (and podman log) is attached.
podman.log
distrobox.log

Desktop (please complete the following information):

  • Are you using podman, docker or lilipod?
    • podman
  • Which version or podman, docker or lilipod?
    • podman version 5.3.1
  • Which version of distrobox?
    • distrobox: 1.8.0
  • Which host distribution?
    • KDE Linux (based on Arch Linux)
  • How did you install distrobox?
    • pacman (arch repos)

Additional context

as far as I can tell, my /etc/localtime is just a regular symlink pointing to /usr/share/zoneinfo/America/Chicago

@shocklateboy92 shocklateboy92 added the bug Something isn't working label Dec 2, 2024
@shocklateboy92
Copy link
Author

Okay, I figured out the issue.

distrobox/distrobox-init

Lines 268 to 306 in 18053c2

get_locked_mount_flags()
{
src="$1"
prev=""
locked_flags=""
# If findmnt does not exist, exit
if ! command -v findmnt 2> /dev/null > /dev/null; then
return 0
fi
# If we can't read the file/directory, exit
if ! ls "${src}" 2> /dev/null > /dev/null; then
return 0
fi
# Get mount flags of given file/directory, using nearest mountpoint.
# Earlier versions of findmnt did not check parents until it found a mountpoint,
# so we use a workaround with dirname.
while true; do
flags="$(findmnt --noheadings --output OPTIONS --target "${src}" || :)"
# shellcheck disable=SC2181
if [ -n "${flags}" ]; then
break
fi
prev="${src}"
src="$(dirname "${src}")"
[ "${src}" = "${prev}" ] && return 1
done
for flag in nodev noexec nosuid; do
if printf "%s" "${flags}" | grep -q "${flag}"; then
# Locked flag found, append to list while avoiding leading/trailing commas
locked_flags="${locked_flags:+${locked_flags},}${flag}"
fi
done
printf "%s" "${locked_flags}"
}

get_locked_mount_flags checks if there are any flags that need to be passed to the bind mount for the file. However, if the file is a symlink the the flags of the destination must also be checked and passed. It doesn't currently handle this case.

PR incoming.

kdesysadmin pushed a commit to KDE/kde-linux that referenced this issue Dec 7, 2024
There are just too many bugs to deal with in podman, whereas docker just works.

https://invent.kde.org/-/snippets/3274

89luca89/distrobox#1624

89luca89/distrobox#1401

and a ton more every time I try to do something.

This also gives docker permissions to the `wheel` group (instead of having to add users to a newly-created `docker` group). Since everyone in `wheel` are already root-equivalent, this makes more sense anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant