@@ -836,24 +836,49 @@ krb5_error_code smb_krb5_get_allowed_etypes(krb5_context context,
836
836
krb5_error_code smb_krb5_parse_name (krb5_context context ,
837
837
const char * name ,
838
838
krb5_principal * principal )
839
+ {
840
+ return smb_krb5_parse_name_flags (context , name , 0 , principal );
841
+ }
842
+
843
+ /**
844
+ * @brief Convert a string principal name to a Kerberos principal.
845
+ *
846
+ * @param[in] context The library context
847
+ *
848
+ * @param[in] name The principal as a unix charset string.
849
+ *
850
+ * @param[in] flags Flags for krb5_parse_name_flags()
851
+ *
852
+ * @param[out] principal The newly allocated principal.
853
+ *
854
+ * Use krb5_free_principal() to free a principal when it is no longer needed.
855
+ *
856
+ * @return 0 on success, a Kerberos error code otherwise.
857
+ */
858
+ krb5_error_code smb_krb5_parse_name_flags (krb5_context context ,
859
+ const char * name ,
860
+ int flags ,
861
+ krb5_principal * principal )
839
862
{
840
863
krb5_error_code ret ;
841
864
char * utf8_name ;
842
865
size_t converted_size ;
843
866
TALLOC_CTX * frame = talloc_stackframe ();
844
867
845
868
if (!push_utf8_talloc (frame , & utf8_name , name , & converted_size )) {
846
- talloc_free (frame );
869
+ TALLOC_FREE (frame );
847
870
return ENOMEM ;
848
871
}
872
+ TALLOC_FREE (frame );
849
873
850
- ret = krb5_parse_name (context , utf8_name , principal );
851
- if (ret == KRB5_PARSE_MALFORMED ) {
852
- ret = krb5_parse_name_flags (context , utf8_name ,
853
- KRB5_PRINCIPAL_PARSE_ENTERPRISE ,
854
- principal );
874
+ ret = krb5_parse_name_flags (context , utf8_name , flags , principal );
875
+ if (ret != KRB5_PARSE_MALFORMED ) {
876
+ return ret ;
855
877
}
856
- TALLOC_FREE (frame );
878
+
879
+ flags |= KRB5_PRINCIPAL_PARSE_ENTERPRISE ;
880
+ ret = krb5_parse_name_flags (context , utf8_name , flags , principal );
881
+
857
882
return ret ;
858
883
}
859
884
0 commit comments