Skip Menu |

This queue is for tickets about the Authen-Krb5-Admin CPAN distribution.

Report information
The Basics
Id: 81110
Status: open
Priority: 0/
Queue: Authen-Krb5-Admin

People
Owner: Nobody in particular
Requestors: d.thomas [...] its.uq.edu.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: patch to return kerberos error code
As far as I can see both Authen::Krb5 and Authen::Krb5::Admin have an error() method which translates the kerberos error code into the corresponding error message. I've heard such messages have changed between some kerberos versions. Anyway this patch adds an error_code() method It seems to work for me but I've never done XS before. diff -u Authen-Krb5-Admin-0.15.orig/Admin.xs Authen-Krb5-Admin-0.15/Admin.xs --- Authen-Krb5-Admin-0.15.orig/Admin.xs 2012-11-01 19:55:24.000000000 +1000 +++ Authen-Krb5-Admin-0.15/Admin.xs 2012-11-10 16:15:26.000000000 +1000 @@ -1106,6 +1106,13 @@ SvIOK_on(ST(0)); } +int +kadm5_error_code () + CODE: + RETVAL = err; + OUTPUT: + RETVAL + Authen::Krb5::Admin::Policy kadm5_get_policy(handle, name = "default") Authen::Krb5::Admin handle
Thanks for the suggestion, this does seem like a useful little addition. Note that due to the "magic" nature of the value returned from the error() function it is already possible to do numerical comparisons. For example: my $kadm5 = Authen::Krb5::Admin->init_with_password($user,$pass); if ( Authen::Krb5::Admin::error == KADM5_BAD_PASSWORD ) { print "You entered the wrong password\n"; } else { print Authen::Krb5::Admin::error . "\n"; } An additional function which simply returns the integer value of the error code makes it possible to work with that code as a string (useful for debugging, I guess). Cheers, Stephen Quinney On Sun Nov 11 15:42:47 2012, d.thomas@its.uq.edu.au wrote: Show quoted text
> As far as I can see both Authen::Krb5 and Authen::Krb5::Admin have an > error() > method which translates the kerberos error code into the corresponding > error > message. > > I've heard such messages have changed between some kerberos versions. > > Anyway this patch adds an error_code() method > It seems to work for me but I've never done XS before. > > > diff -u Authen-Krb5-Admin-0.15.orig/Admin.xs Authen-Krb5-Admin- > 0.15/Admin.xs > --- Authen-Krb5-Admin-0.15.orig/Admin.xs 2012-11-01 19:55:24.000000000 > +1000 > +++ Authen-Krb5-Admin-0.15/Admin.xs 2012-11-10 16:15:26.000000000 > +1000 > @@ -1106,6 +1106,13 @@ > SvIOK_on(ST(0)); > } > > +int > +kadm5_error_code () > + CODE: > + RETVAL = err; > + OUTPUT: > + RETVAL > + > Authen::Krb5::Admin::Policy > kadm5_get_policy(handle, name = "default") > Authen::Krb5::Admin handle