@@ -295,6 +295,7 @@ opt manage-submodules 1 "let the build manage the git submodules"
295
295
opt mingw-cross 0 " cross-compile for win32 using mingw"
296
296
opt clang 0 " prefer clang to gcc for building the runtime"
297
297
opt local-rust 0 " use an installed rustc rather than downloading a snapshot"
298
+ opt pax-flags 0 " apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
298
299
valopt prefix " /usr/local" " set installation prefix"
299
300
valopt local-rust-root " /usr/local" " set prefix for local rust binary"
300
301
valopt llvm-root " " " set LLVM root"
@@ -343,6 +344,11 @@ probe CFG_PDFLATEX pdflatex
343
344
probe CFG_XETEX xetex
344
345
probe CFG_LUATEX luatex
345
346
probe CFG_NODE nodejs node
347
+ if [ " $CFG_OSTYPE " = " unknown-linux-gnu" ]
348
+ then
349
+ probe CFG_PAXCTL paxctl /sbin/paxctl
350
+ probe CFG_ZCAT zcat
351
+ fi
346
352
347
353
if [ ! -z " $CFG_PANDOC " ]
348
354
then
@@ -354,6 +360,51 @@ then
354
360
fi
355
361
fi
356
362
363
+ if [ " $CFG_OSTYPE " = " unknown-linux-gnu" ]
364
+ then
365
+ if [ ! -z " $CFG_ENABLE_PAX_FLAGS " -a -z " $CFG_PAXCTL " ]
366
+ then
367
+ err " enabled PaX markings but no paxctl binary found"
368
+ fi
369
+
370
+ if [ -z " $CFG_DISABLE_PAX_FLAGS " ]
371
+ then
372
+ # GRSecurity/PaX detection. This can be very flaky.
373
+ GRSEC_DETECTED=
374
+
375
+ # /dev/grsec only exists if CONFIG_GRKERNSEC_NO_RBAC is not set.
376
+ # /proc/sys/kernel/grsecurity is not available if ÇONFIG_GRKERNSEC_SYSCTL is not set.
377
+ if [ -e /dev/grsec -o -d /proc/sys/kernel/grsecurity ]
378
+ then
379
+ GRSEC_DETECTED=1
380
+ # /proc/config.gz is normally only available to root, and only if CONFIG_IKCONFIG_PROC has been set.
381
+ elif [ -r /proc/config.gz -a ! -z " $CFG_ZCAT " ]
382
+ then
383
+ if " $CFG_ZCAT " /proc/config.gz | grep --quiet " CONFIG_GRKERNSEC=y"
384
+ then
385
+ GRSEC_DETECTED=1
386
+ fi
387
+ # Flaky.
388
+ elif grep --quiet grsec /proc/version
389
+ then
390
+ GRSEC_DETECTED=1
391
+ fi
392
+
393
+ if [ ! -z " $GRSEC_DETECTED " ]
394
+ then
395
+ step_msg " GRSecurity: yes"
396
+ if [ ! -z " $CFG_PAXCTL " ]
397
+ then
398
+ CFG_ENABLE_PAX_FLAGS=1
399
+ else
400
+ warn " GRSecurity kernel detected but no paxctl binary found: not setting CFG_ENABLE_PAX_FLAGS"
401
+ fi
402
+ else
403
+ step_msg " GRSecurity: no"
404
+ fi
405
+ fi
406
+ fi
407
+
357
408
if [ ! -z " $CFG_ENABLE_LOCAL_RUST " ]
358
409
then
359
410
if [ ! -f ${CFG_LOCAL_RUST_ROOT} /bin/rustc ]
@@ -523,15 +574,23 @@ then
523
574
msg " git: submodule sync"
524
575
" ${CFG_GIT} " submodule --quiet sync
525
576
577
+ msg " git: submodule update"
578
+ " ${CFG_GIT} " submodule --quiet update --init
579
+ need_ok " git failed"
580
+
581
+ msg " git: submodule foreach sync"
582
+ " ${CFG_GIT} " submodule --quiet foreach --recursive git submodule sync
583
+ need_ok " git failed"
584
+
585
+ msg " git: submodule foreach update"
586
+ " ${CFG_GIT} " submodule --quiet update --init --recursive
587
+ need_ok " git failed"
588
+
526
589
# NB: this is just for the sake of getting the submodule SHA1 values
527
590
# and status written into the build log.
528
591
msg " git: submodule status"
529
592
" ${CFG_GIT} " submodule status --recursive
530
593
531
- msg " git: submodule update"
532
- " ${CFG_GIT} " submodule --quiet update --init --recursive
533
- need_ok " git failed"
534
-
535
594
msg " git: submodule clobber"
536
595
" ${CFG_GIT} " submodule --quiet foreach --recursive git clean -dxf
537
596
need_ok " git failed"
@@ -699,6 +758,12 @@ putvar CFG_C_COMPILER
699
758
putvar CFG_LIBDIR
700
759
putvar CFG_DISABLE_MANAGE_SUBMODULES
701
760
761
+ if [ ! -z " $CFG_ENABLE_PAX_FLAGS " ]
762
+ then
763
+ putvar CFG_ENABLE_PAX_FLAGS
764
+ putvar CFG_PAXCTL
765
+ fi
766
+
702
767
if [ ! -z $BAD_PANDOC ]
703
768
then
704
769
CFG_PANDOC=
0 commit comments