summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Park <pjpark@mit.edu>1995-08-21 21:16:02 +0000
committerPaul Park <pjpark@mit.edu>1995-08-21 21:16:02 +0000
commit40b80b8572e01834020131329366365416c9eb7e (patch)
tree74e7d4c937bee5ff70210fe76e1015a56f31ff5a /src
parentb163dc0f033f82d9ba36da08148cbf45ba21c2ef (diff)
Use libkadm string conversion routines
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6559 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/clients/kinit/ChangeLog7
-rw-r--r--src/clients/kinit/configure.in1
-rw-r--r--src/clients/kinit/kinit.M4
-rw-r--r--src/clients/kinit/kinit.c103
4 files changed, 25 insertions, 90 deletions
diff --git a/src/clients/kinit/ChangeLog b/src/clients/kinit/ChangeLog
index 6e39921bd..0a964f41d 100644
--- a/src/clients/kinit/ChangeLog
+++ b/src/clients/kinit/ChangeLog
@@ -1,4 +1,11 @@
+Mon Aug 21 16:49:06 EDT 1995 Paul Park (pjpark@mit.edu)
+ * kinit.c - Use string_to_deltat to parse lifetime arguments so that
+ we use common code. Remove convtime(). Fix gcc -Wall.
+ * configure.in - Add -lkadm.
+ * kinit.M - Remove restriction on lifetimes.
+
+
Fri Jul 7 15:53:29 EDT 1995 Paul Park (pjpark@mit.edu)
* Makefile.in - Remove explicit library handling.
* configure.in - Add KRB5_LIBRARIES.
diff --git a/src/clients/kinit/configure.in b/src/clients/kinit/configure.in
index 0b6b9df56..0e440da82 100644
--- a/src/clients/kinit/configure.in
+++ b/src/clients/kinit/configure.in
@@ -2,6 +2,7 @@ AC_INIT(kinit.c)
CONFIG_RULES
AC_PROG_INSTALL
AC_HAVE_HEADERS(pwd.h)
+USE_KADM_LIBRARY
KRB5_LIBRARIES
V5_USE_SHARED_LIB
V5_AC_OUTPUT_MAKEFILE
diff --git a/src/clients/kinit/kinit.M b/src/clients/kinit/kinit.M
index c04868aee..0e58eea10 100644
--- a/src/clients/kinit/kinit.M
+++ b/src/clients/kinit/kinit.M
@@ -47,7 +47,7 @@ obtains and caches an initial ticket-granting ticket for
.IR principal .
The
.B \-l
-option specifies the lifetime (in hours) to be requested for the ticket;
+option specifies the lifetime to be requested for the ticket;
if this option is not specified, the default ticket lifetime (configured
by each site) is used instead.
.PP
@@ -65,7 +65,7 @@ The
.B \-r
.I rlife
option specifies that the RENEWABLE option should be requested for the
-ticket, and specifies (in hours) the desired total lifetime of the ticket.
+ticket, and specifies the desired total lifetime of the ticket.
.PP
The
.B \-c
diff --git a/src/clients/kinit/kinit.c b/src/clients/kinit/kinit.c
index 5e66b7e82..52a4d8180 100644
--- a/src/clients/kinit/kinit.c
+++ b/src/clients/kinit/kinit.c
@@ -26,6 +26,7 @@
#include "k5-int.h"
#include "com_err.h"
+#include "adm_proto.h"
#include <stdio.h>
#ifdef HAVE_PWD_H
@@ -38,17 +39,6 @@
extern int optind;
extern char *optarg;
-static time_t convtime();
-
-krb5_error_code
-krb5_parse_lifetime (time, len)
- char *time;
- long *len;
-{
- *len = convtime(time);
- return 0;
-}
-
krb5_data tgtname = {
0,
KRB5_TGS_NAME_SIZE,
@@ -70,8 +60,8 @@ main(argc, argv)
krb5_ccache ccache = NULL;
char *cache_name = NULL; /* -f option */
char *keytab_name = NULL; /* -t option */
- long lifetime = KRB5_DEFAULT_LIFE; /* -l option */
- long rlife = 0;
+ krb5_deltat lifetime = KRB5_DEFAULT_LIFE; /* -l option */
+ krb5_deltat rlife = 0;
int options = KRB5_DEFAULT_OPTIONS;
int option;
int errflg = 0;
@@ -96,9 +86,9 @@ main(argc, argv)
switch (option) {
case 'r':
options |= KDC_OPT_RENEWABLE;
- code = krb5_parse_lifetime(optarg, &rlife);
+ code = krb5_string_to_deltat(optarg, &rlife);
if (code != 0 || rlife == 0) {
- fprintf(stderr, "Bad lifetime value (%s hours?)\n", optarg);
+ fprintf(stderr, "Bad lifetime value %s\n", optarg);
errflg++;
}
break;
@@ -129,9 +119,9 @@ main(argc, argv)
break;
#endif
case 'l':
- code = krb5_parse_lifetime(optarg, &lifetime);
+ code = krb5_string_to_deltat(optarg, &lifetime);
if (code != 0 || lifetime == 0) {
- fprintf(stderr, "Bad lifetime value (%s hours?)\n", optarg);
+ fprintf(stderr, "Bad lifetime value %s\n", optarg);
errflg++;
}
break;
@@ -169,7 +159,7 @@ main(argc, argv)
}
if (ccache == NULL) {
- if (code = krb5_cc_default(kcontext, &ccache)) {
+ if ((code = krb5_cc_default(kcontext, &ccache))) {
com_err(argv[0], code, "while getting default ccache");
exit(1);
}
@@ -196,7 +186,8 @@ main(argc, argv)
/* Else search passwd file for client */
pw = getpwuid((int) getuid());
if (pw) {
- if (code = krb5_parse_name(kcontext,pw->pw_name,&me)) {
+ if ((code = krb5_parse_name(kcontext,pw->pw_name,
+ &me))) {
com_err (argv[0], code, "when parsing name %s",
pw->pw_name);
exit(1);
@@ -213,12 +204,12 @@ main(argc, argv)
}
}
} /* Use specified name */
- else if (code = krb5_parse_name (kcontext, argv[optind], &me)) {
+ else if ((code = krb5_parse_name (kcontext, argv[optind], &me))) {
com_err (argv[0], code, "when parsing name %s",argv[optind]);
exit(1);
}
- if (code = krb5_unparse_name(kcontext, me, &client_name)) {
+ if ((code = krb5_unparse_name(kcontext, me, &client_name))) {
com_err (argv[0], code, "when unparsing name");
exit(1);
}
@@ -234,20 +225,20 @@ main(argc, argv)
my_creds.client = me;
- if (code = krb5_build_principal_ext(kcontext, &server,
+ if((code = 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)) {
+ 0))) {
com_err(argv[0], code, "while building server name");
exit(1);
}
my_creds.server = server;
- if (code = krb5_timeofday(kcontext, &now)) {
+ if ((code = krb5_timeofday(kcontext, &now))) {
com_err(argv[0], code, "while getting time of day");
exit(1);
}
@@ -298,67 +289,3 @@ main(argc, argv)
}
exit(0);
}
-
-/*
- * this next function was lifted from the source to sendmail, which is:
- *
- * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <ctype.h> /* for isdigit */
-
-static time_t
-convtime(p)
- char *p;
-{
- register time_t t, r;
- register char c;
-
- r = 0;
- while (*p != '\0')
- {
- t = 0;
- while (isdigit(c = *p++))
- t = t * 10 + (c - '0');
- if (c == '\0')
- p--;
- switch (c)
- {
- case 'w': /* weeks */
- t *= 7;
-
- case 'd': /* days */
- t *= 24;
-
- case 'h': /* hours */
- default:
- t *= 60;
-
- case 'm': /* minutes */
- t *= 60;
-
- case 's': /* seconds */
- break;
- }
- r += t;
- }
-
- return (r);
-}
-