pcnfsd_misc.c revision 1.5 1 1.5 mycroft /* $NetBSD: pcnfsd_misc.c,v 1.5 1998/07/27 15:14:05 mycroft Exp $ */
2 1.2 gwr
3 1.1 jtc /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_misc.c 1.5 92/01/24 19:59:13 SMI */
4 1.1 jtc /*
5 1.1 jtc **=====================================================================
6 1.1 jtc ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
7 1.1 jtc ** @(#)pcnfsd_misc.c 1.5 1/24/92
8 1.1 jtc **=====================================================================
9 1.1 jtc */
10 1.1 jtc /*
11 1.1 jtc **=====================================================================
12 1.1 jtc ** I N C L U D E F I L E S E C T I O N *
13 1.1 jtc ** *
14 1.1 jtc ** If your port requires different include files, add a suitable *
15 1.1 jtc ** #define in the customization section, and make the inclusion or *
16 1.1 jtc ** exclusion of the files conditional on this. *
17 1.1 jtc **=====================================================================
18 1.1 jtc */
19 1.1 jtc
20 1.1 jtc #include <sys/file.h>
21 1.3 lukem #include <sys/ioctl.h>
22 1.3 lukem #include <sys/socket.h>
23 1.3 lukem #include <sys/stat.h>
24 1.1 jtc #include <sys/time.h>
25 1.3 lukem #include <sys/wait.h>
26 1.3 lukem
27 1.3 lukem #include <netinet/in.h>
28 1.3 lukem #include <arpa/inet.h>
29 1.3 lukem
30 1.3 lukem #include <ctype.h>
31 1.3 lukem #include <errno.h>
32 1.1 jtc #include <netdb.h>
33 1.3 lukem #include <pwd.h>
34 1.3 lukem #include <signal.h>
35 1.3 lukem #include <stdio.h>
36 1.3 lukem #include <stdlib.h>
37 1.1 jtc #include <string.h>
38 1.3 lukem #include <unistd.h>
39 1.1 jtc
40 1.1 jtc #ifdef ISC_2_0
41 1.1 jtc #include <sys/fcntl.h>
42 1.1 jtc #endif
43 1.1 jtc
44 1.1 jtc #ifdef SHADOW_SUPPORT
45 1.1 jtc #include <shadow.h>
46 1.1 jtc #endif
47 1.1 jtc
48 1.1 jtc #ifdef WTMP
49 1.3 lukem int wtmp_enabled = 1;
50 1.1 jtc #endif
51 1.1 jtc
52 1.3 lukem #include "common.h"
53 1.3 lukem #include "pcnfsd.h"
54 1.3 lukem #include "extern.h"
55 1.1 jtc
56 1.1 jtc /*
57 1.1 jtc **---------------------------------------------------------------------
58 1.3 lukem ** Other #define's
59 1.1 jtc **---------------------------------------------------------------------
60 1.1 jtc */
61 1.1 jtc
62 1.1 jtc #define zchar 0x5b
63 1.1 jtc
64 1.3 lukem char tempstr[256];
65 1.3 lukem
66 1.3 lukem char *mapfont __P((char, char, char));
67 1.3 lukem void myhandler __P((int));
68 1.3 lukem void start_watchdog __P((int));
69 1.3 lukem void stop_watchdog __P((void));
70 1.1 jtc
71 1.1 jtc /*
72 1.1 jtc **=====================================================================
73 1.3 lukem ** C O D E S E C T I O N *
74 1.3 lukem **=====================================================================
75 1.1 jtc */
76 1.1 jtc /*
77 1.1 jtc **---------------------------------------------------------------------
78 1.3 lukem ** Support procedures
79 1.1 jtc **---------------------------------------------------------------------
80 1.1 jtc */
81 1.1 jtc
82 1.1 jtc
83 1.1 jtc void
84 1.1 jtc scramble(s1, s2)
85 1.3 lukem char *s1;
86 1.3 lukem char *s2;
87 1.1 jtc {
88 1.3 lukem while (*s1) {
89 1.3 lukem *s2++ = (*s1 ^ zchar) & 0x7f;
90 1.3 lukem s1++;
91 1.3 lukem }
92 1.1 jtc *s2 = 0;
93 1.1 jtc }
94 1.1 jtc
95 1.1 jtc
96 1.1 jtc
97 1.3 lukem struct passwd *
98 1.1 jtc get_password(usrnam)
99 1.3 lukem char *usrnam;
100 1.1 jtc {
101 1.3 lukem struct passwd *p;
102 1.3 lukem static struct passwd localp;
103 1.5 mycroft __aconst char *pswd, *ushell;
104 1.1 jtc
105 1.1 jtc
106 1.1 jtc #ifdef SHADOW_SUPPORT
107 1.3 lukem struct spwd *sp;
108 1.3 lukem int shadowfile;
109 1.1 jtc #endif
110 1.1 jtc
111 1.1 jtc #ifdef SHADOW_SUPPORT
112 1.3 lukem /*
113 1.3 lukem **--------------------------------------------------------------
114 1.3 lukem ** Check the existence of SHADOW. If it is there, then we are
115 1.3 lukem ** running a two-password-file system.
116 1.3 lukem **--------------------------------------------------------------
117 1.3 lukem */
118 1.1 jtc if (access(SHADOW, 0))
119 1.3 lukem shadowfile = 0; /* SHADOW is not there */
120 1.1 jtc else
121 1.3 lukem shadowfile = 1;
122 1.1 jtc
123 1.1 jtc setpwent();
124 1.1 jtc if (shadowfile)
125 1.3 lukem (void) setspent(); /* Setting the shadow password file */
126 1.3 lukem if ((p = getpwnam(usrnam)) == (struct passwd *) NULL ||
127 1.3 lukem (shadowfile && (sp = getspnam(usrnam)) == (struct spwd *) NULL))
128 1.3 lukem return ((struct passwd *) NULL);
129 1.3 lukem
130 1.3 lukem if (shadowfile) {
131 1.3 lukem pswd = sp->sp_pwdp;
132 1.3 lukem (void) endspent();
133 1.3 lukem } else
134 1.3 lukem pswd = p->pw_passwd;
135 1.1 jtc
136 1.1 jtc #else
137 1.1 jtc p = getpwnam(usrnam);
138 1.3 lukem if (p == (struct passwd *) NULL)
139 1.3 lukem return ((struct passwd *) NULL);
140 1.1 jtc pswd = p->pw_passwd;
141 1.1 jtc #endif
142 1.1 jtc
143 1.1 jtc #ifdef ISC_2_0
144 1.3 lukem /* *----------------------------------------------------------- * We
145 1.3 lukem * may have an 'x' in which case look in /etc/shadow ..
146 1.3 lukem * *----------------------------------------------------------- */
147 1.3 lukem if (((strlen(pswd)) == 1) && pswd[0] == 'x') {
148 1.3 lukem struct spwd *shadow = getspnam(usrnam);
149 1.3 lukem
150 1.3 lukem if (!shadow)
151 1.3 lukem return ((struct passwd *) NULL);
152 1.3 lukem pswd = shadow->sp_pwdp;
153 1.3 lukem }
154 1.1 jtc #endif
155 1.1 jtc localp = *p;
156 1.1 jtc localp.pw_passwd = pswd;
157 1.1 jtc #ifdef USE_GETUSERSHELL
158 1.1 jtc
159 1.1 jtc setusershell();
160 1.3 lukem while (ushell = getusershell()) {
161 1.3 lukem if (!strcmp(ushell, localp.pw_shell)) {
162 1.1 jtc ok = 1;
163 1.1 jtc break;
164 1.1 jtc }
165 1.1 jtc }
166 1.1 jtc endusershell();
167 1.3 lukem if (!ok)
168 1.3 lukem return ((struct passwd *) NULL);
169 1.1 jtc #else
170 1.1 jtc /*
171 1.3 lukem * the best we can do is to ensure that the shell ends in "sh"
172 1.3 lukem */
173 1.1 jtc ushell = localp.pw_shell;
174 1.3 lukem if (strlen(ushell) < 2)
175 1.3 lukem return ((struct passwd *) NULL);
176 1.1 jtc ushell += strlen(ushell) - 2;
177 1.3 lukem if (strcmp(ushell, "sh"))
178 1.3 lukem return ((struct passwd *) NULL);
179 1.1 jtc
180 1.1 jtc #endif
181 1.1 jtc return (&localp);
182 1.1 jtc }
183 1.1 jtc
184 1.3 lukem
185 1.3 lukem
186 1.1 jtc /*
187 1.1 jtc **---------------------------------------------------------------------
188 1.3 lukem ** Print support procedures
189 1.1 jtc **---------------------------------------------------------------------
190 1.1 jtc */
191 1.1 jtc
192 1.3 lukem
193 1.3 lukem char *
194 1.1 jtc mapfont(f, i, b)
195 1.3 lukem char f;
196 1.3 lukem char i;
197 1.3 lukem char b;
198 1.1 jtc {
199 1.3 lukem static char fontname[64];
200 1.1 jtc
201 1.1 jtc fontname[0] = 0; /* clear it out */
202 1.1 jtc
203 1.1 jtc switch (f) {
204 1.1 jtc case 'c':
205 1.3 lukem (void) strcpy(fontname, "Courier");
206 1.1 jtc break;
207 1.1 jtc case 'h':
208 1.3 lukem (void) strcpy(fontname, "Helvetica");
209 1.1 jtc break;
210 1.1 jtc case 't':
211 1.3 lukem (void) strcpy(fontname, "Times");
212 1.1 jtc break;
213 1.1 jtc default:
214 1.3 lukem (void) strcpy(fontname, "Times-Roman");
215 1.3 lukem goto finis;
216 1.1 jtc }
217 1.1 jtc if (i != 'o' && b != 'b') { /* no bold or oblique */
218 1.1 jtc if (f == 't') /* special case Times */
219 1.3 lukem (void) strcat(fontname, "-Roman");
220 1.1 jtc goto finis;
221 1.1 jtc }
222 1.3 lukem (void) strcat(fontname, "-");
223 1.1 jtc if (b == 'b')
224 1.3 lukem (void) strcat(fontname, "Bold");
225 1.1 jtc if (i == 'o') /* o-blique */
226 1.3 lukem (void) strcat(fontname, f == 't' ? "Italic" : "Oblique");
227 1.1 jtc
228 1.1 jtc finis: return (&fontname[0]);
229 1.1 jtc }
230 1.1 jtc /*
231 1.3 lukem * run_ps630 performs the Diablo 630 emulation filtering process. ps630
232 1.3 lukem * was broken in certain Sun releases: it would not accept point size or
233 1.3 lukem * font changes. If your version is fixed, undefine the symbol
234 1.3 lukem * PS630_IS_BROKEN and rebuild pc-nfsd.
235 1.3 lukem */
236 1.1 jtc /* #define PS630_IS_BROKEN 1 */
237 1.1 jtc
238 1.1 jtc void
239 1.1 jtc run_ps630(f, opts)
240 1.3 lukem char *f;
241 1.3 lukem char *opts;
242 1.1 jtc {
243 1.3 lukem char temp_file[256];
244 1.3 lukem char commbuf[256];
245 1.3 lukem int i;
246 1.1 jtc
247 1.3 lukem (void) strcpy(temp_file, f);
248 1.3 lukem (void) strcat(temp_file, "X"); /* intermediate file name */
249 1.1 jtc
250 1.1 jtc #ifndef PS630_IS_BROKEN
251 1.3 lukem (void) sprintf(commbuf, "ps630 -s %c%c -p %s -f ",
252 1.3 lukem opts[2], opts[3], temp_file);
253 1.3 lukem (void) strcat(commbuf, mapfont(opts[4], opts[5], opts[6]));
254 1.3 lukem (void) strcat(commbuf, " -F ");
255 1.3 lukem (void) strcat(commbuf, mapfont(opts[7], opts[8], opts[9]));
256 1.3 lukem (void) strcat(commbuf, " ");
257 1.3 lukem (void) strcat(commbuf, f);
258 1.3 lukem #else /* PS630_IS_BROKEN */
259 1.3 lukem /*
260 1.3 lukem * The pitch and font features of ps630 appear to be broken at
261 1.3 lukem * this time.
262 1.3 lukem */
263 1.3 lukem (void) sprintf(commbuf, "ps630 -p %s %s", temp_file, f);
264 1.3 lukem #endif /* PS630_IS_BROKEN */
265 1.1 jtc
266 1.1 jtc
267 1.3 lukem if ((i = system(commbuf)) != 0) {
268 1.1 jtc /*
269 1.1 jtc * Under (un)certain conditions, ps630 may return -1 even
270 1.1 jtc * if it worked. Hence the commenting out of this error
271 1.1 jtc * report.
272 1.1 jtc */
273 1.1 jtc /* (void)fprintf(stderr, "\n\nrun_ps630 rc = %d\n", i) */ ;
274 1.1 jtc /* exit(1); */
275 1.1 jtc }
276 1.1 jtc if (rename(temp_file, f)) {
277 1.1 jtc perror("run_ps630: rename");
278 1.1 jtc exit(1);
279 1.1 jtc }
280 1.1 jtc return;
281 1.1 jtc }
282 1.1 jtc
283 1.1 jtc
284 1.1 jtc
285 1.3 lukem
286 1.3 lukem
287 1.1 jtc /*
288 1.1 jtc **---------------------------------------------------------------------
289 1.3 lukem ** WTMP update support
290 1.1 jtc **---------------------------------------------------------------------
291 1.1 jtc */
292 1.1 jtc
293 1.1 jtc
294 1.1 jtc #ifdef WTMP
295 1.1 jtc
296 1.1 jtc #include <utmp.h>
297 1.1 jtc
298 1.1 jtc #ifndef _PATH_WTMP
299 1.1 jtc #define _PATH_WTMP "/usr/adm/wtmp"
300 1.1 jtc #endif
301 1.1 jtc
302 1.1 jtc void
303 1.1 jtc wlogin(name, req)
304 1.3 lukem char *name;
305 1.1 jtc struct svc_req *req;
306 1.1 jtc {
307 1.1 jtc struct sockaddr_in *who;
308 1.1 jtc struct hostent *hp;
309 1.3 lukem char *host;
310 1.1 jtc struct utmp ut;
311 1.3 lukem int fd;
312 1.1 jtc
313 1.3 lukem if (!wtmp_enabled)
314 1.1 jtc return;
315 1.1 jtc
316 1.3 lukem /* Get network address of client. */
317 1.1 jtc who = &req->rq_xprt->xp_raddr;
318 1.1 jtc
319 1.3 lukem /* Get name of connected client */
320 1.3 lukem hp = gethostbyaddr((char *) &who->sin_addr,
321 1.3 lukem sizeof(struct in_addr),
322 1.3 lukem who->sin_family);
323 1.1 jtc
324 1.1 jtc if (hp && (strlen(hp->h_name) <= sizeof(ut.ut_host))) {
325 1.1 jtc host = hp->h_name;
326 1.1 jtc } else {
327 1.1 jtc host = inet_ntoa(who->sin_addr);
328 1.1 jtc }
329 1.1 jtc
330 1.1 jtc (void) strcpy(ut.ut_line, "PC-NFS");
331 1.3 lukem (void) strncpy(ut.ut_name, name, sizeof ut.ut_name);
332 1.1 jtc (void) strncpy(ut.ut_host, host, sizeof ut.ut_host);
333 1.3 lukem ut.ut_time = time((time_t *) 0);
334 1.1 jtc
335 1.3 lukem if ((fd = open(_PATH_WTMP, O_WRONLY | O_APPEND, 0)) >= 0) {
336 1.3 lukem (void) write(fd, (char *) &ut, sizeof(struct utmp));
337 1.3 lukem (void) close(fd);
338 1.1 jtc }
339 1.1 jtc }
340 1.3 lukem #endif /* WTMP */
341 1.3 lukem
342 1.3 lukem
343 1.1 jtc /*
344 1.1 jtc **---------------------------------------------------------------------
345 1.3 lukem ** Run-process-as-user procedures
346 1.1 jtc **---------------------------------------------------------------------
347 1.1 jtc */
348 1.1 jtc
349 1.1 jtc
350 1.1 jtc #define READER_FD 0
351 1.1 jtc #define WRITER_FD 1
352 1.1 jtc
353 1.3 lukem static int child_pid;
354 1.1 jtc
355 1.3 lukem static char cached_user[64] = "";
356 1.3 lukem static uid_t cached_uid;
357 1.3 lukem static gid_t cached_gid;
358 1.3 lukem
359 1.3 lukem static struct sigaction old_action;
360 1.3 lukem static struct sigaction new_action;
361 1.3 lukem static struct itimerval timer;
362 1.1 jtc
363 1.3 lukem int interrupted = 0;
364 1.3 lukem static FILE *pipe_handle;
365 1.1 jtc
366 1.3 lukem void
367 1.3 lukem myhandler(dummy)
368 1.3 lukem int dummy;
369 1.1 jtc {
370 1.3 lukem interrupted = 1;
371 1.3 lukem fclose(pipe_handle);
372 1.3 lukem kill(child_pid, SIGKILL);
373 1.3 lukem msg_out("rpc.pcnfsd: su_popen timeout - killed child process");
374 1.1 jtc }
375 1.1 jtc
376 1.3 lukem void
377 1.3 lukem start_watchdog(n)
378 1.3 lukem int n;
379 1.1 jtc {
380 1.3 lukem /*
381 1.3 lukem * Setup SIGALRM handler, force interrupt of ongoing syscall
382 1.3 lukem */
383 1.1 jtc
384 1.1 jtc new_action.sa_handler = myhandler;
385 1.1 jtc sigemptyset(&(new_action.sa_mask));
386 1.1 jtc new_action.sa_flags = 0;
387 1.1 jtc #ifdef SA_INTERRUPT
388 1.1 jtc new_action.sa_flags |= SA_INTERRUPT;
389 1.1 jtc #endif
390 1.1 jtc sigaction(SIGALRM, &new_action, &old_action);
391 1.1 jtc
392 1.3 lukem /*
393 1.3 lukem * Set interval timer for n seconds
394 1.3 lukem */
395 1.1 jtc timer.it_interval.tv_sec = 0;
396 1.1 jtc timer.it_interval.tv_usec = 0;
397 1.1 jtc timer.it_value.tv_sec = n;
398 1.1 jtc timer.it_value.tv_usec = 0;
399 1.1 jtc setitimer(ITIMER_REAL, &timer, NULL);
400 1.1 jtc interrupted = 0;
401 1.1 jtc
402 1.1 jtc }
403 1.1 jtc
404 1.3 lukem void
405 1.3 lukem stop_watchdog()
406 1.1 jtc {
407 1.3 lukem /*
408 1.3 lukem * Cancel timer
409 1.3 lukem */
410 1.1 jtc
411 1.1 jtc timer.it_interval.tv_sec = 0;
412 1.1 jtc timer.it_interval.tv_usec = 0;
413 1.1 jtc timer.it_value.tv_sec = 0;
414 1.1 jtc timer.it_value.tv_usec = 0;
415 1.1 jtc setitimer(ITIMER_REAL, &timer, NULL);
416 1.1 jtc
417 1.3 lukem /*
418 1.3 lukem * restore old signal handling
419 1.3 lukem */
420 1.1 jtc sigaction(SIGALRM, &old_action, NULL);
421 1.1 jtc }
422 1.1 jtc
423 1.3 lukem FILE *
424 1.1 jtc su_popen(user, cmd, maxtime)
425 1.3 lukem char *user;
426 1.3 lukem char *cmd;
427 1.3 lukem int maxtime;
428 1.1 jtc {
429 1.3 lukem int p[2];
430 1.3 lukem int parent_fd, child_fd, pid;
431 1.1 jtc struct passwd *pw;
432 1.1 jtc
433 1.1 jtc if (strcmp(cached_user, user)) {
434 1.1 jtc pw = getpwnam(user);
435 1.1 jtc if (!pw)
436 1.1 jtc pw = getpwnam("nobody");
437 1.1 jtc if (pw) {
438 1.1 jtc cached_uid = pw->pw_uid;
439 1.1 jtc cached_gid = pw->pw_gid;
440 1.1 jtc strcpy(cached_user, user);
441 1.1 jtc } else {
442 1.1 jtc cached_uid = (uid_t) (-2);
443 1.1 jtc cached_gid = (gid_t) (-2);
444 1.1 jtc cached_user[0] = '\0';
445 1.1 jtc }
446 1.1 jtc }
447 1.1 jtc if (pipe(p) < 0) {
448 1.1 jtc msg_out("rpc.pcnfsd: unable to create pipe in su_popen");
449 1.1 jtc return (NULL);
450 1.1 jtc }
451 1.1 jtc parent_fd = p[READER_FD];
452 1.1 jtc child_fd = p[WRITER_FD];
453 1.1 jtc if ((pid = fork()) == 0) {
454 1.3 lukem int i;
455 1.1 jtc
456 1.1 jtc for (i = 0; i < 10; i++)
457 1.1 jtc if (i != child_fd)
458 1.1 jtc (void) close(i);
459 1.1 jtc if (child_fd != 1) {
460 1.1 jtc (void) dup2(child_fd, 1);
461 1.1 jtc (void) close(child_fd);
462 1.1 jtc }
463 1.1 jtc dup2(1, 2); /* let's get stderr as well */
464 1.1 jtc
465 1.1 jtc (void) setgid(cached_gid);
466 1.1 jtc (void) setuid(cached_uid);
467 1.1 jtc
468 1.1 jtc (void) execl("/bin/sh", "sh", "-c", cmd, (char *) NULL);
469 1.1 jtc _exit(255);
470 1.1 jtc }
471 1.1 jtc if (pid == -1) {
472 1.1 jtc msg_out("rpc.pcnfsd: fork failed");
473 1.1 jtc close(parent_fd);
474 1.1 jtc close(child_fd);
475 1.1 jtc return (NULL);
476 1.1 jtc }
477 1.1 jtc child_pid = pid;
478 1.1 jtc close(child_fd);
479 1.1 jtc start_watchdog(maxtime);
480 1.1 jtc pipe_handle = fdopen(parent_fd, "r");
481 1.1 jtc return (pipe_handle);
482 1.1 jtc }
483 1.1 jtc
484 1.1 jtc int
485 1.1 jtc su_pclose(ptr)
486 1.3 lukem FILE *ptr;
487 1.1 jtc {
488 1.3 lukem int pid, status;
489 1.1 jtc
490 1.1 jtc stop_watchdog();
491 1.1 jtc
492 1.1 jtc fclose(ptr);
493 1.1 jtc if (child_pid == -1)
494 1.1 jtc return (-1);
495 1.1 jtc while ((pid = wait(&status)) != child_pid && pid != -1);
496 1.1 jtc return (pid == -1 ? -1 : status);
497 1.1 jtc }
498 1.1 jtc
499 1.3 lukem
500 1.3 lukem
501 1.3 lukem #if XXX_unused
502 1.1 jtc /*
503 1.1 jtc ** The following routine reads a file "/etc/pcnfsd.conf" if present,
504 1.1 jtc ** and uses it to replace certain builtin elements, like the
505 1.1 jtc ** name of the print spool directory. The configuration file
506 1.1 jtc ** Is the usual kind: Comments begin with '#', blank lines are ignored,
507 1.1 jtc ** and valid lines are of the form
508 1.1 jtc **
509 1.1 jtc ** <keyword><whitespace><value>
510 1.1 jtc **
511 1.1 jtc ** The following keywords are recognized:
512 1.1 jtc **
513 1.1 jtc ** spooldir
514 1.1 jtc ** printer name alias-for command
515 1.1 jtc ** wtmp yes|no
516 1.1 jtc */
517 1.1 jtc void
518 1.1 jtc config_from_file()
519 1.1 jtc {
520 1.3 lukem FILE *fd;
521 1.3 lukem char buff[1024];
522 1.3 lukem char *cp;
523 1.3 lukem char *kw;
524 1.3 lukem char *val;
525 1.3 lukem char *arg1;
526 1.3 lukem char *arg2;
527 1.1 jtc
528 1.3 lukem if ((fd = fopen("/etc/pcnfsd.conf", "r")) == NULL)
529 1.1 jtc return;
530 1.3 lukem while (fgets(buff, 1024, fd)) {
531 1.1 jtc cp = strchr(buff, '\n');
532 1.1 jtc *cp = '\0';
533 1.1 jtc cp = strchr(buff, '#');
534 1.3 lukem if (cp)
535 1.1 jtc *cp = '\0';
536 1.1 jtc kw = strtok(buff, " \t");
537 1.3 lukem if (kw == NULL)
538 1.1 jtc continue;
539 1.1 jtc val = strtok(NULL, " \t");
540 1.3 lukem if (val == NULL)
541 1.1 jtc continue;
542 1.3 lukem if (!strcasecmp(kw, "spooldir")) {
543 1.1 jtc strcpy(sp_name, val);
544 1.1 jtc continue;
545 1.1 jtc }
546 1.1 jtc #ifdef WTMP
547 1.3 lukem if (!strcasecmp(kw, "wtmp")) {
548 1.1 jtc /* assume default is YES, just look for negatives */
549 1.3 lukem if (!strcasecmp(val, "no") ||
550 1.3 lukem !strcasecmp(val, "off") ||
551 1.3 lukem !strcasecmp(val, "disable") ||
552 1.3 lukem !strcmp(val, "0"))
553 1.1 jtc wtmp_enabled = 0;;
554 1.1 jtc continue;
555 1.1 jtc }
556 1.3 lukem #endif
557 1.3 lukem if (!strcasecmp(kw, "printer")) {
558 1.1 jtc arg1 = strtok(NULL, " \t");
559 1.1 jtc arg2 = strtok(NULL, "");
560 1.3 lukem (void) add_printer_alias(val, arg1, arg2);
561 1.1 jtc continue;
562 1.1 jtc }
563 1.1 jtc /*
564 1.1 jtc ** Add new cases here
565 1.1 jtc */
566 1.1 jtc }
567 1.1 jtc fclose(fd);
568 1.1 jtc }
569 1.3 lukem #endif /* XXX_unused */
570 1.1 jtc
571 1.1 jtc
572 1.1 jtc /*
573 1.1 jtc ** strembedded - returns true if s1 is embedded (in any case) in s2
574 1.1 jtc */
575 1.1 jtc
576 1.3 lukem int
577 1.3 lukem strembedded(s1, s2)
578 1.3 lukem const char *s1;
579 1.3 lukem const char *s2;
580 1.1 jtc {
581 1.3 lukem while (*s2) {
582 1.3 lukem if (!strcasecmp(s1, s2))
583 1.1 jtc return 1;
584 1.1 jtc s2++;
585 1.1 jtc }
586 1.1 jtc return 0;
587 1.1 jtc }
588