From 7f772c822f19d60f06de9fe90f5dc1ddbadc4546 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 7 Sep 2004 19:55:37 +0000 Subject: [PATCH] Add an extra param to touch() for nsec --- check.c | 4 ++-- fileops.c | 9 +++++---- sudo.h | 2 +- sudo_edit.c | 2 +- visudo.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/check.c b/check.c index a333e15d9..826d952d7 100644 --- a/check.c +++ b/check.c @@ -153,7 +153,7 @@ update_timestamp(timestampdir, timestampfile) if (timestamp_uid != 0) set_perms(PERM_TIMESTAMP); - if (touch(-1, timestampfile ? timestampfile : timestampdir, now) == -1) { + if (touch(-1, timestampfile ? timestampfile : timestampdir, now, 0) == -1) { if (timestampfile) { int fd = open(timestampfile, O_WRONLY|O_CREAT|O_TRUNC, 0600); @@ -552,7 +552,7 @@ remove_timestamp(remove) 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); } diff --git a/fileops.c b/fileops.c index 643de5da3..fd8407efe 100644 --- a/fileops.c +++ b/fileops.c @@ -43,15 +43,16 @@ static const char rcsid[] = "$Sudo$"; * Update the access and modify times on an fd or file. */ int -touch(fd, path, when) +touch(fd, path, sec, nsec) int fd; char *path; - time_t when; + time_t sec; + long nsec; { struct timeval times[2]; - times[0].tv_sec = times[1].tv_sec = when; - times[0].tv_usec = times[1].tv_usec = 0; + times[0].tv_sec = times[1].tv_sec = sec; + times[0].tv_usec = times[1].tv_usec = nsec; #if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES) if (fd != -1) diff --git a/sudo.h b/sudo.h index 098702995..b404129de 100644 --- a/sudo.h +++ b/sudo.h @@ -229,7 +229,7 @@ void dump_defaults __P((void)); void dump_auth_methods __P((void)); void init_envtables __P((void)); 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)); void set_fqdn __P((void)); int set_runaspw __P((char *)); diff --git a/sudo_edit.c b/sudo_edit.c index f2924edd3..c5a638b41 100644 --- a/sudo_edit.c +++ b/sudo_edit.c @@ -159,7 +159,7 @@ int sudo_edit(argc, argv) * 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(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) tf[i].omtime = sb.st_mtime; } diff --git a/visudo.c b/visudo.c index e2c8eebab..cef880ee7 100644 --- a/visudo.c +++ b/visudo.c @@ -220,7 +220,7 @@ main(argc, argv) 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); /* Parse sudoers to pull in editor and env_editor conf values. */ -- 2.40.0