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
2f216e73
Unverified
Commit
2f216e73
authored
Dec 05, 2017
by
Christian Brauner
Committed by
GitHub
Dec 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1992 from lifeng68/add_init_cwd
confile:add lxc.init.cwd
parents
4fe9a9b7
3c491553
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
0 deletions
+52
-0
lxc.container.conf.sgml.in
doc/lxc.container.conf.sgml.in
+20
-0
conf.c
src/lxc/conf.c
+1
-0
conf.h
src/lxc/conf.h
+4
-0
confile.c
src/lxc/confile.c
+22
-0
start.c
src/lxc/start.c
+5
-0
No files found.
doc/lxc.container.conf.sgml.in
View file @
2f216e73
...
@@ -285,6 +285,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -285,6 +285,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</refsect2>
</refsect2>
<refsect2>
<refsect2>
<title>Init working directory</title>
<para>
Sets the absolute path inside the container as the working directory for the containers.
LXC will switch to this directory before executing init.
</para>
<variablelist>
<varlistentry>
<term>
<option>lxc.init.cwd</option>
</term>
<listitem>
<para>
Absolute path inside the container to use as the working directory.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>Init ID</title>
<title>Init ID</title>
<para>
<para>
Sets the UID/GID to use for the init system, and subsequent commands.
Sets the UID/GID to use for the init system, and subsequent commands.
...
...
src/lxc/conf.c
View file @
2f216e73
...
@@ -3432,6 +3432,7 @@ void lxc_conf_free(struct lxc_conf *conf)
...
@@ -3432,6 +3432,7 @@ void lxc_conf_free(struct lxc_conf *conf)
free
(
conf
->
rcfile
);
free
(
conf
->
rcfile
);
free
(
conf
->
execute_cmd
);
free
(
conf
->
execute_cmd
);
free
(
conf
->
init_cmd
);
free
(
conf
->
init_cmd
);
free
(
conf
->
init_cwd
);
free
(
conf
->
unexpanded_config
);
free
(
conf
->
unexpanded_config
);
free
(
conf
->
pty_names
);
free
(
conf
->
pty_names
);
free
(
conf
->
syslog
);
free
(
conf
->
syslog
);
...
...
src/lxc/conf.h
View file @
2f216e73
...
@@ -359,6 +359,10 @@ struct lxc_conf {
...
@@ -359,6 +359,10 @@ struct lxc_conf {
struct
lxc_cgroup
cgroup_meta
;
struct
lxc_cgroup
cgroup_meta
;
char
*
inherit_ns
[
LXC_NS_MAX
];
char
*
inherit_ns
[
LXC_NS_MAX
];
/* init working directory */
char
*
init_cwd
;
};
};
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
int
write_id_mapping
(
enum
idtype
idtype
,
pid_t
pid
,
const
char
*
buf
,
...
...
src/lxc/confile.c
View file @
2f216e73
...
@@ -95,6 +95,7 @@ lxc_config_define(hooks);
...
@@ -95,6 +95,7 @@ lxc_config_define(hooks);
lxc_config_define
(
idmaps
);
lxc_config_define
(
idmaps
);
lxc_config_define
(
includefiles
);
lxc_config_define
(
includefiles
);
lxc_config_define
(
init_cmd
);
lxc_config_define
(
init_cmd
);
lxc_config_define
(
init_cwd
);
lxc_config_define
(
init_gid
);
lxc_config_define
(
init_gid
);
lxc_config_define
(
init_uid
);
lxc_config_define
(
init_uid
);
lxc_config_define
(
log_file
);
lxc_config_define
(
log_file
);
...
@@ -176,6 +177,7 @@ static struct lxc_config_t config[] = {
...
@@ -176,6 +177,7 @@ static struct lxc_config_t config[] = {
{
"lxc.init.cmd"
,
false
,
set_config_init_cmd
,
get_config_init_cmd
,
clr_config_init_cmd
,
},
{
"lxc.init.cmd"
,
false
,
set_config_init_cmd
,
get_config_init_cmd
,
clr_config_init_cmd
,
},
{
"lxc.init.gid"
,
false
,
set_config_init_gid
,
get_config_init_gid
,
clr_config_init_gid
,
},
{
"lxc.init.gid"
,
false
,
set_config_init_gid
,
get_config_init_gid
,
clr_config_init_gid
,
},
{
"lxc.init.uid"
,
false
,
set_config_init_uid
,
get_config_init_uid
,
clr_config_init_uid
,
},
{
"lxc.init.uid"
,
false
,
set_config_init_uid
,
get_config_init_uid
,
clr_config_init_uid
,
},
{
"lxc.init.cwd"
,
false
,
set_config_init_cwd
,
get_config_init_cwd
,
clr_config_init_cwd
,
},
{
"lxc.log.file"
,
false
,
set_config_log_file
,
get_config_log_file
,
clr_config_log_file
,
},
{
"lxc.log.file"
,
false
,
set_config_log_file
,
get_config_log_file
,
clr_config_log_file
,
},
{
"lxc.log.level"
,
false
,
set_config_log_level
,
get_config_log_level
,
clr_config_log_level
,
},
{
"lxc.log.level"
,
false
,
set_config_log_level
,
get_config_log_level
,
clr_config_log_level
,
},
{
"lxc.log.syslog"
,
false
,
set_config_log_syslog
,
get_config_log_syslog
,
clr_config_log_syslog
,
},
{
"lxc.log.syslog"
,
false
,
set_config_log_syslog
,
get_config_log_syslog
,
clr_config_log_syslog
,
},
...
@@ -945,6 +947,12 @@ static int set_config_init_cmd(const char *key, const char *value,
...
@@ -945,6 +947,12 @@ static int set_config_init_cmd(const char *key, const char *value,
return
set_config_path_item
(
&
lxc_conf
->
init_cmd
,
value
);
return
set_config_path_item
(
&
lxc_conf
->
init_cmd
,
value
);
}
}
static
int
set_config_init_cwd
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
return
set_config_path_item
(
&
lxc_conf
->
init_cwd
,
value
);
}
static
int
set_config_init_uid
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_init_uid
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
...
@@ -3249,6 +3257,12 @@ static int get_config_init_cmd(const char *key, char *retv, int inlen,
...
@@ -3249,6 +3257,12 @@ static int get_config_init_cmd(const char *key, char *retv, int inlen,
return
lxc_get_conf_str
(
retv
,
inlen
,
c
->
init_cmd
);
return
lxc_get_conf_str
(
retv
,
inlen
,
c
->
init_cmd
);
}
}
static
int
get_config_init_cwd
(
const
char
*
key
,
char
*
retv
,
int
inlen
,
struct
lxc_conf
*
c
,
void
*
data
)
{
return
lxc_get_conf_str
(
retv
,
inlen
,
c
->
init_cwd
);
}
static
int
get_config_init_uid
(
const
char
*
key
,
char
*
retv
,
int
inlen
,
static
int
get_config_init_uid
(
const
char
*
key
,
char
*
retv
,
int
inlen
,
struct
lxc_conf
*
c
,
void
*
data
)
struct
lxc_conf
*
c
,
void
*
data
)
{
{
...
@@ -3665,6 +3679,14 @@ static inline int clr_config_init_cmd(const char *key, struct lxc_conf *c,
...
@@ -3665,6 +3679,14 @@ static inline int clr_config_init_cmd(const char *key, struct lxc_conf *c,
return
0
;
return
0
;
}
}
static
inline
int
clr_config_init_cwd
(
const
char
*
key
,
struct
lxc_conf
*
c
,
void
*
data
)
{
free
(
c
->
init_cwd
);
c
->
init_cwd
=
NULL
;
return
0
;
}
static
inline
int
clr_config_init_uid
(
const
char
*
key
,
struct
lxc_conf
*
c
,
static
inline
int
clr_config_init_uid
(
const
char
*
key
,
struct
lxc_conf
*
c
,
void
*
data
)
void
*
data
)
{
{
...
...
src/lxc/start.c
View file @
2f216e73
...
@@ -979,6 +979,11 @@ static int do_start(void *data)
...
@@ -979,6 +979,11 @@ static int do_start(void *data)
setsid
();
setsid
();
if
(
handler
->
conf
->
init_cwd
&&
chdir
(
handler
->
conf
->
init_cwd
))
{
SYSERROR
(
"Could not change directory to
\"
%s
\"
"
,
handler
->
conf
->
init_cwd
);
goto
out_warn_father
;
}
if
(
lxc_sync_barrier_parent
(
handler
,
LXC_SYNC_CGROUP_LIMITS
))
if
(
lxc_sync_barrier_parent
(
handler
,
LXC_SYNC_CGROUP_LIMITS
))
goto
out_warn_father
;
goto
out_warn_father
;
...
...
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