Subject: bin/4104: k5login.c fix for krb5-1.0pl1
To: None <gnats-bugs@gnats.netbsd.org>
From: Chris Jones <cjones@clydesdale.math.montana.edu>
List: netbsd-bugs
Date: 09/10/1997 17:25:00
>Number:         4104
>Category:       bin
>Synopsis:       k5login.c fix for krb5-1.0pl1
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 10 16:35:01 1997
>Last-Modified:
>Originator:     Chris Jones
>Organization:
-------------------------------------------------------------------------------
Chris Jones                                      cjones@rupert.oscs.montana.edu
           Mad scientist in training...
"Is this going to be a stand-up programming session, sir, or another bug hunt?"
>Release:        09/09/97
>Environment:
	
System: NetBSD clydesdale.math.montana.edu 1.2G NetBSD 1.2G (CLYDESDALE) #0: Wed Sep 3 11:54:47 MDT 1997 cjones@caesar.honors.montana.edu:/usr/src/sys/arch/i386/compile/CLYDESDALE i386

Kerberos: krb5-1.0pl1

>Description:
This is a continuation of an earlier PR which I sent and which I believe
was closed; however, I was unable to find it via query-pr.

The enclosed patch makes k5login.c and login.c in usr.bin/login compile
with fewer warnings when using krb5-1.0pl1 and KERBEROS5 is set.  However,
there are still a few prototype warnings which the compiler, of course,
treats as errors:


cd /usr/src/usr.bin/login/
make -k 
cc -O -DSKEY -I/usr/local/include -DKERBEROS5  -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes  -c login.c
cc1: warnings being treated as errors
In file included from login.c:80:
/usr/local/include/krb5.h:2386: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2422: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2486: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2506: warning: function declaration isn't a prototype
In file included from login.c:81:
/usr/local/include/com_err.h:87: warning: function declaration isn't a prototype
*** Error code 1 (continuing)
cc -O -DSKEY -I/usr/local/include -DKERBEROS5  -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes  -c k5login.c
cc1: warnings being treated as errors
In file included from k5login.c:47:
/usr/local/include/krb5.h:2386: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2422: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2486: warning: function declaration isn't a prototype
/usr/local/include/krb5.h:2506: warning: function declaration isn't a prototype
In file included from k5login.c:48:
/usr/local/include/com_err.h:87: warning: function declaration isn't a prototype
*** Error code 1 (continuing)
`all' not remade because of errors.

Compilation finished at Wed Sep 10 16:53:09

As you can see, these warnings come from the krb5 includes, krb5.h and
com_err.h.  Should -Wmissing-prototypes be turned off if KERBEROS5 is set?


>How-To-Repeat:
	
>Fix:


diff -c /foo/src/usr.bin/login/k5login.c /usr/src/usr.bin/login/k5login.c
*** /foo/src/usr.bin/login/k5login.c	Thu Aug 21 06:49:36 1997
--- /usr/src/usr.bin/login/k5login.c	Wed Sep 10 16:51:52 1997
***************
*** 45,56 ****
--- 45,61 ----
  #include <sys/param.h>
  #include <sys/syslog.h>
  #include <krb5.h>
+ #include <com_err.h>
  #include <pwd.h>
  #include <netdb.h>
+ #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  #include <unistd.h>
  
+ void kdestroy __P((void));
+ int klogin __P((struct passwd *, char *, char *, char *));
+ 
  #define KRB5_DEFAULT_OPTIONS 0
  #define KRB5_DEFAULT_LIFE 60*60*10 /* 10 hours */
  
***************
*** 85,94 ****
  	krb5_creds my_creds;
  	krb5_timestamp now;
  	krb5_ccache ccache = NULL;
- 	int preauth_type = -1;
  	long lifetime = KRB5_DEFAULT_LIFE;
  	int options = KRB5_DEFAULT_OPTIONS;
- 	int i;
  	char *realm, *client_name;
  	char *principal;
  	
--- 90,97 ----
***************
*** 136,154 ****
  	    strcat(principal, instance);	/* XXX strcat is safe */
  	}
  	
! 	if (kerror = krb5_cc_resolve(kcontext, tkt_location, &ccache)) {
  	    syslog(LOG_NOTICE, "warning: %s while getting default ccache",
  		error_message(kerror));
  	    return(1);
  	}
  
! 	if (kerror = krb5_parse_name(kcontext, principal, &me)) {
  	    syslog(LOG_NOTICE, "warning: %s when parsing name %s",
  		error_message(kerror), principal);
  	    return(1);
  	}
      
! 	if (kerror = krb5_unparse_name(kcontext, me, &client_name)) {
  	    syslog(LOG_NOTICE, "warning: %s when unparsing name %s",
  		error_message(kerror), principal);
  	    return(1);
--- 139,157 ----
  	    strcat(principal, instance);	/* XXX strcat is safe */
  	}
  	
! 	if ((kerror = krb5_cc_resolve(kcontext, tkt_location, &ccache))) {
  	    syslog(LOG_NOTICE, "warning: %s while getting default ccache",
  		error_message(kerror));
  	    return(1);
  	}
  
! 	if ((kerror = krb5_parse_name(kcontext, principal, &me))) {
  	    syslog(LOG_NOTICE, "warning: %s when parsing name %s",
  		error_message(kerror), principal);
  	    return(1);
  	}
      
! 	if ((kerror = krb5_unparse_name(kcontext, me, &client_name))) {
  	    syslog(LOG_NOTICE, "warning: %s when unparsing name %s",
  		error_message(kerror), principal);
  	    return(1);
***************
*** 165,178 ****
      
  	my_creds.client = me;
  
! 	if (kerror = krb5_build_principal_ext(kcontext,
  					&server,
  					krb5_princ_realm(kcontext, me)->length,
  					krb5_princ_realm(kcontext, me)->data,
  					tgtname.length, tgtname.data,
  					krb5_princ_realm(kcontext, me)->length,
  					krb5_princ_realm(kcontext, me)->data,
! 					0)) {
  	    syslog(LOG_NOTICE, "%s while building server name",
  		error_message(kerror));
  	    return(1);
--- 168,181 ----
      
  	my_creds.client = me;
  
! 	if ((kerror = krb5_build_principal_ext(kcontext,
  					&server,
  					krb5_princ_realm(kcontext, me)->length,
  					krb5_princ_realm(kcontext, me)->data,
  					tgtname.length, tgtname.data,
  					krb5_princ_realm(kcontext, me)->length,
  					krb5_princ_realm(kcontext, me)->data,
! 					0))) {
  	    syslog(LOG_NOTICE, "%s while building server name",
  		error_message(kerror));
  	    return(1);
***************
*** 187,193 ****
  	    return(1);
  	}
  
! 	if (kerror = krb5_timeofday(kcontext, &now)) {
  	    syslog(LOG_NOTICE, "%s while getting time of day",
  		error_message(kerror));
  	    return(1);
--- 190,196 ----
  	    return(1);
  	}
  
! 	if ((kerror = krb5_timeofday(kcontext, &now))) {
  	    syslog(LOG_NOTICE, "%s while getting time of day",
  		error_message(kerror));
  	    return(1);
***************
*** 229,235 ****
   * Remove any credentials
   */
  void
! kdestroy()
  {
          krb5_error_code code;
  	krb5_ccache ccache = NULL;
--- 232,238 ----
   * Remove any credentials
   */
  void
! kdestroy(void)
  {
          krb5_error_code code;
  	krb5_ccache ccache = NULL;
diff -c /foo/src/usr.bin/login/login.c /usr/src/usr.bin/login/login.c
*** /foo/src/usr.bin/login/login.c	Tue Aug 26 05:25:12 1997
--- /usr/src/usr.bin/login/login.c	Wed Sep 10 16:39:09 1997
***************
*** 78,83 ****
--- 78,84 ----
  
  #ifdef KERBEROS5
  #include <krb5.h>		/* Solely for definition of kcontext */
+ #include <com_err.h>		/* ...and error_message(). */
  #endif
  
  #include "pathnames.h"
>Audit-Trail:
>Unformatted: