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
eee2c6a0
Unverified
Commit
eee2c6a0
authored
Apr 29, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxccontainer: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
429d21a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
lxccontainer.c
src/lxc/lxccontainer.c
+31
-10
No files found.
src/lxc/lxccontainer.c
View file @
eee2c6a0
...
...
@@ -1480,6 +1480,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool need_
static
bool
prepend_lxc_header
(
char
*
path
,
const
char
*
t
,
char
*
const
argv
[])
{
long
flen
;
size_t
len
;
char
*
contents
;
FILE
*
f
;
int
ret
=
-
1
;
...
...
@@ -1493,15 +1494,30 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
if
(
f
==
NULL
)
return
false
;
if
(
fseek
(
f
,
0
,
SEEK_END
)
<
0
)
ret
=
fseek
(
f
,
0
,
SEEK_END
);
if
(
ret
<
0
)
goto
out_error
;
if
((
flen
=
ftell
(
f
))
<
0
)
ret
=
-
1
;
flen
=
ftell
(
f
);
if
(
flen
<
0
)
goto
out_error
;
if
(
fseek
(
f
,
0
,
SEEK_SET
)
<
0
)
ret
=
fseek
(
f
,
0
,
SEEK_SET
);
if
(
ret
<
0
)
goto
out_error
;
if
((
contents
=
malloc
(
flen
+
1
))
==
NULL
)
ret
=
fseek
(
f
,
0
,
SEEK_SET
);
if
(
ret
<
0
)
goto
out_error
;
ret
=
-
1
;
contents
=
malloc
(
flen
+
1
);
if
(
!
contents
)
goto
out_error
;
if
(
fread
(
contents
,
1
,
flen
,
f
)
!=
flen
)
len
=
fread
(
contents
,
1
,
flen
,
f
);
if
(
len
!=
flen
)
goto
out_free_contents
;
contents
[
flen
]
=
'\0'
;
...
...
@@ -1513,25 +1529,25 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
#if HAVE_LIBGNUTLS
tpath
=
get_template_path
(
t
);
if
(
!
tpath
)
{
ERROR
(
"
bad template: %s
"
,
t
);
ERROR
(
"
Invalid template
\"
%s
\"
specified
"
,
t
);
goto
out_free_contents
;
}
ret
=
sha1sum_file
(
tpath
,
md_value
);
free
(
tpath
);
if
(
ret
<
0
)
{
ERROR
(
"Error getting sha1sum of %s"
,
tpath
);
free
(
tpath
);
ERROR
(
"Failed to get sha1sum of %s"
,
tpath
);
goto
out_free_contents
;
}
free
(
tpath
);
#endif
f
=
fopen
(
path
,
"w"
);
if
(
f
==
NULL
)
{
SYSERROR
(
"
r
eopening config for writing"
);
SYSERROR
(
"
R
eopening config for writing"
);
free
(
contents
);
return
false
;
}
fprintf
(
f
,
"# Template used to create this container: %s
\n
"
,
t
);
if
(
argv
)
{
fprintf
(
f
,
"# Parameters passed to the template:"
);
...
...
@@ -1557,9 +1573,12 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
fclose
(
f
);
return
false
;
}
ret
=
0
;
out_free_contents
:
free
(
contents
);
out_error
:
if
(
f
)
{
int
newret
;
...
...
@@ -1567,10 +1586,12 @@ out_error:
if
(
ret
==
0
)
ret
=
newret
;
}
if
(
ret
<
0
)
{
SYSERROR
(
"Error prepending header"
);
return
false
;
}
return
true
;
}
...
...
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