summaryrefslogtreecommitdiffstats
path: root/src/kadmin/client/kadmin_done.c
blob: a9585851dc5f1b75b094040c0518ec30c4cca781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * kadmin/client/kadmin_done.c
 *
 * Copyright 1988 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 *
 */

/* 
 * Sandia National Laboratories also makes no representations about the 
 * suitability of the modifications, or additions to this software for 
 * any purpose.  It is provided "as is" without express or implied warranty.
 */


/*
 * kadmin_done
 * Perform Remote Kerberos Administrative Functions
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
#include "com_err.h"

#include "k5-int.h"

krb5_error_code
kadm_done(context, my_creds, rep_ret, local_addr, foreign_addr, 
	  local_socket, seqno)
    krb5_context context;
    krb5_creds *my_creds;
    krb5_ap_rep_enc_part *rep_ret;
    krb5_address *local_addr, *foreign_addr;
    int *local_socket;
    krb5_int32 *seqno;
{
    krb5_data msg_data, inbuf;
    krb5_error_code retval;     /* return code */
    char buf[16];

    inbuf.data = buf;

    inbuf.data[0] = KADMIN;
    inbuf.data[1] = COMPLETE;
    inbuf.data[2] = SENDDATA2;
    inbuf.data[3] = 0xff;
    (void) memset( inbuf.data + 4, 0, 4);
    inbuf.length = 16;

    if ((retval = krb5_mk_priv(context, &inbuf,
			ETYPE_DES_CBC_CRC,
			&my_creds->keyblock, 
			local_addr, 
			foreign_addr,
			*seqno,
			KRB5_PRIV_DOSEQUENCE|KRB5_PRIV_NOTIME,
			0,
			0,
			&msg_data))) {
        fprintf(stderr, "Error during Second Message Encoding: %s!\n",
			error_message(retval));
        return(1);
    }

    /* write private message to server */
    if (krb5_write_message(context, local_socket, &msg_data)) {
	free(msg_data.data);
        fprintf(stderr, "Write Error During Second Message Transmission!\n");
        return(1);
    } 
    free(msg_data.data);
    return(0);
}