Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
45e854dc
Commit
45e854dc
authored
Jan 20, 2014
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
>
parent
f407c5e4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
27 deletions
+36
-27
lxc.spec.in
lxc.spec.in
+1
-1
Makefile.am
src/lxc/Makefile.am
+19
-16
conf.c
src/lxc/conf.c
+5
-2
monitor.c
src/lxc/monitor.c
+2
-1
lxc-test-usernic
src/tests/lxc-test-usernic
+9
-7
No files found.
lxc.spec.in
View file @
45e854dc
...
@@ -124,7 +124,6 @@ rm -rf %{buildroot}
...
@@ -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}
...
@@ -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
...
...
src/lxc/Makefile.am
View file @
45e854dc
...
@@ -113,6 +113,7 @@ AM_CFLAGS=-I$(top_srcdir)/src \
...
@@ -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
...
@@ -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
...
@@ -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
*
src/lxc/conf.c
View file @
45e854dc
...
@@ -2979,6 +2979,8 @@ void lxc_delete_network(struct lxc_handler *handler)
...
@@ -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)
...
@@ -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
);
}
}
...
...
src/lxc/monitor.c
View file @
45e854dc
...
@@ -269,6 +269,7 @@ int lxc_monitor_read(int fd, struct lxc_msg *msg)
...
@@ -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)
...
@@ -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
,
...
...
src/tests/lxc-test-usernic
View file @
45e854dc
...
@@ -68,13 +68,15 @@ brctl addbr usernic-br1
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment