* under an alternate open source license please contact
  * Landon Fuller <landonf@threerings.net>.
  */
-/*  
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-  
-   This library is distributed in the hope that it will be useful,
+/*
+   Copyright (C) 2005 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-  
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-   MA 02111-1307, USA.
- */
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
+ */
 
 #include "bacula.h"
 #include <assert.h>
             X509V3_EXT_METHOD *method;
             STACK_OF(CONF_VALUE) *val;
             CONF_VALUE *nval;
-            unsigned char *data;
             void *extstr = NULL;
+#if (OPENSSL_VERSION_NUMBER >= 0x0090800FL)
+            const unsigned char *ext_value_data;
+#else
+            unsigned char *ext_value_data;
+#endif
 
             /* Get x509 extension method structure */
             if (!(method = X509V3_EXT_get(ext))) {
                break;
             }
 
-            data = ext->value->data;
+            ext_value_data = ext->value->data;
 
 #if (OPENSSL_VERSION_NUMBER > 0x00907000L)
             if (method->it) {
                /* New style ASN1 */
 
                /* Decode ASN1 item in data */
-               extstr = ASN1_item_d2i(NULL, &data, ext->value->length,
+               extstr = ASN1_item_d2i(NULL, &ext_value_data, ext->value->length,
                                       ASN1_ITEM_ptr(method->it));
             } else {
                /* Old style ASN1 */
 
                /* Decode ASN1 item in data */
-               extstr = method->d2i(NULL, &data, ext->value->length);
+               extstr = method->d2i(NULL, &ext_value_data, ext->value->length);
             }
 
 #else
-            extstr = method->d2i(NULL, &data, ext->value->length);
+            extstr = method->d2i(NULL, &ext_value_data, ext->value->length);
 #endif
 
             /* Iterate through to find the dNSName field(s) */
 
 bool first_open_device(DCR *dcr)
 {
    DEVICE *dev = dcr->dev;
+   bool ok = true;
 
    Dmsg0(120, "start open_output_device()\n");
    if (!dev) {
    /* Defer opening files */
    if (!dev->is_tape()) {
       Dmsg0(129, "Device is file, deferring open.\n");
-      unlock_device(dev);
-      return true;
+      goto bail_out;
    }
 
     int mode;
    dev->open_nowait = true;
    if (dev->open(dcr, mode) < 0) {
       Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
-      dev->open_nowait = false;
-      unlock_device(dev);
-      return false;
+      ok = false;
+      goto bail_out;
    }
    Dmsg1(129, "open dev %s OK\n", dev->print_name());
+
+bail_out:
    dev->open_nowait = false;
    unlock_device(dev);
-   return true;
+   return ok;
 }
 
 /*