krb5_wrap: Add smb_krb5_open_keytab_relative() function
[samba.git] / lib / krb5_wrap / krb5_samba.c
index 7cf62436b87026bce57a629b9da93a30b70231a7..9d2f6982524fffb760e89b55ac047f0ea9392ed4 100644 (file)
@@ -1301,10 +1301,10 @@ krb5_error_code smb_krb5_enctype_to_string(krb5_context context,
 #define MAX_KEYTAB_NAME_LEN 1100
 #endif
 
-krb5_error_code smb_krb5_open_keytab(krb5_context context,
-                                    const char *keytab_name_req,
-                                    bool write_access,
-                                    krb5_keytab *keytab)
+krb5_error_code smb_krb5_open_keytab_relative(krb5_context context,
+                                             const char *keytab_name_req,
+                                             bool write_access,
+                                             krb5_keytab *keytab)
 {
        krb5_error_code ret = 0;
        TALLOC_CTX *mem_ctx;
@@ -1343,11 +1343,6 @@ krb5_error_code smb_krb5_open_keytab(krb5_context context,
                        goto resolve;
                }
 
-               if (keytab_name_req[0] != '/') {
-                       ret = KRB5_KT_BADNAME;
-                       goto out;
-               }
-
                tmp = talloc_asprintf(mem_ctx, "%s:%s", pragma, keytab_name_req);
                if (!tmp) {
                        ret = ENOMEM;
@@ -1426,6 +1421,23 @@ krb5_error_code smb_krb5_open_keytab(krb5_context context,
        return ret;
 }
 
+krb5_error_code smb_krb5_open_keytab(krb5_context context,
+                                    const char *keytab_name_req,
+                                    bool write_access,
+                                    krb5_keytab *keytab)
+{
+       if (keytab_name_req != NULL) {
+               if (keytab_name_req[0] != '/') {
+                       return KRB5_KT_BADNAME;
+               }
+       }
+
+       return smb_krb5_open_keytab_relative(context,
+                                            keytab_name_req,
+                                            write_access,
+                                            keytab);
+}
+
 krb5_error_code smb_krb5_keytab_name(TALLOC_CTX *mem_ctx,
                                     krb5_context context,
                                     krb5_keytab keytab,