Add an extra param to touch() for nsec

This commit is contained in:
Todd C. Miller
2004-09-07 19:55:37 +00:00
parent 707c3c2cb9
commit 7f772c822f
5 changed files with 10 additions and 9 deletions

View File

@@ -153,7 +153,7 @@ update_timestamp(timestampdir, timestampfile)
if (timestamp_uid != 0) if (timestamp_uid != 0)
set_perms(PERM_TIMESTAMP); set_perms(PERM_TIMESTAMP);
if (touch(-1, timestampfile ? timestampfile : timestampdir, now) == -1) { if (touch(-1, timestampfile ? timestampfile : timestampdir, now, 0) == -1) {
if (timestampfile) { if (timestampfile) {
int fd = open(timestampfile, O_WRONLY|O_CREAT|O_TRUNC, 0600); int fd = open(timestampfile, O_WRONLY|O_CREAT|O_TRUNC, 0600);
@@ -552,7 +552,7 @@ remove_timestamp(remove)
remove = FALSE; remove = FALSE;
} }
} }
if (!remove && touch(-1, ts, 0) == -1) if (!remove && touch(-1, ts, 0, 0) == -1)
err(1, "can't reset %s to Epoch", ts); err(1, "can't reset %s to Epoch", ts);
} }

View File

@@ -43,15 +43,16 @@ static const char rcsid[] = "$Sudo$";
* Update the access and modify times on an fd or file. * Update the access and modify times on an fd or file.
*/ */
int int
touch(fd, path, when) touch(fd, path, sec, nsec)
int fd; int fd;
char *path; char *path;
time_t when; time_t sec;
long nsec;
{ {
struct timeval times[2]; struct timeval times[2];
times[0].tv_sec = times[1].tv_sec = when; times[0].tv_sec = times[1].tv_sec = sec;
times[0].tv_usec = times[1].tv_usec = 0; times[0].tv_usec = times[1].tv_usec = nsec;
#if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES) #if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES)
if (fd != -1) if (fd != -1)

2
sudo.h
View File

@@ -229,7 +229,7 @@ void dump_defaults __P((void));
void dump_auth_methods __P((void)); void dump_auth_methods __P((void));
void init_envtables __P((void)); void init_envtables __P((void));
int lock_file __P((int, int)); int lock_file __P((int, int));
int touch __P((int, char *, time_t)); int touch __P((int, char *, time_t, long));
int user_is_exempt __P((void)); int user_is_exempt __P((void));
void set_fqdn __P((void)); void set_fqdn __P((void));
int set_runaspw __P((char *)); int set_runaspw __P((char *));

View File

@@ -159,7 +159,7 @@ int sudo_edit(argc, argv)
* file's mtime. It is better than nothing and we only use the info * file's mtime. It is better than nothing and we only use the info
* to determine whether or not a file has been modified. * to determine whether or not a file has been modified.
*/ */
if (touch(tf[i].tfd, NULL, tf[i].omtime) == -1) { if (touch(tf[i].tfd, NULL, tf[i].omtime, 0) == -1) {
if (fstat(tf[i].tfd, &sb) == 0) if (fstat(tf[i].tfd, &sb) == 0)
tf[i].omtime = sb.st_mtime; tf[i].omtime = sb.st_mtime;
} }

View File

@@ -220,7 +220,7 @@ main(argc, argv)
write(stmp_fd, buf, 1); write(stmp_fd, buf, 1);
} }
(void) touch(stmp_fd, stmp, sudoers_sb.st_mtime); (void) touch(stmp_fd, stmp, sudoers_sb.st_mtime, 0);
(void) close(stmp_fd); (void) close(stmp_fd);
/* Parse sudoers to pull in editor and env_editor conf values. */ /* Parse sudoers to pull in editor and env_editor conf values. */