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
238b3e5e
Unverified
Commit
238b3e5e
authored
Feb 24, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxccontainer: move macros to utils.h
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0e1a60b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
error.h
src/lxc/error.h
+1
-0
lxccontainer.c
src/lxc/lxccontainer.c
+13
-16
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/error.h
View file @
238b3e5e
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#define __LXC_ERROR_H
#define __LXC_ERROR_H
#define LXC_CLONE_ERROR "Failed to clone a new set of namespaces"
#define LXC_CLONE_ERROR "Failed to clone a new set of namespaces"
#define LXC_UNPRIV_EOPNOTSUPP "the requested function %s is not currently supported with unprivileged containers"
extern
int
lxc_error_set_and_log
(
int
pid
,
int
status
);
extern
int
lxc_error_set_and_log
(
int
pid
,
int
status
);
...
...
src/lxc/lxccontainer.c
View file @
238b3e5e
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
#include "confile_utils.h"
#include "confile_utils.h"
#include "console.h"
#include "console.h"
#include "criu.h"
#include "criu.h"
#include "error.h"
#include "initutils.h"
#include "initutils.h"
#include "log.h"
#include "log.h"
#include "lxc.h"
#include "lxc.h"
...
@@ -70,7 +71,7 @@
...
@@ -70,7 +71,7 @@
/* major()/minor() */
/* major()/minor() */
#ifdef MAJOR_IN_MKDEV
#ifdef MAJOR_IN_MKDEV
#
include <sys/mkdev.h>
#include <sys/mkdev.h>
#endif
#endif
#if HAVE_IFADDRS_H
#if HAVE_IFADDRS_H
...
@@ -85,19 +86,15 @@
...
@@ -85,19 +86,15 @@
#include <mntent.h>
#include <mntent.h>
#endif
#endif
#define MAX_BUFFER 4096
#define NOT_SUPPORTED_ERROR "the requested function %s is not currently supported with unprivileged containers"
/* Define faccessat() if missing from the C library */
/* Define faccessat() if missing from the C library */
#ifndef HAVE_FACCESSAT
#ifndef HAVE_FACCESSAT
static
int
faccessat
(
int
__fd
,
const
char
*
__file
,
int
__type
,
int
__flag
)
static
int
faccessat
(
int
__fd
,
const
char
*
__file
,
int
__type
,
int
__flag
)
{
{
#ifdef __NR_faccessat
#ifdef __NR_faccessat
return
syscall
(
__NR_faccessat
,
__fd
,
__file
,
__type
,
__flag
);
return
syscall
(
__NR_faccessat
,
__fd
,
__file
,
__type
,
__flag
);
#else
#else
errno
=
ENOSYS
;
errno
=
ENOSYS
;
return
-
1
;
return
-
1
;
#endif
#endif
}
}
#endif
#endif
...
@@ -4317,7 +4314,7 @@ static bool add_remove_device_node(struct lxc_container *c, const char *src_path
...
@@ -4317,7 +4314,7 @@ static bool add_remove_device_node(struct lxc_container *c, const char *src_path
{
{
int
ret
;
int
ret
;
struct
stat
st
;
struct
stat
st
;
char
value
[
MAX_BUFFER
];
char
value
[
LXC_
MAX_BUFFER
];
const
char
*
p
;
const
char
*
p
;
/* make sure container is running */
/* make sure container is running */
...
@@ -4335,14 +4332,14 @@ static bool add_remove_device_node(struct lxc_container *c, const char *src_path
...
@@ -4335,14 +4332,14 @@ static bool add_remove_device_node(struct lxc_container *c, const char *src_path
/* continue if path is character device or block device */
/* continue if path is character device or block device */
if
(
S_ISCHR
(
st
.
st_mode
))
if
(
S_ISCHR
(
st
.
st_mode
))
ret
=
snprintf
(
value
,
MAX_BUFFER
,
"c %d:%d rwm"
,
major
(
st
.
st_rdev
),
minor
(
st
.
st_rdev
));
ret
=
snprintf
(
value
,
LXC_
MAX_BUFFER
,
"c %d:%d rwm"
,
major
(
st
.
st_rdev
),
minor
(
st
.
st_rdev
));
else
if
(
S_ISBLK
(
st
.
st_mode
))
else
if
(
S_ISBLK
(
st
.
st_mode
))
ret
=
snprintf
(
value
,
MAX_BUFFER
,
"b %d:%d rwm"
,
major
(
st
.
st_rdev
),
minor
(
st
.
st_rdev
));
ret
=
snprintf
(
value
,
LXC_
MAX_BUFFER
,
"b %d:%d rwm"
,
major
(
st
.
st_rdev
),
minor
(
st
.
st_rdev
));
else
else
return
false
;
return
false
;
/* check snprintf return code */
/* check snprintf return code */
if
(
ret
<
0
||
ret
>=
MAX_BUFFER
)
if
(
ret
<
0
||
ret
>=
LXC_
MAX_BUFFER
)
return
false
;
return
false
;
if
(
!
do_add_remove_node
(
do_lxcapi_init_pid
(
c
),
p
,
add
,
&
st
))
if
(
!
do_add_remove_node
(
do_lxcapi_init_pid
(
c
),
p
,
add
,
&
st
))
...
@@ -4368,7 +4365,7 @@ static bool do_lxcapi_add_device_node(struct lxc_container *c, const char *src_p
...
@@ -4368,7 +4365,7 @@ static bool do_lxcapi_add_device_node(struct lxc_container *c, const char *src_p
{
{
// cannot mknod if we're not privileged wrt init_user_ns
// cannot mknod if we're not privileged wrt init_user_ns
if
(
am_host_unpriv
())
{
if
(
am_host_unpriv
())
{
ERROR
(
NOT_SUPPORTED_ERROR
,
__FUNCTION__
);
ERROR
(
LXC_UNPRIV_EOPNOTSUPP
,
__FUNCTION__
);
return
false
;
return
false
;
}
}
return
add_remove_device_node
(
c
,
src_path
,
dest_path
,
true
);
return
add_remove_device_node
(
c
,
src_path
,
dest_path
,
true
);
...
@@ -4379,7 +4376,7 @@ WRAP_API_2(bool, lxcapi_add_device_node, const char *, const char *)
...
@@ -4379,7 +4376,7 @@ WRAP_API_2(bool, lxcapi_add_device_node, const char *, const char *)
static
bool
do_lxcapi_remove_device_node
(
struct
lxc_container
*
c
,
const
char
*
src_path
,
const
char
*
dest_path
)
static
bool
do_lxcapi_remove_device_node
(
struct
lxc_container
*
c
,
const
char
*
src_path
,
const
char
*
dest_path
)
{
{
if
(
am_guest_unpriv
())
{
if
(
am_guest_unpriv
())
{
ERROR
(
NOT_SUPPORTED_ERROR
,
__FUNCTION__
);
ERROR
(
LXC_UNPRIV_EOPNOTSUPP
,
__FUNCTION__
);
return
false
;
return
false
;
}
}
return
add_remove_device_node
(
c
,
src_path
,
dest_path
,
false
);
return
add_remove_device_node
(
c
,
src_path
,
dest_path
,
false
);
...
@@ -4395,7 +4392,7 @@ static bool do_lxcapi_attach_interface(struct lxc_container *c,
...
@@ -4395,7 +4392,7 @@ static bool do_lxcapi_attach_interface(struct lxc_container *c,
int
ret
=
0
;
int
ret
=
0
;
if
(
am_guest_unpriv
())
{
if
(
am_guest_unpriv
())
{
ERROR
(
NOT_SUPPORTED_ERROR
,
__FUNCTION__
);
ERROR
(
LXC_UNPRIV_EOPNOTSUPP
,
__FUNCTION__
);
return
false
;
return
false
;
}
}
...
@@ -4438,7 +4435,7 @@ static bool do_lxcapi_detach_interface(struct lxc_container *c,
...
@@ -4438,7 +4435,7 @@ static bool do_lxcapi_detach_interface(struct lxc_container *c,
* But for other types guest privilege suffices.
* But for other types guest privilege suffices.
*/
*/
if
(
am_guest_unpriv
())
{
if
(
am_guest_unpriv
())
{
ERROR
(
NOT_SUPPORTED_ERROR
,
__FUNCTION__
);
ERROR
(
LXC_UNPRIV_EOPNOTSUPP
,
__FUNCTION__
);
return
false
;
return
false
;
}
}
...
...
src/lxc/utils.h
View file @
238b3e5e
...
@@ -100,6 +100,7 @@
...
@@ -100,6 +100,7 @@
#define LXC_NUMSTRLEN64 21
#define LXC_NUMSTRLEN64 21
#define LXC_LINELEN 4096
#define LXC_LINELEN 4096
#define LXC_IDMAPLEN 4096
#define LXC_IDMAPLEN 4096
#define LXC_MAX_BUFFER 4096
/* returns 1 on success, 0 if there were any failures */
/* returns 1 on success, 0 if there were any failures */
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
...
...
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