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
e86dcc91
Commit
e86dcc91
authored
Dec 08, 2017
by
Felix Abecassis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc-oci: add basic handling of numerical uid/gid
Signed-off-by:
Felix Abecassis
<
fabecassis@nvidia.com
>
parent
f6812e7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
lxc-oci.in
templates/lxc-oci.in
+23
-0
No files found.
templates/lxc-oci.in
View file @
e86dcc91
...
...
@@ -121,6 +121,25 @@ getenv() {
return
}
# FIXME 1: only support numerical values in the configuration file.
# FIXME 2: from the OCI image spec: "If group/gid is not specified,
# the default group and supplementary groups of the given user/uid in
# /etc/passwd from the container are applied."
getuidgid
()
{
if
[
"$#"
-eq
0
]
;
then
echo
"0 0"
return
fi
configpath
=
"
$1
"
uidgid
=
`
cat
"
${
configpath
}
"
| jq
-c
-r
'.config.User // "0:0"'
`
uidgid
=(
${
uidgid
//
:/
}
)
printf
'%d %d'
${
uidgid
[0]
:-
0
}
${
uidgid
[1]
:-
0
}
2>/dev/null
||
true
return
}
usage
()
{
cat
<<
EOF
LXC container template for OCI images
...
...
@@ -291,6 +310,10 @@ cat <<EOF > ${LXC_ROOTFS}/etc/hosts
127.0.1.1
${
LXC_NAME
}
EOF
uidgid
=(
$(
getuidgid
${
OCI_CONF_FILE
})
)
echo
"lxc.init.uid =
${
uidgid
[0]
}
"
>>
"
${
LXC_CONF_FILE
}
"
echo
"lxc.init.gid =
${
uidgid
[1]
}
"
>>
"
${
LXC_CONF_FILE
}
"
if
[
-n
"
$LXC_MAPPED_UID
"
]
&&
[
"
$LXC_MAPPED_UID
"
!=
"-1"
]
;
then
chown
$LXC_MAPPED_UID
$LXC_PATH
/config
$LXC_PATH
/fstab
>
/dev/null 2>&1
||
true
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