s4: import lorikeet-heimdal-200810271034
[sfrench/samba-autobuild/.git] / source4 / heimdal / lib / hdb / ext.c
index 92147254ee6e6bf8b0d4bca0656d6a8f6f79282c..f792b85c096d15dcc9bcb0a3b2df49a0247b7835 100644 (file)
@@ -1,34 +1,34 @@
 /*
- * Copyright (c) 2004 - 2005 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden). 
- * All rights reserved. 
+ * Copyright (c) 2004 - 2005 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
  *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
  *
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
  *
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- * 3. Neither the name of the Institute nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
- * SUCH DAMAGE. 
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #include "hdb_locl.h"
@@ -44,12 +44,12 @@ hdb_entry_check_mandatory(krb5_context context, const hdb_entry *ent)
     if (ent->extensions == NULL)
        return 0;
 
-    /* 
+    /*
      * check for unknown extensions and if they where tagged mandatory
      */
 
     for (i = 0; i < ent->extensions->len; i++) {
-       if (ent->extensions->val[i].data.element != 
+       if (ent->extensions->val[i].data.element !=
            choice_HDB_extension_data_asn1_ellipsis)
            continue;
        if (ent->extensions->val[i].mandatory) {
@@ -83,8 +83,8 @@ hdb_find_extension(const hdb_entry *entry, int type)
  */
 
 krb5_error_code
-hdb_replace_extension(krb5_context context, 
-                     hdb_entry *entry, 
+hdb_replace_extension(krb5_context context,
+                     hdb_entry *entry,
                      const HDB_extension *ext)
 {
     HDB_extension *ext2;
@@ -102,7 +102,7 @@ hdb_replace_extension(krb5_context context,
     } else if (ext->data.element != choice_HDB_extension_data_asn1_ellipsis) {
        ext2 = hdb_find_extension(entry, ext->data.element);
     } else {
-       /* 
+       /*
         * This is an unknown extention, and we are asked to replace a
         * possible entry in `entry' that is of the same type. This
         * might seem impossible, but ASN.1 CHOICE comes to our
@@ -159,7 +159,7 @@ hdb_replace_extension(krb5_context context,
        return ret;
     }
 
-    es = realloc(entry->extensions->val, 
+    es = realloc(entry->extensions->val,
                 (entry->extensions->len+1)*sizeof(entry->extensions->val[0]));
     if (es == NULL) {
        krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
@@ -178,8 +178,8 @@ hdb_replace_extension(krb5_context context,
 }
 
 krb5_error_code
-hdb_clear_extension(krb5_context context, 
-                   hdb_entry *entry, 
+hdb_clear_extension(krb5_context context,
+                   hdb_entry *entry,
                    int type)
 {
     int i;
@@ -249,7 +249,7 @@ hdb_entry_get_pw_change_time(const hdb_entry *entry, time_t *t)
 }
 
 krb5_error_code
-hdb_entry_set_pw_change_time(krb5_context context, 
+hdb_entry_set_pw_change_time(krb5_context context,
                             hdb_entry *entry,
                             time_t t)
 {
@@ -265,7 +265,7 @@ hdb_entry_set_pw_change_time(krb5_context context,
 }
 
 int
-hdb_entry_get_password(krb5_context context, HDB *db, 
+hdb_entry_get_password(krb5_context context, HDB *db,
                       const hdb_entry *entry, char **p)
 {
     HDB_extension *ext;
@@ -280,7 +280,7 @@ hdb_entry_get_password(krb5_context context, HDB *db,
        if (db->hdb_master_key_set && ext->data.u.password.mkvno) {
            hdb_master_key key;
 
-           key = _hdb_find_master_key(ext->data.u.password.mkvno, 
+           key = _hdb_find_master_key(ext->data.u.password.mkvno,
                                       db->hdb_master_key);
 
            if (key == NULL) {
@@ -298,7 +298,7 @@ hdb_entry_get_password(krb5_context context, HDB *db,
            ret = der_copy_octet_string(&ext->data.u.password.password, &pw);
        }
        if (ret) {
-           krb5_clear_error_string(context);
+           krb5_clear_error_message(context);
            return ret;
        }
 
@@ -322,14 +322,14 @@ hdb_entry_get_password(krb5_context context, HDB *db,
     if (ret == 0) {
        krb5_set_error_message(context, ENOENT, "no password attributefor %s", str);
        free(str);
-    } else 
-       krb5_clear_error_string(context);
+    } else
+       krb5_clear_error_message(context);
 
     return ENOENT;
 }
 
 int
-hdb_entry_set_password(krb5_context context, HDB *db, 
+hdb_entry_set_password(krb5_context context, HDB *db,
                       hdb_entry *entry, const char *p)
 {
     HDB_extension ext;
@@ -350,12 +350,12 @@ hdb_entry_set_password(krb5_context context, HDB *db,
        }
 
        ret = _hdb_mkey_encrypt(context, key, HDB_KU_MKEY,
-                               p, strlen(p) + 1, 
+                               p, strlen(p) + 1,
                                &ext.data.u.password.password);
        if (ret)
            return ret;
 
-       ext.data.u.password.mkvno = 
+       ext.data.u.password.mkvno =
            malloc(sizeof(*ext.data.u.password.mkvno));
        if (ext.data.u.password.mkvno == NULL) {
            free_HDB_extension(&ext);
@@ -367,7 +367,7 @@ hdb_entry_set_password(krb5_context context, HDB *db,
     } else {
        ext.data.u.password.mkvno = NULL;
 
-       ret = krb5_data_copy(&ext.data.u.password.password, 
+       ret = krb5_data_copy(&ext.data.u.password.password,
                             p, strlen(p) + 1);
        if (ret) {
            krb5_set_error_message(context, ret, "malloc: out of memory");
@@ -386,17 +386,17 @@ hdb_entry_set_password(krb5_context context, HDB *db,
 int
 hdb_entry_clear_password(krb5_context context, hdb_entry *entry)
 {
-    return hdb_clear_extension(context, entry, 
+    return hdb_clear_extension(context, entry,
                               choice_HDB_extension_data_password);
 }
 
 krb5_error_code
-hdb_entry_get_ConstrainedDelegACL(const hdb_entry *entry, 
+hdb_entry_get_ConstrainedDelegACL(const hdb_entry *entry,
                                  const HDB_Ext_Constrained_delegation_acl **a)
 {
     const HDB_extension *ext;
 
-    ext = hdb_find_extension(entry, 
+    ext = hdb_find_extension(entry,
                             choice_HDB_extension_data_allowed_to_delegate_to);
     if (ext)
        *a = &ext->data.u.allowed_to_delegate_to;