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
5014ff2e
Unverified
Commit
5014ff2e
authored
May 31, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: add getter for lxc.id_map
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b863bf92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
53 deletions
+55
-53
confile.c
src/lxc/confile.c
+55
-53
No files found.
src/lxc/confile.c
View file @
5014ff2e
...
@@ -91,7 +91,9 @@ static int get_config_lsm_se_context(struct lxc_container *, const char *, char
...
@@ -91,7 +91,9 @@ static int get_config_lsm_se_context(struct lxc_container *, const char *, char
static
int
set_config_cgroup
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_cgroup
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
get_config_cgroup
(
struct
lxc_container
*
,
const
char
*
,
char
*
,
int
);
static
int
get_config_cgroup
(
struct
lxc_container
*
,
const
char
*
,
char
*
,
int
);
static
int
set_config_idmap
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_idmaps
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
get_config_idmaps
(
struct
lxc_container
*
,
const
char
*
,
char
*
,
int
);
static
int
set_config_loglevel
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_loglevel
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_logfile
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_logfile
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_mount
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
static
int
set_config_mount
(
const
char
*
,
const
char
*
,
struct
lxc_conf
*
);
...
@@ -153,7 +155,7 @@ static struct lxc_config_t config[] = {
...
@@ -153,7 +155,7 @@ static struct lxc_config_t config[] = {
{
"lxc.aa_allow_incomplete"
,
set_config_lsm_aa_incomplete
,
get_config_lsm_aa_incomplete
,
NULL
},
{
"lxc.aa_allow_incomplete"
,
set_config_lsm_aa_incomplete
,
get_config_lsm_aa_incomplete
,
NULL
},
{
"lxc.se_context"
,
set_config_lsm_se_context
,
get_config_lsm_se_context
,
NULL
},
{
"lxc.se_context"
,
set_config_lsm_se_context
,
get_config_lsm_se_context
,
NULL
},
{
"lxc.cgroup"
,
set_config_cgroup
,
get_config_cgroup
,
NULL
},
{
"lxc.cgroup"
,
set_config_cgroup
,
get_config_cgroup
,
NULL
},
{
"lxc.id_map"
,
set_config_idmap
,
NULL
,
NULL
},
{
"lxc.id_map"
,
set_config_idmap
s
,
get_config_idmaps
,
NULL
},
{
"lxc.loglevel"
,
set_config_loglevel
,
NULL
,
NULL
},
{
"lxc.loglevel"
,
set_config_loglevel
,
NULL
,
NULL
},
{
"lxc.logfile"
,
set_config_logfile
,
NULL
,
NULL
},
{
"lxc.logfile"
,
set_config_logfile
,
NULL
,
NULL
},
{
"lxc.mount.entry"
,
set_config_mount
,
NULL
,
NULL
},
{
"lxc.mount.entry"
,
set_config_mount
,
NULL
,
NULL
},
...
@@ -1815,7 +1817,8 @@ out:
...
@@ -1815,7 +1817,8 @@ out:
return
-
1
;
return
-
1
;
}
}
static
int
set_config_idmap
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
static
int
set_config_idmaps
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
)
{
{
unsigned
long
hostid
,
nsid
,
range
;
unsigned
long
hostid
,
nsid
,
range
;
char
type
;
char
type
;
...
@@ -2928,54 +2931,6 @@ static int lxc_get_item_network(struct lxc_conf *c, char *retv, int inlen)
...
@@ -2928,54 +2931,6 @@ static int lxc_get_item_network(struct lxc_conf *c, char *retv, int inlen)
return
fulllen
;
return
fulllen
;
}
}
static
int
lxc_get_idmaps
(
struct
lxc_conf
*
c
,
char
*
retv
,
int
inlen
)
{
struct
lxc_list
*
it
;
int
len
,
listlen
,
ret
;
int
fulllen
=
0
;
/* "u 1000 1000000 65536"
*
* let's render this as
*
* sizeof(char)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* \0
*/
#define __LXC_IDMAP_STR_BUF (3 * LXC_NUMSTRLEN64 + 3 + 1 + 1)
char
buf
[
__LXC_IDMAP_STR_BUF
];
if
(
!
retv
)
inlen
=
0
;
else
memset
(
retv
,
0
,
inlen
);
listlen
=
lxc_list_len
(
&
c
->
id_map
);
lxc_list_for_each
(
it
,
&
c
->
id_map
)
{
struct
id_map
*
map
=
it
->
elem
;
ret
=
snprintf
(
buf
,
__LXC_IDMAP_STR_BUF
,
"%c %lu %lu %lu"
,
(
map
->
idtype
==
ID_TYPE_UID
)
?
'u'
:
'g'
,
map
->
nsid
,
map
->
hostid
,
map
->
range
);
if
(
ret
<
0
||
ret
>=
__LXC_IDMAP_STR_BUF
)
return
-
1
;
strprint
(
retv
,
inlen
,
"%s%s"
,
buf
,
(
listlen
--
>
1
)
?
"
\n
"
:
""
);
}
return
fulllen
;
}
int
lxc_get_config_item
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
int
lxc_get_config_item
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
int
inlen
)
{
{
...
@@ -3045,8 +3000,6 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
...
@@ -3045,8 +3000,6 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
return
lxc_get_limit_entry
(
c
,
retv
,
inlen
,
"all"
);
return
lxc_get_limit_entry
(
c
,
retv
,
inlen
,
"all"
);
else
if
(
strncmp
(
key
,
"lxc.limit."
,
10
)
==
0
)
// specific limit
else
if
(
strncmp
(
key
,
"lxc.limit."
,
10
)
==
0
)
// specific limit
return
lxc_get_limit_entry
(
c
,
retv
,
inlen
,
key
+
10
);
return
lxc_get_limit_entry
(
c
,
retv
,
inlen
,
key
+
10
);
else
if
(
strcmp
(
key
,
"lxc.id_map"
)
==
0
)
return
lxc_get_idmaps
(
c
,
retv
,
inlen
);
else
if
(
strcmp
(
key
,
"lxc.haltsignal"
)
==
0
)
else
if
(
strcmp
(
key
,
"lxc.haltsignal"
)
==
0
)
return
lxc_get_conf_int
(
c
,
retv
,
inlen
,
c
->
haltsignal
);
return
lxc_get_conf_int
(
c
,
retv
,
inlen
,
c
->
haltsignal
);
else
if
(
strcmp
(
key
,
"lxc.rebootsignal"
)
==
0
)
else
if
(
strcmp
(
key
,
"lxc.rebootsignal"
)
==
0
)
...
@@ -3753,3 +3706,52 @@ static int get_config_cgroup(struct lxc_container *c, const char *key,
...
@@ -3753,3 +3706,52 @@ static int get_config_cgroup(struct lxc_container *c, const char *key,
return
fulllen
;
return
fulllen
;
}
}
static
int
get_config_idmaps
(
struct
lxc_container
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
{
struct
lxc_list
*
it
;
int
len
,
listlen
,
ret
;
int
fulllen
=
0
;
/* "u 1000 1000000 65536"
*
* let's render this as
*
* sizeof(char)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* sizeof(" ")
* +
* sizeof(uint64_t)
* +
* \0
*/
#define __LXC_IDMAP_STR_BUF (3 * LXC_NUMSTRLEN64 + 3 + 1 + 1)
char
buf
[
__LXC_IDMAP_STR_BUF
];
if
(
!
retv
)
inlen
=
0
;
else
memset
(
retv
,
0
,
inlen
);
listlen
=
lxc_list_len
(
&
c
->
lxc_conf
->
id_map
);
lxc_list_for_each
(
it
,
&
c
->
lxc_conf
->
id_map
)
{
struct
id_map
*
map
=
it
->
elem
;
ret
=
snprintf
(
buf
,
__LXC_IDMAP_STR_BUF
,
"%c %lu %lu %lu"
,
(
map
->
idtype
==
ID_TYPE_UID
)
?
'u'
:
'g'
,
map
->
nsid
,
map
->
hostid
,
map
->
range
);
if
(
ret
<
0
||
ret
>=
__LXC_IDMAP_STR_BUF
)
return
-
1
;
strprint
(
retv
,
inlen
,
"%s%s"
,
buf
,
(
listlen
--
>
1
)
?
"
\n
"
:
""
);
}
return
fulllen
;
}
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