]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
- ldns-verify-zone error messages to stderr
authorWillem Toorop <willem@NLnetLabs.nl>
Tue, 6 Mar 2012 20:57:05 +0000 (20:57 +0000)
committerWillem Toorop <willem@NLnetLabs.nl>
Tue, 6 Mar 2012 20:57:05 +0000 (20:57 +0000)
- ldns-verify-zone errors on empty key files
- make Makefile in examples subdir work for ldns-verify-zone
- make lint test pass (at least on open)

examples/Makefile.in
examples/ldns-duration.c
examples/ldns-duration.h
examples/ldns-verify-zone.c
install-sh

index 5344ee6739c0387e6289e229717e7693bfac4213..07aa76b1243e28652651696853d3ac34558e158d 100644 (file)
@@ -72,7 +72,7 @@ MAIN_SSL_SOURCES = ldns-signzone.c \
                  ldns-revoke.c \
                  ldns-nsec3-hash.c
 
-OTHER_SOURCES = ldns-testpkts.c
+OTHER_SOURCES = ldns-testpkts.c ldns-duration.c
 
 PROGRAMS=$(MAIN_SOURCES:.c=)
 SSL_PROGRAMS=$(MAIN_SSL_SOURCES:.c=)
@@ -92,6 +92,11 @@ ldns-testns.o: $(srcdir)/ldns-testns.c $(srcdir)/ldns-testpkts.c $(srcdir)/ldns-
 ldns-testns.prg: ldns-testpkts.o
 ldns-testns.stc: ldns-testpkts.o
 
+# ldns-verify-zone uses more sources.
+ldns-verify-zone.o: $(srcdir)/ldns-verify-zone.c $(srcdir)/ldns-duration.c $(srcdir)/ldns-duration.h
+ldns-verify-zone.prg-ssl: ldns-duration.o
+ldns-verify-zone.stc-ssl: ldns-duration.o
+
 ldnsd.prg: ldnsd.o
        @if test ! -f $(@:.prg=) -o $< -nt $(@:.prg=); then \
        echo $(LINK) $(LIBNSL_LIBS) -o $(@:.prg=) $^ ; \
index b5086d84c0a7c4b327ae8a4b4edf346d4894f4c3..a7bbf14deb04ed3fe2bff99b27af18ba07ba1066 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: duration.c 4518 2011-02-24 15:39:09Z matthijs $
+ * $Id: ldns-duration.c 4518 2011-02-24 15:39:09Z matthijs $
  *
  * Copyright (c) 2009 NLNet Labs. All rights reserved.
  *
@@ -84,25 +84,25 @@ ldns_duration_compare(ldns_duration_type* d1, ldns_duration_type* d2)
     }
 
     if (d1->years != d2->years) {
-        return d1->years - d2->years;
+        return (int) (d1->years - d2->years);
     }
     if (d1->months != d2->months) {
-        return d1->months - d2->months;
+        return (int) (d1->months - d2->months);
     }
     if (d1->weeks != d2->weeks) {
-        return d1->weeks - d2->weeks;
+        return (int) (d1->weeks - d2->weeks);
     }
     if (d1->days != d2->days) {
-        return d1->days - d2->days;
+        return (int) (d1->days - d2->days);
     }
     if (d1->hours != d2->hours) {
-        return d1->hours - d2->hours;
+        return (int) (d1->hours - d2->hours);
     }
     if (d1->minutes != d2->minutes) {
-        return d1->minutes - d2->minutes;
+        return (int) (d1->minutes - d2->minutes);
     }
     if (d1->seconds != d2->seconds) {
-        return d1->seconds - d2->seconds;
+        return (int) (d1->seconds - d2->seconds);
     }
 
     return 0;
@@ -136,19 +136,19 @@ ldns_duration_create_from_string(const char* str)
     T = strchr(str, 'T');
     X = strchr(str, 'Y');
     if (X) {
-        duration->years = atoi(str+1);
+        duration->years = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
     X = strchr(str, 'M');
     if (X && (!T || (size_t) (X-P) < (size_t) (T-P))) {
-        duration->months = atoi(str+1);
+        duration->months = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
     X = strchr(str, 'D');
     if (X) {
-        duration->days = atoi(str+1);
+        duration->days = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
@@ -158,19 +158,19 @@ ldns_duration_create_from_string(const char* str)
     }
     X = strchr(str, 'H');
     if (X && T) {
-        duration->hours = atoi(str+1);
+        duration->hours = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
     X = strrchr(str, 'M');
     if (X && T && (size_t) (X-P) > (size_t) (T-P)) {
-        duration->minutes = atoi(str+1);
+        duration->minutes = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
     X = strchr(str, 'S');
     if (X && T) {
-        duration->seconds = atoi(str+1);
+        duration->seconds = (time_t) atoi(str+1);
         str = X;
         not_weeks = 1;
     }
@@ -181,7 +181,7 @@ ldns_duration_create_from_string(const char* str)
             ldns_duration_cleanup(duration);
             return NULL;
         } else {
-            duration->weeks = atoi(str+1);
+            duration->weeks = (time_t) atoi(str+1);
             str = W;
         }
     }
@@ -257,28 +257,28 @@ ldns_duration2string(ldns_duration_type* duration)
     if (duration->years > 0) {
         count = digits_in_number(duration->years);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uY", (uint32_t) duration->years);
+        snprintf(num, count+2, "%uY", (unsigned int) duration->years);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
     if (duration->months > 0) {
         count = digits_in_number(duration->months);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uM", (uint32_t) duration->months);
+        snprintf(num, count+2, "%uM", (unsigned int) duration->months);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
     if (duration->weeks > 0) {
         count = digits_in_number(duration->weeks);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uW", (uint32_t) duration->weeks);
+        snprintf(num, count+2, "%uW", (unsigned int) duration->weeks);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
     if (duration->days > 0) {
         count = digits_in_number(duration->days);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uD", (uint32_t) duration->days);
+        snprintf(num, count+2, "%uD", (unsigned int) duration->days);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
@@ -288,21 +288,21 @@ ldns_duration2string(ldns_duration_type* duration)
     if (duration->hours > 0) {
         count = digits_in_number(duration->hours);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uH", (uint32_t) duration->hours);
+        snprintf(num, count+2, "%uH", (unsigned int) duration->hours);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
     if (duration->minutes > 0) {
         count = digits_in_number(duration->minutes);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uM", (uint32_t) duration->minutes);
+        snprintf(num, count+2, "%uM", (unsigned int) duration->minutes);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
     if (duration->seconds > 0) {
         count = digits_in_number(duration->seconds);
         num = (char*) calloc(count+2, sizeof(char));
-        snprintf(num, count+2, "%uS", (uint32_t) duration->seconds);
+        snprintf(num, count+2, "%uS", (unsigned int) duration->seconds);
         str = strncat(str, num, count+2);
         free((void*) num);
     }
@@ -318,7 +318,6 @@ time_t
 ldns_duration2time(ldns_duration_type* duration)
 {
     time_t period = 0;
-    char* dstr = NULL;
 
     if (duration) {
         period += (duration->seconds);
@@ -376,77 +375,6 @@ ods_rand(time_t mod)
 }
 
 
-/* Number of days per month (except for February in leap years). */
-static const int mdays[] = {
-    31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-
-static int
-is_leap_year(int year)
-{
-    return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
-}
-
-
-static int
-leap_days(int y1, int y2)
-{
-    --y1;
-    --y2;
-    return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400);
-}
-
-
-/*
- * Code taken from NSD 3.2.5, which is
- * code adapted from Python 2.4.1 sources (Lib/calendar.py).
- */
-static time_t
-mktime_from_utc(const struct tm *tm)
-{
-    int year = 1900 + tm->tm_year;
-    time_t days = 365 * (year - 1970) + leap_days(1970, year);
-    time_t hours;
-    time_t minutes;
-    time_t seconds;
-    int i;
-
-    for (i = 0; i < tm->tm_mon; ++i) {
-        days += mdays[i];
-    }
-    if (tm->tm_mon > 1 && is_leap_year(year)) {
-        ++days;
-    }
-    days += tm->tm_mday - 1;
-
-    hours = days * 24 + tm->tm_hour;
-    minutes = hours * 60 + tm->tm_min;
-    seconds = minutes * 60 + tm->tm_sec;
-
-    return seconds;
-}
-
-
-/**
- * Convert time in string format into seconds.
- *
- */
-static time_t
-timeshift2time(const char *time)
-{
-        /* convert a string in format YYMMDDHHMMSS to time_t */
-        struct tm tm;
-        time_t timeshift = 0;
-
-        /* Try to scan the time... */
-        if (strptime(time, "%Y%m%d%H%M%S", &tm)) {
-                timeshift = mktime_from_utc(&tm);
-       }
-        return timeshift;
-}
-
-
 /**
  * Return the time since Epoch, measured in seconds.
  *
@@ -502,7 +430,7 @@ time_datestamp(time_t tt, const char* format, char** str)
 static void
 time_itoa_reverse(char* s)
 {
-    int i, j;
+    size_t i, j;
     char c;
 
     for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
@@ -524,7 +452,7 @@ time_itoa(time_t n, char* s)
     int i = 0;
 
     do {       /* generate digits in reverse order */
-        s[i++] = n % 10 + '0';   /* get next digit */
+        s[i++] = (char) n % 10 + '0';   /* get next digit */
     } while ((n /= 10) > 0);     /* delete it */
     s[i] = '\0';
     time_itoa_reverse(s);
index 24becd5032752812553ac6edfe036cdc59a7997b..da7d510322be1618328295377e294f3a5d7b1e91 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: duration.h 4341 2011-01-31 15:21:09Z matthijs $
+ * $Id: ldns-duration.h 4341 2011-01-31 15:21:09Z matthijs $
  *
  * Copyright (c) 2009 NLNet Labs. All rights reserved.
  *
index 5bb5ac9eb681b85ad8abceecb72dddc63a8718a2..27f5bf793ed5910e630ae6fa8cac5613f790a5bd 100644 (file)
@@ -935,11 +935,11 @@ main(int argc, char **argv)
        struct tm tm;
        ldns_duration_type *duration;
        ldns_rr_list *keys = ldns_rr_list_new();
+       size_t nkeys = 0;
 
        check_time = ldns_time(NULL);
        myout = stdout;
-       // myerr = stderr;
-       myerr = stdout;
+       myerr = stderr;
 
        while ((c = getopt(argc, argv, "ae:hi:k:vV:p:St:")) != -1) {
                switch(c) {
@@ -1028,6 +1028,14 @@ main(int argc, char **argv)
                                       );
                                 exit(EXIT_FAILURE);
                        }
+                       if (ldns_rr_list_rr_count(keys) == nkeys) {
+                               fprintf( myerr
+                                      , "No keys found in file %s\n"
+                                      , optarg
+                                      );
+                               exit(EXIT_FAILURE);
+                       }
+                       nkeys = ldns_rr_list_rr_count(keys);
                        break;
                 case 'p':
                         percentage = atoi(optarg);
@@ -1070,7 +1078,7 @@ main(int argc, char **argv)
                        break;
                }
        }
-       if (do_sigchase && ldns_rr_list_rr_count(keys) == 0) {
+       if (do_sigchase && nkeys == 0) {
                fprintf(myerr, "Unable to chase signature without keys.\n");
                exit(EXIT_SUCCESS);
        }
index 3f83ce9b555a535ca90c450882953554c7e4ded5..a9244eb0786534553fdd9eb0050bb4b172bad0a3 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2010-02-06.18; # UTC
+scriptversion=2011-01-19.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -156,6 +156,10 @@ while test $# -ne 0; do
     -s) stripcmd=$stripprog;;
 
     -t) dst_arg=$2
+       # Protect names problematic for `test' and other utilities.
+       case $dst_arg in
+         -* | [=\(\)!]) dst_arg=./$dst_arg;;
+       esac
        shift;;
 
     -T) no_target_directory=true;;
@@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
     fi
     shift # arg
     dst_arg=$arg
+    # Protect names problematic for `test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
   done
 fi
 
@@ -232,9 +240,9 @@ fi
 
 for src
 do
-  # Protect names starting with `-'.
+  # Protect names problematic for `test' and other utilities.
   case $src in
-    -*) src=./$src;;
+    -* | [=\(\)!]) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
@@ -256,12 +264,7 @@ do
       echo "$0: no destination specified." >&2
       exit 1
     fi
-
     dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
@@ -389,7 +392,7 @@ do
 
       case $dstdir in
        /*) prefix='/';;
-       -*) prefix='./';;
+       [-=\(\)!]*) prefix='./';;
        *)  prefix='';;
       esac
 
@@ -407,7 +410,7 @@ do
 
       for d
       do
-       test -z "$d" && continue
+       test X"$d" = X && continue
 
        prefix=$prefix$d
        if test -d "$prefix"; then