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
ebf3a6af
Unverified
Commit
ebf3a6af
authored
Mar 01, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: remove fgets() from run_buffer()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
e613d684
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
conf.c
src/lxc/conf.c
+20
-3
utils.h
src/lxc/utils.h
+4
-4
No files found.
src/lxc/conf.c
View file @
ebf3a6af
...
@@ -307,7 +307,7 @@ static struct limit_opt limit_opt[] = {
...
@@ -307,7 +307,7 @@ static struct limit_opt limit_opt[] = {
static
int
run_buffer
(
char
*
buffer
)
static
int
run_buffer
(
char
*
buffer
)
{
{
__do_free
char
*
output
=
NULL
;
__do_free
char
*
output
=
NULL
;
int
ret
;
int
fd
,
ret
;
struct
lxc_popen_FILE
*
f
;
struct
lxc_popen_FILE
*
f
;
f
=
lxc_popen
(
buffer
);
f
=
lxc_popen
(
buffer
);
...
@@ -323,8 +323,25 @@ static int run_buffer(char *buffer)
...
@@ -323,8 +323,25 @@ static int run_buffer(char *buffer)
return
-
1
;
return
-
1
;
}
}
while
(
fgets
(
output
,
LXC_LOG_BUFFER_SIZE
,
f
->
f
))
fd
=
fileno
(
f
->
f
);
DEBUG
(
"Script %s with output: %s"
,
buffer
,
output
);
if
(
fd
<
0
)
{
SYSERROR
(
"Failed to retrieve underlying file descriptor"
);
lxc_pclose
(
f
);
return
-
1
;
}
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
ssize_t
bytes_read
;
bytes_read
=
lxc_read_nointr
(
fd
,
output
,
LXC_LOG_BUFFER_SIZE
-
1
);
if
(
bytes_read
>
0
)
{
output
[
bytes_read
]
=
'\0'
;
DEBUG
(
"Script %s produced output: %s"
,
buffer
,
output
);
continue
;
}
break
;
}
ret
=
lxc_pclose
(
f
);
ret
=
lxc_pclose
(
f
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
...
...
src/lxc/utils.h
View file @
ebf3a6af
...
@@ -61,10 +61,10 @@ static inline int lxc_set_cloexec(int fd)
...
@@ -61,10 +61,10 @@ static inline int lxc_set_cloexec(int fd)
return
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
return
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
}
}
/*
Struct to carry child pid from lxc_popen() to lxc_pclose().
/*
*
Not an opaque struct to allow direct access to the underlying FILE *
*
Struct to carry child pid from lxc_popen() to lxc_pclose(). Not an opaque
*
(i.e., struct lxc_popen_FILE *file; fgets(buf, sizeof(buf), file->f))
*
struct to allow direct access to the underlying FILE without additional
* w
ithout additional w
rappers.
* wrappers.
*/
*/
struct
lxc_popen_FILE
{
struct
lxc_popen_FILE
{
int
pipe
;
int
pipe
;
...
...
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