4 Copyright (c) 2000 The Regents of the University of Michigan.
7 Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>.
8 Copyright (c) 2002 Andy Adamson <andros@UMICH.EDU>.
9 Copyright (c) 2002 Marius Aamodt Eriksen <marius@UMICH.EDU>.
10 All rights reserved, all wrongs reversed.
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21 3. Neither the name of the University nor the names of its
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
25 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include <sys/param.h>
42 #include <sys/socket.h>
54 #include "krb5_util.h"
56 char pipefs_dir[PATH_MAX] = GSSD_PIPEFS_DIR;
57 char pipefs_nfsdir[PATH_MAX] = GSSD_PIPEFS_DIR;
58 char keytabfile[PATH_MAX] = GSSD_DEFAULT_KEYTAB_FILE;
59 char ccachedir[PATH_MAX] = GSSD_DEFAULT_CRED_DIR;
60 char *ccachesearch[GSSD_MAX_CCACHE_SEARCH + 1];
62 int root_uses_machine_creds = 1;
63 unsigned int context_timeout = 0;
64 char *preferred_realm = NULL;
69 /* destroy krb5 machine creds */
70 if (root_uses_machine_creds)
71 gssd_destroy_krb5_machine_creds();
72 printerr(1, "exiting on signal %d\n", signal);
79 /* don't exit on SIGHUP */
80 printerr(1, "Received SIGHUP... Ignoring.\n");
87 fprintf(stderr, "usage: %s [-f] [-M] [-n] [-v] [-r] [-p pipefsdir] [-k keytab] [-d ccachedir] [-t timeout] [-R preferred realm]\n",
93 main(int argc, char *argv[])
97 int rpc_verbosity = 0;
103 memset(ccachesearch, 0, sizeof(ccachesearch));
104 while ((opt = getopt(argc, argv, "fvrmnMp:k:d:t:R:")) != -1) {
110 /* Accept but ignore this. Now the default. */
116 root_uses_machine_creds = 0;
125 strncpy(pipefs_dir, optarg, sizeof(pipefs_dir));
126 if (pipefs_dir[sizeof(pipefs_dir)-1] != '\0')
127 errx(1, "pipefs path name too long");
130 strncpy(keytabfile, optarg, sizeof(keytabfile));
131 if (keytabfile[sizeof(keytabfile)-1] != '\0')
132 errx(1, "keytab path name too long");
135 strncpy(ccachedir, optarg, sizeof(ccachedir));
136 if (ccachedir[sizeof(ccachedir)-1] != '\0')
137 errx(1, "ccachedir path name too long");
140 context_timeout = atoi(optarg);
143 preferred_realm = strdup(optarg);
152 ccachesearch[i++] = strtok(ccachedir, ":");
154 ccachesearch[i++] = strtok(NULL, ":");
155 } while (ccachesearch[i-1] != NULL && i < GSSD_MAX_CCACHE_SEARCH);
157 if (preferred_realm == NULL)
158 gssd_k5_get_default_realm(&preferred_realm);
160 snprintf(pipefs_nfsdir, sizeof(pipefs_nfsdir), "%s/%s",
161 pipefs_dir, GSSD_SERVICE_NAME);
162 if (pipefs_nfsdir[sizeof(pipefs_nfsdir)-1] != '\0')
163 errx(1, "pipefs_nfsdir path name too long");
165 if ((progname = strrchr(argv[0], '/')))
170 initerr(progname, verbosity, fg);
171 #ifdef HAVE_AUTHGSS_SET_DEBUG_LEVEL
172 authgss_set_debug_level(rpc_verbosity);
174 if (rpc_verbosity > 0)
175 printerr(0, "Warning: rpcsec_gss library does not "
176 "support setting debug level\n");
179 if (gssd_check_mechs() != 0)
180 errx(1, "Problem with gssapi library");
182 if (!fg && daemon(0, 0) < 0)
185 signal(SIGINT, sig_die);
186 signal(SIGTERM, sig_die);
187 signal(SIGHUP, sig_hup);
190 printerr(0, "gssd_run returned!\n");