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
d899f11b
Commit
d899f11b
authored
Jun 29, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: lxc-execute: share internal API symbols
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
a9cb0fb8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
14 deletions
+95
-14
Makefile.am
src/lxc/Makefile.am
+1
-1
confile.c
src/lxc/confile.c
+74
-1
lxc_execute.c
src/lxc/tools/lxc_execute.c
+20
-12
No files found.
src/lxc/Makefile.am
View file @
d899f11b
...
...
@@ -272,7 +272,7 @@ lxc_config_SOURCES = tools/lxc_config.c tools/arguments.c
lxc_console_SOURCES
=
tools/lxc_console.c tools/arguments.c
lxc_destroy_SOURCES
=
tools/lxc_destroy.c tools/arguments.c
lxc_device_SOURCES
=
tools/lxc_device.c tools/arguments.c
lxc_execute_SOURCES
=
tools/lxc_execute.c tools/arguments.c
tools/tool_utils.c
lxc_execute_SOURCES
=
tools/lxc_execute.c tools/arguments.c
lxc_freeze_SOURCES
=
tools/lxc_freeze.c tools/arguments.c
lxc_info_SOURCES
=
tools/lxc_info.c tools/arguments.c
lxc_monitor_SOURCES
=
tools/lxc_monitor.c tools/arguments.c tools/tool_utils.c
...
...
src/lxc/confile.c
View file @
d899f11b
...
...
@@ -2388,6 +2388,74 @@ on_error:
return
ret
;
}
static
struct
new_config_item
*
parse_new_conf_line
(
char
*
buffer
)
{
char
*
dot
,
*
key
,
*
line
,
*
linep
,
*
value
;
int
ret
=
0
;
char
*
dup
=
buffer
;
struct
new_config_item
*
new
=
NULL
;
linep
=
line
=
strdup
(
dup
);
if
(
!
line
)
return
NULL
;
line
+=
lxc_char_left_gc
(
line
,
strlen
(
line
));
/* martian option - don't add it to the config itself */
if
(
strncmp
(
line
,
"lxc."
,
strlen
(
line
)))
goto
on_error
;
ret
=
-
1
;
dot
=
strchr
(
line
,
'='
);
if
(
!
dot
)
{
ERROR
(
"Invalid configuration item: %s"
,
line
);
goto
on_error
;
}
*
dot
=
'\0'
;
value
=
dot
+
1
;
key
=
line
;
key
[
lxc_char_right_gc
(
key
,
strlen
(
key
))]
=
'\0'
;
value
+=
lxc_char_left_gc
(
value
,
strlen
(
value
));
value
[
lxc_char_right_gc
(
value
,
strlen
(
value
))]
=
'\0'
;
if
(
*
value
==
'\''
||
*
value
==
'\"'
)
{
size_t
len
;
len
=
strlen
(
value
);
if
(
len
>
1
&&
value
[
len
-
1
]
==
*
value
)
{
value
[
len
-
1
]
=
'\0'
;
value
++
;
}
}
ret
=
-
1
;
new
=
malloc
(
sizeof
(
struct
new_config_item
));
if
(
!
new
)
goto
on_error
;
new
->
key
=
strdup
(
key
);
new
->
val
=
strdup
(
value
);
if
(
!
new
->
val
||
!
new
->
key
)
goto
on_error
;
ret
=
0
;
on_error:
free
(
linep
);
if
(
ret
<
0
&&
new
)
{
free
(
new
->
key
);
free
(
new
->
val
);
free
(
new
);
new
=
NULL
;
}
return
new
;
}
int
lxc_config_read
(
const
char
*
file
,
struct
lxc_conf
*
conf
,
bool
from_include
)
{
int
ret
;
...
...
@@ -2415,7 +2483,12 @@ int lxc_config_define_add(struct lxc_list *defines, char *arg)
if
(
!
dent
)
return
-
1
;
dent
->
elem
=
arg
;
dent
->
elem
=
parse_new_conf_line
(
arg
);
if
(
!
dent
->
elem
)
{
free
(
dent
);
return
-
1
;
}
lxc_list_add_tail
(
defines
,
dent
);
return
0
;
}
...
...
src/lxc/tools/lxc_execute.c
View file @
d899f11b
...
...
@@ -36,12 +36,16 @@
#include <lxc/lxccontainer.h>
#include "arguments.h"
#include "tool_list.h"
#include "tool_utils.h"
#include "caps.h"
#include "confile.h"
#include "log.h"
#include "utils.h"
lxc_log_define
(
lxc_execute
,
lxc
);
static
struct
lxc_list
defines
;
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
int
ret
;
...
...
@@ -78,6 +82,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
args
->
share_ns
[
LXC_NS_PID
]
=
arg
;
break
;
}
return
0
;
}
...
...
@@ -117,10 +122,10 @@ Options :\n\
static
bool
set_argv
(
struct
lxc_container
*
c
,
struct
lxc_arguments
*
args
)
{
int
ret
;
char
buf
[
TOOL_
MAXPATHLEN
];
char
buf
[
MAXPATHLEN
];
char
**
components
,
**
p
;
ret
=
c
->
get_config_item
(
c
,
"lxc.execute.cmd"
,
buf
,
TOOL_
MAXPATHLEN
);
ret
=
c
->
get_config_item
(
c
,
"lxc.execute.cmd"
,
buf
,
MAXPATHLEN
);
if
(
ret
<
0
)
return
false
;
...
...
@@ -166,31 +171,33 @@ int main(int argc, char *argv[])
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
if
(
!
c
)
{
fprintf
(
stderr
,
"Failed to create lxc_container
\n
"
);
ERROR
(
"Failed to create lxc_container
"
);
exit
(
err
);
}
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
ERROR
(
"Failed to load rcfile
"
);
goto
out
;
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
ERROR
(
"Out of memory setting new config filename
"
);
goto
out
;
}
}
if
(
!
c
->
lxc_conf
)
{
fprintf
(
stderr
,
"Executing a container with no configuration file may crash the host
\n
"
);
ERROR
(
"Executing a container with no configuration file may crash the host
"
);
goto
out
;
}
if
(
my_args
.
argc
==
0
)
{
if
(
!
set_argv
(
c
,
&
my_args
))
{
fprintf
(
stderr
,
"missing command to execute!
\n
"
);
ERROR
(
"Missing command to execute!
"
);
goto
out
;
}
}
...
...
@@ -227,11 +234,13 @@ int main(int argc, char *argv[])
goto
out
;
c
->
daemonize
=
my_args
.
daemonize
==
1
;
bret
=
c
->
start
(
c
,
1
,
my_args
.
argv
);
if
(
!
bret
)
{
fprintf
(
stderr
,
"Failed run an application inside container
\n
"
);
ERROR
(
"Failed run an application inside container
"
);
goto
out
;
}
if
(
c
->
daemonize
)
{
err
=
EXIT_SUCCESS
;
}
else
{
...
...
@@ -243,7 +252,6 @@ int main(int argc, char *argv[])
}
}
out:
lxc_container_put
(
c
);
exit
(
err
);
...
...
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