mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-04-30 13:43:14 +00:00
Move lxc-user-nic and lxc-monitord to libexec
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
f407c5e4c1
commit
45e854dc86
@ -124,7 +124,6 @@ rm -rf %{buildroot}
|
|||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%{_bindir}/*
|
%{_bindir}/*
|
||||||
%attr(4111,root,root) %{_bindir}/lxc-user-nic
|
|
||||||
%{_mandir}/man1/lxc*
|
%{_mandir}/man1/lxc*
|
||||||
%{_mandir}/man5/lxc*
|
%{_mandir}/man5/lxc*
|
||||||
%{_mandir}/man7/lxc*
|
%{_mandir}/man7/lxc*
|
||||||
@ -150,6 +149,7 @@ rm -rf %{buildroot}
|
|||||||
%endif
|
%endif
|
||||||
%{_localstatedir}/*
|
%{_localstatedir}/*
|
||||||
%attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
|
%attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
|
||||||
|
%attr(4111,root,root) %{_libexecdir}/%{name}/lxc-user-nic
|
||||||
%if %{with_systemd}
|
%if %{with_systemd}
|
||||||
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
|
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
|
||||||
%endif
|
%endif
|
||||||
|
@ -113,6 +113,7 @@ AM_CFLAGS=-I$(top_srcdir)/src \
|
|||||||
-DLXCPATH=\"$(LXCPATH)\" \
|
-DLXCPATH=\"$(LXCPATH)\" \
|
||||||
-DLXC_GLOBAL_CONF=\"$(LXC_GLOBAL_CONF)\" \
|
-DLXC_GLOBAL_CONF=\"$(LXC_GLOBAL_CONF)\" \
|
||||||
-DLXCINITDIR=\"$(LXCINITDIR)\" \
|
-DLXCINITDIR=\"$(LXCINITDIR)\" \
|
||||||
|
-DLIBEXECDIR=\"$(LIBEXECDIR)\" \
|
||||||
-DLXCTEMPLATEDIR=\"$(LXCTEMPLATEDIR)\" \
|
-DLXCTEMPLATEDIR=\"$(LXCTEMPLATEDIR)\" \
|
||||||
-DLOGPATH=\"$(LOGPATH)\" \
|
-DLOGPATH=\"$(LOGPATH)\" \
|
||||||
-DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" \
|
-DLXC_DEFAULT_CONFIG=\"$(LXC_DEFAULT_CONFIG)\" \
|
||||||
@ -181,28 +182,28 @@ endif
|
|||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
lxc-attach \
|
lxc-attach \
|
||||||
lxc-autostart \
|
lxc-autostart \
|
||||||
lxc-unshare \
|
lxc-cgroup \
|
||||||
lxc-stop \
|
|
||||||
lxc-start \
|
|
||||||
lxc-clone \
|
lxc-clone \
|
||||||
lxc-execute \
|
lxc-config \
|
||||||
lxc-monitor \
|
|
||||||
lxc-monitord \
|
|
||||||
lxc-wait \
|
|
||||||
lxc-console \
|
lxc-console \
|
||||||
|
lxc-create \
|
||||||
|
lxc-destroy \
|
||||||
|
lxc-execute \
|
||||||
lxc-freeze \
|
lxc-freeze \
|
||||||
lxc-info \
|
lxc-info \
|
||||||
lxc-cgroup \
|
lxc-monitor \
|
||||||
lxc-unfreeze \
|
|
||||||
lxc-config \
|
|
||||||
lxc-destroy \
|
|
||||||
lxc-create \
|
|
||||||
lxc-user-nic \
|
|
||||||
lxc-snapshot \
|
lxc-snapshot \
|
||||||
lxc-usernsexec
|
lxc-start \
|
||||||
|
lxc-stop \
|
||||||
|
lxc-unfreeze \
|
||||||
|
lxc-unshare \
|
||||||
|
lxc-usernsexec \
|
||||||
|
lxc-wait
|
||||||
|
|
||||||
pkglibexec_PROGRAMS = \
|
pkglibexec_PROGRAMS = \
|
||||||
lxc-init
|
lxc-init \
|
||||||
|
lxc-monitord \
|
||||||
|
lxc-user-nic
|
||||||
|
|
||||||
AM_LDFLAGS = -Wl,-E
|
AM_LDFLAGS = -Wl,-E
|
||||||
if ENABLE_RPATH
|
if ENABLE_RPATH
|
||||||
@ -245,7 +246,9 @@ install-exec-local: install-soPROGRAMS
|
|||||||
cd $(DESTDIR)$(libdir); \
|
cd $(DESTDIR)$(libdir); \
|
||||||
ln -sf liblxc.so.$(VERSION) liblxc.so.$(firstword $(subst ., ,$(VERSION))); \
|
ln -sf liblxc.so.$(VERSION) liblxc.so.$(firstword $(subst ., ,$(VERSION))); \
|
||||||
ln -sf liblxc.so.$(firstword $(subst ., ,$(VERSION))) liblxc.so
|
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:
|
uninstall-local:
|
||||||
$(RM) $(DESTDIR)$(libdir)/liblxc.so*
|
$(RM) $(DESTDIR)$(libdir)/liblxc.so*
|
||||||
|
@ -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)
|
static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
|
||||||
{
|
{
|
||||||
pid_t child;
|
pid_t child;
|
||||||
@ -2998,11 +3000,12 @@ static int unpriv_assign_nic(struct lxc_netdev *netdev, pid_t pid)
|
|||||||
return wait_for_pid(child);
|
return wait_for_pid(child);
|
||||||
|
|
||||||
// Call lxc-user-nic pid type bridge
|
// Call lxc-user-nic pid type bridge
|
||||||
|
|
||||||
char pidstr[20];
|
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);
|
snprintf(pidstr, 19, "%lu", (unsigned long) pid);
|
||||||
pidstr[19] = '\0';
|
pidstr[19] = '\0';
|
||||||
execvp("lxc-user-nic", args);
|
execvp(args[0], args);
|
||||||
SYSERROR("execvp lxc-user-nic");
|
SYSERROR("execvp lxc-user-nic");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -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
|
/* used to spawn a monitord either on startup of a daemon container, or when
|
||||||
* lxc-monitor starts
|
* lxc-monitor starts
|
||||||
@ -280,7 +281,7 @@ int lxc_monitord_spawn(const char *lxcpath)
|
|||||||
char pipefd_str[11];
|
char pipefd_str[11];
|
||||||
|
|
||||||
char * const args[] = {
|
char * const args[] = {
|
||||||
"lxc-monitord",
|
LXC_MONITORD_PATH,
|
||||||
(char *)lxcpath,
|
(char *)lxcpath,
|
||||||
pipefd_str,
|
pipefd_str,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -68,13 +68,15 @@ brctl addbr usernic-br1
|
|||||||
ifconfig usernic-br0 0.0.0.0 up
|
ifconfig usernic-br0 0.0.0.0 up
|
||||||
ifconfig usernic-br1 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
|
# 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-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"
|
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 }'`
|
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
|
# 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
|
if [ $? -eq 0 ]; then
|
||||||
echo "FAIL: able to create nic with no entries"
|
echo "FAIL: able to create nic with no entries"
|
||||||
cleanup 1
|
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
|
echo "lxc-usernet veth usernic-br0 2" >> /etc/lxc/lxc-usernet
|
||||||
|
|
||||||
# Assign one veth to second bridge, should fail
|
# 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
|
if [ $? -eq 0 ]; then
|
||||||
echo "FAIL: able to create nic with no entries"
|
echo "FAIL: able to create nic with no entries"
|
||||||
cleanup 1
|
cleanup 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Assign two veths, should succeed
|
# 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
|
if [ $? -ne 0 ]; then
|
||||||
echo "FAIL: unable to create first nic"
|
echo "FAIL: unable to create first nic"
|
||||||
cleanup 1
|
cleanup 1
|
||||||
fi
|
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
|
if [ $? -ne 0 ]; then
|
||||||
echo "FAIL: unable to create second nic"
|
echo "FAIL: unable to create second nic"
|
||||||
cleanup 1
|
cleanup 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Assign one more veth, should fail.
|
# 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
|
if [ $? -eq 0 ]; then
|
||||||
echo "FAIL: able to create third nic"
|
echo "FAIL: able to create third nic"
|
||||||
cleanup 1
|
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-stop -P /tmp/usernic-test/lxcbase -n b1"
|
||||||
su -l usernic-user -c "lxc-start -P /tmp/usernic-test/lxcbase -n b1 -d"
|
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 }'`
|
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
|
if [ $? -ne 0 ]; then
|
||||||
echo "FAIL: unable to create nic after destroying the old"
|
echo "FAIL: unable to create nic after destroying the old"
|
||||||
cleanup 1
|
cleanup 1
|
||||||
@ -129,7 +131,7 @@ lxc-start -n usernic-c1 -d
|
|||||||
p2=`lxc-info -n usernic-c1 -p | awk -F: '{ print $2}'`
|
p2=`lxc-info -n usernic-c1 -p | awk -F: '{ print $2}'`
|
||||||
|
|
||||||
# assign veth to it - should fail
|
# 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=$?
|
ret=$?
|
||||||
lxc-stop -n usernic-c1
|
lxc-stop -n usernic-c1
|
||||||
lxc-destroy -n usernic-c1
|
lxc-destroy -n usernic-c1
|
||||||
|
Loading…
Reference in New Issue
Block a user