]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Move lxc-user-nic and lxc-monitord to libexec
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 21 Jan 2014 02:40:54 +0000 (21:40 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 21 Jan 2014 04:27:16 +0000 (23:27 -0500)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
lxc.spec.in
src/lxc/Makefile.am
src/lxc/conf.c
src/lxc/monitor.c
src/tests/lxc-test-usernic

index c8ff08e8f6a98f8e8aa5cb606d4d3913c619ed01..5e68df26cb8e7613bf12f47b821c9941ad1b6f3b 100644 (file)
@@ -124,7 +124,6 @@ rm -rf %{buildroot}
 %files
 %defattr(-,root,root)
 %{_bindir}/*
-%attr(4111,root,root) %{_bindir}/lxc-user-nic
 %{_mandir}/man1/lxc*
 %{_mandir}/man5/lxc*
 %{_mandir}/man7/lxc*
@@ -150,6 +149,7 @@ rm -rf %{buildroot}
 %endif
 %{_localstatedir}/*
 %attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
+%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
 %if %{with_systemd}
 %attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
 %endif
index 602447e37a465e1053fe717fe5e291b3c4167a48..25cdf6d86a190942386ea0d40c4cabfd1abedea7 100644 (file)
@@ -113,6 +113,7 @@ AM_CFLAGS=-I$(top_srcdir)/src \
        -DLXCPATH=\"$(LXCPATH)\" \
        -DLXC_GLOBAL_CONF=\"$(LXC_GLOBAL_CONF)\" \
        -DLXCINITDIR=\"$(LXCINITDIR)\" \
+       -DLIBEXECDIR=\"$(LIBEXECDIR)\" \
        -DLXCTEMPLATEDIR=\"$(LXCTEMPLATEDIR)\" \
        -DLOGPATH=\"$(LOGPATH)\" \
        -DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" \
@@ -181,28 +182,28 @@ endif
 bin_PROGRAMS = \
        lxc-attach \
        lxc-autostart \
-       lxc-unshare \
-       lxc-stop \
-       lxc-start \
+       lxc-cgroup \
        lxc-clone \
-       lxc-execute \
-       lxc-monitor \
-       lxc-monitord \
-       lxc-wait \
+       lxc-config \
        lxc-console \
+       lxc-create \
+       lxc-destroy \
+       lxc-execute \
        lxc-freeze \
        lxc-info \
-       lxc-cgroup \
-       lxc-unfreeze \
-       lxc-config \
-       lxc-destroy \
-       lxc-create \
-       lxc-user-nic \
+       lxc-monitor \
        lxc-snapshot \
-       lxc-usernsexec
+       lxc-start \
+       lxc-stop \
+       lxc-unfreeze \
+       lxc-unshare \
+       lxc-usernsexec \
+       lxc-wait
 
 pkglibexec_PROGRAMS = \
-       lxc-init
+       lxc-init \
+       lxc-monitord \
+       lxc-user-nic
 
 AM_LDFLAGS = -Wl,-E
 if ENABLE_RPATH
@@ -245,7 +246,9 @@ install-exec-local: install-soPROGRAMS
        cd $(DESTDIR)$(libdir); \
        ln -sf liblxc.so.$(VERSION) liblxc.so.$(firstword $(subst ., ,$(VERSION))); \
        ln -sf liblxc.so.$(firstword $(subst ., ,$(VERSION))) liblxc.so
-       chmod u+s $(DESTDIR)$(bindir)/lxc-user-nic
+
+install-exec-hook:
+       chmod u+s $(DESTDIR)$(libexecdir)/lxc/lxc-user-nic
 
 uninstall-local:
        $(RM) $(DESTDIR)$(libdir)/liblxc.so*
index 8ce783bef48e56c3d6e3a6205644938429fc2cd5..30d72d4f8333ba031c8506989939226208069ce5 100644 (file)
@@ -2979,6 +2979,8 @@ void lxc_delete_network(struct lxc_handler *handler)
        }
 }
 
+#define LXC_USERNIC_PATH LIBEXECDIR "/lxc/lxc-user-nic"
+
 static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
 {
        pid_t child;
@@ -2998,11 +3000,12 @@ static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
                return wait_for_pid(child);
 
        // Call lxc-user-nic pid type bridge
+
        char pidstr[20];
-       char *args[] = { "lxc-user-nic", pidstr, "veth", netdev->link, netdev->name, NULL };
+       char *args[] = {LXC_USERNIC_PATH, pidstr, "veth", netdev->link, netdev->name, NULL };
        snprintf(pidstr, 19, "%lu", (unsigned long) pid);
        pidstr[19] = '\0';
-       execvp("lxc-user-nic", args);
+       execvp(args[0], args);
        SYSERROR("execvp lxc-user-nic");
        exit(1);
 }
index 1fe117072b28e4e9ccf2a77182942708b5f154e3..87925dc741c7a36e3df16a0f4d9f1e699e08fbc0 100644 (file)
@@ -269,6 +269,7 @@ int lxc_monitor_read(int fd, struct lxc_msg *msg)
 }
 
 
+#define LXC_MONITORD_PATH LIBEXECDIR "/lxc/lxc-monitord"
 
 /* used to spawn a monitord either on startup of a daemon container, or when
  * lxc-monitor starts
@@ -280,7 +281,7 @@ int lxc_monitord_spawn(const char *lxcpath)
        char pipefd_str[11];
 
        char * const args[] = {
-               "lxc-monitord",
+               LXC_MONITORD_PATH,
                (char *)lxcpath,
                pipefd_str,
                NULL,
index 801419a870d3f35f5fb98cf501afed0df6aabc53..e641cb9bc71b7042007232a1333e193e4c48bc29 100755 (executable)
@@ -68,13 +68,15 @@ brctl addbr usernic-br1
 ifconfig usernic-br0 0.0.0.0 up
 ifconfig usernic-br1 0.0.0.0 up
 
+LXC_USERNIC_PATH=$(ls -1 /usr/lib/*/lxc/lxc-user-nic | head -1)
+
 # Create three containers
 su -l usernic-user -c "lxc-create -P /tmp/usernic-test/lxcbase -t busybox -n b1 -f /tmp/lxc-usernic.conf"
 su -l usernic-user -c "lxc-start -P /tmp/usernic-test/lxcbase -n b1 -d"
 p1=`lxc-info -P /tmp/usernic-test/lxcbase -n b1 -p | awk -F: '{ print $2 }'`
 
 # Assign one veth, should fail as no allowed entries yet
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br0 xx1"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br0 xx1"
 if [ $? -eq 0 ]; then
        echo "FAIL: able to create nic with no entries"
        cleanup 1
@@ -86,26 +88,26 @@ sed -i '/^lxc-usernet/d' /etc/lxc/lxc-usernet
 echo "lxc-usernet veth usernic-br0 2" >> /etc/lxc/lxc-usernet
 
 # Assign one veth to second bridge, should fail
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br1 xx1"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br1 xx1"
 if [ $? -eq 0 ]; then
        echo "FAIL: able to create nic with no entries"
        cleanup 1
 fi
 
 # Assign two veths, should succeed
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br0 xx2"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br0 xx2"
 if [ $? -ne 0 ]; then
        echo "FAIL: unable to create first nic"
        cleanup 1
 fi
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br0 xx3"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br0 xx3"
 if [ $? -ne 0 ]; then
        echo "FAIL: unable to create second nic"
        cleanup 1
 fi
 
 # Assign one more veth, should fail.
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br0 xx4"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br0 xx4"
 if [ $? -eq 0 ]; then
        echo "FAIL: able to create third nic"
        cleanup 1
@@ -115,7 +117,7 @@ fi
 su -l usernic-user -c "lxc-stop -P /tmp/usernic-test/lxcbase -n b1"
 su -l usernic-user -c "lxc-start -P /tmp/usernic-test/lxcbase -n b1 -d"
 p1=`lxc-info -P /tmp/usernic-test/lxcbase -n b1 -p | awk -F: '{ print $2 }'`
-su -l usernic-user -c "lxc-user-nic $p1 veth usernic-br0 xx5"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p1 veth usernic-br0 xx5"
 if [ $? -ne 0 ]; then
        echo "FAIL: unable to create nic after destroying the old"
        cleanup 1
@@ -129,7 +131,7 @@ lxc-start -n usernic-c1 -d
 p2=`lxc-info -n usernic-c1 -p | awk -F: '{ print $2}'`
 
 # assign veth to it - should fail
-su -l usernic-user -c "lxc-user-nic $p2 veth usernic-br0 xx6"
+su -l usernic-user -c "$LXC_USERNIC_PATH $p2 veth usernic-br0 xx6"
 ret=$?
 lxc-stop -n usernic-c1
 lxc-destroy -n usernic-c1