Bump to lsof 4.91
[platform/upstream/lsof.git] / Customize
1 #!/bin/sh
2 #
3 # $Id: Customize,v 1.9 2005/05/11 13:02:18 abe Exp $
4 #
5 # Customize: customize dialect's machine.h header file.
6 #
7 # Allows easy modification of some important compile-time definitions for
8 # lsof, made in the dialect's machine.h header file, including:
9 #
10 #       HASSECURITY     the security option
11 #       HASNOSOCKSECURITY
12 #                       the socket oberalization of HASSECURITY
13 #       HASDCACHE       enabling/disabling the device cache file
14 #                       (Note: changing the device cache file option isn't
15 #                              offered when machine.h contains NEVER_HASDCACHE
16 #                              anywhere, including in a comment.)
17 #       HASENVDC        enabling/disabling device cache path from environment
18 #       HASKERNIDCK     enabling/disabling the kernel identity check
19 #                       (not done for some dialects)
20 #       HASPERSDC       enabling/disabling personal device cache path
21 #                       construction
22 #       HASPERSDCPATH   enabling/disabling additional personal device cache
23 #                       path component
24 #       HASSYSDC        enabling/disabling system-wide device cache file path
25 #       HASXOPT_ROOT    enabling/disabling root use of the -X option
26 #       WARNDEVACCESS   enabling inaccessible /dev node warnings
27 #                       (Note: changing the inaccessible /dev/node warning
28 #                              option isn't offered when machine.h contains
29 #                              NEVER_WARNDEVACCESS anywhere, including in a
30 #                              comment.)
31 #       WARNINGSTATE    enable/disabling default warning message state
32 #
33 # Usage: Customize [dialect_directory]
34 #
35 # where: dialect_directory (optional) is the directory in which the dialect's
36 #        dialect's sources, Makefile and scripts are found
37
38 OLD=machine.h
39 NEW=new_machine.h
40
41 # Save optional dialect directory.
42
43 if test $# -eq 1
44 then
45   DialDir=$1
46 else
47   DialDir=""
48 fi
49
50 # Establish trap and stty handling.
51
52 ISIG=":"
53 trap 'rm -f $NEW; $ISIG; exit 1' 1 2 3 15
54 stty -a 2>&1 | grep isig > /dev/null
55 if test $? -eq 0
56 then
57   stty -a 2>&1 | egrep -e -isig > /dev/null
58   if test $? -eq 0
59   then
60     ISIG="stty -isig"
61     stty isig
62   fi
63 fi
64
65 # Decide how to use echo.
66
67 ECHO=`echo -n ""`
68 if test "X$ECHO" = "X-n "
69 then
70   EC="\c"
71   EO=""
72 else
73   EC=""
74   EO="-n"
75 fi
76
77 # Decide how to use tail(1).
78
79 TMP1=`tail -n 1 $0 2> /dev/null`
80 if test $? -eq 0 -a "X$TMP1" = "X#LAST_LINE"
81 then
82   TA="-n 1"
83 else
84   TA="-1"
85 fi
86
87 # Display the introduction and basic explanation.
88
89 cat << .CAT_MARK
90
91 You may now customize the machine.h header file for this UNIX
92 dialect.  The customizations will take effect when you compile
93 lsof.  You may also choose to skip customization and proceed to
94 the compilation of lsof.
95
96 If you don't know if you need to customize or want to know more
97 about what you can customize, consult the 00DCACHE, 00FAQ, 00PORTING,
98 and 00README files of the lsof distribution.  You might also find
99 it helpful to examine the machine.h header file for the dialect
100 you're customizing.
101
102 You don't need to use this procedure to customize lsof; you can
103 edit the machine.h header file directly.  If you later decide you
104 want to use this procedure to customize machine.h, execute the
105 ./Customize script.
106 .CAT_MARK
107
108 END=0
109 while test $END -eq 0
110 do
111   echo ""
112   echo $EO "Do you want to customize (y|n) [y]? $EC"
113   read ANS EXCESS
114   if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
115   then
116     exit 0
117   fi
118   if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
119   then
120     echo ""
121     echo "Customizing ..."
122     END=1
123   else
124     echo ""
125     echo "Please answer y|n [y]."
126   fi
127 done
128
129 # See if $OLD exists.
130
131 if test ! -r $OLD
132 then
133   echo ""
134   echo "FATAL: The file \"$OLD\" doesn't exist.  Customization can't"
135   echo "continue without it."
136   echo ""
137   echo "Did you run the Configure script?"
138   echo ""
139   echo "Customize quits."
140   echo ""
141   exit 1
142 fi
143
144 # See if $NEW exists.
145
146 if test -r $NEW
147 then
148   echo ""
149   echo "====================================================================="
150   echo ""
151   echo "WARNING: \"$NEW\" exists.  Customization will replace it."
152   END=0
153   while test $END -eq 0
154   do
155     echo ""
156     echo $EO "Do you want to remove $NEW (y|n) [y]? $EC"
157     read ANS EXCESS
158     if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
159     then
160       echo ""
161       echo "Removing $NEW"
162       echo ""
163       rm -f $NEW
164       END=1
165     else
166       if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
167       then
168         echo ""
169         echo "FATAL: Customize quits; it must be able to create \"$NEW\"."
170         echo ""
171         exit 1
172       else
173         echo ""
174         echo "Please answer y|n [y]."
175       fi
176     fi
177   done
178 fi
179
180 # Process HASSECURITY.
181
182 cat << .CAT_MARK
183
184 =====================================================================
185
186 When HASSECURITY is enabled, only the root user may use lsof to
187 examine all open files; other users may examine only the files
188 belonging to the real user ID of their lsof process.  If
189 HASNOSOCKSECURITY is also defined, anyone may list anyone else's
190 open socket files, provided their listing is selected with the "-i"
191 option.
192
193 When HASSECURITY is disabled, anyone may use lsof to examine all
194 open files.
195
196 .CAT_MARK
197
198 grep HASSECURITY $OLD | tail $TA | egrep "^#define" > /dev/null
199 if test $? -eq 0
200 then
201   echo "HASSECURITY is enabled."
202   NSEC=1
203 else
204   echo "HASSECURITY is disabled."
205   NSEC=0
206 fi
207 END=0
208 while test $END -eq 0
209 do
210   echo ""
211   if test $NSEC -eq 1
212   then
213     echo $EO "Disable HASSECURITY (y|n) [n]? $EC"
214   else
215     echo $EO "Enable HASSECURITY (y|n) [n]? $EC"
216   fi
217   read ANS EXCESS
218   if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
219   then
220     echo ""
221     if test $NSEC -eq 1
222     then
223       NSEC=0
224       echo "HASSECURITY will be disabled."
225     else
226       NSEC=1
227       echo "HASSECURITY will be enabled."
228     fi
229     END=1
230   else
231     if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
232     then
233       echo ""
234       echo "HASSECURITY will not be changed."
235       END=1
236     else
237       echo ""
238       echo "Please answer y|n [n]."
239     fi
240   fi
241 done
242
243 # If HASSECURITY is enabled, see if HASNOSOCKSECURITY should also be defined.
244
245 if test $NSEC -eq 1
246 then
247   cat << .CAT_MARK
248
249 ====================================================================
250
251 When HASSECURITY is enabled, you may also define HASNOSOCKSECURITY.
252
253 When both are defined, no one but root may list all of anyone else's
254 open files -- only their own open files -- but anyone may list
255 anyone else's open socket files.
256
257 This option is useful with ntop (http://www.ntop.org).
258
259 .CAT_MARK
260
261   grep HASNOSOCKSECURITY $OLD | tail $TA | egrep "^#define" > /dev/null
262   if test $? -eq 0
263   then
264     echo "HASNOSOCKSECURITY is enabled."
265     SOCKSEC=1
266   else
267     echo "HASNOSOCKSECURITY is disabled."
268     SOCKSEC=0
269   fi
270   END=0
271   while test $END -eq 0
272   do
273     echo ""
274     if test $SOCKSEC -eq 1
275     then
276       echo $EO "Disable HASNOSOCKSECURITY (y|n) [n]? $EC"
277     else
278       echo $EO "Enable HASNOSOCKSECURITY (y|n) [n]? $EC"
279     fi
280     read ANS EXCESS
281     if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
282     then
283       echo ""
284       if test $SOCKSEC -eq 1
285       then
286         SOCKSEC=0
287         echo "HASNOSOCKSECURITY will be disabled."
288       else
289         SOCKSEC=1
290         echo "HASNOSOCKSECURITY will be enabled."
291       fi
292       END=1
293     else
294       if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
295       then
296         echo ""
297         echo "HASNOSOCKSECURITY will not be changed."
298         END=1
299       else
300         echo ""
301         echo "Please answer y|n [n]."
302       fi
303     fi
304   done
305 else
306   SOCKSEC=0
307 fi
308
309 # Process WARNINGSTATE.
310
311 cat << .CAT_MARK
312
313 =====================================================================
314
315 When WARNINGSTATE is enabled, lsof will will issue whatever warning
316 messages it finds necessary.  When WARNINGSTATE is disabled, lsof
317 will issue no warning messages.  For individual uses of lsof, -w
318 disables warning state and +w enables it.
319
320 .CAT_MARK
321
322 grep WARNINGSTATE $OLD | tail $TA | egrep "^#define" > /dev/null
323 if test $? -eq 0
324 then
325   echo "WARNINGSTATE is disabled."
326   WST=0
327 else
328   echo "WARNINGSTATE is enabled."
329   WST=1
330 fi
331 END=0
332 NWST=$WST
333 while test $END -eq 0
334 do
335   echo ""
336   if test $NWST -eq 0
337   then
338     echo $EO "Enable WARNINGSTATE? (y|n) [n]? $EC"
339   else
340     echo $EO "Disable WARNINGSTATE? (y|n) [n]? $EC"
341   fi
342   read ANS EXCESS
343   if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
344   then
345     echo ""
346     if test $NWST -eq 0
347     then
348       echo "WARNINGSTATE will be enabled."
349       NWST=1
350     else
351       echo "WARNINGSTATE will be disabled."
352       NWST=0
353     fi
354     END=1
355   else
356     if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
357     then
358       echo ""
359       echo "WARNINGSTATE will not be changed."
360       END=1
361     else
362       echo ""
363       echo "Please answer y|n [n]."
364     fi
365   fi
366 done
367
368 # Process WARNDEVACCESS, unless the dialect's machine.h header file contains
369 # NEVER_WARNDEVACCESS.
370
371 grep NEVER_WARNDEVACCESS $OLD > /dev/null
372 if test $? -eq 0
373 then
374   NEVERWDA=1
375   NWDA=0
376 else
377   NEVERWDA=0
378   cat << .CAT_MARK
379
380 =====================================================================
381
382 When WARNDEVACCESS is enabled, lsof will issue warning messages
383 when it can't access nodes in /dev (or /devices), subject to the
384 default or explicit (-w) WARNINGSTATE.
385
386 When WARNDEVACCESS is disabled, lsof will silently skip nodes in
387 /dev (or /devices) that it can't access.
388
389 .CAT_MARK
390
391   grep WARNDEVACCESS $OLD | tail $TA | egrep "^#define" > /dev/null
392   if test $? -eq 0
393   then
394     echo "WARNDEVACCESS is enabled."
395     WDA=1
396   else
397     echo "WARNDEVACCESS is disabled."
398     WDA=0
399   fi
400   END=0
401   NWDA=$WDA
402   while test $END -eq 0
403   do
404     echo ""
405     if test $NWDA -eq 1
406     then
407       echo $EO "Disable WARNDEVACCESS (y|n) [n]? $EC"
408     else
409       echo $EO "Enable WARNDEVACCESS (y|n) [n]? $EC"
410     fi
411     read ANS EXCESS
412     if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
413     then
414       echo ""
415       if test $NWDA -eq 1
416       then
417         echo "WARNDEVACCESS will be disabled."
418         NWDA=0
419       else
420         echo "WARNDEVACCESS will be enabled."
421         NWDA=1
422       fi
423       END=1
424     else
425       if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
426       then
427         echo ""
428         echo "WARNDEVACCESS will not be changed."
429         END=1
430       else
431         echo ""
432         echo "Please answer y|n [n]."
433       fi
434     fi
435   done
436 fi
437
438 # Process HASDCACHE, unless the dialect's machine.h header file contains
439 # NEVER_HASDCACHE.
440
441 ENVV=""
442 ENVN=0
443 PDCV=""
444 PDCN=0
445 PDCPV=""
446 PDCPN=0
447 SDCV=""
448 SDCN=0
449 grep NEVER_HASDCACHE $OLD > /dev/null
450 if test $? -eq 0
451 then
452   NEVERDC=1
453   CDC=0
454   DC=0
455   NDC=0
456 else
457   NEVERDC=0
458   cat << .CAT_MARK
459
460 =====================================================================
461
462 When HASDCACHE is enabled, lsof will write a device cache file that
463 contains information about the nodes in /dev (or /devices).  The
464 options HASENVDC, HASPERSDC, HASPERSDCPATH, and HASSYSDC define
465 the device cache file path.
466
467 When HASDCACHE is disabled, lsof won't write a device cache file.
468
469 Consult the 00DCACHE and 00FAQ files of the lsof distribution for
470 more information.
471
472 .CAT_MARK
473
474   grep HASDCACHE $OLD | tail $TA | egrep "^#define" > /dev/null
475   if test $? -eq 0
476   then
477     echo "HASDCACHE is enabled."
478     DC=1
479   else
480     echo "HASDCACHE is disabled."
481     DC=0
482   fi
483   END=0
484   NDC=$DC
485   while test $END -eq 0
486   do
487     echo ""
488     if test $NDC -eq 1
489     then
490       echo $EO "Disable HASDCACHE (y|n) [n]? $EC"
491     else
492       echo $EO "Enable HASDCACHE (y|n) [n]? $EC"
493     fi
494     read ANS EXCESS
495     if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
496     then
497       echo ""
498       if test $NDC -eq 1
499       then
500         echo "HASDCACHE will be disabled."
501         NDC=0
502       else
503         echo "HASDCACHE will be enabled."
504         NDC=1
505       fi
506       END=1
507     else
508       if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
509       then
510         echo ""
511         echo "HASDCACHE will not be changed."
512         END=1
513       else
514         echo ""
515         echo "Please answer y|n [n]."
516       fi
517     fi
518   done
519
520   # See if other device cache options need to be declared.
521
522   if test $DC -eq 1 -a $NDC -eq 1
523   then
524     cat << .CAT_MARK
525
526 =====================================================================
527
528 You have decided that HASDCACHE should be defined.  There are other
529 definitions associated with HASDCACHE that specify options for the
530 formation of the device cache file path.  You may change them.
531
532 Consult the 00DCACHE and 00FAQ files of the lsof distribution for
533 more information.
534
535 The current path options are:
536   
537 .CAT_MARK
538
539     grep HASENVDC $OLD | tail $TA | egrep "^#define"
540     egrep "HASPERSDC$|HASPERSDC[        ]" $OLD | tail $TA | egrep "^#define"
541     grep HASPERSDCPATH $OLD | tail $TA | egrep "^#define"
542     grep HASSYSDC $OLD | tail $TA | egrep "^#define"
543     END=0
544     while test $END -eq 0
545     do
546       echo ""
547       echo $EO "Do you want to change path options (y|n) [n]? $EC"
548       read ANS EXCESS
549       if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
550       then
551         CDC=1
552         END=1
553       else
554         if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
555         then
556           CDC=0
557           END=1
558         else
559           if test "X$ANS" = "X"
560           then
561             echo ""
562             echo "The path options will not be changed."
563             CDC=0
564             END=1
565           else
566             echo ""
567             echo "Please answer y|n [n]."
568           fi
569         fi
570       fi
571     done
572   else
573     CDC=0
574   fi
575   if test \( $NDC -eq 1 -a $DC -eq 0 \) -o \( $DC -eq 1 -a $CDC -eq 1 \)
576   then
577     cat << .CAT_MARK
578
579 =====================================================================
580
581 You may specify for HASENVDC the name of the environment variable
582 from which lsof should take the device cache file path for non-root
583 users.  Press ENTER to use the current value of HASENVDC:
584
585 .CAT_MARK
586
587     echo $EO "        $EC"
588     TMP1=`grep HASENVDC $OLD | tail $TA | egrep "^#define"`
589     if test "X$TMP1" != "X"
590     then
591       TMP1=`echo "$TMP1" | sed 's/^#define[     ]HASENVDC[      ]"\([^"]*\)".*$/\1/'`
592       echo "$TMP1"
593     else
594       echo "no current HASENVDC value"
595     fi
596     END=0
597     GV=0
598     while test $END -eq 0
599     do
600       echo ""
601       echo $EO "Do you want to define a name for HASENVDC (y|n) [n]? $EC"
602       read ANS EXCESS
603       if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
604       then
605         ENVV=""
606         END=1
607       else
608         if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
609         then
610           GV=1
611           END=1
612         else
613           if test "X$ANS" = "X"
614           then
615             echo ""
616             echo "HASENVDC will not be changed."
617             ENVV=$TMP1
618             END=1
619           else
620             echo ""
621             echo "Please answer y|n [n]."
622           fi
623         fi
624       fi
625     done
626     if test $GV -eq 1
627     then
628       echo ""
629       echo $EO "Please enter the HASENVDC name (no quotes): $EC"
630       read TMP1 EXCESS
631       ENVV=`echo $TMP1 | sed 's/^\"//' | sed 's/\"$//'`
632       if test "X$ENVV" = "X"
633       then
634         ENVN=1
635       fi
636     fi
637     cat << .CAT_MARK
638
639 =====================================================================
640
641 HASPERSDC is a format that specifies how the personal device cache
642 path is constructed.  Consult the 00DCACHE and 00FAQ files of the
643 lsof distribution for information on the conversions supported in
644 HASPERSDC.  Press ENTER to use the curent HASPERSDC format:
645
646 .CAT_MARK
647
648     echo $EO "        $EC"
649     TMP1=`egrep "HASPERSDC$|HASPERSDC[  ]" $OLD | tail $TA | egrep "^#define"`
650     if test "X$TMP1" != "X"
651     then
652       TMP1=`echo "$TMP1" | sed 's/^#define[     ]HASPERSDC[     ]"\([^"]*\)".*$/\1/'`
653       echo "$TMP1"
654     else
655       echo "no current HASPERSDC format"
656     fi
657     END=0
658     GV=0
659     while test $END -eq 0
660     do
661       echo ""
662       echo $EO "Do you want to define a format for HASPERSDC (y|n) [n]? $EC"
663       read ANS EXCESS
664       if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
665       then
666         END=1
667       else
668         if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
669         then
670           GV=1
671           END=1
672         else
673           if test "X$ANS" = "X"
674           then
675             echo ""
676             echo "HASPERSDC will not be changed."
677             PDCV=$TMP1
678             END=1
679           else
680             echo ""
681             echo "Please answer y|n [n]."
682           fi
683         fi
684       fi
685     done
686     if test $GV -eq 1
687     then
688       echo ""
689       echo $EO "Please enter the HASPERSDC format (no quotes): $EC"
690       read TMP1 EXCESS
691       PDCV=`echo $TMP1 | sed 's/^\"//' | sed 's/\"$//'`
692       if test "X$PDCV" = "X"
693       then
694         PDCN=1
695       fi
696     fi
697     cat << .CAT_MARK
698
699 =====================================================================
700
701 Specify for HASPERSDCPATH the name of the environment variable from
702 which lsof should take a path name component to insert at the %p
703 conversion in the HASPERSDC format.
704
705 Consult the 00FAQ and 00DCACHE files of the lsof distribution for
706 more information on HASPERSDCPATH usage.
707
708 Press ENTER to use the current value for HASPERSDCPATH:
709
710 .CAT_MARK
711
712     echo $EO "        $EC"
713     TMP1=`grep HASPERSDCPATH $OLD | tail $TA | egrep "^#define"`
714     if test "X$TMP1" != "X"
715     then
716       TMP1=`echo "$TMP1" | sed 's/^#define[     ]HASPERSDCPATH[         ]"\([^"]*\)".*$/\1/'`
717       echo "$TMP1"
718     else
719       echo "no current HASPERSDCPATH value"
720     fi
721     END=0
722     GV=0
723     while test $END -eq 0
724     do
725       echo ""
726       echo $EO "Do you want to change HASPERSDCPATH (y|n) [n]? $EC"
727       read ANS EXCESS
728       if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
729       then
730         echo ""
731         echo "HASPERSDCPATH will not be changed."
732         PDCPV=$TMP1
733         END=1
734       else
735         if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
736         then
737           GV=1
738           END=1
739         else
740           echo ""
741           echo "Please answer y|n [n]."
742         fi
743       fi
744     done
745     if test $GV -eq 1
746     then
747       echo ""
748       echo $EO "Please enter the HASPERSDCPATH name (no quotes): $EC"
749       read TMP1 EXCESS
750       PDCPV=`echo $TMP1 | sed 's/^\"//' | sed 's/\"$//'`
751       if test "X$PDCPV" = "X"
752       then
753         PDCPN=1
754       fi
755     fi
756     cat << .CAT_MARK
757
758 =====================================================================
759
760 Specify for HASSYSDC the system-wide device cache file path.  Press
761 ENTER to use the current HASSYSDC value:
762
763 .CAT_MARK
764
765     echo $EO "        $EC"
766     TMP1=`grep HASSYSDC $OLD | tail $TA | egrep "^#define"`
767     if test "X$TMP1" != "X"
768     then
769       TMP1=`echo "$TMP1" | sed 's/^#define[     ]HASSYSDC[      ]"\([^"]*\)".*$/\1/'`
770       echo "$TMP1"
771     else
772       echo "no current HASSYSDC value"
773     fi
774     END=0
775     GV=0
776     while test $END -eq 0
777     do
778       echo ""
779       echo $EO "Do you want to define a system-device path (y|n) [n]? $EC"
780       read ANS EXCESS
781       if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
782       then
783         END=1
784       else
785         if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
786         then
787           GV=1
788           END=1
789         else
790           if test "X$ANS" = "X"
791           then
792             echo ""
793             echo "No HASSYSDC change will be made."
794             SDCV=$TMP1
795             END=1
796           else
797             echo ""
798             echo "Please answer y|n [n]."
799           fi
800         fi
801       fi
802     done
803     if test $GV -eq 1
804     then
805       echo ""
806       echo $EO "Please enter the system-wide path (no quotes): $EC"
807       read TMP1 EXCESS
808       SDCV=`echo $TMP1 | sed 's/^\"//' | sed 's/\"$//'`
809       if test "X$SDCV" = "X"
810       then
811         SDCN=1
812       fi
813     fi
814   fi
815 fi
816
817 # If HASXOPT is defined, and HASXOPT_ROOT is mentioned,
818 # ask about changing HASXOPT_ROOT.
819
820 HXRC=0
821 grep HASXOPT $OLD | tail $TA | egrep "^#define" > /dev/null
822 if test $? -eq 0
823 then
824   grep HASXOPT_ROOT $OLD > /dev/null
825   if test $? -eq 0
826   then
827     cat << .CAT_MARK
828
829 =====================================================================
830
831 HASXOPT is defined.  If the dialect for which you are customizing
832 appears in the following list, you may want to change the definition
833 of HASXOPT_ROOT to restrict the use of the X option to lsof processes
834 whose real user ID is root, or enable use of it by all user IDs.
835
836   AIX           the -X option enables the risky operation of letting
837                 lsof read library entry structures with readx().
838                 If HASXOPT_ROOT is defined, only processes whose
839                 real user ID is root will be allowed to use -X.
840                 If HASXOPT_ROOT is undefined, any process will be
841                 allowed to use -X.  Consult the 00FAQ file of the
842                 lsof distribution for more information on why
843                 readx() may be risky.
844
845 .CAT_MARK
846
847     grep HASXOPT_ROOT $OLD | tail $TA | egrep "^#define" > /dev/null
848     if test $? -eq 0
849     then
850       echo "HASXOPT_ROOT is defined."
851       HXR="undefine"
852       HXRS=1
853     else
854       echo "HASXOPT_ROOT is not defined."
855       HXR="define"
856       HXRS=0
857     fi
858     END=0
859     while test $END -eq 0
860     do
861       echo ""
862       echo $EO "Do you want to $HXR HASXOPT_ROOT (y|n) [n]? $EC"
863       read ANS EXCESS
864       if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
865       then
866         HXRA=1
867         END=1
868       else
869         if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
870         then
871           echo ""
872           echo "HASXOPT_ROOT will not be changed."
873           HXRA=0
874           END=1
875         else
876           echo ""
877           echo "Please answer y|n [n]."
878         fi
879       fi
880     done
881     if test $HXRA -eq 1
882     then
883       HXRC=1
884     fi
885   fi
886 fi
887
888 # Process HASKERNIDCK.  Skip processing for selected dialect directories.
889
890 case $DialDir in
891   linux/proc)
892     NIDCK=0
893     ;;
894   *)
895     cat << .CAT_MARK
896
897 =====================================================================
898
899 When HASKERNIDCK is enabled, lsof compares the identity of the
900 kernel where it was built to the identity of the kernel where it
901 is running.  This check can detect an lsof executable inappropriate
902 for the system on which it is being run.
903
904 The kernel identity check can take considerable time on some UNIX
905 dialects -- e.g., AIX -- so there may be occasions when it is
906 desirable to disable it, in spite of the increased risk of using
907 an inappropriate lsof executable.
908
909 .CAT_MARK
910
911     grep HASKERNIDCK $OLD | tail $TA | grep "^#define" > /dev/null
912     if test $? -eq 0
913     then
914       echo "HASKERNIDCK is enabled."
915       IDCK=1
916     else
917       echo "HASKERNIDCK is disabled."
918       IDCK=0
919     fi
920     END=0
921     NIDCK=$IDCK
922     while test $END -eq 0
923     do
924       echo ""
925       if test $NIDCK -eq 1
926       then
927         echo $EO "Disable HASKERNIDCK (y|n) [n]? $EC"
928       else
929         echo $EO "Enable HASKERNIDCK (y|n) [n]? $EC"
930       fi
931       read ANS EXCESS
932       if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
933       then
934         echo ""
935         if test $NIDCK -eq 1
936         then
937           NIDCK=0
938           echo "HASKERNIDCK will be disabled."
939         else
940           NIDCK=1
941           echo "HASKERNIDCK will be enabled."
942         fi
943         END=1
944       else
945         if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
946         then
947           echo ""
948           echo "HASKERNIDCK will not be changed."
949           END=1
950           NIDCK=$IDCK
951         else
952           echo ""
953           echo "Please answer y|n [n]."
954         fi
955       fi
956     done
957     ;;
958 esac
959
960 # Initialize new machine.h.
961
962 rm -f $NEW
963 cp $OLD $NEW
964 chmod 0644 $NEW
965 echo "" >> $NEW
966 echo "/*" >> $NEW
967 echo $EO " * Added by Customize on $EC" >> $NEW
968 date >> $NEW
969 echo " */" >> $NEW
970 echo "" >> $NEW
971
972 # Change HASSECURITY and HASNOSOCKSECURITY, as required.
973
974 echo "#undef    HASSECURITY" >> $NEW
975 echo "#undef    HASNOSOCKSECURITY" >> $NEW
976 if test $NSEC -eq 1
977 then
978   echo "#define HASSECURITY     1" >> $NEW
979   if test $SOCKSEC -eq 1
980   then
981     echo "#define       HASNOSOCKSECURITY       1" >> $NEW
982   fi
983 fi
984
985 # Change WARNDEVACCESS, as required.
986
987 if test $NEVERWDA -eq 0
988 then
989   echo "#undef  WARNDEVACCESS" >> $NEW
990   if test $NWDA -eq 1
991   then
992     echo "#define       WARNDEVACCESS   1" >> $NEW
993   fi
994 fi
995
996 # Change WARNINGSTATE, as required.
997
998 echo "#undef    WARNINGSTATE" >> $NEW
999 if test $NWST -eq 0
1000 then
1001   echo "#define WARNINGSTATE    1" >> $NEW
1002 fi
1003
1004 # Change device cache definitions, as required.
1005
1006 if test \( $NDC -eq 1 -a $DC -eq 0 \) -o \( $DC -eq 1 -a $CDC -eq 1 \)
1007 then
1008   if test "X$ENVV" = "X" -a "X$PDCV" = "X" -a "X$SDCV" = "X"
1009   then
1010     cat << .CAT_MARK
1011
1012 FATAL: HASDCACHE is defined, but there is no definition for
1013        any of HASENVDC, HASPERSDC, or HASSYSDC
1014
1015        No new machine.h has been created.
1016
1017        Customize quits.
1018
1019        Restart Customize and define at least one of HASENVDC,
1020        HASPERSDC, or HASSYSDC.
1021
1022 .CAT_MARK
1023
1024     rm -f $NEW
1025     exit 1
1026   fi
1027 fi
1028 if test "X$PDCV" != "X"
1029 then
1030   echo "$PDCV" | grep "%p" > /dev/null
1031   if test $? -eq 0 -a $PDCPN -eq 1
1032   then
1033     cat << .CAT_MARK
1034
1035 FATAL: HASDCACHE is defined and HASPERSDC has a %p conversion,
1036        but HASPERSDCPATH is NULL.
1037
1038        No new machine.h has been created.
1039
1040        Customize quits.
1041
1042        Restart Customize and define HASPERSDCPATH.
1043
1044 .CAT_MARK
1045
1046     rm -f $NEW
1047     exit 1
1048   fi
1049 fi
1050 echo "#undef    HASDCACHE" >> $NEW
1051 if test $NEVERDC -eq 1
1052 then
1053   echo "#undef  HASENVDC" >> $NEW
1054   echo "#undef  HASPERSDC" >> $NEW
1055   echo "#undef  HASPERSDCPATH" >> $NEW
1056   echo "#undef  HASSYSDC" >> $NEW
1057 else
1058   if test $NDC -eq 1
1059   then
1060     echo "#define       HASDCACHE       1" >> $NEW
1061     if test "X$ENVV" != "X" -o $ENVN -eq 1
1062     then
1063       echo "#undef      HASENVDC" >> $NEW
1064       if test $ENVN -eq 0
1065       then
1066         echo "#define   HASENVDC        \"$ENVV\"" >> $NEW
1067       fi
1068     fi
1069     if test "X$PDCV" != "X" -o $PDCN -eq 1
1070     then
1071       echo "#undef      HASPERSDC" >> $NEW
1072       if test $PDCN -eq 0
1073       then
1074         echo "#define   HASPERSDC       \"$PDCV\"" >> $NEW
1075       fi
1076     fi
1077     if test "X$PDCPV" != "X" -o $PDCPN -eq 1
1078     then
1079       echo "#undef      HASPERSDCPATH" >> $NEW
1080       if test $PDCPN -eq 0
1081       then
1082         echo "#define   HASPERSDCPATH   \"$PDCPV\"" >> $NEW
1083       fi
1084     fi
1085     if test "X$SDCV" != "X" -o $SDCN -eq 1
1086     then
1087       echo "#undef      HASSYSDC" >> $NEW
1088       if test $SDCN -eq 0
1089       then
1090         echo "#define   HASSYSDC        \"$SDCV\"" >> $NEW
1091       fi
1092     fi
1093   fi
1094 fi
1095
1096 # Change HASXOPT_ROOT, as required.
1097
1098 if test $HXRC -eq 1
1099 then
1100   if test $HXRS -eq 1
1101   then
1102     echo "#undef        HASXOPT_ROOT" >> $NEW
1103   else
1104     echo "#define       HASXOPT_ROOT    1" >> $NEW
1105   fi
1106 fi
1107
1108 # Change HASKERNIDCK, as required.
1109
1110 echo "#undef    HASKERNIDCK" >> $NEW
1111 if test $NIDCK -eq 1
1112 then
1113   echo "#define HASKERNIDCK     1" >> $NEW
1114 fi
1115
1116 # Replace the current machine.h with the new one, as requested.
1117
1118 echo ""
1119 echo "====================================================================="
1120 echo ""
1121 echo "A new $OLD file has been created in \"$NEW\"."
1122 END=0
1123 while test $END -eq 0
1124 do
1125   echo ""
1126   echo "Do you want to rename $OLD to ${OLD}.old and replace it with"
1127   echo $EO "$NEW (y|n) [y]? $EC"
1128   read ANS EXCESS
1129   if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
1130   then
1131     END=1
1132   else
1133     if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
1134     then
1135       rm -f ${OLD}.old
1136       mv $OLD ${OLD}.old
1137       mv $NEW $OLD
1138       END=1
1139     else
1140       echo ""
1141       echo "Please answer y|n [y]."
1142     fi
1143   fi
1144 done
1145 echo ""
1146 echo "You may now run the make command -- e.g.,"
1147 echo ""
1148 echo "        $ make"
1149 echo ""
1150 exit 0
1151 #LAST_LINE