master - exec: pipe open
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f6dd5a294b9beaf1d3ef68385eeeb8d55ec3a344 Commit: f6dd5a294b9beaf1d3ef68385eeeb8d55ec3a344 Parent: b6437a61806bdec29951eb80616db121c4ec4eff Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Aug 6 14:27:37 2013 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Aug 6 16:18:43 2013 +0200
exec: pipe open
Function replaces popen() system and avoids shell execution and argument parsing (no surprices).
--- WHATS_NEW | 1 + lib/misc/lvm-exec.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/misc/lvm-exec.h | 30 +++++++++++++++ 3 files changed, 130 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.100 - ================================ + Add pipe_open/close() to replace less secure popen() glibc call. Fix metadata area offset/size overflow if it's >= 4g and while using lvmetad. Inherit and apply any profile attached to a VG if creating new thin pool. Add initial support thin pool lvconvert --repair.
lib/misc/lvm-exec.c +99 -0
102 lines not on this page · raw message
lib/misc/lvm-exec.h +30 -0
@@ -37,4 +37,34 @@ struct cmd_context;int exec_cmd (struct cmd_context *cmd,const char *const argv[],int *rstatus,int sync_needed); + +struct FILE ; +struct pipe_data { +FILE *fp; +pid_t pid; +}; + +/** +* popen() like function to read-only output from executed command +* without running shell. +* +* \param argv +* Arguments for execvp. +* +* \param sync_needed +* Bool specifying whether local devices needs to be synchronized +* before executing command. +* Note: You cannot synchronize devices within activation context. +* +* \param pdata +* Arguments to store data needed for pclose_exec(). +* +* \return +* 1 (success) or 0 (failure). +*/ +FILE *pipe_open (struct cmd_context *cmd,const char *const argv[], +int sync_needed,struct pipe_data *pdata); + +int pipe_close (struct pipe_data *pdata); +#endif