summaryrefslogtreecommitdiff
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2013-04-03 16:14:03 +0200
committerKarel Zak <kzak@redhat.com>2013-04-03 16:14:03 +0200
commit1eb8539d3b1d2cb636bb73222daeb0bf4f68d7ae (patch)
treed2d8c594952d8abd82c42df4b610fbdd82fc1932 /libmount/src
parenta61cac5b6474494fe5c409b82d09236c45856b07 (diff)
downloadutil-linux-1eb8539d3b1d2cb636bb73222daeb0bf4f68d7ae.tar.gz
libmount: use O_CLOEXEC
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/lock.c4
-rw-r--r--libmount/src/tab_parse.c8
-rw-r--r--libmount/src/tab_update.c2
-rw-r--r--libmount/src/utils.c6
4 files changed, 10 insertions, 10 deletions
diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index e5393d0a..9e583cc0 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -558,7 +558,7 @@ void increment_data(const char *filename, int verbose, int loopno)
FILE *f;
char buf[256];
- if (!(f = fopen(filename, "r")))
+ if (!(f = fopen(filename, "r" UL_CLOEXECSTR)))
err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename);
if (!fgets(buf, sizeof(buf), f))
@@ -567,7 +567,7 @@ void increment_data(const char *filename, int verbose, int loopno)
fclose(f);
num = atol(buf) + 1;
- if (!(f = fopen(filename, "w")))
+ if (!(f = fopen(filename, "w" UL_CLOEXECSTR)))
err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename);
fprintf(f, "%ld", num);
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index b4b64707..7368d8c9 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -579,7 +579,7 @@ int mnt_table_parse_file(struct libmnt_table *tb, const char *filename)
if (!filename || !tb)
return -EINVAL;
- f = fopen(filename, "r");
+ f = fopen(filename, "r" UL_CLOEXECSTR);
if (f) {
rc = mnt_table_parse_stream(tb, f, filename);
fclose(f);
@@ -639,7 +639,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
!S_ISREG(st.st_mode))
continue;
- f = fopen_at(dd, ".", d->d_name, O_RDONLY, "r");
+ f = fopen_at(dd, ".", d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
if (f) {
mnt_table_parse_stream(tb, f, d->d_name);
fclose(f);
@@ -679,8 +679,8 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
!S_ISREG(st.st_mode))
continue;
- f = fopen_at(dirfd(dir), _PATH_MNTTAB_DIR,
- d->d_name, O_RDONLY, "r");
+ f = fopen_at(dirfd(dir), _PATH_MNTTAB_DIR, d->d_name,
+ O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
if (f) {
mnt_table_parse_stream(tb, f, d->d_name);
fclose(f);
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index 7ae540ab..044a13f5 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -514,7 +514,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
if (fd < 0)
return fd; /* error */
- f = fdopen(fd, "w");
+ f = fdopen(fd, "w" UL_CLOEXECSTR);
if (f) {
struct stat st;
struct libmnt_iter itr;
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 5453789e..c910035d 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -462,7 +462,7 @@ static int get_filesystems(const char *filename, char ***filesystems, const char
FILE *f;
char line[128];
- f = fopen(filename, "r");
+ f = fopen(filename, "r" UL_CLOEXECSTR);
if (!f)
return 1;
@@ -837,7 +837,7 @@ int mnt_open_uniq_filename(const char *filename, char **name)
*/
oldmode = umask(S_IRGRP|S_IWGRP|S_IXGRP|
S_IROTH|S_IWOTH|S_IXOTH);
- fd = mkstemp(n);
+ fd = mkostemp(n, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
umask(oldmode);
if (fd >= 0 && name)
@@ -949,7 +949,7 @@ char *mnt_get_kernel_cmdline_option(const char *name)
if (!path)
path = _PATH_PROC_CMDLINE;
#endif
- f = fopen(path, "r");
+ f = fopen(path, "r" UL_CLOEXECSTR);
if (!f)
return NULL;