Skip to contentSkip to conversation

hwclock: increase debug output precision

PATCH Applied J William Piggott 2 participants 3 messages Mar 17, 2015 – Mar 25, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hwclock: increase debug output precision

Increased the precision in debug output showing
the clock drift and the time lapsed.

Showing a clock drift of 0.0 while giving a value that the drift factor was adjusted by makes no sense.

---
 sys-utils/hwclock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sys-utils/hwclock.c +2 -2
index 52a7874..e8732b8 100644
@@ -1062,8 +1062,8 @@ adjust_drift_factor(struct adjtime *adjtime_p,
 			drift_factor = 0;
 		} else {
 			if (debug)
-				printf(_("Clock drifted %.1f seconds in the past "
-					 "%.1f seconds\nin spite of a drift factor of "
+				printf(_("Clock drifted %f seconds in the past "
+					 "%f seconds\nin spite of a drift factor of "
 					 "%f seconds/day.\n"
 					 "Adjusting drift factor by %f seconds/day\n"),
 				       time_diff(nowtime, hclocktime),
#1 lore raw

PATCH 2/2 hwclock: non-root access in test mode

Allow a non-root user to call all hwclock
functions when the --test option is used.

---
 sys-utils/hwclock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sys-utils/hwclock.c +3 -3
index e8732b8..e1e5816 100644
@@ -1914,15 +1914,15 @@ int main(int argc, char **argv)
 		permitted = TRUE;
 	else {
 		/* program is designed to run setuid (in some situations) */
-		if (set || systohc || adjust) {
+		if ((set || systohc || adjust) && !testing) {
 			warnx(_("Sorry, only the superuser can change "
 				"the Hardware Clock."));
 			permitted = FALSE;
-		} else if (systz || hctosys) {
+		} else if ((systz || hctosys) && !testing) {
 			warnx(_("Sorry, only the superuser can change "
 				"the System Clock."));
 			permitted = FALSE;
-		} else if (setepoch) {
+		} else if (setepoch && !testing) {
 			warnx(_("Sorry, only the superuser can change the "
 				"Hardware Clock epoch in the kernel."));
 			permitted = FALSE;
maintainer Applied
#2 lore raw
In reply to J William Piggott
Quoted 2 lines · J William Piggott
 sys-utils/hwclock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied both patches (week ago:-), thanks

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com