ksetpw.c revision c386eb9c22c7c00fc48a982f238576e16b113bda
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <locale.h>
#include <netdb.h>
#include "k5-int.h"
#define QUOTE(x) #x
const krb5_principal princ);
static void usage();
int
{
krb5_error_code code = 0;
int enctype_count = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif /* TEXT_DOMAIN */
(void) textdomain(TEXT_DOMAIN);
/* Misc init stuff */
if (code != 0) {
exit(1);
}
switch (c) {
case 'n':
nflag++;
break;
case 'k':
usage();
gettext("Couldn't allocate memory\n"));
exit(1);
}
"keytab %s"), optarg);
exit(1);
}
break;
case 'c':
usage();
exit(1);
}
break;
case 'e':
usage();
do {
if (enctype_count++ == 0) {
} else {
sizeof (*enctypes) * enctype_count);
}
("Couldn't allocate memory"));
exit(1);
}
if (code != 0) {
"or unsupported enctype %s"),
optarg);
exit(1);
}
NULL);
break;
case 'v':
break;
case 's':
if (code != 0) {
gettext("krb5_parse_name(%s) failed"),
exit(1);
}
break;
default:
usage();
break;
}
}
if (nflag && enctype_count == 0)
usage();
exit(1);
}
exit(1);
}
usage();
if (code != 0) {
exit(1);
}
gettext("Couldn't read new password\n"));
exit(1);
}
gettext("Couldn't allocate memory\n"));
exit(1);
}
} else {
gettext("Couldn't read new password\n"));
exit(1);
}
gettext("Couldn't allocate memory\n"));
exit(1);
}
}
if (nflag == 0) {
if (code != 0) {
gettext("krb5_set_password() failed"));
exit(1);
}
(void) printf("Result: %.*s (%d) %.*s\n",
result_code == 0 ?
if (result_code != 0) {
}
}
goto error;
for (i = 0; i < enctype_count; i++)
return (code ? 1 : 0);
}
static
{
/*
* This is not a fatal error, we expect this to fail in the majority
* of cases (when clients are first initialized).
*/
if (code != 0) {
gettext("Could not retrieve entry in keytab"));
return (0);
}
if (code != 0) {
return (code);
}
if (code != 0) {
gettext("While temporarily "
"ending keytab scan"));
return (code);
}
if (code != 0) {
gettext("While deleting entry "
"from keytab"));
return (code);
}
if (code != 0) {
gettext("While restarting keytab scan"));
return (code);
}
}
}
return (code);
}
return (code);
}
return (0);
}
static
void
const char *pw)
{
char buf[100];
enctype);
return;
}
return;
}
return;
}
if (code != 0) {
enctype);
return;
}
gettext("Could not add entry to keytab"));
}
}
static
void
usage()
{
"[-e enctype_list] [-n] princ\n"), whoami);
gettext("\t-n\tDon't set the principal's password\n"));
" separated list\n"));
"used\n"));
exit(1);
}