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
b8cfbbd1
Commit
b8cfbbd1
authored
Sep 21, 2018
by
Jungsub Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template: oci template supports for char user info
oci template changes character user info to uid, gid according to OCI image spec. Signed-off-by: Jungsub Shin jungsub_shin@tmax.co.kr
parent
78852a0c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
lxc-oci.in
templates/lxc-oci.in
+31
-12
No files found.
templates/lxc-oci.in
View file @
b8cfbbd1
...
@@ -129,23 +129,42 @@ getenv() {
...
@@ -129,23 +129,42 @@ getenv() {
return
return
}
}
# FIXME 1: only support numerical values in the configuration file.
# check var is decimal.
# FIXME 2: from the OCI image spec: "If group/gid is not specified,
isdecimal
()
{
# the default group and supplementary groups of the given user/uid in
var
=
"
$1
"
# /etc/passwd from the container are applied."
if
[
"
${
var
}
"
-eq
"
${
var
}
"
]
2> /dev/null
;
then
getuidgid
()
{
return
0
if
[
"$#"
-eq
0
]
;
then
else
echo
"0 0"
return
1
return
fi
fi
}
# get uid, gid from oci image.
getuidgid
()
{
configpath
=
"
$1
"
configpath
=
"
$1
"
rootpath
=
"
$2
"
passwdpath
=
"
${
rootpath
}
/etc/passwd"
grouppath
=
"
${
rootpath
}
/etc/group"
u
idgid
=
$(
jq
-c
-r
'.config.User // "0:0"
'
<
"
${
configpath
}
"
)
u
sergroup
=
$(
jq
-c
-r
'.config.User
'
<
"
${
configpath
}
"
)
# shellcheck disable=SC2039
# shellcheck disable=SC2039
uidgid
=(
${
uidgid
//
:/
}
)
usergroup
=(
${
usergroup
//
:/
}
)
user
=
${
usergroup
[0]
:-
0
}
if
!
isdecimal
"
${
user
}
"
&&
[
-f
${
passwdpath
}
]
;
then
user
=
$(
grep
"^
${
user
}
:"
"
${
passwdpath
}
"
|
awk
-F
:
'{print $3}'
)
else
user
=
0
fi
group
=
${
usergroup
[1]
:-}
if
[
-z
"
${
group
}
"
]
&&
[
-f
"
${
passwdpath
}
"
]
;
then
group
=
$(
grep
"^[^:]*:[^:]*:
${
user
}
:"
"
${
passwdpath
}
"
|
awk
-F
:
'{print $4}'
)
elif
!
isdecimal
"
${
group
}
"
&&
[
-f
"
${
grouppath
}
"
]
;
then
group
=
$(
grep
"^
${
group
}
:"
"
${
grouppath
}
"
|
awk
-F
:
'{print $3}'
)
fi
printf
'%d %d'
"
${
uidgid
[0]
:-
0
}
"
"
${
uidgid
[1]
:-
0
}
"
2>/dev/null
||
true
echo
"
${
user
:-
0
}
${
group
:-
0
}
"
return
return
}
}
...
@@ -364,7 +383,7 @@ ff02::2 ip6-allrouters
...
@@ -364,7 +383,7 @@ ff02::2 ip6-allrouters
EOF
EOF
# shellcheck disable=SC2039
# shellcheck disable=SC2039
uidgid
=(
$(
getuidgid
"
${
OCI_CONF_FILE
}
"
)
)
uidgid
=(
$(
getuidgid
"
${
OCI_CONF_FILE
}
"
"
${
LXC_ROOTFS
}
"
)
)
# shellcheck disable=SC2039
# shellcheck disable=SC2039
echo
"lxc.init.uid =
${
uidgid
[0]
}
"
>>
"
${
LXC_CONF_FILE
}
"
echo
"lxc.init.uid =
${
uidgid
[0]
}
"
>>
"
${
LXC_CONF_FILE
}
"
# shellcheck disable=SC2039
# shellcheck disable=SC2039
...
...
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