/*
*/
/*
*
* Copyright 1990,1991 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*
*/
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <string.h>
#include <netdb.h>
#include <fcntl.h>
#include <libintl.h>
#include <locale.h>
#include <k5-int.h>
#include "com_err.h"
#include "kprop.h"
char *progname = 0;
int debug = 0;
char *srvtab = 0;
char *slave_host;
char *realm = 0;
short port = 0;
/* running under, initialized in */
/* get_tickets() */
void PRS
(int, char **);
void get_tickets
(krb5_context);
static void usage
(void);
(char *, int *, char *, unsigned int);
int, krb5_principal, krb5_creds **);
int open_database
(krb5_context, char *, int *);
void close_database
(krb5_context, int);
void xmit_database
int, int, int);
void send_error
(char *, char *);
static void usage()
{
("\nUsage: %s [-r realm] [-f file] [-d] [-P port] [-s srvtab] slave_host\n\n"),
progname);
exit(1);
}
int
int argc;
char **argv;
{
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
if (retval) {
exit(1);
}
if (retval) {
Errmsg, slave_host);
exit(1);
}
if (fd < 0) {
gettext("%s: %s while opening connection to %s\n"),
exit(1);
}
&my_creds);
exit(0);
}
int argc;
char **argv;
{
int c;
extern int optind;
extern char *optarg;
switch (c) {
case 'r':
if (!realm)
usage();
break;
case 'f':
if (!file)
usage();
break;
case 'd':
debug++;
break;
case 'P':
if (!port)
usage();
break;
case 's':
if (!srvtab)
usage();
break;
case '?':
default:
usage();
}
}
if (*argv)
slave_host = *argv;
else
usage();
}
{
/*
* Figure out what tickets we'll be using to send stuff
*/
if (realm) {
gettext("while allocating default realm name '%s'"),
realm);
exit(1);
}
} else {
if (retval) {
gettext("while getting default realm"));
exit(1);
}
}
/*
* Always pick up the master hostname from krb5.conf, as
* opposed to picking up the localhost, so we do not get bit
* if the master KDC is HA and hence points to a logicalhost.
*/
if (retval) {
gettext("while getting admin server fqdn"));
exit(1);
}
if (retval) {
exit(1);
}
if (realm) {
if (retval) {
gettext("while setting client principal realm"));
exit(1);
}
}
#if 0
#endif
/*
* Initialize cache file which we're going to be using
*/
if (retval) {
buf);
exit(1);
}
if (retval) {
buf);
exit(1);
}
/*
* Get the tickets we'll need.
*
* Construct the principal name for the slave host.
*/
if (retval) {
exit(1);
}
if (realm) {
if (retval) {
gettext("while setting server principal realm"));
exit(1);
}
}
/*
* Now fill in the client....
*/
if (retval) {
exit(1);
}
if (srvtab) {
if (retval) {
exit(1);
}
}
if (retval) {
exit (1);
}
if (svcname)
if (retval) {
exit(1);
}
if (keytab)
/*
* Now destroy the cache right away --- the credentials we
* need will be in my_creds.
*/
if (retval) {
exit(1);
}
}
/* SUNW14resync - SOCKET is defed in 1.4 in port-sockets.h */
#ifdef SOCKET
#endif
char *host;
int *fd;
char *Errmsg;
unsigned int ErrmsgSz;
{
int s;
int socket_length;
int which_err;
if (port != 0)
port);
else
host);
*fd = -1;
return(0);
}
continue;
if (s < 0) {
continue;
}
errno != EINPROGRESS) {
close(s);
continue; /* fail -- try next */
}
break; /* success */
}
switch (which_err) {
case SOCKET:
gettext("in call to socket"));
break;
case CONNECT:
gettext("in call to connect"));
break;
default :
gettext("could not setup network"));
break;
}
return(retval);
}
*fd = s;
/*
* Set receiver_addr and sender_addr.
*/
== NULL) {
gettext("while converting socket address"));
return(retval);
}
socket_length = sizeof(ss);
close(s);
gettext("in call to getsockname"));
return(retval);
}
gettext("while converting socket address"));
return(retval);
}
return(0);
}
int fd;
krb5_creds ** new_creds;
{
if (retval)
exit(1);
if (retval) {
exit(1);
}
if (retval) {
if (error) {
gettext("Generic remote error: %s\n"),
gettext("signalled from server"));
gettext("Error text from server: %s\n"),
}
}
exit(1);
}
}
char * dbpathname;
/*
* Open the Kerberos database dump file. Takes care of locking it
* and making sure that the .ok file is more recent that the database
* dump file itself.
*
* Returns the file descriptor of the database dump file. Also fills
* in the size of the database file.
*/
int
char *data_fn;
int *size;
{
int fd;
int err;
char *data_ok_fn;
if (!dbpathname) {
data_fn);
exit(1);
}
exit(1);
}
exit(1);
} else if (err) {
exit(1);
}
data_fn);
exit(1);
}
== NULL) {
exit(1);
}
exit(1);
}
exit(1);
}
return(fd);
}
void
int fd;
{
int err;
if (err)
return;
}
/*
* Now we send over the database. We use the following protocol:
* Send over a KRB_SAFE message with the size. Then we send over the
* database in blocks of KPROP_BLKSIZE, encrypted using KRB_PRIV.
* Then we expect to see a KRB_SAFE message with the size sent back.
*
* At any point in the protocol, we may send a KRB_ERROR message; this
* will abort the entire operation.
*/
void
int fd;
int database_fd;
int in_database_size;
{
/* These must be 4 bytes */
/*
* Send over the size
*/
/* KPROP_CKSUMTYPE */
if (retval) {
exit(1);
}
if (retval) {
exit(1);
}
/*
* Initialize the initial vector.
*/
if (retval) {
exit(1);
}
/*
* Send over the file, block by block....
*/
sent_size = 0;
if (retval) {
gettext("while encoding database block starting at %d"),
exit(1);
}
if (retval) {
gettext("while sending database block starting at %d"),
exit(1);
}
sent_size += n;
if (debug)
}
if (sent_size != database_size) {
exit(1);
}
/*
* OK, we've sent the database; now let's wait for a success
* indication from the remote end.
*/
if (retval) {
gettext("while reading response from server"));
exit(1);
}
/*
* If we got an error response back from the server, display
* the error message
*/
if (krb5_is_krb_error(&inbuf)) {
if (retval) {
gettext("while decoding error response from server"));
exit(1);
}
gettext("Generic remote error: %s\n"),
gettext("signalled from server"));
gettext("Error text from server: %s\n"),
}
exit(1);
}
if (retval) {
gettext("while decoding final size packet from server"));
exit(1);
}
if (send_size != database_size) {
gettext("Kpropd sent database size %d, expecting %d"),
exit(1);
}
}
void
int fd;
char *err_text;
{
const char *text;
if (err_text)
else
}
}
}
char *hostname;
char *file_name;
{
char *file_last_prop;
int fd;
gettext("while allocating filename for update_last_prop_file"));
return;
}
/*
* If a nondefault file name was specified then we should not add an
* extraneous host name to the file name given that a file name could
* have already specified a host name and therefore would be redundant.
*/
}
gettext("while creating 'last_prop' file, '%s'"),
return;
}
return;
}