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
20cfa342
Commit
20cfa342
authored
Mar 28, 2014
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use on_path to find init.lxc
Signed-off-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
Acked-by:
Serge E. Hallyn
<
serge.hallyn@ubuntu.com
>
parent
320ab1d6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
11 deletions
+44
-11
conf.c
src/lxc/conf.c
+16
-3
execute.c
src/lxc/execute.c
+22
-2
utils.c
src/lxc/utils.c
+5
-5
utils.h
src/lxc/utils.h
+1
-1
No files found.
src/lxc/conf.c
View file @
20cfa342
...
...
@@ -3197,10 +3197,23 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
{
struct
lxc_list
*
iterator
;
struct
id_map
*
map
;
int
ret
=
0
;
int
ret
=
0
,
use_shadow
=
0
;
enum
idtype
type
;
char
*
buf
=
NULL
,
*
pos
;
int
use_shadow
=
(
on_path
(
"newuidmap"
)
&&
on_path
(
"newgidmap"
));
char
*
buf
=
NULL
,
*
pos
,
*
cmdpath
=
NULL
;
cmdpath
=
on_path
(
"newuidmap"
);
if
(
cmdpath
)
{
use_shadow
=
1
;
free
(
cmdpath
);
}
if
(
!
use_shadow
)
{
cmdpath
=
on_path
(
"newgidmap"
);
if
(
cmdpath
)
{
use_shadow
=
1
;
free
(
cmdpath
);
}
}
if
(
!
use_shadow
&&
geteuid
())
{
ERROR
(
"Missing newuidmap/newgidmap"
);
...
...
src/lxc/execute.c
View file @
20cfa342
...
...
@@ -30,6 +30,7 @@
#include "conf.h"
#include "log.h"
#include "start.h"
#include "utils.h"
lxc_log_define
(
lxc_execute
,
lxc_start
);
...
...
@@ -43,9 +44,27 @@ struct execute_args {
*/
static
char
*
choose_init
(
void
)
{
char
*
retv
=
malloc
(
PATH_MAX
)
;
int
ret
;
char
*
retv
=
NULL
;
int
ret
,
env_set
=
0
;
struct
stat
mystat
;
if
(
!
getenv
(
"PATH"
))
{
if
(
setenv
(
"PATH"
,
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
,
0
))
SYSERROR
(
"Failed to setenv"
);
env_set
=
1
;
}
retv
=
on_path
(
"init.lxc"
);
if
(
env_set
)
{
if
(
unsetenv
(
"PATH"
))
SYSERROR
(
"Failed to unsetenv"
);
}
if
(
retv
)
return
retv
;
retv
=
malloc
(
PATH_MAX
);
if
(
!
retv
)
return
NULL
;
...
...
@@ -54,6 +73,7 @@ static char *choose_init(void)
ERROR
(
"pathname too long"
);
goto
out1
;
}
ret
=
stat
(
retv
,
&
mystat
);
if
(
ret
==
0
)
return
retv
;
...
...
src/lxc/utils.c
View file @
20cfa342
...
...
@@ -1274,7 +1274,7 @@ int detect_ramfs_rootfs(void)
return
0
;
}
bool
on_path
(
char
*
cmd
)
{
char
*
on_path
(
char
*
cmd
)
{
char
*
path
=
NULL
;
char
*
entry
=
NULL
;
char
*
saveptr
=
NULL
;
...
...
@@ -1283,11 +1283,11 @@ bool on_path(char *cmd) {
path
=
getenv
(
"PATH"
);
if
(
!
path
)
return
false
;
return
NULL
;
path
=
strdup
(
path
);
if
(
!
path
)
return
false
;
return
NULL
;
entry
=
strtok_r
(
path
,
":"
,
&
saveptr
);
while
(
entry
)
{
...
...
@@ -1298,7 +1298,7 @@ bool on_path(char *cmd) {
if
(
access
(
cmdpath
,
X_OK
)
==
0
)
{
free
(
path
);
return
true
;
return
strdup
(
cmdpath
)
;
}
next_loop
:
...
...
@@ -1306,5 +1306,5 @@ next_loop:
}
free
(
path
);
return
false
;
return
NULL
;
}
src/lxc/utils.h
View file @
20cfa342
...
...
@@ -279,4 +279,4 @@ uint64_t fnv_64a_buf(void *buf, size_t len, uint64_t hval);
int
detect_shared_rootfs
(
void
);
int
detect_ramfs_rootfs
(
void
);
bool
on_path
(
char
*
cmd
);
char
*
on_path
(
char
*
cmd
);
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