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
b61a67fa
Unverified
Commit
b61a67fa
authored
Aug 13, 2018
by
Christian Brauner
Committed by
GitHub
Aug 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2524 from 2xsec/bugfix
fix thread-safe issue (localtime => localtime_r)
parents
f728ff0c
df05fa0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
17 deletions
+15
-17
log.c
src/lxc/log.c
+0
-1
lxccontainer.c
src/lxc/lxccontainer.c
+15
-12
macro.h
src/lxc/macro.h
+0
-4
No files found.
src/lxc/log.c
View file @
b61a67fa
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <string.h>
#include <string.h>
#include <pthread.h>
#include <pthread.h>
#include <time.h>
#include <syslog.h>
#include <syslog.h>
#include <stdio.h>
#include <stdio.h>
...
...
src/lxc/lxccontainer.c
View file @
b61a67fa
...
@@ -4121,15 +4121,19 @@ static bool get_snappath_dir(struct lxc_container *c, char *snappath)
...
@@ -4121,15 +4121,19 @@ static bool get_snappath_dir(struct lxc_container *c, char *snappath)
static
int
do_lxcapi_snapshot
(
struct
lxc_container
*
c
,
const
char
*
commentfile
)
static
int
do_lxcapi_snapshot
(
struct
lxc_container
*
c
,
const
char
*
commentfile
)
{
{
int
i
,
flags
,
ret
;
int
i
,
flags
,
ret
;
time_t
timer
;
struct
tm
tm_info
;
struct
lxc_container
*
c2
;
struct
lxc_container
*
c2
;
char
snappath
[
MAXPATHLEN
],
newname
[
20
];
char
snappath
[
MAXPATHLEN
],
newname
[
20
];
char
buffer
[
25
];
FILE
*
f
;
if
(
!
c
||
!
lxcapi_is_defined
(
c
))
if
(
!
c
||
!
lxcapi_is_defined
(
c
))
return
-
1
;
return
-
1
;
if
(
!
storage_can_backup
(
c
->
lxc_conf
))
{
if
(
!
storage_can_backup
(
c
->
lxc_conf
))
{
ERROR
(
"%s's backing store cannot be backed up
.
"
,
c
->
name
);
ERROR
(
"%s's backing store cannot be backed up"
,
c
->
name
);
ERROR
(
"Your container must use another backing store type
.
"
);
ERROR
(
"Your container must use another backing store type"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -4154,31 +4158,30 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
...
@@ -4154,31 +4158,30 @@ static int do_lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
flags
=
LXC_CLONE_SNAPSHOT
|
LXC_CLONE_KEEPMACADDR
|
LXC_CLONE_KEEPNAME
|
flags
=
LXC_CLONE_SNAPSHOT
|
LXC_CLONE_KEEPMACADDR
|
LXC_CLONE_KEEPNAME
|
LXC_CLONE_KEEPBDEVTYPE
|
LXC_CLONE_MAYBE_SNAPSHOT
;
LXC_CLONE_KEEPBDEVTYPE
|
LXC_CLONE_MAYBE_SNAPSHOT
;
if
(
storage_is_dir
(
c
->
lxc_conf
))
{
if
(
storage_is_dir
(
c
->
lxc_conf
))
{
ERROR
(
"Snapshot of directory-backed container requested
.
"
);
ERROR
(
"Snapshot of directory-backed container requested"
);
ERROR
(
"Making a copy-clone. If you do want snapshots, then"
);
ERROR
(
"Making a copy-clone. If you do want snapshots, then"
);
ERROR
(
"please create overlay clone first, snapshot that"
);
ERROR
(
"please create overlay clone first, snapshot that"
);
ERROR
(
"and keep the original container pristine
.
"
);
ERROR
(
"and keep the original container pristine"
);
flags
&=
~
LXC_CLONE_SNAPSHOT
|
LXC_CLONE_MAYBE_SNAPSHOT
;
flags
&=
~
LXC_CLONE_SNAPSHOT
|
LXC_CLONE_MAYBE_SNAPSHOT
;
}
}
c2
=
do_lxcapi_clone
(
c
,
newname
,
snappath
,
flags
,
NULL
,
NULL
,
0
,
NULL
);
c2
=
do_lxcapi_clone
(
c
,
newname
,
snappath
,
flags
,
NULL
,
NULL
,
0
,
NULL
);
if
(
!
c2
)
{
if
(
!
c2
)
{
ERROR
(
"
clone of %s:%s failed
"
,
c
->
config_path
,
c
->
name
);
ERROR
(
"
Failed to clone of %s:%s
"
,
c
->
config_path
,
c
->
name
);
return
-
1
;
return
-
1
;
}
}
lxc_container_put
(
c2
);
lxc_container_put
(
c2
);
/* Now write down the creation time. */
/* Now write down the creation time. */
time_t
timer
;
char
buffer
[
25
];
struct
tm
*
tm_info
;
FILE
*
f
;
time
(
&
timer
);
time
(
&
timer
);
tm_info
=
localtime
(
&
timer
);
strftime
(
buffer
,
25
,
"%Y:%m:%d %H:%M:%S"
,
tm_info
);
if
(
!
localtime_r
(
&
timer
,
&
tm_info
))
{
ERROR
(
"Failed to get localtime"
);
return
-
1
;
}
strftime
(
buffer
,
25
,
"%Y:%m:%d %H:%M:%S"
,
&
tm_info
);
char
*
dfnam
=
alloca
(
strlen
(
snappath
)
+
strlen
(
newname
)
+
5
);
char
*
dfnam
=
alloca
(
strlen
(
snappath
)
+
strlen
(
newname
)
+
5
);
sprintf
(
dfnam
,
"%s/%s/ts"
,
snappath
,
newname
);
sprintf
(
dfnam
,
"%s/%s/ts"
,
snappath
,
newname
);
...
...
src/lxc/macro.h
View file @
b61a67fa
...
@@ -43,10 +43,6 @@
...
@@ -43,10 +43,6 @@
#define PR_CAPBSET_DROP 24
#define PR_CAPBSET_DROP 24
#endif
#endif
#ifndef LO_FLAGS_AUTOCLEAR
#define LO_FLAGS_AUTOCLEAR 4
#endif
#ifndef CAP_SETUID
#ifndef CAP_SETUID
#define CAP_SETUID 7
#define CAP_SETUID 7
#endif
#endif
...
...
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