From 5583c1316296272a216e62365c15f0ad5d89ab15 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Sat, 19 Jul 2008 21:31:40 +0000 Subject: Use errx instead of fprintf, exit combo. Diff from Gleydson Soares gsoares (at) gmail (dot) com OK henning@ --- usr.sbin/ntpd/ntpd.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index 89012f4cf34..fcffb36ed5e 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.60 2008/05/16 06:13:25 ckuethe Exp $ */ +/* $OpenBSD: ntpd.c,v 1.61 2008/07/19 21:31:39 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -29,6 +29,7 @@ #include #include #include +#include #include "ntpd.h" @@ -137,15 +138,12 @@ main(int argc, char *argv[]) exit(0); } - if (geteuid()) { - fprintf(stderr, "ntpd: need root privileges\n"); - exit(1); - } + if (geteuid()) + errx(1, "need root privileges"); + + if ((pw = getpwnam(NTPD_USER)) == NULL) + errx(1, "unknown user %s", NTPD_USER); - if ((pw = getpwnam(NTPD_USER)) == NULL) { - fprintf(stderr, "ntpd: unknown user %s\n", NTPD_USER); - exit(1); - } endpwent(); reset_adjtime(); -- cgit v1.2.3