| 1 |
#! /bin/sh |
| 2 |
: |
| 3 |
# Copyright (c) 1990-1997, S.R. van den Berg, The Netherlands |
| 4 |
#$Id: autoconf,v 1.136 2001/08/10 18:52:30 guenther Exp $ |
| 5 |
|
| 6 |
# All possible entries in autoconf.h: |
| 7 |
|
| 8 |
# #define UNISTD_H_MISSING |
| 9 |
# #define STDDEF_H_MISSING |
| 10 |
# #define STDLIB_H_MISSING |
| 11 |
# #define DIRENT_H_MISSING |
| 12 |
# #define SYS_DIRENT_H_MISSING |
| 13 |
# #define NDIR_H_MISSING |
| 14 |
# #define SYS_NDIR_H_MISSING |
| 15 |
# #define SYS_DIR_H_MISSING |
| 16 |
# #define SYS_WAIT_H_MISSING |
| 17 |
# #define SYS_UTSNAME_H_MISSING |
| 18 |
# #define STRING_H_MISSING |
| 19 |
# #define SYSEXITS_H_MISSING |
| 20 |
#Ok #define SYS_FILE_H_MISSING |
| 21 |
#Ok #define SYSLOG_H_MISSING |
| 22 |
# #define MATH_H_MISSING |
| 23 |
# #define LIMITS_H_MISSING |
| 24 |
# #define NO_const |
| 25 |
# #define volatile |
| 26 |
# #define P(args) () |
| 27 |
# #define NO_enum |
| 28 |
# #define void char |
| 29 |
# typedef int mode_t; |
| 30 |
# typedef int pid_t; |
| 31 |
# typedef int uid_t; |
| 32 |
# typedef int gid_t; |
| 33 |
# typedef unsigned size_t; |
| 34 |
# typedef long off_t; |
| 35 |
# typedef long time_t; |
| 36 |
# #define NOmemmove |
| 37 |
#Ok #define NObcopy |
| 38 |
# #define NOstrcspn |
| 39 |
# #define NOstrpbrk |
| 40 |
# #define NOopendir |
| 41 |
# #define NOrename |
| 42 |
# #define NOsetrgid |
| 43 |
# #define NOsetegid |
| 44 |
# #define NOsetregid |
| 45 |
# #define NOsetresgid |
| 46 |
# #define setrgid_BRAIN_DAMAGE |
| 47 |
# #define setrgid_RUNTIME_CHECK |
| 48 |
#Ok #define TOGGLE_SGID_OK |
| 49 |
# #define NOpow |
| 50 |
# #define NOmkdir |
| 51 |
# #define NOfstat |
| 52 |
# #define NOuname |
| 53 |
# #define NO_exit |
| 54 |
# #define NOstrtol |
| 55 |
# #define NOstrtod |
| 56 |
# #define NOstrerror |
| 57 |
#Ok #define NOstrlcat |
| 58 |
#Ok #define NOstrncasecmp |
| 59 |
#Ok #define NOsys_errlist |
| 60 |
#Ok #define NObzero |
| 61 |
# #define NOmemset |
| 62 |
# #define NOwaitpid |
| 63 |
#Ok #define NOftruncate |
| 64 |
# #define SLOWstrstr |
| 65 |
#Ok #define CAN_chown |
| 66 |
# #define strchr(s,c) index(s,c) |
| 67 |
# #define NOinitgroups |
| 68 |
# #define NOfsync |
| 69 |
#Ok #define endpwent() |
| 70 |
#Ok #define endgrent() |
| 71 |
#Ok #define endhostent() |
| 72 |
#Ok #define endservent() |
| 73 |
#Ok #define endprotoent() |
| 74 |
# #define h_0addr_list h_addr |
| 75 |
#Ok #define NOpw_passwd |
| 76 |
#Ok #define NOpw_class |
| 77 |
#Ok #define NOpw_gecos |
| 78 |
#Ok #define NO_COMSAT |
| 79 |
# #define _GUID_T |
| 80 |
#Ok #define UDP_protocolno 17 |
| 81 |
#Ok #define BIFF_serviceport "512" |
| 82 |
#Ok #define IP_localhost {127,0,0,1} |
| 83 |
# #define WMACROS_NON_POSIX |
| 84 |
# #define oBRAIN_DAMAGE |
| 85 |
#Ok #define GOT_bin_test |
| 86 |
#Ok #define MAX_argc 128 |
| 87 |
#Ok #define MAX_envc 128 |
| 88 |
#Ok #define SMALLHEAP |
| 89 |
# #define NOfcntl_lock |
| 90 |
#Ok #define USElockf |
| 91 |
#Ok #define USEflock |
| 92 |
#Ok #define MAILSPOOLDIR "/var/mail/" |
| 93 |
#Ok #define SENDMAIL "/usr/sbin/sendmail" |
| 94 |
# #define buggy_SENDMAIL |
| 95 |
# #define DEFflagsendmail "" |
| 96 |
#Ok #define CF_no_procmail_yet |
| 97 |
#Ok #define defSPATH "PATH=/bin:/usr/bin:/usr/local/bin" |
| 98 |
#Ok #define defPATH "PATH=$HOME/bin:/bin:/usr/bin:/usr/local/bin" |
| 99 |
#Ok #define INEFFICIENTrealloc |
| 100 |
#Ok #define PM_VERSION "n.nn" |
| 101 |
|
| 102 |
# A conforming ISO C compiler and POSIX library should not have any defines |
| 103 |
# not marked as "Ok" in the autoconf.h file. |
| 104 |
# Anything else indicates failure of your system to comply with either |
| 105 |
# the ISO or POSIX standards (but procmail should be installable anyway). |
| 106 |
|
| 107 |
if test -z "$IFS" |
| 108 |
then IFS=" \ |
| 109 |
\ |
| 110 |
|
| 111 |
" |
| 112 |
export IFS |
| 113 |
fi |
| 114 |
|
| 115 |
SHELL=$1 |
| 116 |
PATH=.:$PATH |
| 117 |
shift; RM="$1" |
| 118 |
shift; MV="$1" |
| 119 |
shift; DEVNULL=$1 |
| 120 |
shift; FGREP="$1" |
| 121 |
shift; MAKE="$1" |
| 122 |
shift; O=$1 |
| 123 |
shift; LOCKINGTEST="$1" |
| 124 |
shift; BINDIR=$1 |
| 125 |
shift; ACONF=$1 |
| 126 |
|
| 127 |
test 1 != $# && |
| 128 |
echo "Don't start this script directly, use \`make ../autoconf.h'" && exit 1 |
| 129 |
|
| 130 |
if test -f make_n |
| 131 |
then |
| 132 |
$RM make_n |
| 133 |
else |
| 134 |
# We were mistakenly invoked under "make -n", so pretend this didn't happen. |
| 135 |
exit 0 |
| 136 |
fi |
| 137 |
|
| 138 |
export SHELL PATH |
| 139 |
|
| 140 |
test "X$LOCKINGTEST" = X__defaults__ && LOCKINGTEST="" |
| 141 |
|
| 142 |
OLDTESTDIRS="" |
| 143 |
tailpid="" |
| 144 |
echo "" >_locktst.pid |
| 145 |
|
| 146 |
if test -f $ACONF |
| 147 |
then |
| 148 |
if $FGREP -e "/* autoconf completed */" $ACONF >$DEVNULL |
| 149 |
then |
| 150 |
cat <<HERE |
| 151 |
============================================================================== |
| 152 |
Would you like to skip running autoconf and use the existing autoconf.h file? |
| 153 |
When in doubt, press return [n]: |
| 154 |
HERE |
| 155 |
read a |
| 156 |
case "$a"n in |
| 157 |
[yY]*) touch $ACONF; exit 0;; |
| 158 |
esac |
| 159 |
fi |
| 160 |
trap "kill \`cat _locktst.pid\` 2>$DEVNULL;cp $ACONF $ACONF.tmp |
| 161 |
test ! -z \"\$OLDTESTDIRS\" && $RM -r \$OLDTESTDIRS \$OLDTESTDIRS 2>$DEVNULL |
| 162 |
test ! -z \"\$tailpid\" && kill \$tailpid 2>$DEVNULL |
| 163 |
kill \`cat _locktst.pid\` 2>$DEVNULL; exit 1" 1 2 3 13 15 |
| 164 |
else |
| 165 |
trap "kill \`cat _locktst.pid\` 2>$DEVNULL;$RM -r $ACONF.tmp |
| 166 |
test ! -z \"\$OLDTESTDIRS\" && $RM -r \$OLDTESTDIRS \$OLDTESTDIRS 2>$DEVNULL |
| 167 |
mv $ACONF $ACONF.tmp 2>$DEVNULL |
| 168 |
test ! -z \"\$tailpid\" && kill \$tailpid 2>$DEVNULL |
| 169 |
kill \`cat _locktst.pid\` 2>$DEVNULL; exit 1" 1 2 3 13 15 |
| 170 |
fi |
| 171 |
|
| 172 |
nocore=yes |
| 173 |
set dummy *core* |
| 174 |
test -f $2 && nocore=no |
| 175 |
|
| 176 |
set dummy $LOCKINGTEST |
| 177 |
shift |
| 178 |
LOCKINGTEST="$*" |
| 179 |
|
| 180 |
test ! -z "$LOCKINGTEST" && exec 9>&1 1>$DEVNULL # make it shut up |
| 181 |
|
| 182 |
cat <<HERE |
| 183 |
============================================================================== |
| 184 |
In order for the kernel-locking tests to work as intended I have to be able to |
| 185 |
test-lock files on as many semantically different filesystems as possible (for |
| 186 |
more information about this, READ PARAGRAPH TWO in INSTALL). To suppress this |
| 187 |
prompt you can set the LOCKINGTEST variable in the Makefile. |
| 188 |
|
| 189 |
Please add writable directories to the list. You should only add directories |
| 190 |
that reside on filesystems that have unique characteristics. E.g. if you have |
| 191 |
several remote NFS partitions, pick some unique client-server pairs, there is |
| 192 |
little use in picking the same server twice from the same client-machine. |
| 193 |
An excellent candidate would be a remotely mounted mail spool directory. |
| 194 |
============================================================================== |
| 195 |
HERE |
| 196 |
|
| 197 |
testdirs="/tmp ." |
| 198 |
|
| 199 |
case "$LOCKINGTEST" in |
| 200 |
""|*[a-zA-Z/]*) b=dummy ;; |
| 201 |
*) b=""; testdirs=$LOCKINGTEST; LOCKINGTEST=dummy ;; |
| 202 |
esac |
| 203 |
|
| 204 |
while test ! -z "$b" |
| 205 |
do |
| 206 |
echo "" |
| 207 |
b="" |
| 208 |
OLDTESTDIRS="$TESTDIRS" |
| 209 |
TESTDIRS="" |
| 210 |
for a in $testdirs |
| 211 |
do $RM -r $a/_locktest |
| 212 |
if mkdir $a/_locktest 2>$DEVNULL |
| 213 |
then |
| 214 |
b="$b $a" |
| 215 |
TESTDIRS="$TESTDIRS $a/_locktest" |
| 216 |
else |
| 217 |
echo 2>&1 "Can't create $a/_locktest" |
| 218 |
fi |
| 219 |
done |
| 220 |
OLDTESTDIRS="$TESTDIRS" |
| 221 |
testdirs="$b" |
| 222 |
echo "" |
| 223 |
echo "I will temporarily use a testdirectory named _locktest" |
| 224 |
echo "in the following directories:" |
| 225 |
echo "" |
| 226 |
echo $testdirs |
| 227 |
echo "" |
| 228 |
echo "If you would like to add any, please specify them below," |
| 229 |
echo "press return to continue:" |
| 230 |
echo "" |
| 231 |
if test -z "$LOCKINGTEST" |
| 232 |
then |
| 233 |
read b |
| 234 |
elif test dummy = "$LOCKINGTEST" |
| 235 |
then |
| 236 |
b="" |
| 237 |
else |
| 238 |
testdirs=""; b="$LOCKINGTEST"; LOCKINGTEST=dummy |
| 239 |
echo $b |
| 240 |
fi |
| 241 |
testdirs="$testdirs $b" |
| 242 |
done |
| 243 |
|
| 244 |
if test dummy = "$LOCKINGTEST" |
| 245 |
then |
| 246 |
exec 1>&9 9>&- # you can speak again |
| 247 |
echo "Using the following directories for the LOCKINGTESTs:" |
| 248 |
echo " $testdirs" |
| 249 |
fi |
| 250 |
|
| 251 |
cat >grepfor <<HERE |
| 252 |
$FGREP -e "\$1" _autotst.rrr >$DEVNULL && echo "\$2" >>$ACONF |
| 253 |
HERE |
| 254 |
chmod 0755 grepfor |
| 255 |
|
| 256 |
cat >$ACONF <<HERE |
| 257 |
/* This file was automagically generated by autoconf */ |
| 258 |
|
| 259 |
HERE |
| 260 |
|
| 261 |
echo >_locktst.h |
| 262 |
|
| 263 |
$RM _autotst.$O |
| 264 |
|
| 265 |
cat >_autotst.c <<HERE |
| 266 |
#include "$ACONF" |
| 267 |
#include <sys/types.h> |
| 268 |
#include <time.h> |
| 269 |
void*vvoid; |
| 270 |
int main(){int i=0;char*p="t"; |
| 271 |
vvoid=p; |
| 272 |
{time_t vtime;i+=vtime=1;} |
| 273 |
{off_t voff;i+=voff=1;} |
| 274 |
return !vvoid+!i;} |
| 275 |
#include <unistd.h> |
| 276 |
int empty() |
| 277 |
{ return setsid(); |
| 278 |
} |
| 279 |
HERE |
| 280 |
|
| 281 |
if $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr |
| 282 |
test -f _autotst.$O |
| 283 |
then |
| 284 |
$MAKE _autotst >$DEVNULL 2>&1 || echo "#define setsid()" >>_locktst.h |
| 285 |
else |
| 286 |
grepfor void '#define void char' |
| 287 |
grepfor time_t 'typedef long time_t;' |
| 288 |
grepfor off_t 'typedef long off_t;' |
| 289 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 |
| 290 |
then |
| 291 |
$MAKE _autotst >$DEVNULL 2>&1 || echo "#define setsid()" >>_locktst.h |
| 292 |
else |
| 293 |
echo "#define UNISTD_H_MISSING" >>$ACONF |
| 294 |
echo "#define setsid()" >>_locktst.h |
| 295 |
fi |
| 296 |
fi |
| 297 |
|
| 298 |
$RM _autotst.$O _autotst |
| 299 |
|
| 300 |
cat >_autotst.c <<HERE |
| 301 |
#include "$ACONF" |
| 302 |
#include <sys/types.h> |
| 303 |
#ifndef UNISTD_H_MISSING |
| 304 |
#include <unistd.h> |
| 305 |
#endif |
| 306 |
#include <fcntl.h> |
| 307 |
#ifndef SYS_FILE_H_MISSING |
| 308 |
#include <sys/file.h> |
| 309 |
#endif |
| 310 |
int main(){ |
| 311 |
#ifdef F_SETLKW |
| 312 |
fcntl(0,F_SETLKW,0); |
| 313 |
#endif |
| 314 |
#ifdef F_LOCK |
| 315 |
lockf(0,F_LOCK,(off_t)0); |
| 316 |
#endif |
| 317 |
#ifdef LOCK_EX |
| 318 |
flock(0,LOCK_EX); |
| 319 |
#endif |
| 320 |
return 0;} |
| 321 |
HERE |
| 322 |
|
| 323 |
echo 'Initiating fcntl()/kernel-locking-support tests' |
| 324 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 |
| 325 |
then |
| 326 |
: |
| 327 |
else |
| 328 |
$RM _autotst.$O |
| 329 |
echo "#define SYS_FILE_H_MISSING" >>$ACONF |
| 330 |
if $MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 331 |
then |
| 332 |
: |
| 333 |
else |
| 334 |
echo 2>&1 "Whoeaaa! There's something fishy going on here." |
| 335 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 336 |
echo 2>&1 "*******************************************************" |
| 337 |
cat 2>&1 _autotst.rrr |
| 338 |
echo 2>&1 "*******************************************************" |
| 339 |
echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC" |
| 340 |
echo 2>&1 "in the Makefile before you try make again." |
| 341 |
kill -15 $$ |
| 342 |
fi |
| 343 |
fi |
| 344 |
$MAKE _autotst >_autotst.rrr 2>&1 |
| 345 |
$RM _autotst.$O _autotst |
| 346 |
|
| 347 |
$FGREP fcntl _autotst.rrr >$DEVNULL && echo "#undef F_SETLKW" >>_locktst.h |
| 348 |
$FGREP lockf _autotst.rrr >$DEVNULL && echo "#undef F_LOCK" >>_locktst.h |
| 349 |
$FGREP flock _autotst.rrr >$DEVNULL && cat >>_locktst.h <<HERE |
| 350 |
#ifdef LOCK_EX |
| 351 |
#undef LOCK_EX |
| 352 |
#endif |
| 353 |
#ifndef SYS_FILE_H_MISSING |
| 354 |
#define SYS_FILE_H_MISSING |
| 355 |
#endif |
| 356 |
HERE |
| 357 |
|
| 358 |
cat >_autotst.c <<HERE |
| 359 |
#include "$ACONF" |
| 360 |
#include "../config.h" |
| 361 |
#include <sys/types.h> |
| 362 |
#ifndef UNISTD_H_MISSING |
| 363 |
#include <unistd.h> /* getpid() getppid() */ |
| 364 |
#endif |
| 365 |
#include <stdio.h> |
| 366 |
#include <time.h> |
| 367 |
#include <fcntl.h> |
| 368 |
#include <signal.h> /* SIGKILL */ |
| 369 |
#ifndef tell |
| 370 |
#define tell(fd) lseek(fd,(off_t)0,SEEK_CUR) |
| 371 |
#endif |
| 372 |
#ifndef EXIT_SUCCESS |
| 373 |
#define EXIT_SUCCESS 0 |
| 374 |
#endif |
| 375 |
#include "_locktst.h" |
| 376 |
#ifndef SYS_FILE_H_MISSING |
| 377 |
#include <sys/file.h> |
| 378 |
#endif |
| 379 |
#ifndef SEEK_SET |
| 380 |
#define SEEK_SET 0 |
| 381 |
#define SEEK_CUR 1 |
| 382 |
#define SEEK_END 2 |
| 383 |
#endif |
| 384 |
|
| 385 |
#define MIN_locks 128 /* minimum of consecutive successful locks */ |
| 386 |
#define SLEEP_loop 64 /* iterations in the busy loop */ |
| 387 |
#define SLEEP_delay 0 /* sleep() time per busy iteration */ |
| 388 |
#define SLEEP_retreat 1 /* extra sleep() when quota reached */ |
| 389 |
#define TIME_OUT_SEC 16 /* initial timeout per lock */ |
| 390 |
#define NR_of_forks 8 /* concurrent test-programs */ |
| 391 |
#define NR_of_lockfiles 2 /* lockfiles used in testing (<=4) */ |
| 392 |
#define GROW 3 /* when timing got worse */ |
| 393 |
#define DECAY 7/8 /* when timing got better */ |
| 394 |
#define GOBBLE 256 /* for the SunOS crash test */ |
| 395 |
|
| 396 |
#define LOCKS_per_child (((MIN_locks+NR_of_forks-1)/NR_of_forks+1)/2) |
| 397 |
#define SHIFT_childno 3 |
| 398 |
#define MASK_fileno ((1<<SHIFT_childno)-1) |
| 399 |
#define MASK_childno (~MASK_fileno) |
| 400 |
|
| 401 |
#ifdef NO_fcntl_LOCK |
| 402 |
#undef F_SETLKW |
| 403 |
#endif |
| 404 |
#ifdef NO_lockf_LOCK |
| 405 |
#undef F_LOCK |
| 406 |
#endif |
| 407 |
#ifdef NO_flock_LOCK |
| 408 |
#undef LOCK_EX |
| 409 |
#endif |
| 410 |
|
| 411 |
#define FIRST_lock 0x04 /* testing is in order of importance */ |
| 412 |
#define MSK_fcntl 0x04 /* don't change this order unless you */ |
| 413 |
#define MSK_lockf 0x02 /* change locking.c as well, fdlock() */ |
| 414 |
#define MSK_flock 0x01 /* and hotwired LOCKINGTEST */ |
| 415 |
|
| 416 |
int dolock,child[NR_of_forks],timeout,fdcollect; |
| 417 |
char dirlocktest[]="_locktest"; |
| 418 |
|
| 419 |
void stimeout() |
| 420 |
{ timeout=1;close(fdcollect);killchildren(); |
| 421 |
} |
| 422 |
|
| 423 |
void Terminate() |
| 424 |
{ stimeout();exit(1); |
| 425 |
} |
| 426 |
|
| 427 |
static unsigned long seed; |
| 428 |
|
| 429 |
unsigned psrand() |
| 430 |
{ return (unsigned)(seed*=69069L)>>8; |
| 431 |
} |
| 432 |
|
| 433 |
unsigned sfork() |
| 434 |
{ int pid; |
| 435 |
while((pid=fork())<0) |
| 436 |
fprintf(stderr,"Couldn't fork _locktst, retrying\n"),sleep(TIME_OUT_SEC); |
| 437 |
return pid; |
| 438 |
} |
| 439 |
|
| 440 |
int main(argc,argv)char*argv[]; |
| 441 |
{ int goodlock,testlock,i,pip[2],pipw[2];time_t otimet;unsigned dtimet; |
| 442 |
static char filename[]="_locktst.l0"; |
| 443 |
close(0);goodlock=0;testlock=FIRST_lock;signal(SIGPIPE,SIG_DFL); |
| 444 |
if(argc==2) |
| 445 |
{ char*p; |
| 446 |
for(p=argv[1];;) |
| 447 |
{ switch(*p++) /* parse the hotwire */ |
| 448 |
{ case '1':goodlock<<=1;goodlock++; |
| 449 |
continue; |
| 450 |
case '0':goodlock<<=1; |
| 451 |
continue; |
| 452 |
case '\0': |
| 453 |
#ifndef F_SETLKW /* sanity check, for the less gifted */ |
| 454 |
goodlock&=~MSK_fcntl; |
| 455 |
#endif |
| 456 |
#ifndef F_LOCK |
| 457 |
goodlock&=~MSK_lockf; |
| 458 |
#endif |
| 459 |
#ifndef LOCK_EX |
| 460 |
goodlock&=~MSK_flock; |
| 461 |
#endif |
| 462 |
goto skip_tests; |
| 463 |
} |
| 464 |
break; /* oops, no hotwire */ |
| 465 |
} |
| 466 |
goodlock=0; |
| 467 |
} |
| 468 |
if(sfork()) /* try to ditch the controlling tty */ |
| 469 |
return EXIT_SUCCESS; /* to prevent rather messy kernel-diagnostics */ |
| 470 |
setsid(); /* from appearing on your tty */ |
| 471 |
fprintf(stderr,"\ |
| 472 |
Every two digits a file is locked. First digit: which file, second digit:\n\ |
| 473 |
which program, XX indicates a lock conflict or failure\n"); |
| 474 |
do |
| 475 |
{ int countlocks; |
| 476 |
signal(SIGTERM,SIG_DFL);argc=1;dolock=goodlock|testlock; |
| 477 |
do |
| 478 |
{ char*curdir; |
| 479 |
curdir=argv[argc];otimet=time((time_t*)0); |
| 480 |
if(sfork()) |
| 481 |
{ close(1);close(2);i=NR_of_lockfiles;chdir(curdir); |
| 482 |
chdir(dirlocktest); |
| 483 |
do /* prime the lock, see if it vanishes */ |
| 484 |
{ filename[sizeof filename-2]='0'+--i; |
| 485 |
lseek(goodlock=open(filename,O_WRONLY),(off_t)0,SEEK_END); |
| 486 |
fdlock(goodlock); |
| 487 |
} |
| 488 |
while(i); |
| 489 |
for(;;) /* synchronising "busy"-wait */ |
| 490 |
sleep(TIME_OUT_SEC); /* until the games can be started */ |
| 491 |
} |
| 492 |
sleep(1);pipe(pip);pipe(pipw);i=NR_of_forks;*child=0; |
| 493 |
fprintf(stderr,"\nStarting test %x on %s\n",dolock,curdir); |
| 494 |
while((child[--i]=sfork())&&i); /* divide and conquer */ |
| 495 |
if(!*child) |
| 496 |
{ unsigned char lockflag;int fd,childno=i<<SHIFT_childno; |
| 497 |
int mylocks=LOCKS_per_child; |
| 498 |
close(pipw[0]);close(pip[0]);close(1); |
| 499 |
seed=time((time_t*)0)+getpid()|1;chdir(curdir);chdir(dirlocktest); |
| 500 |
close(pipw[1]); |
| 501 |
for(;;) /* and lock away! */ |
| 502 |
{ filename[sizeof filename-2]='0'+(i=psrand()%NR_of_lockfiles); |
| 503 |
lockflag=childno|i<<1|1; |
| 504 |
lseek(fd=open(filename,O_WRONLY),(off_t)0,SEEK_END); |
| 505 |
if(sfdlock(fd)) |
| 506 |
lockflag&=~1,fprintf(stderr,"XX%x",lockflag); |
| 507 |
write(pip[1],&lockflag,1); |
| 508 |
fprintf(stderr," %x%x",i,childno>>SHIFT_childno); |
| 509 |
lseek(fd,(off_t)0,SEEK_END);write(fd,&lockflag,1); |
| 510 |
for(i=SLEEP_loop;i;i--,time((time_t*)0),sleep(SLEEP_delay)); |
| 511 |
lockflag&=~1;write(pip[1],&lockflag,1); |
| 512 |
if(fdunlock()||close(fd)) |
| 513 |
{ write(pip[1],&lockflag,1);fprintf(stderr,"XX%x",lockflag); |
| 514 |
return 1; |
| 515 |
} |
| 516 |
if(--mylocks<0) |
| 517 |
sleep(SLEEP_retreat); |
| 518 |
} |
| 519 |
} |
| 520 |
signal(SIGTERM,Terminate); |
| 521 |
;{ unsigned char lckdfil[NR_of_lockfiles],curflag; |
| 522 |
int j,ppid; /* give all children a chance */ |
| 523 |
ppid=getppid(); |
| 524 |
if(sfork()) /* discard the old body, let init adopt our children */ |
| 525 |
return EXIT_SUCCESS; |
| 526 |
;{ FILE*fp; |
| 527 |
if(fp=fopen("_locktst.pid","w")) |
| 528 |
fprintf(fp,"%ld",(long)getpid()),fclose(fp); |
| 529 |
} |
| 530 |
countlocks=MIN_locks;close(pip[1]);close(pipw[1]); |
| 531 |
for(j=NR_of_lockfiles;lckdfil[--j]=0,j;); |
| 532 |
timeout=0;sleep(1);read(pipw[0],&curflag,1);close(pipw[0]); |
| 533 |
kill(ppid,SIGKILL);fdcollect=pip[0];signal(SIGALRM,stimeout); |
| 534 |
dtimet=(time((time_t*)0)-otimet)*GROW+TIME_OUT_SEC; |
| 535 |
do |
| 536 |
{ unlink("_locktst.alive");alarm(dtimet+2); /* watchdog */ |
| 537 |
dtimet=(otimet=time((time_t*)0)-otimet)>dtimet? |
| 538 |
otimet*GROW:otimet+(dtimet-otimet)*DECAY+1; /* load dependent */ |
| 539 |
otimet=time((time_t*)0); |
| 540 |
} |
| 541 |
while(1==read(fdcollect,&curflag,1)&& |
| 542 |
(j=lckdfil[i=(curflag&MASK_fileno)>>1],!timeout)&& |
| 543 |
((j^(lckdfil[i]=curflag))==1||!(j&1)&&curflag&1)&&--countlocks); |
| 544 |
alarm(0);close(fdcollect);killchildren(); |
| 545 |
fprintf(stdout, |
| 546 |
"/*locktype: %x, countlocks: %x, timeout %x, watchdog %x, %s*/\n", |
| 547 |
dolock,countlocks,timeout,dtimet,curdir);fflush(stdout); |
| 548 |
} |
| 549 |
} |
| 550 |
while(!countlocks&&argv[++argc]); |
| 551 |
if(!countlocks) /* Hurray! Locking was flawless */ |
| 552 |
goodlock=dolock; /* make a mark on our colt */ |
| 553 |
} |
| 554 |
while(testlock>>=1); |
| 555 |
skip_tests: |
| 556 |
printf("/* Hotwire LOCKINGTEST=%c%c%c */\n",goodlock&0x4?'1':'0', |
| 557 |
goodlock&0x2?'1':'0',goodlock&0x1?'1':'0'); |
| 558 |
printf("/* Procmail will lock via: dotlocking"); /* report our findings */ |
| 559 |
if(goodlock&MSK_fcntl) |
| 560 |
printf(", fcntl()"); |
| 561 |
if(goodlock&MSK_lockf) |
| 562 |
printf(", lockf()"); |
| 563 |
if(goodlock&MSK_flock) |
| 564 |
printf(", flock()"); |
| 565 |
puts(" */"); |
| 566 |
if(!(goodlock&MSK_fcntl)) /* and in machine readable format */ |
| 567 |
puts("#define NOfcntl_lock"); |
| 568 |
if(goodlock&MSK_lockf) |
| 569 |
puts("#define USElockf"); |
| 570 |
if(goodlock&MSK_flock) |
| 571 |
{ puts("#define USEflock"); |
| 572 |
#ifdef SYS_FILE_H_MISSING |
| 573 |
puts("#define SYS_FILE_H_MISSING"); |
| 574 |
#endif |
| 575 |
} |
| 576 |
puts("Kernel-locking tests completed.");fprintf(stderr,"\n"); |
| 577 |
return EXIT_SUCCESS; |
| 578 |
} |
| 579 |
|
| 580 |
int killchildren() |
| 581 |
{ int i; |
| 582 |
i=NR_of_forks; |
| 583 |
do |
| 584 |
if(child[--i]>0) |
| 585 |
kill(child[i],SIGTERM),child[i]=0; |
| 586 |
while(i); |
| 587 |
return 0; |
| 588 |
} |
| 589 |
|
| 590 |
int sfdlock(fd) |
| 591 |
{ int i;unsigned gobble[GOBBLE>>2]; |
| 592 |
for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */ |
| 593 |
return fdlock(fd); |
| 594 |
} |
| 595 |
|
| 596 |
static oldfdlock; |
| 597 |
#ifdef F_SETLKW |
| 598 |
static struct flock flck; /* why can't it be a local variable? */ |
| 599 |
#endif |
| 600 |
#ifdef F_LOCK |
| 601 |
static off_t oldlockoffset; |
| 602 |
#endif |
| 603 |
|
| 604 |
int fdlock(fd) |
| 605 |
{ int i;unsigned gobble[GOBBLE>>2]; |
| 606 |
for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */ |
| 607 |
oldfdlock=fd;fd=0; |
| 608 |
if(MSK_fcntl&dolock) |
| 609 |
#ifdef F_SETLKW |
| 610 |
{ static unsigned extra; |
| 611 |
flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_start=tell(oldfdlock); |
| 612 |
if(!extra--) |
| 613 |
extra=MIN_locks/4,flck.l_len=2,i|=fcntl(oldfdlock,F_SETLK,&flck); |
| 614 |
flck.l_len=0;fd|=fcntl(oldfdlock,F_SETLKW,&flck); |
| 615 |
} |
| 616 |
#else |
| 617 |
fd=1; |
| 618 |
#endif |
| 619 |
if(MSK_lockf&dolock) |
| 620 |
#ifdef F_LOCK |
| 621 |
oldlockoffset=tell(oldfdlock),fd|=lockf(oldfdlock,F_LOCK,(off_t)0); |
| 622 |
#else |
| 623 |
fd=1; |
| 624 |
#endif |
| 625 |
if(MSK_flock&dolock) |
| 626 |
#ifdef LOCK_EX |
| 627 |
fd|=flock(oldfdlock,LOCK_EX); |
| 628 |
#else |
| 629 |
fd=1; |
| 630 |
#endif |
| 631 |
return fd; |
| 632 |
} |
| 633 |
|
| 634 |
int fdunlock() |
| 635 |
{ int i;unsigned gobble[GOBBLE]; |
| 636 |
for(i=GOBBLE;i;gobble[--i]=~(unsigned)0); /* some SunOS libs mess this up */ |
| 637 |
if(MSK_flock&dolock) |
| 638 |
#ifdef LOCK_EX |
| 639 |
i|=flock(oldfdlock,LOCK_UN); |
| 640 |
#else |
| 641 |
i=1; |
| 642 |
#endif |
| 643 |
if(MSK_lockf&dolock) |
| 644 |
#ifdef F_LOCK |
| 645 |
{ lseek(oldfdlock,oldlockoffset,SEEK_SET); |
| 646 |
i|=lockf(oldfdlock,F_LOCK,(off_t)2);i|=lockf(oldfdlock,F_ULOCK,(off_t)0); |
| 647 |
} |
| 648 |
#else |
| 649 |
i=1; |
| 650 |
#endif |
| 651 |
if(MSK_fcntl&dolock) |
| 652 |
#ifdef F_SETLKW |
| 653 |
flck.l_type=F_UNLCK,flck.l_len=0,i|=fcntl(oldfdlock,F_SETLK,&flck); |
| 654 |
#else |
| 655 |
i=1; |
| 656 |
#endif |
| 657 |
if(!i) |
| 658 |
for(i=GOBBLE;i&&gobble[--i]==~(unsigned)0;); |
| 659 |
return i; |
| 660 |
} |
| 661 |
HERE |
| 662 |
|
| 663 |
if $MAKE _autotst >_autotst.rrr 2>&1 |
| 664 |
then |
| 665 |
: |
| 666 |
else |
| 667 |
echo 2>&1 "Whoeaaa! There's something fishy going on here." |
| 668 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 669 |
echo 2>&1 "*******************************************************" |
| 670 |
cat 2>&1 _autotst.rrr |
| 671 |
echo 2>&1 "*******************************************************" |
| 672 |
echo 2>&1 "I suggest you take a look at the definition of LDFLAGS*" |
| 673 |
echo 2>&1 "in the Makefile before you try make again." |
| 674 |
kill -15 $$ |
| 675 |
fi |
| 676 |
|
| 677 |
$MV _locktst _locktst.$$ 2>$DEVNULL |
| 678 |
$RM _autotst.$O _autotst.rrr _locktst* 2>$DEVNULL |
| 679 |
echo "" >_locktst.pid |
| 680 |
$MV _autotst _locktst |
| 681 |
|
| 682 |
case "$testdirs" in |
| 683 |
*[a-zA-Z/]*) |
| 684 |
for b in $TESTDIRS |
| 685 |
do |
| 686 |
for a in 0 1 2 3 |
| 687 |
do echo dummy_file >$b/_locktst.l$a |
| 688 |
done |
| 689 |
done ;; |
| 690 |
*) TESTDIRS=$testdirs ;; |
| 691 |
esac |
| 692 |
|
| 693 |
echo 2>&1 "" |
| 694 |
|
| 695 |
_locktst $TESTDIRS >_locktst.rrr 2>lock.log # will finish in the background |
| 696 |
echo 'Proceeding with kernel-locking-support tests in the background' |
| 697 |
|
| 698 |
|
| 699 |
cat >_autotst.c <<HERE |
| 700 |
#include "$ACONF" |
| 701 |
#ifndef UNISTD_H_MISSING |
| 702 |
#include <unistd.h> /* execvp() */ |
| 703 |
#endif |
| 704 |
int a(b)const int b[]; |
| 705 |
{ return *++b; /* watcom 10.6 on QNX refuses this */ |
| 706 |
} |
| 707 |
int main() |
| 708 |
{ char r[]="",*const*p;char*q="";const char*s=""; |
| 709 |
static const char*const nullp=0,*const*d= &nullp; /* AIX 3.2.3 failure */ |
| 710 |
static struct{const int a;int b;}c[2]={{0,0},{0,0}};/* IRIX 7.3.1 compiler */ |
| 711 |
/* requires initializers on static const objects */ |
| 712 |
--(c+1)->b; /* AIX 3.1.5 machines can't do this */ |
| 713 |
p= &q; |
| 714 |
;{ int pip[2]; |
| 715 |
pipe(pip); |
| 716 |
if(fork()) /* this should hide core dumps from the shell */ |
| 717 |
{ close(pip[1]); /* close the writing end */ |
| 718 |
return 1==read(pip[0],r,1)?0:1; /* wait for the rendevouz */ |
| 719 |
} |
| 720 |
close(pip[0]); /* close the writing end */ |
| 721 |
if(!*d&&c[1].b) /* some magic to confuse the optimiser */ |
| 722 |
d=(const char*const*)p; /* core dumps Ultrix 4.3 ANSI C */ |
| 723 |
else /* so that it can't complain about the uselessness of this program */ |
| 724 |
execvp(q,p); /* IRIX 4.0.1 system-includes are wrong on this point */ |
| 725 |
if(write(pip[1],r,1)!=1) /* notify mam that we survived */ |
| 726 |
return 1; /* oops, lost mam somehow */ |
| 727 |
} |
| 728 |
return r==s; /* Domain/OS warns here, not about "r==s" though */ |
| 729 |
} |
| 730 |
HERE |
| 731 |
|
| 732 |
echo 'Testing for const' |
| 733 |
if $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr |
| 734 |
test -f _autotst.$O && $MAKE _autotst >$DEVNULL 2>&1 && _autotst |
| 735 |
then |
| 736 |
grepfor const '#define NO_const' |
| 737 |
else |
| 738 |
echo '#define NO_const' >>$ACONF |
| 739 |
set dummy *core* |
| 740 |
if test -f $2 -a $nocore = yes |
| 741 |
then |
| 742 |
echo "Removing core file (bogus readonly segment)" |
| 743 |
$RM *core* |
| 744 |
fi |
| 745 |
fi |
| 746 |
$RM _autotst.$O _autotst |
| 747 |
|
| 748 |
cat >_autotst.c <<HERE |
| 749 |
int main(){volatile int i;return (i=0);} |
| 750 |
HERE |
| 751 |
|
| 752 |
echo 'Testing for volatile' |
| 753 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O |
| 754 |
then |
| 755 |
: |
| 756 |
else |
| 757 |
echo '#define volatile' >>$ACONF |
| 758 |
not_ISO=yep |
| 759 |
fi |
| 760 |
$RM _autotst.$O |
| 761 |
|
| 762 |
if $FGREP NO_const $ACONF >$DEVNULL |
| 763 |
then |
| 764 |
echo '#define P(args) ()' >>$ACONF |
| 765 |
not_ISO=yep |
| 766 |
else |
| 767 |
cat >_autotst.c <<HERE |
| 768 |
int main(const int argc,const char*const argv[]){return argc;} |
| 769 |
HERE |
| 770 |
|
| 771 |
echo 'Testing for prototypes' |
| 772 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O |
| 773 |
then |
| 774 |
: |
| 775 |
else |
| 776 |
echo '#define P(args) ()' >>$ACONF |
| 777 |
not_ISO=yep |
| 778 |
fi |
| 779 |
$RM _autotst.$O |
| 780 |
fi |
| 781 |
|
| 782 |
cat >_autotst.c <<HERE |
| 783 |
enum foo { A, B, C, D=7, E, F= -3, G }; |
| 784 |
int main(){return !(A==0&&B==1&&C==2&&D==7&&E==8&&F==-3&&G==-2);} |
| 785 |
HERE |
| 786 |
|
| 787 |
echo 'Testing for enum' |
| 788 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O && |
| 789 |
$MAKE _autotst >$DEVNULL 2>&1 && _autotst |
| 790 |
then |
| 791 |
: |
| 792 |
else |
| 793 |
echo '#define NO_enum' >>$ACONF |
| 794 |
not_ISO=yep |
| 795 |
fi |
| 796 |
$RM _autotst.$O |
| 797 |
|
| 798 |
if test -n "$not_ISO" |
| 799 |
then |
| 800 |
cat <<HERE |
| 801 |
|
| 802 |
Your system appears to not (correctly) support at least one of: |
| 803 |
const, volatile, function prototypes, and enum types. Future |
| 804 |
versions of procmail will probably require support for all of them, |
| 805 |
so you should either upgrade your compiler to one that's compliant |
| 806 |
with the ISO C standard (the standard's over 10 years old, for |
| 807 |
goodness sake), or send email to <[email protected]> explaining why |
| 808 |
you need procmail to continue to support K&R C. |
| 809 |
|
| 810 |
HERE |
| 811 |
fi |
| 812 |
|
| 813 |
echo 'Checking for POSIX and ANSI/ISO system include files' |
| 814 |
|
| 815 |
cat >_autotst.c <<HERE |
| 816 |
#include "includes.h" |
| 817 |
int a; |
| 818 |
#ifndef SYS_DIRENT_H_MISSING |
| 819 |
typedef DIR*tDIR; |
| 820 |
tDIR vDIR; |
| 821 |
#endif |
| 822 |
HERE |
| 823 |
|
| 824 |
i0="";i1="";i2="";i3="";i4="";i5="";i6="";i7="";i8="";i9="";i10="";i11=""; |
| 825 |
i12="";i13="" |
| 826 |
oldi="" |
| 827 |
|
| 828 |
while $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr |
| 829 |
test ! -f _autotst.$O |
| 830 |
do |
| 831 |
test -z "$i0" && grepfor stddef.h "#define STDDEF_H_MISSING" && i0=I |
| 832 |
test -z "$i1" && grepfor stdlib.h "#define STDLIB_H_MISSING" && i1=I |
| 833 |
test -z "$i2" && grepfor dirent.h "#define DIRENT_H_MISSING" && i2=I |
| 834 |
test -z "$i2" && grepfor DIR "#define DIRENT_H_MISSING \ |
| 835 |
/* <dirent.h> is there, but empty */" && i2=I |
| 836 |
test -z "$i3" && grepfor ndir.h "#define NDIR_H_MISSING" && i3=I |
| 837 |
test I = "$i3$i4" && grepfor sys/ndir.h "#define SYS_NDIR_H_MISSING" && i4=I |
| 838 |
test I = "$i4$i5" && grepfor sys/dir.h "#define SYS_DIR_H_MISSING" && i5=I |
| 839 |
test I = "$i5$i6" && grepfor sys/dirent.h "#define SYS_DIRENT_H_MISSING" \ |
| 840 |
&& i6=I |
| 841 |
test -z "$i7" && grepfor sys/wait.h "#define SYS_WAIT_H_MISSING" && i7=I |
| 842 |
test -z "$i8" && grepfor sys/utsname.h "#define SYS_UTSNAME_H_MISSING" && |
| 843 |
i8=I |
| 844 |
test -z "$i9" && grepfor string.h "#define STRING_H_MISSING" && i9=I |
| 845 |
test -z "$i10" && grepfor sysexits.h "#define SYSEXITS_H_MISSING" && i10=I |
| 846 |
test -z "$i11" && grepfor math.h "#define MATH_H_MISSING" && i11=I |
| 847 |
test -z "$i12" && grepfor limits.h "#define LIMITS_H_MISSING" && i12=I |
| 848 |
test -z "$i13" && grepfor syslog.h "#define SYSLOG_H_MISSING" && i13=I |
| 849 |
newi="$i0$i1$i2$i3$i4$i5$i6$i7$i8$i9$i10$i11$i12$i13" |
| 850 |
if test a$oldi = a$newi |
| 851 |
then |
| 852 |
echo 2>&1 "Whoeaaa! There's something fishy going on here." |
| 853 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 854 |
echo 2>&1 "*******************************************************" |
| 855 |
$MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 856 |
cat 2>&1 _autotst.rrr |
| 857 |
echo 2>&1 "*******************************************************" |
| 858 |
echo 2>&1 "I suggest you take a look at the definition of CFLAGS*" |
| 859 |
echo 2>&1 "in the Makefile before you try make again." |
| 860 |
kill -15 $$ |
| 861 |
fi |
| 862 |
oldi=$newi |
| 863 |
echo \ |
| 864 |
" ...missing `expr $oldi : '.*'` include files, doublechecking..." |
| 865 |
done |
| 866 |
|
| 867 |
$RM _autotst.$O |
| 868 |
|
| 869 |
cat >_autotst.c <<HERE |
| 870 |
#include "includes.h" |
| 871 |
#include "network.h" |
| 872 |
int a; |
| 873 |
HERE |
| 874 |
|
| 875 |
echo 'Checking for network/comsat/biff support' |
| 876 |
|
| 877 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 |
| 878 |
test -f _autotst.$O |
| 879 |
then |
| 880 |
: |
| 881 |
else |
| 882 |
echo "#define NO_COMSAT" >>$ACONF |
| 883 |
fi |
| 884 |
|
| 885 |
$RM _autotst.$O |
| 886 |
|
| 887 |
cat >_autotst.c <<HERE |
| 888 |
#include "includes.h" |
| 889 |
#ifndef NO_COMSAT |
| 890 |
#include "network.h" |
| 891 |
#endif |
| 892 |
int main(){int i=0; |
| 893 |
{size_t vsize_t;i+=vsize_t=1;} |
| 894 |
{pid_t vpid_t;i+=vpid_t=1;} |
| 895 |
{mode_t vmode_t;i+=vmode_t=1;} |
| 896 |
{uid_t vuid_t;i+=vuid_t=1;} |
| 897 |
{gid_t vgid_t;i+=vgid_t=1;} |
| 898 |
#ifndef NO_COMSAT |
| 899 |
{struct hostent vhostent;i+=!(vhostent.h_addr_list=0);} |
| 900 |
#endif |
| 901 |
#ifndef NOuname |
| 902 |
{struct utsname vutsname;i+=!(*vutsname.nodename='\0');} |
| 903 |
#endif |
| 904 |
return !i;} |
| 905 |
HERE |
| 906 |
|
| 907 |
echo 'Testing for void*, size_t, off_t, pid_t, time_t, mode_t, uid_t & gid_t' |
| 908 |
|
| 909 |
i1="";i2="";i3="";i4="";i5="";i6="";i7="" |
| 910 |
oldi="" |
| 911 |
|
| 912 |
while $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr |
| 913 |
test ! -f _autotst.$O |
| 914 |
do |
| 915 |
test -z "$i1" && grepfor size_t 'typedef unsigned size_t;' && i1=I |
| 916 |
test -z "$i2" && grepfor pid_t 'typedef int pid_t;' && i2=I |
| 917 |
test -z "$i3" && grepfor mode_t 'typedef int mode_t;' && i3=I |
| 918 |
test -z "$i4" && grepfor uid_t 'typedef int uid_t;' && i4=I |
| 919 |
test -z "$i5" && grepfor gid_t 'typedef int gid_t;' && i5=I |
| 920 |
test -z "$i6" && grepfor h_addr_list '#define h_0addr_list h_addr' && i6=I |
| 921 |
test -z "$i6" && grepfor hostent '#define h_0addr_list h_addr' && i6=I |
| 922 |
test -z "$i6" && grepfor member '#define h_0addr_list h_addr' && i6=I |
| 923 |
test -z "$i7" && grepfor utsname "#define NOuname \ |
| 924 |
/* <sys/utsname.h> is there, but empty */" && i7=I |
| 925 |
newi="$i1$i2$i3$i4$i5$i6$i7" |
| 926 |
if test a$oldi = a$newi |
| 927 |
then |
| 928 |
echo 2>&1 "Whoeaaa! There's something fishy going on here." |
| 929 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 930 |
echo 2>&1 "*******************************************************" |
| 931 |
$MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 932 |
cat 2>&1 _autotst.rrr |
| 933 |
echo 2>&1 "*******************************************************" |
| 934 |
echo 2>&1 "I suggest you take a look at the definition of CFLAGS*" |
| 935 |
echo 2>&1 "in the Makefile before you try make again." |
| 936 |
kill -15 $$ |
| 937 |
fi |
| 938 |
oldi=$newi |
| 939 |
echo \ |
| 940 |
" ...missing `expr $oldi : '.*'` types, doublechecking..." |
| 941 |
done |
| 942 |
|
| 943 |
$RM _autotst.$O |
| 944 |
|
| 945 |
cat >_autotst.c <<HERE |
| 946 |
#include "$ACONF" |
| 947 |
#include "../config.h" |
| 948 |
#include <stdio.h> |
| 949 |
#ifndef STDLIB_H_MISSING |
| 950 |
#include <stdlib.h> |
| 951 |
#define INITIAL 60 |
| 952 |
#else |
| 953 |
void*realloc(),*malloc(); |
| 954 |
#endif |
| 955 |
int main() |
| 956 |
{ char*p=malloc(1),*q=0; |
| 957 |
size_t len,last,max=BLKSIZ*64; /* 1M on non-SMALLHEAP systems */ |
| 958 |
int count=0; |
| 959 |
for(last=len=INITIAL;len<=max+INITIAL;len+=BLKSIZ) |
| 960 |
{ if(!(p=realloc(p,len))) |
| 961 |
break; |
| 962 |
if(p!=q) |
| 963 |
count++,q=p,fprintf(stderr,"len=%lu p=%p\n",(unsigned long)len,p); |
| 964 |
for(;last<len;last+=1024) /* touch at least every new page */ |
| 965 |
p[last]=last%127; |
| 966 |
} |
| 967 |
free(q); |
| 968 |
printf("/* %d move%s in %d steps of size %d when reallocing */\n", |
| 969 |
count,count==1?"":"s",(int)(max/BLKSIZ),BLKSIZ); |
| 970 |
if(BLKSIZ*(10*count+1)>max) |
| 971 |
{ puts("#define INEFFICIENTrealloc"); |
| 972 |
exit(1); |
| 973 |
} |
| 974 |
exit(0); |
| 975 |
} |
| 976 |
HERE |
| 977 |
|
| 978 |
echo 'Checking realloc implementation' |
| 979 |
|
| 980 |
if $MAKE _autotst >$DEVNULL 2>&1 |
| 981 |
test -f _autotst |
| 982 |
then |
| 983 |
_autotst >_autotst.rrr 2>realloc.log |
| 984 |
case "$?" in |
| 985 |
0) cat _autotst.rrr >>$ACONF;; |
| 986 |
1) cat _autotst.rrr >>$ACONF |
| 987 |
echo 'Sorry, repeatedly reallocing is inefficient';; |
| 988 |
*) echo "The test program failed somehow. Assuming realloc is fine";; |
| 989 |
esac |
| 990 |
fi |
| 991 |
|
| 992 |
$RM _autotst.$O _autotst _autotst.rrr |
| 993 |
|
| 994 |
cat >_autotst.c <<HERE |
| 995 |
#include "includes.h" |
| 996 |
int main(){int i;i=1; |
| 997 |
i+=WIFEXITED(i); |
| 998 |
i+=WIFSTOPPED(i); |
| 999 |
i+=WEXITSTATUS(i); |
| 1000 |
i+=WSIGTERM(i); |
| 1001 |
return i;} |
| 1002 |
HERE |
| 1003 |
|
| 1004 |
echo 'Testing for WIFEXITED(), WIFSTOPPED(), WEXITSTATUS() & WSIGTERM()' |
| 1005 |
if $MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 1006 |
then |
| 1007 |
$FGREP -v include/ <_autotst.rrr >_autotst.$O |
| 1008 |
$MV _autotst.$O _autotst.rrr |
| 1009 |
grepfor struct '#define WMACROS_NON_POSIX' || |
| 1010 |
grepfor union '#define WMACROS_NON_POSIX' |
| 1011 |
else |
| 1012 |
echo '#define WMACROS_NON_POSIX' >>$ACONF |
| 1013 |
fi |
| 1014 |
$RM _autotst.$O _autotst.rrr |
| 1015 |
|
| 1016 |
cat >_autotst.c <<HERE |
| 1017 |
#include <pwd.h> |
| 1018 |
int main() |
| 1019 |
{ struct passwd*pw=getpwuid(0); |
| 1020 |
return (pw->pw_passwd==0)+(pw->pw_class==0)+(pw->pw_gecos==0); |
| 1021 |
} |
| 1022 |
HERE |
| 1023 |
|
| 1024 |
echo 'Testing for various struct passwd members' |
| 1025 |
$MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 1026 |
grepfor pw_passwd '#define NOpw_passwd' |
| 1027 |
grepfor pw_class '#define NOpw_class' |
| 1028 |
grepfor pw_gecos '#define NOpw_gecos' |
| 1029 |
$RM _autotst.$O _autotst.rrr |
| 1030 |
|
| 1031 |
cat >_autotst.c <<HERE |
| 1032 |
#include "includes.h" |
| 1033 |
#ifndef NO_COMSAT |
| 1034 |
#include "network.h" |
| 1035 |
#endif |
| 1036 |
int main(){char a[2]; |
| 1037 |
endpwent();endgrent();memmove(a,"0",1);bcopy("0",a,1);strcspn(a,"0"); |
| 1038 |
strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");rename(a,"0"); |
| 1039 |
setrgid(0);setegid(0);setregid(0,0);setresgid(0,0,0);opendir("0"); |
| 1040 |
initgroups("0",0);strstr("0","0");mkdir("0",0);pow(0.,0.);clock(); |
| 1041 |
waitpid((pid_t)-1,(int*)0,0);ftruncate(0,0);fsync(0);strtod("0.0",(char**)0); |
| 1042 |
strncasecmp("0","0",3);strerror(ENOENT);strlcat(a,"0",2); |
| 1043 |
bzero(a,2);memset(a,'\0',2); |
| 1044 |
#ifdef S_ISLNK |
| 1045 |
{struct stat stbuf;fstat(0,&stbuf);} |
| 1046 |
#endif |
| 1047 |
#ifndef NOuname |
| 1048 |
{struct utsname b;uname(&b);} |
| 1049 |
#endif |
| 1050 |
#ifndef NO_COMSAT |
| 1051 |
gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent(); |
| 1052 |
endprotoent(); |
| 1053 |
#endif |
| 1054 |
_exit(0); |
| 1055 |
return 0;} |
| 1056 |
HERE |
| 1057 |
|
| 1058 |
echo 'Testing for memmove, strchr, strpbrk, strcspn, strtol, strstr,' |
| 1059 |
echo ' rename, setrgid, setegid, pow, opendir, mkdir, waitpid, fsync,' |
| 1060 |
echo ' ftruncate, strtod, strncasecmp, strerror, strlcat,' |
| 1061 |
echo ' memset, bzero, and _exit' |
| 1062 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 |
| 1063 |
then |
| 1064 |
: |
| 1065 |
else |
| 1066 |
echo 2>&1 "Whoeaaa! There's something fishy going on here." |
| 1067 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 1068 |
echo 2>&1 "*******************************************************" |
| 1069 |
cat 2>&1 _autotst.rrr |
| 1070 |
echo 2>&1 "*******************************************************" |
| 1071 |
echo 2>&1 "Your include files seem to be beyond repair <sigh>." |
| 1072 |
echo 2>&1 "I give up." |
| 1073 |
kill -15 $$ |
| 1074 |
fi |
| 1075 |
$MAKE _autotst >_autotst.rrr 2>&1 |
| 1076 |
$RM _autotst _autotst.$O |
| 1077 |
|
| 1078 |
# The simple ones |
| 1079 |
for func in strcspn strpbrk rename pow mkdir fstat initgroups \ |
| 1080 |
strtol waitpid ftruncate fsync strtod strncasecmp strlcat memset bzero _exit |
| 1081 |
do |
| 1082 |
grepfor $func "#define NO$func" |
| 1083 |
done |
| 1084 |
|
| 1085 |
NOstrerror=no |
| 1086 |
grepfor strerror "#define NOstrerror" && NOstrerror=yes |
| 1087 |
|
| 1088 |
grepfor opendir " |
| 1089 |
#define NOopendir /* the readdir library does not seem to be available |
| 1090 |
this will slightly affect the way a filenumber is |
| 1091 |
selected in MH-folders by procmail */ |
| 1092 |
" |
| 1093 |
a=no |
| 1094 |
grepfor setrgid '#define NOsetrgid' && a=yes |
| 1095 |
if grepfor setegid '#define NOsetegid' || test $a = yes |
| 1096 |
then |
| 1097 |
grepfor setregid '#define NOsetregid' && |
| 1098 |
grepfor setresgid '#define NOsetresgid' |
| 1099 |
fi |
| 1100 |
grepfor strchr '#define strchr(s,c) index(s,c)' |
| 1101 |
grepfor uname "\ |
| 1102 |
#define NOuname \ |
| 1103 |
/* <sys/utsname.h> defines it, the libraries don't */" |
| 1104 |
grepfor endpwent '#define endpwent()' |
| 1105 |
grepfor endgrent '#define endgrent()' |
| 1106 |
if grepfor gethostbyname '#define NO_COMSAT' |
| 1107 |
then |
| 1108 |
: |
| 1109 |
else |
| 1110 |
grepfor getprotobyname '#define UDP_protocolno 17' |
| 1111 |
grepfor endhostent '#define endhostent()' |
| 1112 |
grepfor endservent '#define endservent()' |
| 1113 |
grepfor endprotoent '#define endprotoent()' |
| 1114 |
fi |
| 1115 |
grepfor strstr '#define SLOWstrstr' || |
| 1116 |
grepfor clock '#define SLOWstrstr' |
| 1117 |
grepfor memmove '#define NOmemmove' && |
| 1118 |
if $FGREP -e bcopy _autotst.rrr >$DEVNULL |
| 1119 |
then |
| 1120 |
echo '#define NObcopy' >>$ACONF |
| 1121 |
|
| 1122 |
if test $NOstrerror = yes |
| 1123 |
then |
| 1124 |
cat >_autotst.c <<HERE |
| 1125 |
#include "includes.h" |
| 1126 |
extern int sys_nerr;extern char*sys_errlist[]; |
| 1127 |
int main(){ |
| 1128 |
return puts(sys_errlist[sys_nerr-1]);} |
| 1129 |
HERE |
| 1130 |
|
| 1131 |
echo 'Testing for sys_errlist' |
| 1132 |
if $MAKE _autotst.$O >_autotst.rrr 2>&1 |
| 1133 |
then |
| 1134 |
if $MAKE _autotst >_autotst.rrr 2>&1 |
| 1135 |
then |
| 1136 |
echo '' >_autotst.rrr |
| 1137 |
fi |
| 1138 |
fi |
| 1139 |
grepfor sys_errlist '#define NOsys_errlist' |
| 1140 |
$RM _autotst _autotst.$O _autotst.rrr |
| 1141 |
fi |
| 1142 |
|
| 1143 |
echo 'Testing for brain damage' |
| 1144 |
cat >_autotst.c <<HERE |
| 1145 |
#include "includes.h" |
| 1146 |
struct tests{int a,b;}; |
| 1147 |
int main(){ |
| 1148 |
return offsetof(struct tests,b);} |
| 1149 |
HERE |
| 1150 |
if $MAKE _autotst.$O >$DEVNULL 2>&1 |
| 1151 |
then |
| 1152 |
: |
| 1153 |
else |
| 1154 |
echo 'Yep, it is' # ISC chokes on its own offsetof() |
| 1155 |
echo '#define oBRAIN_DAMAGE' >>$ACONF |
| 1156 |
fi |
| 1157 |
$RM _autotst.$O |
| 1158 |
|
| 1159 |
else |
| 1160 |
|
| 1161 |
cat >_autotst.c <<HERE |
| 1162 |
#include "includes.h" |
| 1163 |
#define M256 256 |
| 1164 |
#define F33 33 |
| 1165 |
int main(){int j=0,i=M256-1;static char a[M256]; |
| 1166 |
do a[i]=i;while(i--); |
| 1167 |
bcopy(a+F33,a,M256-F33);bcopy(a,a+F33,M256-F33);i=F33-1; |
| 1168 |
do j|=a[i]!=(char)(i+F33);while(i--);i=M256-1; |
| 1169 |
do j|=a[i]!=(char)i;while(--i!=F33-1);return !j;} |
| 1170 |
HERE |
| 1171 |
|
| 1172 |
echo 'Testing for bcopy handling overlaps' |
| 1173 |
$MAKE _autotst >$DEVNULL 2>&1 |
| 1174 |
|
| 1175 |
if _autotst |
| 1176 |
then |
| 1177 |
echo 'Sorry, incompetent bcopy, using substitute instead' |
| 1178 |
echo '#define NObcopy' >>$ACONF |
| 1179 |
fi |
| 1180 |
$RM _autotst.$O _autotst |
| 1181 |
fi |
| 1182 |
test -f /bin/test && echo "#define GOT_bin_test" >>$ACONF |
| 1183 |
|
| 1184 |
cat >_autotst.c <<\HERE |
| 1185 |
#define BENCHSIZE 16384 |
| 1186 |
#define GRANULARITY 64 /* maximal benchmark granularity */ |
| 1187 |
#include "sublib.c" |
| 1188 |
#ifndef NO_COMSAT |
| 1189 |
#include "network.h" /* also for ntohs() */ |
| 1190 |
#endif |
| 1191 |
#undef malloc /* from shell.h */ |
| 1192 |
#ifdef BENCHSIZE |
| 1193 |
#undef strstr /* from includes.h */ |
| 1194 |
#undef free /* from shell.h */ |
| 1195 |
unsigned long dobench(strstr,iter,haystack)char*(*const strstr)(); |
| 1196 |
unsigned long iter;const char*const haystack; |
| 1197 |
{ unsigned long to; |
| 1198 |
to=(unsigned long)clock(); |
| 1199 |
do (*strstr)(haystack,FROM_EXPR); |
| 1200 |
while(--iter); |
| 1201 |
return (unsigned long)clock()-to; |
| 1202 |
} |
| 1203 |
#endif |
| 1204 |
int main(argc,argv)int argc;const char*argv[]; |
| 1205 |
{ if(argc==1) |
| 1206 |
{ char*haystack; |
| 1207 |
#ifdef BENCHSIZE |
| 1208 |
if(haystack=malloc(BENCHSIZE)) |
| 1209 |
{ unsigned c1,c2,i;time_t t; |
| 1210 |
unsigned long iter,titer,syscnt; |
| 1211 |
for(i=c1=c2=0;i<BENCHSIZE-1;i++,c1++,c2++) |
| 1212 |
{ haystack[i]='a'; |
| 1213 |
if(c1==37) |
| 1214 |
c1=0,haystack[i]='\n'; |
| 1215 |
if(c2==51) |
| 1216 |
c2=0,haystack[i]='\n'; |
| 1217 |
} |
| 1218 |
haystack[i]='\0'; |
| 1219 |
for(titer=~(unsigned long)0,t=0,iter=1;t<=1&&iter<<1&&iter<titer;) |
| 1220 |
{ t=time((time_t*)0); |
| 1221 |
if((syscnt=dobench(strstr,iter<<=1,haystack))&&!~titer) |
| 1222 |
titer=iter*GRANULARITY; |
| 1223 |
t=time((time_t*)0)-t; |
| 1224 |
} |
| 1225 |
iter=dobench(sstrstr,iter,haystack);free(haystack); |
| 1226 |
if(!syscnt) |
| 1227 |
syscnt=1; |
| 1228 |
if(!iter) |
| 1229 |
iter=1; |
| 1230 |
printf("\ |
| 1231 |
/* Your system's strstr() is %.2f times %sER than my C-routine */\n", |
| 1232 |
syscnt>=iter?(double)syscnt/iter:(double)iter/syscnt, |
| 1233 |
syscnt>=iter?"SLOW":"FAST"); |
| 1234 |
if(syscnt>iter+iter/16) /* if at least 1.0625 times slower */ |
| 1235 |
printf("\ |
| 1236 |
#define SLOWstrstr\t\t\t /* using my substitute instead */\n"); |
| 1237 |
} |
| 1238 |
else |
| 1239 |
printf("/* Insufficient memory to perform the benchmark! */\n"); |
| 1240 |
#endif /* SLOWstrstr */ |
| 1241 |
#ifndef NO_COMSAT |
| 1242 |
#ifndef UDP_protocolno |
| 1243 |
;{ const struct protoent*p; |
| 1244 |
if(p=getprotobyname(COMSATprotocol)) |
| 1245 |
{ printf("#define UDP_protocolno %d\n",p->p_proto); |
| 1246 |
#else |
| 1247 |
;{ if(1) |
| 1248 |
{ |
| 1249 |
#endif |
| 1250 |
;{ const struct servent*serv; |
| 1251 |
if(serv=getservbyname(COMSATservice,COMSATprotocol)) |
| 1252 |
printf("#define BIFF_serviceport \"%d\"\n", |
| 1253 |
ntohs(serv->s_port)); |
| 1254 |
} |
| 1255 |
#ifdef AF_INET |
| 1256 |
;{ const struct hostent*host; |
| 1257 |
if(!strcmp("localhost",COMSAThost)&& |
| 1258 |
(host=gethostbyname(COMSAThost))&& |
| 1259 |
host->h_0addr_list&&host->h_addrtype==AF_INET&& |
| 1260 |
host->h_length) |
| 1261 |
{ int j=host->h_length; |
| 1262 |
const unsigned char*ad=(void*)host->h_0addr_list; |
| 1263 |
printf("#define IP_localhost {"); |
| 1264 |
printf("%d",*ad++); |
| 1265 |
while(--j) |
| 1266 |
printf(",%d",*ad++); |
| 1267 |
puts("}"); |
| 1268 |
} |
| 1269 |
} |
| 1270 |
#endif /* AF_INET */ |
| 1271 |
} |
| 1272 |
else |
| 1273 |
puts("#define NO_COMSAT"); |
| 1274 |
} |
| 1275 |
#endif /* NO_COMSAT */ |
| 1276 |
;{ unsigned long s=(size_t)~0;int bits; |
| 1277 |
for(bits=1;s>>=1;bits++); |
| 1278 |
if(bits<=16) |
| 1279 |
{ puts("#define SMALLHEAP"); |
| 1280 |
return 0; |
| 1281 |
} |
| 1282 |
} |
| 1283 |
#ifdef _GUID_T /* ISC cc hack */ |
| 1284 |
;{ struct passwd*p; |
| 1285 |
if(sizeof(int)>sizeof(uid_t)&&(p=getpwnam("root"))&&(*p->pw_dir!='/'|| |
| 1286 |
(*p->pw_shell&&!(p->pw_shell)[1]))) |
| 1287 |
{ puts("#define _GUID_T\ntypedef int uid_t;\ntypedef int gid_t;"); |
| 1288 |
goto skipsetrgid; |
| 1289 |
} |
| 1290 |
} |
| 1291 |
#endif |
| 1292 |
#ifndef NOinitgroups |
| 1293 |
if(geteuid()==ROOT_uid) |
| 1294 |
{ setgid(2); |
| 1295 |
if(!setrgid(3)&&(getgid()!=3||getegid()!=2)) |
| 1296 |
puts("#define setrgid_BRAIN_DAMAGE"); |
| 1297 |
else |
| 1298 |
{ setuid(2); |
| 1299 |
if(!setgid(3)&&!setgid(2)) |
| 1300 |
puts("#define TOGGLE_SGID_OK"); |
| 1301 |
} |
| 1302 |
} |
| 1303 |
else |
| 1304 |
#ifndef NGROUPS_MAX /* is this safeguard really needed? */ |
| 1305 |
#define NGROUPS_MAX 3 |
| 1306 |
#endif /* some OSes expect an array of ints? */ |
| 1307 |
{ gid_t groups[NGROUPS_MAX*sizeof(int)/sizeof(gid_t)];unsigned i; |
| 1308 |
for(i=getgroups(NGROUPS_MAX,groups); |
| 1309 |
--i<NGROUPS_MAX&&groups[i]==getgid();); |
| 1310 |
if(i<NGROUPS_MAX) |
| 1311 |
{ setegid(groups[i]); |
| 1312 |
if(!setrgid(groups[i])&&getgid()!=groups[i]) |
| 1313 |
puts("#define setrgid_BRAIN_DAMAGE"); |
| 1314 |
} |
| 1315 |
else |
| 1316 |
puts("#define setrgid_RUNTIME_CHECK"); |
| 1317 |
} |
| 1318 |
#endif |
| 1319 |
skipsetrgid:; |
| 1320 |
} |
| 1321 |
#ifdef DEFsendmail |
| 1322 |
if(argc==3) |
| 1323 |
{ printf("#define SENDMAIL \"%s\"\n",DEFsendmail); |
| 1324 |
return 1; |
| 1325 |
} |
| 1326 |
#endif |
| 1327 |
if(argc==4) |
| 1328 |
{ FILE*fp; /* in case we are root */ |
| 1329 |
chown(argv[1],2,getegid());setuid(2); /* adjust the directory first */ |
| 1330 |
if(!(fp=fopen(argv[2],"w"))) |
| 1331 |
goto openerr; /* shouldn't happen, really */ |
| 1332 |
fclose(fp); /* always clean up after yourself */ |
| 1333 |
if(!chown(argv[2],geteuid()==3?4:3,getegid())) |
| 1334 |
openerr: |
| 1335 |
printf("#define CAN_chown\n"); |
| 1336 |
} |
| 1337 |
if(argc>4) |
| 1338 |
#define MAX_ENVMEM 2048 /* typical environment size */ |
| 1339 |
#define MAX_ARGMEM (2048*1024L) /* upper limit arguments size */ |
| 1340 |
{ static const char arg[]="e%04u=6789012345";unsigned diff; |
| 1341 |
charNUM(num,diff);char**nargv;const char*einfo=""; |
| 1342 |
#define MAXT(type) (~(type)0>>1) |
| 1343 |
sscanf(argv[1],"%u",&diff); /* what did our previous incarnation want? */ |
| 1344 |
if(!diff) /* first run? initialise the environment */ |
| 1345 |
{ char*envs,**nenviron,**nenv; |
| 1346 |
diff=MAX_ENVMEM/sizeof arg+1; |
| 1347 |
if(!(nenviron=malloc(diff*sizeof*environ+MAX_ENVMEM))) |
| 1348 |
goto printit; /* oops, panic already */ |
| 1349 |
envs=(char*)((nenv=nenviron)+diff); |
| 1350 |
while(--diff) /* put in some colour */ |
| 1351 |
sprintf(*nenviron++=envs,arg,diff),envs+=sizeof arg; |
| 1352 |
*(environ=nenv)="PATH=.";*nenviron=0;diff=argc; /* start doubling */ |
| 1353 |
} |
| 1354 |
if(MAX_ARGMEM/sizeof arg<=argc) /* we are satisfied */ |
| 1355 |
{ einfo=" /* soft limit */"; /* no reason to hog memory */ |
| 1356 |
goto printit; |
| 1357 |
} |
| 1358 |
;{ unsigned narg; |
| 1359 |
while(narg=argc+diff+1, /* allocate space for the new args */ |
| 1360 |
!(nargv=malloc(narg*sizeof*argv+(size_t)diff*sizeof arg))) |
| 1361 |
if(!(diff>>=1)) /* oops, no space, back off */ |
| 1362 |
goto printit; /* panic */ |
| 1363 |
tmemmove(nargv,argv,argc*sizeof*argv);nargv[1]=num; /* copy old */ |
| 1364 |
;{ char**pargv,*args;unsigned i; |
| 1365 |
pargv=nargv+argc;args=(char*)(nargv+narg);i=diff; |
| 1366 |
do |
| 1367 |
{ const char*p; /* and paint in the new ones */ |
| 1368 |
for(*pargv++=args,p=arg;*args++= *p++;); |
| 1369 |
} |
| 1370 |
while(--i); |
| 1371 |
} |
| 1372 |
} |
| 1373 |
for(;;diff>>=1) |
| 1374 |
{ unsigned newdiff=diff>>1; /* take a small step for mankind */ |
| 1375 |
if(argc==diff) /* or shall we boldly go */ |
| 1376 |
newdiff=(unsigned)argc<<1; /* where no man has gone before? */ |
| 1377 |
;{ unsigned maxdiff=MAXT(unsigned)-argc; |
| 1378 |
if(newdiff>maxdiff) /* that would overflow argc */ |
| 1379 |
newdiff=maxdiff; /* and we wouldn't want that, would we now? */ |
| 1380 |
} |
| 1381 |
if(!newdiff) /* reductio ad adsurdum? */ |
| 1382 |
break; /* yes, break off the engagement */ |
| 1383 |
sprintf(num,"%u",newdiff);nargv[argc+diff]=0; /* pass on the target */ |
| 1384 |
execv(argv[0],nargv); /* jeronimo! */ |
| 1385 |
} |
| 1386 |
printit: /* we proudly present the findings */ |
| 1387 |
printf("#define MAX_argc %d%s\n",argc-2,einfo); /* of the jury! */ |
| 1388 |
} |
| 1389 |
return EXIT_SUCCESS; |
| 1390 |
} |
| 1391 |
HERE |
| 1392 |
|
| 1393 |
echo "Determining the maximum number of 16 byte arguments execv() takes" |
| 1394 |
|
| 1395 |
if $MAKE _autotst >$DEVNULL 2>_autotst.rrr && |
| 1396 |
_autotst 0 012345678901234 012345678901234 012345678901234 \ |
| 1397 |
>>$ACONF 2>>_autotst.rrr |
| 1398 |
then |
| 1399 |
: |
| 1400 |
else |
| 1401 |
echo 2>&1 "Whoeaaa! This actually can't happen." |
| 1402 |
echo 2>&1 "You have a look and see if you detect anything uncanny:" |
| 1403 |
echo 2>&1 "*******************************************************" |
| 1404 |
cat 2>&1 _autotst.rrr |
| 1405 |
echo 2>&1 "*******************************************************" |
| 1406 |
echo 2>&1 "I suggest you take a look at the definition of LDFLAGS*" |
| 1407 |
echo 2>&1 "in the Makefile before you try make again." |
| 1408 |
kill -15 $$ |
| 1409 |
fi |
| 1410 |
|
| 1411 |
$RM _autotst.rrr |
| 1412 |
|
| 1413 |
echo "Benchmarking your system's strstr() implementation" |
| 1414 |
|
| 1415 |
_autotst >>$ACONF |
| 1416 |
|
| 1417 |
found=no |
| 1418 |
|
| 1419 |
for a in /var/mail /var/spool/mail /usr/spool/mail /usr/mail /spool/mail |
| 1420 |
do |
| 1421 |
test -d $a -a $found != yes && |
| 1422 |
echo '#define MAILSPOOLDIR "'$a'/"' >>$ACONF && found=yes |
| 1423 |
done |
| 1424 |
if test $found != yes |
| 1425 |
then |
| 1426 |
echo '#define MAILSPOOLDIR "/var/mail/"' >>$ACONF |
| 1427 |
echo Could not find the system-mailbox directory, supplied default. |
| 1428 |
fi |
| 1429 |
|
| 1430 |
cat >lookfor <<HERE |
| 1431 |
for a in /usr/sbin /usr/lib /lib /usr/etc /etc /usr/bin /bin /usr/local/bin \ |
| 1432 |
/usr/lbin /usr/local/lib /usr/local /usr/.lib /local/bin /sbin |
| 1433 |
do |
| 1434 |
if test -f "\$a/\$1" |
| 1435 |
then |
| 1436 |
echo '#define SENDMAIL "'"\$a/\$1"'"' >>$ACONF |
| 1437 |
exit 0 |
| 1438 |
fi |
| 1439 |
done |
| 1440 |
exit 1 |
| 1441 |
HERE |
| 1442 |
chmod 0755 lookfor |
| 1443 |
|
| 1444 |
if _autotst 2 3 >>$ACONF |
| 1445 |
test $? != 0 || |
| 1446 |
lookfor sendmail || lookfor smail || lookfor mail #|| lookfor rmail |
| 1447 |
then |
| 1448 |
: |
| 1449 |
else |
| 1450 |
echo 'Could not find any mailer. It should be a mailer accepting at least' |
| 1451 |
echo 'one plain destination address as its only argument (any sendmail' |
| 1452 |
echo 'compatible mailer will do), and the mail-to-be-sent on stdin.' |
| 1453 |
echo 'What is your mailer called? (You can override this in config.h)' |
| 1454 |
read a |
| 1455 |
echo "#define SENDMAIL \"$a\"" >>$ACONF |
| 1456 |
fi |
| 1457 |
|
| 1458 |
grep '^#define SENDMAIL ".*/sendmail"' $ACONF >$DEVNULL || |
| 1459 |
echo "#define DEFflagsendmail \"\"" >>$ACONF |
| 1460 |
|
| 1461 |
a=/tmp/_chowntst.$$ |
| 1462 |
$RM -r $a |
| 1463 |
OLDTESTDIRS="$a $OLDTESTDIRS" |
| 1464 |
mkdir $a |
| 1465 |
mkdir $a/__ |
| 1466 |
|
| 1467 |
_autotst $a/__ $a/__/__ 4 >>$ACONF |
| 1468 |
|
| 1469 |
cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL | |
| 1470 |
grep 'Mlocal.*procmail' >$DEVNULL || |
| 1471 |
echo '#define CF_no_procmail_yet' >>$ACONF |
| 1472 |
|
| 1473 |
# cat /usr/lib/sendmail.cf /etc/sendmail.cf /etc/mail/sendmail.cf 2>$DEVNULL | |
| 1474 |
# grep '^V' >$DEVNULL || |
| 1475 |
# echo '#define buggy_SENDMAIL' >>$ACONF |
| 1476 |
|
| 1477 |
lpath='/bin' |
| 1478 |
bins="/bin" |
| 1479 |
|
| 1480 |
for newd in /usr/bin $BINDIR /usr/bin/X11 /usr/X*/bin |
| 1481 |
do |
| 1482 |
if test -d $newd |
| 1483 |
then |
| 1484 |
oldid=`cd $newd; ls -id . .. ../.. 2>&1` |
| 1485 |
for oldd in $bins |
| 1486 |
do |
| 1487 |
test "X`cd $oldd; ls -id . .. ../.. 2>&1`" = "X$oldid" && oldid=found |
| 1488 |
done |
| 1489 |
test found != "$oldid" && bins="$bins $newd" && lpath="$lpath:$newd" |
| 1490 |
fi |
| 1491 |
done |
| 1492 |
|
| 1493 |
echo "#define defPATH \"PATH=\$HOME/bin:$lpath\"" >>$ACONF |
| 1494 |
echo "#define defSPATH \"PATH=$lpath\"" >>$ACONF |
| 1495 |
|
| 1496 |
sed -n -e 's/^ v\([^ ]*\) .*$/#define PM_VERSION "\1"/p' \ |
| 1497 |
../patchlevel.h >>$ACONF |
| 1498 |
|
| 1499 |
while $FGREP -e "Kernel-locking tests completed." _locktst.rrr >$DEVNULL; \ |
| 1500 |
test 0 != $? |
| 1501 |
do |
| 1502 |
if test -z "$tailpid" |
| 1503 |
then |
| 1504 |
echo "Waiting for the kernel-locking tests to finish..." |
| 1505 |
exec 9>&2 2>$DEVNULL |
| 1506 |
tail -f lock.log & |
| 1507 |
tailpid=$! |
| 1508 |
exec 2>&9 9>&- |
| 1509 |
fi |
| 1510 |
# if test ! -f _locktst.alive |
| 1511 |
# then |
| 1512 |
# echo >_locktst.alive |
| 1513 |
# echo "Waiting for kernel-locking tests to finish..." |
| 1514 |
# fi |
| 1515 |
sleep 4 |
| 1516 |
done |
| 1517 |
exec 9>&2 2>$DEVNULL |
| 1518 |
test ! -z "$tailpid" && kill $tailpid && echo "" && echo "" |
| 1519 |
tailpid="" |
| 1520 |
wait # wait now, to prevent a notification message afterward |
| 1521 |
exec 2>&9 9>&- |
| 1522 |
echo "Collecting results from kernel-locking tests" |
| 1523 |
sed -e '/^Kernel-locking tests completed./,$ d' <_locktst.rrr >>$ACONF |
| 1524 |
set dummy *core* |
| 1525 |
if test -f $2 -a $nocore = yes |
| 1526 |
then |
| 1527 |
echo "Removing core file (probably from the locking tests)" |
| 1528 |
$RM *core* |
| 1529 |
fi |
| 1530 |
|
| 1531 |
echo "/* autoconf completed */" >>$ACONF |
| 1532 |
|
| 1533 |
$RM -r $OLDTESTDIRS $OLDTESTDIRS 2>$DEVNULL |
| 1534 |
$RM _autotst* _locktst* lookfor grepfor 2>$DEVNULL |
| 1535 |
|
| 1536 |
echo =============================autoconf.h=================================== |
| 1537 |
cat $ACONF |
| 1538 |
echo ========================================================================== |