[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Mon Mar 12 22:01:05 UTC 2018


The branch master has been updated
       via  a5829ae282f47c39d1dd0642e4a84c0a6f3d80f4 (commit)
       via  86a227ee1b7cae68dfbe5737bf3193a8f03eb138 (commit)
       via  4f7c840a4dba37d8465137eae6867968e251c13c (commit)
      from  c130c0fe1d386fcc05d5b7accf062fe72b7272e8 (commit)


- Log -----------------------------------------------------------------
commit a5829ae282f47c39d1dd0642e4a84c0a6f3d80f4
Author: Richard Levitte <levitte at openssl.org>
Date:   Sun Mar 11 23:48:04 2018 +0100

    Adjust LPdir_unix.c on VMS for OpenSSL expectations
    
    When OPENSSL_DIR_read implemented by LPdir_unix.c gets a Unixy path,
    it will return file names like you'd expect them on Unix.
    
    However, if given a path with VMS syntax, such as "[.foo]", it returns
    file names with generation numbers, such as "bar.txt;1", which makes
    sense for VMS expectations, but can be surprising for OpenSSL.
    
    Our solution is to simply shave off the generation number if
    OPENSSL_DIR_read() expects there should be one, and make sure not to
    return the same file name twice.  Note that VMS filesystems are case
    insensitive, so the check for duplicate file names are done without
    regard to character case.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5587)

commit 86a227ee1b7cae68dfbe5737bf3193a8f03eb138
Author: Richard Levitte <levitte at openssl.org>
Date:   Sun Mar 11 23:47:40 2018 +0100

    CONF inclusion test: Add VMS specific tests
    
    We want to see that VMS syntax paths are treated correctly.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5587)

commit 4f7c840a4dba37d8465137eae6867968e251c13c
Author: Richard Levitte <levitte at openssl.org>
Date:   Sun Mar 11 10:14:11 2018 +0100

    CONF: On VMS, treat VMS syntax inclusion paths correctly
    
    non-VMS syntax inclusion paths get the same treatment as on Unix.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5587)

-----------------------------------------------------------------------

Summary of changes:
 crypto/LPdir_unix.c                                | 39 ++++++++++++++++++++--
 crypto/conf/conf_def.c                             | 22 ++++++++++--
 test/recipes/90-test_includes.t                    | 10 +++++-
 .../{includes.cnf => vms-includes-file.cnf}        |  2 +-
 .../{includes.cnf => vms-includes.cnf}             |  2 +-
 5 files changed, 67 insertions(+), 8 deletions(-)
 copy test/recipes/90-test_includes_data/{includes.cnf => vms-includes-file.cnf} (65%)
 copy test/recipes/90-test_includes_data/{includes.cnf => vms-includes.cnf} (65%)

diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c
index 6648a60..356089d 100644
--- a/crypto/LPdir_unix.c
+++ b/crypto/LPdir_unix.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -11,7 +11,7 @@
  * This file is dual-licensed and is also available under the following
  * terms:
  *
- * Copyright (c) 2004, Richard Levitte <richard at levitte.org>
+ * Copyright (c) 2004, 2018, Richard Levitte <richard at levitte.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,9 @@
 #ifndef LPDIR_H
 # include "LPdir.h"
 #endif
+#ifdef __VMS
+# include <ctype.h>
+#endif
 
 /*
  * The POSIXly macro for the maximum number of characters in a file path is
@@ -73,6 +76,10 @@
 struct LP_dir_context_st {
     DIR *dir;
     char entry_name[LP_ENTRY_SIZE + 1];
+#ifdef __VMS
+    int expect_file_generations;
+    char previous_entry_name[LP_ENTRY_SIZE + 1];
+#endif
 };
 
 const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
@@ -93,6 +100,15 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
         }
         memset(*ctx, 0, sizeof(**ctx));
 
+#ifdef __VMS
+        {
+            char c = directory[strlen(directory) - 1];
+
+            if (c == ']' || c == '>' || c == ':')
+                (*ctx)->expect_file_generations = 1;
+        }
+#endif
+
         (*ctx)->dir = opendir(directory);
         if ((*ctx)->dir == NULL) {
             int save_errno = errno; /* Probably not needed, but I'm paranoid */
@@ -103,6 +119,13 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
         }
     }
 
+#ifdef __VMS
+    strncpy((*ctx)->previous_entry_name, (*ctx)->entry_name,
+            sizeof((*ctx)->previous_entry_name));
+
+ again:
+#endif
+
     direntry = readdir((*ctx)->dir);
     if (direntry == NULL) {
         return 0;
@@ -111,6 +134,18 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
     strncpy((*ctx)->entry_name, direntry->d_name,
             sizeof((*ctx)->entry_name) - 1);
     (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
+#ifdef __VMS
+    if ((*ctx)->expect_file_generations) {
+        char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name);
+
+        while(p > (*ctx)->entry_name && isdigit(p[-1]))
+            p--;
+        if (p > (*ctx)->entry_name && p[-1] == ';')
+            p[-1] = '\0';
+        if (strcasecmp((*ctx)->entry_name, (*ctx)->previous_entry_name) == 0)
+            goto again;
+    }
+#endif
     return (*ctx)->entry_name;
 }
 
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index d689502..752859d 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -685,6 +685,7 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
 
         namelen = strlen(filename);
 
+
         if ((namelen > 5 && strcasecmp(filename + namelen - 5, ".conf") == 0)
             || (namelen > 4 && strcasecmp(filename + namelen - 4, ".cnf") == 0)) {
             size_t newlen;
@@ -697,10 +698,25 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
                 CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE);
                 break;
             }
-            OPENSSL_strlcat(newpath, path, newlen);
-#ifndef OPENSSL_SYS_VMS
-            OPENSSL_strlcat(newpath, "/", newlen);
+#ifdef OPENSSL_SYS_VMS
+            /*
+             * If the given path isn't clear VMS syntax,
+             * we treat it as on Unix.
+             */
+            {
+                size_t pathlen = strlen(path);
+
+                if (path[pathlen - 1] == ']' || path[pathlen - 1] == '>'
+                    || path[pathlen - 1] == ':') {
+                    /* Clear VMS directory syntax, just copy as is */
+                    OPENSSL_strlcpy(newpath, path, newlen);
+                }
+            }
 #endif
+            if (newpath[0] == '\0') {
+                OPENSSL_strlcpy(newpath, path, newlen);
+                OPENSSL_strlcat(newpath, "/", newlen);
+            }
             OPENSSL_strlcat(newpath, filename, newlen);
 
             bio = BIO_new_file(newpath, "r");
diff --git a/test/recipes/90-test_includes.t b/test/recipes/90-test_includes.t
index 9cf75a1..5169700 100644
--- a/test/recipes/90-test_includes.t
+++ b/test/recipes/90-test_includes.t
@@ -10,8 +10,16 @@ setup("test_includes");
 plan skip_all => "test_includes doesn't work without posix-io"
     if disabled("posix-io");
 
-plan tests => 3;                # The number of tests being performed
+plan tests =>                   # The number of tests being performed
+    3
+    + ($^O eq "VMS" ? 2 : 0);
 
 ok(run(test(["conf_include_test", data_file("includes.cnf")])), "test directory includes");
 ok(run(test(["conf_include_test", data_file("includes-file.cnf")])), "test file includes");
+if ($^O eq "VMS") {
+    ok(run(test(["conf_include_test", data_file("vms-includes.cnf")])),
+       "test directory includes, VMS syntax");
+    ok(run(test(["conf_include_test", data_file("vms-includes-file.cnf")])),
+       "test file includes, VMS syntax");
+}
 ok(run(test(["conf_include_test", data_file("includes-broken.cnf"), "f"])), "test broken includes");
diff --git a/test/recipes/90-test_includes_data/includes.cnf b/test/recipes/90-test_includes_data/vms-includes-file.cnf
similarity index 65%
copy from test/recipes/90-test_includes_data/includes.cnf
copy to test/recipes/90-test_includes_data/vms-includes-file.cnf
index 345eeb9..f3b72e7 100644
--- a/test/recipes/90-test_includes_data/includes.cnf
+++ b/test/recipes/90-test_includes_data/vms-includes-file.cnf
@@ -2,4 +2,4 @@
 # Example configuration file using includes.
 #
 
-.include conf-includes
+.include vms-includes.cnf
diff --git a/test/recipes/90-test_includes_data/includes.cnf b/test/recipes/90-test_includes_data/vms-includes.cnf
similarity index 65%
copy from test/recipes/90-test_includes_data/includes.cnf
copy to test/recipes/90-test_includes_data/vms-includes.cnf
index 345eeb9..ed4367b 100644
--- a/test/recipes/90-test_includes_data/includes.cnf
+++ b/test/recipes/90-test_includes_data/vms-includes.cnf
@@ -2,4 +2,4 @@
 # Example configuration file using includes.
 #
 
-.include conf-includes
+.include [.conf-includes]


More information about the openssl-commits mailing list