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
41be52e8
Commit
41be52e8
authored
Mar 23, 2018
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hooks: fix dhclient hook when an AppArmor profile is active
Signed-off-by:
Felix Abecassis
<
fabecassis@nvidia.com
>
parent
4c6fb19b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
dhclient.in
hooks/dhclient.in
+11
-2
No files found.
hooks/dhclient.in
View file @
41be52e8
...
@@ -26,6 +26,15 @@ usage() {
...
@@ -26,6 +26,15 @@ usage() {
echo
"Usage:
${
0
##*/
}
<name> lxc {start-host|stop}"
echo
"Usage:
${
0
##*/
}
<name> lxc {start-host|stop}"
}
}
# Wrap the dhclient command with "aa-exec -p unconfined" if AppArmor is enabled.
dhclient
()
{
bin
=
"/sbin/dhclient"
if
[
-d
"/sys/kernel/security/apparmor"
]
&&
which aa-exec
>
/dev/null
;
then
bin
=
"aa-exec -p unconfined
${
bin
}
"
fi
echo
$bin
}
dhclient_start
()
{
dhclient_start
()
{
ns_args
=(
"--uts"
"--net"
)
ns_args
=(
"--uts"
"--net"
)
if
[
-z
"
$(
readlink
/proc/
${
LXC_PID
}
/ns/user /proc/self/ns/user |
uniq
-d
)
"
]
;
then
if
[
-z
"
$(
readlink
/proc/
${
LXC_PID
}
/ns/user /proc/self/ns/user |
uniq
-d
)
"
]
;
then
...
@@ -39,7 +48,7 @@ dhclient_start() {
...
@@ -39,7 +48,7 @@ dhclient_start() {
else
else
echo
"INFO: Starting DHCP client and acquiring a lease..."
>>
"
${
debugfile
}
"
echo
"INFO: Starting DHCP client and acquiring a lease..."
>>
"
${
debugfile
}
"
nsenter
${
ns_args
[@]
}
--target
"
${
LXC_PID
}
"
--
\
nsenter
${
ns_args
[@]
}
--target
"
${
LXC_PID
}
"
--
\
/sbin/dhclient
-1
${
conffile_arg
}
-pf
"
${
pidfile
}
"
-lf
"
${
leasefile
}
"
-e
"ROOTFS=
${
rootfs_path
}
"
-sf
"
${
LXC_DHCP_SCRIPT
}
"
-v
>>
"
${
debugfile
}
"
2>&1
$(
dhclient
)
-1
${
conffile_arg
}
-pf
"
${
pidfile
}
"
-lf
"
${
leasefile
}
"
-e
"ROOTFS=
${
rootfs_path
}
"
-sf
"
${
LXC_DHCP_SCRIPT
}
"
-v
>>
"
${
debugfile
}
"
2>&1
fi
fi
}
}
...
@@ -63,7 +72,7 @@ dhclient_stop() {
...
@@ -63,7 +72,7 @@ dhclient_stop() {
if
[
-e
"
${
pidfile
}
"
]
;
then
if
[
-e
"
${
pidfile
}
"
]
;
then
echo
"INFO: Stopping DHCP client and releasing leases..."
>>
"
${
debugfile
}
"
echo
"INFO: Stopping DHCP client and releasing leases..."
>>
"
${
debugfile
}
"
nsenter
${
ns_args
[@]
}
--
\
nsenter
${
ns_args
[@]
}
--
\
/sbin/dhclient
-r
${
conffile_arg
}
-pf
"
${
pidfile
}
"
-lf
"
${
leasefile
}
"
-e
"ROOTFS=
${
rootfs_path
}
"
-sf
"
${
LXC_DHCP_SCRIPT
}
"
-v
>>
"
${
debugfile
}
"
2>&1
$(
dhclient
)
-r
${
conffile_arg
}
-pf
"
${
pidfile
}
"
-lf
"
${
leasefile
}
"
-e
"ROOTFS=
${
rootfs_path
}
"
-sf
"
${
LXC_DHCP_SCRIPT
}
"
-v
>>
"
${
debugfile
}
"
2>&1
else
else
echo
"WARN: DHCP client is not running, skipping stop hook."
>>
"
${
debugfile
}
"
echo
"WARN: DHCP client is not running, skipping stop hook."
>>
"
${
debugfile
}
"
fi
fi
...
...
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