Bug 1654366

Summary: lxc-execute fails with "Unable to open lxc.init.static"
Product: [Fedora] Fedora Reporter: Eric Schreiber <eschreiber>
Component: lxcAssignee: Thomas Moschny <thomas.moschny>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: admiller, karlthered, pokorra.mailinglists, sagarun, sgalgano, silas, thomas.moschny
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: lxc-3.0.4-1.fc30 lxc-3.0.4-1.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-09-06 12:33:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Adds BuildRequires libcap-static and glibc-static, and file init.lxc.static. none

Description Eric Schreiber 2018-11-28 15:37:11 UTC
Description of problem:

On Fedora 29, lxc-execute fails to run because it does not find init.lxc.static. init.lxc.static is not installed and is not available in any lxc package.


Version-Release number of selected component (if applicable):

lxc-3.0.2-1.fc29


How reproducible:

Happens every time for directions below.


Steps to Reproduce:
1. Create a simple configuration file:

$ cat /tmp/lxc.conf 
lxc.uts.name=lxc-1
lxc.tty.max=12
lxc.pty.max=12

# loopback interface
lxc.net.0.type=empty
lxc.net.0.flags=up


2. Run lxc-execute

$ sudo lxc-execute -f /tmp/lxc.conf -n lxc-1 -o /tmp/lxc.log -- /usr/bin/ls
lxc-execute: lxc-1: conf.c: lxc_setup: 3574 No such file or directory - Unable to open lxc.init.static
lxc-execute: lxc-1: start.c: do_start: 1234 Failed to setup container "lxc-1"
lxc-execute: lxc-1: sync.c: __sync_wait: 59 An error occurred in another process (expected sequence number 5)  
lxc-execute: lxc-1: start.c: __lxc_start: 1910 Failed to spawn container "lxc-1"
lxc-execute: lxc-1: tools/lxc_execute.c: main: 240 Failed run an application inside container

Note, the log printout is somewhat confusing. The code is looking for "init.lxc.static", not "lxc.init.static" as printed:

conf.c excerpt
---
        if (lxc_conf->is_execute) {
                if (execveat_supported()) {
			int fd;
                        char path[PATH_MAX];

			ret = snprintf(path, PATH_MAX, SBINDIR "/init.lxc.static");
                        if (ret < 0 || ret >= PATH_MAX) {
                                ERROR("Path to init.lxc.static too long");
                                return -1;
                        }

                        fd = open(path, O_PATH | O_CLOEXEC);
                        if (fd < 0) {
                                SYSERROR("Unable to open lxc.init.static");
                                return -1;
                        }

                        ((struct execute_args *)handler->data)->init_fd = fd;
                        ((struct execute_args *)handler->data)->init_path = NULL;
                } else {
                        ret = lxc_execute_bind_init(handler);
                        if (ret < 0) {
                                ERROR("Failed to bind-mount the lxc init system");
                                return -1;
                        }
                }
        }


3.init.lxc.static is not installed and not available to install.

$ dnf provides /usr/sbin/init.lxc
Last metadata expiration check: 0:04:29 ago on Mon 19 Nov 2018 03:18:03 PM EST.
lxc-libs-3.0.2-1.fc29.x86_64 : Runtime library files for lxc
Repo        : @System
Matched from:
Filename    : /usr/sbin/init.lxc

$ dnf provides /usr/sbin/init.lxc.static
Last metadata expiration check: 0:04:43 ago on Mon 19 Nov 2018 03:18:03 PM EST.
Error: No Matches found

$ dnf info lxc-libs
Last metadata expiration check: 0:04:52 ago on Mon 19 Nov 2018 03:18:03 PM EST.
Installed Packages
Name         : lxc-libs
Version      : 3.0.2
Release      : 1.fc29
Arch         : x86_64
Size         : 1.1 M
Source       : lxc-3.0.2-1.fc29.src.rpm
Repo         : @System
From repo    : fedora
Summary      : Runtime library files for lxc
URL          : http://linuxcontainers.org/lxc
License      : LGPLv2+ and GPLv2
Description  : Linux Resource Containers provide process and resource isolation without the
             : overhead of full virtualization.
             : 
             : The lxc-libs package contains libraries for running lxc applications.

$ which init.lxc
/usr/sbin/init.lxc

$ which init.lxc.static
/usr/bin/which: no init.lxc.static in (/usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/sbin)


Expected results:

Expect lxc-execute to run.


Additional info:

I have rebuilt lxc 2.0.9 RPMS and am running that successfully on Fedora 29 for the time being. This report is also posted to lxc issues (https://github.com/lxc/lxc/issues/2729). Also noting that lxc 3.0.x is available in Ubuntu 18.04 where init.lxc.static is included in the package (https://packages.ubuntu.com/bionic/amd64/liblxc-common/filelist).

Comment 1 Eric Schreiber 2018-12-04 11:13:01 UTC
lxc-3.0.3-1.fc29 exhibits the same behavior.

Comment 2 Steven Galgano 2018-12-16 03:21:11 UTC
The missing init.lxc.static binary is caused by two missing BuildRequires packages in lxc.spec:

 BuildRequires:  libcap-static
 BuildRequires:  glibc-static

These packages must be installed in order for configure to set HAVE_STATIC_LIBCAP to yes resulting in make building init.lxc.static. 

The following patch is for the spec used to build lxc-3.0.3-1.fc29:

--- lxc.spec.orig	2018-11-23 04:15:08.000000000 -0500
+++ lxc.spec.new	2018-12-15 22:04:43.523635267 -0500
@@ -28,6 +28,8 @@
 BuildRequires:  libtool
 BuildRequires:  systemd
 BuildRequires:  pkgconfig(bash-completion)
+BuildRequires:  libcap-static
+BuildRequires:  glibc-static
 # lxc-extra subpackage not needed anymore, lxc-ls has been rewriten in
 # C and does not depend on the Python3 binding anymore
 Provides:       lxc-extra = %{version}-%{release}
@@ -197,6 +199,7 @@
 %{_libexecdir}/%{name}
 # fixme: should be in libexecdir?
 %{_sbindir}/init.%{name}
+%{_sbindir}/init.%{name}.static
 %{_bindir}/%{name}-autostart
 %{_sharedstatedir}/%{name}
 %dir %{_sysconfdir}/%{name}

Comment 3 Steven Galgano 2019-01-28 13:06:39 UTC
Created attachment 1524201 [details]
Adds BuildRequires  libcap-static and glibc-static, and file init.lxc.static.

Comment 4 Fedora Update System 2019-08-27 21:06:29 UTC
FEDORA-2019-c1dac1b3b8 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-c1dac1b3b8

Comment 5 Fedora Update System 2019-08-27 21:09:06 UTC
FEDORA-2019-2baa1f7b19 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-2baa1f7b19

Comment 6 Fedora Update System 2019-08-30 00:04:30 UTC
lxc-3.0.4-1.fc30, lxcfs-3.0.4-1.fc30, python3-lxc-3.0.4-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-2baa1f7b19

Comment 7 Fedora Update System 2019-08-30 00:25:29 UTC
lxc-3.0.4-1.fc29, lxcfs-3.0.4-1.fc29, python3-lxc-3.0.4-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-c1dac1b3b8

Comment 8 Fedora Update System 2019-09-06 12:33:06 UTC
lxc-3.0.4-1.fc30, lxcfs-3.0.4-1.fc30, python3-lxc-3.0.4-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2019-09-06 12:58:44 UTC
lxc-3.0.4-1.fc29, lxcfs-3.0.4-1.fc29, python3-lxc-3.0.4-1.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.