the stuff

heads-sup-compile 976B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2016-2018 Ivan J. <parazyd@dyne.org>
  4. # See LICENSE file for copyright and license details.
  5. SUPSRC="/usr/src/sup"
  6. BINS="
  7. /usr/local/bin/heads-init
  8. /usr/local/bin/heads-generate-debug
  9. "
  10. printsettings() {
  11. cat <<EOF
  12. /* sup's configuration file */
  13. #define HASH 1
  14. #define DAEMON 0
  15. #ifndef FLAGSONLY
  16. #define USER 1000
  17. #define GROUP -1
  18. #define SETUID 0
  19. #define SETGID 0
  20. #define CHROOT ""
  21. #define CHRDIR ""
  22. static struct rule_t rules[] = {
  23. /* allow user to run these programs when found in path location */
  24. EOF
  25. }
  26. printrest() {
  27. cat <<EOF
  28. { 0 },
  29. };
  30. #endif
  31. EOF
  32. }
  33. getsha() {
  34. sha256sum "$1" | cut -d' ' -f1
  35. }
  36. cd $SUPSRC
  37. printsettings > config.h
  38. for exe in $BINS; do
  39. which "$exe" >/dev/null 2>&1 || continue
  40. printf "\t{ USER, GROUP, \"%s\", \"%s\", \"%s\" },\n" \
  41. "$(basename $exe)" "$exe" "$(getsha $exe)" >> config.h
  42. done
  43. printrest >> config.h
  44. CFLAGS="-Os -fPIE -fstack-protector-all" LDFLAGS="-s -pie" \
  45. make musl && make install