Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=a40dd4574da78…
Commit: a40dd4574da7881ff980498f834f27aded844454
Parent: 1177eedd0f1681cf3e6cc0271bcb8d65c7f75b52
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Aug 16 10:37:40 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:21:07 2013 +0100
libgfs2: Set umask before calling mkstemp
Coverity highlighted a case where mkstemp() was being called without the
umask being set. This sets the umask to create the file with 0600
permissions and then restores it after mkstemp() is called.
rhbz#1001504
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/misc.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 6807f60..3989bf1 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -219,13 +219,16 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
struct mntent *mountent;
char mtab_tmpfn[PATH_MAX];
int error, fd;
+ mode_t mask;
mtab = setmntent("/etc/mtab", "rt");
if (mtab == NULL)
die("Couldn't open /etc/mtab for writing: %s\n",
strerror(errno));
strcpy(mtab_tmpfn, "/etc/mtab.XXXXXX");
+ mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
fd = mkstemp(mtab_tmpfn);
+ umask(mask);
if (fd < 0)
die("Couldn't open temporary mtab file for writing: %s\n",
strerror(errno));
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=1177eedd0f168…
Commit: 1177eedd0f1681cf3e6cc0271bcb8d65c7f75b52
Parent: cf62f1ff9ec1a9d3aae6a9c473c3e002467b220a
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Aug 15 07:41:56 2013 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:20:44 2013 +0100
libgfs2: Correct error message in mtab update code
If we encounter an error while trying to update the /etc/mtab file
the code was reporting that the problem in adding an entry. The
problem is, it's really trying to add the entries to the temp file,
which will be renamed to /etc/mtab, for the sake of removing an
entry from mtab. Therefore, I'm correcting the error message so that
it makes more sense.
rhbz#1001504
---
gfs2/libgfs2/misc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index f7fab7e..6807f60 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -240,14 +240,14 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
continue;
error = addmntent(mtabnew, mountent);
if (error)
- die("Unable to add mount entry to mtab.\n");
+ die("Unable to remove mount entry from mtab.\n");
}
endmntent(mtab);
fclose(mtabnew);
close(fd);
if (rename(mtab_tmpfn, "/etc/mtab"))
- fprintf(stderr, "Unable to add mount entry to mtab.\n");
+ fprintf(stderr, "Unable to remove mount entry from mtab.\n");
}
void cleanup_metafs(struct gfs2_sbd *sdp)