smbns_ksetpwd.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <syslog.h>
#include <fcntl.h>
#include <kerberosv5/krb5.h>
const char *pw);
/*
* smb_krb5_ctx_init
*
* Initialize the kerberos context.
* Return 0 on success. Otherwise, return -1.
*/
int
{
if (krb5_init_context(ctx) != 0)
return (-1);
return (0);
}
/*
* smb_krb5_get_principal
*
* Setup the krb5_principal given the host principal in string format.
* Return 0 on success. Otherwise, return -1.
*/
int
{
return (-1);
return (0);
}
/*
* smb_krb5_ctx_fini
*
* Free the kerberos context.
*/
void
{
}
/*
* smb_ksetpw
*
* Set the workstation trust account password.
* Returns 0 on success. Otherwise, returns non-zero value.
*/
int
{
int result_code;
return (-1);
}
if (code != 0)
"smb_krb5_setpwd: Result: %.*s (%d) %.*s\n",
result_code == 0 ?
return (code);
}
/*
* smb_krb5_write_keytab
*
* Write all the Kerberos keys to the keytab file.
* Returns 0 on success. Otherwise, returns -1.
*/
int
{
char *ktname;
int i, len;
int rc = 0;
" existing keytab");
return (-1);
}
}
return (-1);
}
"keytab %s\n", fname);
return (-1);
}
for (i = 0; i < enctype_count; i++) {
!= 0) {
rc = -1;
break;
}
}
return (rc);
}
/*
* smb_krb5_ktadd
*
* Add a Keberos key to the keytab file.
* Returns 0 on success. Otherwise, returns -1.
*/
static int
{
char buf[100];
int rc = 0;
enctype);
return (-1);
}
enctype);
return (-1);
}
enctype);
return (-1);
}
if (code != 0) {
enctype);
return (-1);
}
rc = -1;
}
return (rc);
}