]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntp-genkeys.c:
authorHarlan Stenn <stenn@ntp.org>
Tue, 15 Aug 2000 03:15:20 +0000 (03:15 -0000)
committerHarlan Stenn <stenn@ntp.org>
Tue, 15 Aug 2000 03:15:20 +0000 (03:15 -0000)
  * util/ntp-genkeys.c (main): More small steps...

bk: 3998b5c8q0E_sGldK3aCVcbMbnZOXg

util/ntp-genkeys.c

index 5efcb5c0a757a8e12b3faf258c4bd71e6a987dec..158e21ea0f8db62c4447b208096cbc8c1dd4a466 100644 (file)
@@ -597,17 +597,24 @@ cleanlinks(
        */
 #endif /* HAVE_READLINK */
        if (unlink(f1)) {
-               fprintf(stderr, "unlink(%s) failed: %s\n", f1,
-                       strerror(errno));
-               return;
+               if (errno != ENOENT) {
+                       fprintf(stderr, "unlink(%s) failed: %s\n", f1,
+                               strerror(errno));
+                       return;
+               }
        }
        /* file = dirname(f3) / f2 */
-       snprintf(fb, sizeof fb, "%s", f3);
-       cp = strrchr(fb, '/');
-       if (cp) {
-               *cp = 0;
+       if (f3) {
+               snprintf(fb, sizeof fb, "%s", f3);
+               cp = strrchr(fb, '/');
+               if (cp) {
+                       ++cp;
+                       *cp = 0;
+               }
+       } else {
+               *fb = 0;
        }
-       snprintf(fb, sizeof fb, "%s/%s", fb, f2);
+       snprintf(fb, sizeof fb, "%s%s", fb, f2);
        if (debug > 1) printf("cleanlinks 1: file is <%s>\n", fb);
 
        if (symlink(fb, f1)) {
@@ -621,12 +628,14 @@ cleanlinks(
          - if f3 begins with a /, unlink it
          - else, unlink dirname(f1) / f3
        */
-       if (trash) {
+       if (trash && f3) {
                if ('/' == *f3) {
                        if (unlink(f3)) {
-                               fprintf(stderr, "unlink(%s) failed: %s\n", f3,
-                                       strerror(errno));
-                               return;
+                               if (errno != ENOENT) {
+                                       fprintf(stderr, "unlink(%s) failed: %s\n", f3,
+                                               strerror(errno));
+                                       return;
+                               }
                        }
                } else {
                        snprintf(fb, sizeof fb, "%s", f1);
@@ -638,9 +647,11 @@ cleanlinks(
                        if (debug > 1)
                                printf("cleanlinks 2: file is <%s>\n", fb);
                        if (unlink(fb)) {
-                               fprintf(stderr, "unlink(%s) failed: %s\n", fb,
-                                       strerror(errno));
-                               return;
+                               if (errno != ENOENT) {
+                                       fprintf(stderr, "unlink(%s) failed: %s\n", fb,
+                                               strerror(errno));
+                                       return;
+                               }
                        }
                }
        }