|
Bugzilla – Full Text Bug Listing |
| Summary: | sudo_edit.c mtime checks when source and tmp filesystems have different resolution | ||
|---|---|---|---|
| Product: | Sudo | Reporter: | jrrs |
| Component: | Visudo | Assignee: | Todd C. Miller <Todd.Miller> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | jwm |
| Priority: | low | ||
| Version: | 1.6.9 | ||
| Hardware: | PC | ||
| OS: | All | ||
| Attachments: | diff to update stashed copy of mtime based on touched temp file | ||
btw trackdown credits go to Philippe Levan <levan@epix.net> Created attachment 264 [details]
diff to update stashed copy of mtime based on touched temp file
Please try the attached diff, it should fix the issue.
(In reply to comment #2) > Created an attachment (id=264) [details] > diff to update stashed copy of mtime based on touched temp file > > Please try the attached diff, it should fix the issue. verified the diff works - no longer always moves the file into place. |
---(sudo_edit.c) /* * If we are unable to set the mtime on the temp file to the value * of the original file just make the stashed mtime match the temp * file's mtime. It is better than nothing and we only use the info * to determine whether or not a file has been modified. */ if (touch(tfd, NULL, &tf[i].omtim) == -1) { if (fstat(tfd, &sb) == 0) { tf[i].omtim.tv_sec = mtim_getsec(sb); tf[i].omtim.tv_nsec = mtim_getnsec(sb); } /* XXX - else error? */ } --- if sudoedit is invoked on a filesystem who has different filetime resolution (eg one has nsec resolution one doesn't), as long as touch() succeeds, the result will be that the file is moved into place every time (unless it happens to line up on .000000 seconds in which case they'll naturally be equal). take the following from a running copy of sudoedit and its tmpfile, on a linux host where the tmp filesystem (ext3) does not offer nsec resolution, but the source filesystem (netapp nfs) does: --- #linux 0918_02:27:36 $ stat myass /var/tmp/myass.XXYWIq4X File: `myass' Size: 0 Blocks: 0 IO Block: 65536 regular empty file Device: 15h/21d Inode: 3279889 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 645/ jrrs) Gid: ( 645/ jrrs) Access: 2009-09-18 02:23:28.325745000 -0400 Modify: 2009-09-18 02:23:28.325745000 -0400 Change: 2009-09-18 02:23:28.325745000 -0400 File: `/var/tmp/myass.XXYWIq4X' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 807h/2055d Inode: 30 Links: 1 Access: (0600/-rw-------) Uid: ( 645/ jrrs) Gid: ( 645/ jrrs) Access: 2009-09-18 02:27:34.000000000 -0400 Modify: 2009-09-18 02:23:28.000000000 -0400 Change: 2009-09-18 02:27:34.000000000 -0400 ---