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
fe9b7349
Unverified
Commit
fe9b7349
authored
Aug 16, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: list namespaced keys
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
300df83e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
6 deletions
+103
-6
confile.c
src/lxc/confile.c
+61
-0
confile.h
src/lxc/confile.h
+40
-6
lxccontainer.c
src/lxc/lxccontainer.c
+2
-0
No files found.
src/lxc/confile.c
View file @
fe9b7349
...
@@ -4453,6 +4453,67 @@ int lxc_list_config_items(char *retv, int inlen)
...
@@ -4453,6 +4453,67 @@ int lxc_list_config_items(char *retv, int inlen)
return
fulllen
;
return
fulllen
;
}
}
int
lxc_list_subkeys
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
{
int
len
;
int
fulllen
=
0
;
if
(
!
retv
)
inlen
=
0
;
else
memset
(
retv
,
0
,
inlen
);
if
(
!
strcmp
(
key
,
"lxc.apparmor"
))
{
strprint
(
retv
,
inlen
,
"allow_incomplete
\n
"
);
strprint
(
retv
,
inlen
,
"profile
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.selinux"
))
{
strprint
(
retv
,
inlen
,
"context
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.mount"
))
{
strprint
(
retv
,
inlen
,
"auto
\n
"
);
strprint
(
retv
,
inlen
,
"entry
\n
"
);
strprint
(
retv
,
inlen
,
"fstab
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.rootfs"
))
{
strprint
(
retv
,
inlen
,
"mount
\n
"
);
strprint
(
retv
,
inlen
,
"options
\n
"
);
strprint
(
retv
,
inlen
,
"path
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.uts"
))
{
strprint
(
retv
,
inlen
,
"name
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.hook"
))
{
strprint
(
retv
,
inlen
,
"autodev
\n
"
);
strprint
(
retv
,
inlen
,
"clone
\n
"
);
strprint
(
retv
,
inlen
,
"destroy
\n
"
);
strprint
(
retv
,
inlen
,
"mount
\n
"
);
strprint
(
retv
,
inlen
,
"post-stop
\n
"
);
strprint
(
retv
,
inlen
,
"pre-mount
\n
"
);
strprint
(
retv
,
inlen
,
"pre-start
\n
"
);
strprint
(
retv
,
inlen
,
"start
\n
"
);
strprint
(
retv
,
inlen
,
"stop
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.cap"
))
{
strprint
(
retv
,
inlen
,
"drop
\n
"
);
strprint
(
retv
,
inlen
,
"keep
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.console"
))
{
strprint
(
retv
,
inlen
,
"logfile
\n
"
);
strprint
(
retv
,
inlen
,
"path
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.seccomp"
))
{
strprint
(
retv
,
inlen
,
"profile
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.signal"
))
{
strprint
(
retv
,
inlen
,
"halt
\n
"
);
strprint
(
retv
,
inlen
,
"reboot
\n
"
);
strprint
(
retv
,
inlen
,
"stop
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.start"
))
{
strprint
(
retv
,
inlen
,
"auto
\n
"
);
strprint
(
retv
,
inlen
,
"delay
\n
"
);
strprint
(
retv
,
inlen
,
"order
\n
"
);
}
else
if
(
!
strcmp
(
key
,
"lxc.monitor"
))
{
strprint
(
retv
,
inlen
,
"unshare
\n
"
);
}
else
{
fulllen
=
-
1
;
}
return
fulllen
;
}
int
lxc_list_net
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
int
lxc_list_net
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
)
{
{
int
len
;
int
len
;
...
...
src/lxc/confile.h
View file @
fe9b7349
...
@@ -33,10 +33,21 @@
...
@@ -33,10 +33,21 @@
struct
lxc_conf
;
struct
lxc_conf
;
struct
lxc_list
;
struct
lxc_list
;
/* Callback prototype to set a configuration item.
* Must be implemented when adding a new configuration key.
*/
typedef
int
(
*
config_set_cb
)(
const
char
*
key
,
const
char
*
value
,
typedef
int
(
*
config_set_cb
)(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
conf
,
void
*
data
);
struct
lxc_conf
*
conf
,
void
*
data
);
/* Callback prototype to get a configuration item.
* Must be implemented when adding a new configuration key.
*/
typedef
int
(
*
config_get_cb
)(
const
char
*
key
,
char
*
value
,
int
inlen
,
typedef
int
(
*
config_get_cb
)(
const
char
*
key
,
char
*
value
,
int
inlen
,
struct
lxc_conf
*
conf
,
void
*
data
);
struct
lxc_conf
*
conf
,
void
*
data
);
/* Callback prototype to clear a configuration item.
* Must be implemented when adding a new configuration key.
*/
typedef
int
(
*
config_clr_cb
)(
const
char
*
key
,
struct
lxc_conf
*
conf
,
typedef
int
(
*
config_clr_cb
)(
const
char
*
key
,
struct
lxc_conf
*
conf
,
void
*
data
);
void
*
data
);
...
@@ -47,37 +58,60 @@ struct lxc_config_t {
...
@@ -47,37 +58,60 @@ struct lxc_config_t {
config_clr_cb
clr
;
config_clr_cb
clr
;
};
};
/* Get the jump table entry for the given configuration key. */
extern
struct
lxc_config_t
*
lxc_get_config
(
const
char
*
key
);
extern
struct
lxc_config_t
*
lxc_get_config
(
const
char
*
key
);
/* List all available config items. */
extern
int
lxc_list_config_items
(
char
*
retv
,
int
inlen
);
/* Given a configuration key namespace (e.g. lxc.apparmor) list all associated
* subkeys for that namespace.
* Must be implemented when adding a new configuration key.
*/
extern
int
lxc_list_subkeys
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
char
*
retv
,
int
inlen
);
/* List all configuration items associated with a given network. For example
/* List all configuration items associated with a given network. For example
* pass "lxc.net.[i]" to retrieve all configuration items associated with
* pass "lxc.net.[i]" to retrieve all configuration items associated with
* the network associated with index [i].
* the network associated with index [i].
*/
*/
extern
int
lxc_list_net
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
extern
int
lxc_list_net
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
int
inlen
);
int
inlen
);
extern
int
lxc_list_config_items
(
char
*
retv
,
int
inlen
);
extern
int
lxc_config_read
(
const
char
*
file
,
struct
lxc_conf
*
conf
,
bool
from_include
);
extern
int
lxc_config_read
(
const
char
*
file
,
struct
lxc_conf
*
conf
,
bool
from_include
);
extern
int
append_unexp_config_line
(
const
char
*
line
,
struct
lxc_conf
*
conf
);
extern
int
append_unexp_config_line
(
const
char
*
line
,
struct
lxc_conf
*
conf
);
extern
int
lxc_config_define_add
(
struct
lxc_list
*
defines
,
char
*
arg
);
extern
int
lxc_config_define_add
(
struct
lxc_list
*
defines
,
char
*
arg
);
extern
int
lxc_config_define_load
(
struct
lxc_list
*
defines
,
extern
int
lxc_config_define_load
(
struct
lxc_list
*
defines
,
struct
lxc_conf
*
conf
);
struct
lxc_conf
*
conf
);
/* needed for lxc-attach */
/* needed for lxc-attach */
extern
signed
long
lxc_config_parse_arch
(
const
char
*
arch
);
extern
signed
long
lxc_config_parse_arch
(
const
char
*
arch
);
extern
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
);
extern
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
);
extern
int
lxc_clear_config_item
(
struct
lxc_conf
*
c
,
const
char
*
key
);
extern
int
lxc_clear_config_item
(
struct
lxc_conf
*
c
,
const
char
*
key
);
extern
void
write_config
(
FILE
*
fout
,
struct
lxc_conf
*
c
);
extern
void
write_config
(
FILE
*
fout
,
struct
lxc_conf
*
c
);
extern
bool
do_append_unexp_config_line
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
const
char
*
v
);
extern
bool
do_append_unexp_config_line
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
const
char
*
v
);
/* These are used when cloning a container */
/* These are used when cloning a container */
extern
void
clear_unexp_config_line
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
bool
rm_subkeys
);
extern
void
clear_unexp_config_line
(
struct
lxc_conf
*
conf
,
const
char
*
key
,
bool
rm_subkeys
);
extern
bool
clone_update_unexp_hooks
(
struct
lxc_conf
*
conf
,
const
char
*
oldpath
,
extern
bool
clone_update_unexp_hooks
(
struct
lxc_conf
*
conf
,
const
char
*
oldpath
,
const
char
*
newpath
,
const
char
*
oldname
,
const
char
*
newmame
);
const
char
*
newpath
,
const
char
*
oldname
,
const
char
*
newmame
);
bool
clone_update_unexp_ovl_paths
(
struct
lxc_conf
*
conf
,
const
char
*
oldpath
,
bool
clone_update_unexp_ovl_paths
(
struct
lxc_conf
*
conf
,
const
char
*
oldpath
,
const
char
*
newpath
,
const
char
*
oldname
,
const
char
*
newpath
,
const
char
*
oldname
,
const
char
*
newname
,
const
char
*
ovldir
);
const
char
*
newname
,
const
char
*
ovldir
);
extern
bool
network_new_hwaddrs
(
struct
lxc_conf
*
conf
);
extern
bool
network_new_hwaddrs
(
struct
lxc_conf
*
conf
);
#endif
#endif
/* __LXC_CONFILE_H */
src/lxc/lxccontainer.c
View file @
fe9b7349
...
@@ -2268,6 +2268,8 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re
...
@@ -2268,6 +2268,8 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re
ret
=
lxc_list_net
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
ret
=
lxc_list_net
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
else
if
(
strncmp
(
key
,
"lxc.network."
,
12
)
==
0
)
else
if
(
strncmp
(
key
,
"lxc.network."
,
12
)
==
0
)
ret
=
lxc_list_nicconfigs_legacy
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
ret
=
lxc_list_nicconfigs_legacy
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
else
ret
=
lxc_list_subkeys
(
c
->
lxc_conf
,
key
,
retv
,
inlen
);
container_mem_unlock
(
c
);
container_mem_unlock
(
c
);
return
ret
;
return
ret
;
...
...
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