source: trunk/athena/bin/rkinit/rkinitd/rkinitd.c @ 2269

Revision 2269, 2.6 KB checked in by qjb, 35 years ago (diff)
Initial revision
Line 
1/*
2 * $Header: /afs/dev.mit.edu/source/repository/athena/bin/rkinit/rkinitd/rkinitd.c,v 1.1 1989-11-12 19:34:58 qjb Exp $
3 * $Source: /afs/dev.mit.edu/source/repository/athena/bin/rkinit/rkinitd/rkinitd.c,v $
4 * $Author: qjb $
5 *
6 */
7
8#if !defined(lint) && !defined(SABER)
9static char *rcsid = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/rkinit/rkinitd/rkinitd.c,v 1.1 1989-11-12 19:34:58 qjb Exp $";
10#endif lint || SABER
11
12#include <stdio.h>
13#include <ctype.h>
14#include <errno.h>
15#include <sys/types.h>
16#include <sys/file.h>
17#include <sys/socket.h>
18#include <netinet/in.h>
19#include <netdb.h>
20#include <strings.h>
21#include <signal.h>
22#include <sys/time.h>
23#include <pwd.h>
24#include <krb.h>
25#include <des.h>
26#include <syslog.h>
27
28#include <rkinit.h>
29#include <rkinit_err.h>
30#include <rkinit_private.h>
31
32extern int errno;
33extern char *sys_errlist[];
34
35static int inetd = TRUE;        /* True if we were started by inetd */
36
37void usage()
38{
39    syslog(LOG_ERR, "rkinitd usage: rkinitd [-notimeout]\n");
40    exit(1);
41}
42
43void error()
44{
45    char errbuf[BUFSIZ];
46   
47    strcpy(errbuf, rkinit_errmsg(0));
48    if (inetd)
49        syslog(LOG_ERR, "rkinitd: %s", errbuf);
50    else
51        fprintf(stderr, "rkinitd: %s\n", errbuf);
52}
53
54main(argc, argv)
55  int argc;
56  char *argv[];
57{
58    int version;                /* Version of the transaction */
59
60    int notimeout = FALSE;      /* Should we not timeout? */
61
62    static char    *envinit[1]; /* Empty environment */
63    extern char    **environ;   /* This process's environment */
64
65    int status = 0;             /* General error code */
66
67    /*
68     * Clear the environment so that this process does not inherit
69     * kerberos ticket variable information from the person who started
70     * the process (if a person started it...).
71     */
72    environ = envinit;
73
74    /* Initialize com_err error table */
75    initialize_rkin_error_table();
76
77#ifdef DEBUG
78    /* This only works if the library was compiled with DEBUG defined */
79    rki_i_am_server();
80#endif DEBUG
81
82    /*
83     * Make sure that we are running as root or can arrange to be
84     * running as root.  We need both to be able to read /etc/srvtab
85     * and to be able to change uid to create tickets.
86     */
87   
88    (void) setuid(0);
89    if (getuid() != 0) {
90        syslog(LOG_ERR, "rkinitd: not running as root.\n");
91        exit(1);
92    }
93
94    /* Determine whether to time out */
95    if (argc == 2) {
96        if (strcmp(argv[1], "-notimeout"))
97            usage();
98        else
99            notimeout = TRUE;
100    }
101    else if (argc != 1)
102        usage();
103
104    inetd = setup_rpc(notimeout);
105
106    if ((status = choose_version(&version) != RKINIT_SUCCESS)) {
107        error();
108        exit(1);
109    }
110
111    if ((status = get_tickets(version) != RKINIT_SUCCESS)) {
112        error();
113        exit(1);
114    }
115
116    exit(0);
117}
118
119   
Note: See TracBrowser for help on using the repository browser.