diff options
author | Jan Kara <jack@suse.cz> | 2015-01-05 15:55:52 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2015-01-05 15:55:52 +0100 |
commit | ade969d2640e1752444060da34e47b2fce5bfda2 (patch) | |
tree | 3db1acb95bfb2273daa385c452c9405f299f73e1 | |
parent | 885a0205b2639e38fdde52754b8075fba8559a71 (diff) | |
download | quota-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.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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!")); |