X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=timestamp.c;h=bca260d1071f3f2436708c4aa6c1588567c9b009;hb=b82ffa68a6436ce3f4c4b480bc9c12ac284b0d99;hp=c7edb56409e109aea271e04b9ad51f5e5e21cfac;hpb=31d95b9c3339af50f0e6758a1e3a66d846e5145d;p=opendoas.git diff --git a/timestamp.c b/timestamp.c index c7edb56..bca260d 100644 --- a/timestamp.c +++ b/timestamp.c @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2020 Duncan Overbruck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "config.h" + /* * 1) Timestamp files and directories * @@ -64,7 +82,8 @@ #include #include -#include "includes.h" +#include "openbsd.h" +#include "doas.h" #ifndef TIMESTAMP_DIR # define TIMESTAMP_DIR "/run/doas" @@ -205,10 +224,9 @@ timestamp_check(int fd, int secs) if (st.st_uid != 0 || st.st_gid != getgid() || st.st_mode != (S_IFREG | 0000)) errx(1, "timestamp uid, gid or mode wrong"); - if (!timespecisset(&st.st_atim) || !timespecisset(&st.st_mtim)) { - warnx("timestamp atim or mtime not set"); + /* this timestamp was created but never set, invalid but no error */ + if (!timespecisset(&st.st_atim) || !timespecisset(&st.st_mtim)) return 0; - } if (clock_gettime(CLOCK_BOOTTIME, &ts[0]) == -1 || clock_gettime(CLOCK_REALTIME, &ts[1]) == -1) {