Subject: Re: lib/34218: settimeofday(2) causes date(1) command to han
To: None <jnemeth@NetBSD.org, gnats-admin@netbsd.org,>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: netbsd-bugs
Date: 08/16/2006 22:00:20
The following reply was made to PR lib/34218; it has been noted by GNATS.
From: jnemeth@victoria.tc.ca (John Nemeth)
To: gnats-bugs@NetBSD.org, lib-bug-people@NetBSD.org,
gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Cc:
Subject: Re: lib/34218: settimeofday(2) causes date(1) command to han
Date: Wed, 16 Aug 2006 14:56:52 -0700
Can you try the following patch to lib/libc/settimeofday.c, please?
--- settimeofday.c.orig 2006-08-16 14:35:19.000000000 -0700
+++ settimeofday.c 2006-08-16 14:40:54.000000000 -0700
@@ -84,9 +84,12 @@ try_syscall:
* If credentials changed from root to an unprivilegied
* user, and we already had __clockctl_fd = -1, then we
* tried the system call as a non root user, it failed
- * with EPERM, and we will try clockctl.
+ * with EPERM, and we will try clockctl unless the user
+ * is root which means they probably tried to set the
+ * clock backwards and are not allowed to do so because
+ * of the securelevel.
*/
- if (rv != -1 || errno != EPERM)
+ if (rv != -1 || errno != EPERM || geteuid() == 0)
return rv;
__clockctl_fd = -2;
}