Skip Menu |
 

Download (untitled) / with headers
text/plain 7.1KiB
From bbense@shred.stanford.edu Tue Apr 16 16:22:45 2002
Received: from pacific-carrier-annex.mit.edu (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.7.21.83])
by rt-11.mit.edu (8.9.3/8.9.3) with ESMTP id QAA06177
for <bugs@RT-11.mit.edu>; Tue, 16 Apr 2002 16:22:44 -0400 (EDT)
Received: from shred.stanford.edu (shred.Stanford.EDU [171.64.13.91])
by pacific-carrier-annex.mit.edu (8.9.2/8.9.2) with ESMTP id QAA19318
for <krb5-bugs@mit.edu>; Tue, 16 Apr 2002 16:22:44 -0400 (EDT)
Received: (from bbense@localhost)
by shred.stanford.edu (8.11.6.Beta0/8.10.0.PreAlpha1) id g3GKMe028374;
Tue, 16 Apr 2002 13:22:40 -0700 (PDT)
Message-Id: <200204162022.g3GKMe028374@shred.stanford.edu>
Date: Tue, 16 Apr 2002 13:22:40 -0700 (PDT)
From: bbense@stanford.edu
Reply-To: bbense@stanford.edu
To: krb5-bugs@mit.edu
Subject: resend of appdefault patches
X-Send-Pr-Version: 3.99

Show quoted text
>Number: 1090
>Category: krb5-libs
>Synopsis: Patches to implement new appdefault api
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: hartmans
>State: analyzed
>Class: change-request
>Submitter-Id: unknown
>Arrival-Date: Tue Apr 16 16:23:00 EDT 2002
>Last-Modified: Thu Apr 18 11:04:14 EDT 2002
>Originator: Booker C. Bense
>Organization:
Stanford University
Show quoted text
>Release: krb5-1.2.2
>Environment:
UNIX
System: SunOS shred.Stanford.EDU 5.7 Generic_106541-15 sun4u sparc SUNW,Ultra-5_10
Architecture: sun4

Show quoted text
>Description:
This patch implements a new function that allows for a generic
interface to appdefault reading. You set up an array of structs
to define the defaults and call this function to get all the defaults
set in one stroke.
Show quoted text
>How-To-Repeat:

Show quoted text
>Fix:

===================================================================
RCS file: /afs/ir/dev/cvs/kerberos/krb5/lib/krb5/krb/appdefault.c,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- /usr/users/bbense/work/kerberos/krb5/lib/krb5/krb/appdefault.c 5 Jul 2000 22:47:02 -0000 1.1.1.1
+++ /usr/users/bbense/work/kerberos/krb5/lib/krb5/krb/appdefault.c 18 Sep 2000 17:32:56 -0000 1.3
@@ -141,6 +141,9 @@
return 0;
}

+/* public routines */
+
+/* I think this one is a bad idea, bbense@stanford.edu */
KRB5_DLLIMP void KRB5_CALLCONV
krb5_appdefault_boolean(context, appname, realm, option,
default_value, ret_value)
@@ -162,18 +165,28 @@
*ret_value = default_value;
}

+/* At the base level I'd rather see just these two */
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_string_to_boolean (string,value)
+ const char *string;
+ int *value;
+{
+ *value = conf_boolean(string) ;
+ return 0 ;
+}
+
KRB5_DLLIMP void KRB5_CALLCONV
krb5_appdefault_string(context, appname, realm, option, default_value,
ret_value)
krb5_context context;
- const char *appname, *option, *default_value;
- char **ret_value;
+ const char *appname, *option, *default_value;
+ char **ret_value;
const krb5_data *realm;
- {
- krb5_error_code retval;
- char *string;
+{
+ krb5_error_code retval;
+ char *string;

- retval = appdefault_get(context, appname, realm, option, &string);
+ retval = appdefault_get(context, appname, realm, option, &string);

if (! retval && string) {
*ret_value = string;
@@ -181,3 +194,69 @@
*ret_value = strdup(default_value);
}
}
+
+/* A helper routine for appdefault read */
+
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_string_to_string (string,value)
+ const char *string;
+ char **value;
+{
+ *value = strdup(string);
+ return 0 ;
+}
+
+KRB5_DLLIMP void KRB5_CALLCONV
+krb5_free_string(context,string)
+ krb5_context context;
+ char *string ;
+{
+ if ( string != NULL ) {
+ krb5_xfree(string);
+ }
+}
+
+/* Read in all the defaults at once. */
+
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_appdefault_read(context,appname,realm,default_list, count)
+ krb5_context context;
+ const char *appname;
+ const krb5_data *realm;
+ krb5_appdefault_list_item *default_list;
+ int count ;
+{
+ int i,rcode;
+ char *ret_val;
+ /* First check args for sanity */
+ if ( default_list == NULL || count < 0 ) {
+ return EINVAL ;
+ }
+
+ for ( i = 0 ; i < count ; i++ )
+ {
+ if ( default_list[i].option != NULL &&
+ default_list[i].store != NULL &&
+ default_list[i].default_value != NULL )
+ {
+ krb5_appdefault_string(context,appname,realm,default_list[i].option,
+ default_list[i].default_value,&ret_val) ;
+ if ( ret_val != NULL )
+ {
+ rcode = (*default_list[i].parse_function)(ret_val,default_list[i].store);
+ /* too bad libraries can't com_err, it would be very useful
+ to tell the programmer what went wrong here. */
+ free( ret_val );
+ if ( rcode ) return rcode ;
+ } else { /* This should never happen */
+ return ENOMEM ;
+ }
+ }
+ }
+ return 0 ;
+}
+
+
+
+
+

===================================================================
RCS file: /afs/ir/dev/cvs/kerberos/krb5/include/krb5.hin,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- /usr/users/bbense/work/kerberos/krb5/include/krb5.hin 5 Jul 2000 22:46:14 -0000 1.1.1.3
+++ /usr/users/bbense/work/kerberos/krb5/include/krb5.hin 18 Sep 2000 17:43:56 -0000 1.2
@@ -2416,6 +2416,42 @@
int default_value,
int *ret_value));

+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_string_to_boolean
+KRB5_PROTOTYPE((const char FAR *, int FAR *));
+
+ /* helper routine for krb5_appdefault_read */
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_string_to_string
+KRB5_PROTOTYPE((const char FAR *, char FAR * FAR *));
+
+ /* free the string returned above */
+KRB5_DLLIMP void KRB5_CALLCONV
+krb5_free_string
+KRB5_PROTOTYPE((krb5_context context,char FAR * ));
+
+ /* This is for use with krb5_appdefault_read. */
+typedef struct _krb5_appdefault_list_item {
+ char FAR *option ; /* The default name */
+ char FAR *default_value; /* The default value if not found in krb.conf */
+ krb5_error_code (*parse_function)(); /* This function should take a string,
+ parse it and store the resulting
+ value in the second arg.
+ krb5_string_to_deltat is a good
+ example*/
+ void *store; /* This is an address for the second arg to parse function */
+
+} krb5_appdefault_list_item;
+
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_appdefault_read
+KRB5_PROTOTYPE((krb5_context context,
+ const char *appname,
+ const krb5_data *realm,
+ krb5_appdefault_list_item *default_list,
+ const int count));
+
+
/*
* The realm iterator functions
*/
Show quoted text
>Audit-Trail:

Responsible-Changed-From-To: krb5-unassigned->hartmans
Responsible-Changed-By: hartmans
Responsible-Changed-When: Thu Apr 18 11:02:54 2002
Responsible-Changed-Why:

State-Changed-From-To: open-analyzed
State-Changed-By: hartmans
State-Changed-When: Thu Apr 18 11:02:56 2002
State-Changed-Why:

I'm not quite sure I understand why this is better than calling one
function for each app_default. This API exposes structs into the
Kerberos ABI and API which is something we're trying to discourage.
Also, it is not obviouss to me why it provides a better interface.


Show quoted text
>Unformatted: