summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2015-01-05 15:55:52 +0100
committerJan Kara <jack@suse.cz>2015-01-05 15:55:52 +0100
commitade969d2640e1752444060da34e47b2fce5bfda2 (patch)
tree3db1acb95bfb2273daa385c452c9405f299f73e1
parent885a0205b2639e38fdde52754b8075fba8559a71 (diff)
downloadquota-tools-ade969d2640e1752444060da34e47b2fce5bfda2.tar.gz
edquota: Reopen the file with new grace times
Reopen the file with grace times - editor may have written the file into a new inode and thus we cannot read the contents through the old fd. Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--edquota.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/edquota.c b/edquota.c
index 266e67c..019eb19 100644
--- a/edquota.c
+++ b/edquota.c
@@ -285,6 +285,14 @@ int main(int argc, char **argv)
errstr(_("Error while editing grace times.\n"));
ret = -1;
}
+ close(tmpfd);
+ /*
+ * Reopen the file since editor may have written the
+ * file in a new place. Open in rw mode because we can
+ * reuse the file for editting the next user as well.
+ */
+ if ((tmpfd = open(tmpfil, O_RDWR)) < 0)
+ die(1, _("Cannot reopen!"));
if (readtimes(handles, tmpfd) < 0) {
errstr(_("Failed to parse grace times file.\n"));
ret = -1;
@@ -316,8 +324,9 @@ int main(int argc, char **argv)
}
close(tmpfd);
/*
- * Open in rw mode because we can reuse the file for
- * editting next user as well.
+ * Reopen the file since editor may have written the
+ * file in a new place. Open in rw mode because we can
+ * reuse the file for editting the next user as well.
*/
if ((tmpfd = open(tmpfil, O_RDWR)) < 0)
die(1, _("Cannot reopen!"));