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

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