diff options
Diffstat (limited to 'lib/krb5/acl.c')
| -rw-r--r-- | lib/krb5/acl.c | 42 | 
1 files changed, 22 insertions, 20 deletions
| diff --git a/lib/krb5/acl.c b/lib/krb5/acl.c index cab68367f80a..c94aae361b8e 100644 --- a/lib/krb5/acl.c +++ b/lib/krb5/acl.c @@ -1,23 +1,23 @@  /* - * Copyright (c) 2000 - 2002, 2004 Kungliga Tekniska Högskolan + * Copyright (c) 2000 - 2002, 2004 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: - *  + *   * 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. - *  + *   * 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 @@ -34,8 +34,6 @@  #include "krb5_locl.h"  #include <fnmatch.h> -RCSID("$Id: acl.c 22119 2007-12-03 22:02:48Z lha $"); -  struct acl_field {      enum { acl_string, acl_fnmatch, acl_retval } type;      union { @@ -83,7 +81,8 @@ acl_parse_format(krb5_context context,      for(p = format; *p != '\0'; p++) {  	tmp = malloc(sizeof(*tmp));  	if(tmp == NULL) { -	    krb5_set_error_string(context, "malloc: out of memory"); +	    krb5_set_error_message(context, ENOMEM, +				   N_("malloc: out of memory", ""));  	    acl_free_list(acl, 0);  	    return ENOMEM;  	} @@ -98,8 +97,9 @@ acl_parse_format(krb5_context context,  	    tmp->u.retv = va_arg(ap, char **);  	    *tmp->u.retv = NULL;  	} else { -	    krb5_set_error_string(context, "acl_parse_format: " -				  "unknown format specifier %c", *p); +	    krb5_set_error_message(context, EINVAL, +				   N_("Unknown format specifier %c while " +				     "parsing ACL", "specifier"), *p);  	    acl_free_list(acl, 0);  	    free(tmp);  	    return EINVAL; @@ -180,7 +180,7 @@ acl_match_acl(krb5_context context,   *   * @code   * char *s; - *  + *   * ret = krb5_acl_match_string(context, "foo", "s", "foo");   * if (ret)   *     krb5_errx(context, 1, "acl didn't match"); @@ -198,7 +198,7 @@ acl_match_acl(krb5_context context,   * @ingroup krb5_support   */ -krb5_error_code KRB5_LIB_FUNCTION +KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL  krb5_acl_match_string(krb5_context context,  		      const char *string,  		      const char *format, @@ -220,11 +220,11 @@ krb5_acl_match_string(krb5_context context,      if (found) {  	return 0;      } else { -	krb5_set_error_string(context, "ACL did not match"); +	krb5_set_error_message(context, EACCES, N_("ACL did not match", ""));  	return EACCES;      }  } -	        +  /**   * krb5_acl_match_file matches ACL format against each line in a file   * using krb5_acl_match_string(). Lines starting with # are treated @@ -241,7 +241,7 @@ krb5_acl_match_string(krb5_context context,   * @ingroup krb5_support   */ -krb5_error_code KRB5_LIB_FUNCTION +KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL  krb5_acl_match_file(krb5_context context,  		    const char *file,  		    const char *format, @@ -257,11 +257,13 @@ krb5_acl_match_file(krb5_context context,      f = fopen(file, "r");      if(f == NULL) {  	int save_errno = errno; - -	krb5_set_error_string(context, "open(%s): %s", file, -			      strerror(save_errno)); +	rk_strerror_r(save_errno, buf, sizeof(buf)); +	krb5_set_error_message(context, save_errno, +			       N_("open(%s): %s", "file, errno"), +			       file, buf);  	return save_errno;      } +    rk_cloexec_file(f);      va_start(ap, format);      ret = acl_parse_format(context, &acl, format, ap); @@ -287,7 +289,7 @@ krb5_acl_match_file(krb5_context context,      if (found) {  	return 0;      } else { -	krb5_set_error_string(context, "ACL did not match"); +	krb5_set_error_message(context, EACCES, N_("ACL did not match", ""));  	return EACCES;      }  } | 
