pakur.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. make DESTDIR=$PKG install
  2. sed -i 's/yes/no/' $PKG/etc/default/useradd
  3. sed -i 's/GROUP/# GROUP/' $PKG/etc/default/useradd
  4. # Following sed comment appropriate lines in etc/login.defs, and stop login
  5. # from performing these functions. First backup the etc/login.defs
  6. install -v -m644 $PKG/etc/login.defs{,.orig}
  7. for FUNCTION in FAIL_DELAY FAILLOG_ENAB \
  8. LASTLOG_ENAB \
  9. MAIL_CHECK_ENAB \
  10. OBSCURE_CHECKS_ENAB \
  11. PORTTIME_CHECKS_ENAB \
  12. QUOTAS_ENAB \
  13. CONSOLE MOTD_FILE \
  14. FTMP_FILE NOLOGINS_FILE \
  15. ENV_HZ PASS_MIN_LEN \
  16. SU_WHEEL_ONLY \
  17. CRACKLIB_DICTPATH \
  18. PASS_CHANGE_TRIES \
  19. PASS_ALWAYS_WARN \
  20. CHFN_AUTH ENCRYPT_METHOD \
  21. ENVIRON_FILE
  22. do
  23. sed -i "s/^${FUNCTION}/# &/" $PKG/etc/login.defs
  24. done
  25. #
  26. # Configuration files for pam
  27. mkdir -p $PKG/etc/pam.d
  28. cat > $PKG/etc/pam.d/system-account << "EOF"
  29. # Begin /etc/pam.d/system-account
  30. account required pam_unix.so
  31. # End /etc/pam.d/system-account
  32. EOF
  33. cat > $PKG/etc/pam.d/system-auth << "EOF"
  34. # Begin /etc/pam.d/system-auth
  35. auth required pam_unix.so
  36. # End /etc/pam.d/system-auth
  37. EOF
  38. cat > $PKG/etc/pam.d/system-password << "EOF"
  39. # Begin /etc/pam.d/system-password
  40. # use sha512 hash for encryption, use shadow, and try to use any previously
  41. # defined authentication token (chosen password) set by any prior module
  42. password required pam_pwhistory.so retry=3
  43. password required pam_unix.so sha512 shadow try_first_pass
  44. # End /etc/pam.d/system-password
  45. EOF
  46. cat > $PKG/etc/pam.d/system-session << "EOF"
  47. # Begin /etc/pam.d/system-session
  48. session required pam_unix.so
  49. session optional pam_loginuid.so
  50. session optional pam_ck_connector.so nox11
  51. # Systemd additions
  52. session required pam_loginuid.so
  53. session optional pam_systemd.do
  54. # End /etc/pam.d/system-session
  55. EOF
  56. cat > $PKG/etc/pam.d/login << "EOF"
  57. # Begin /etc/pam.d/login
  58. # Set failure delay before next prompt to 3 seconds
  59. auth optional pam_faildelay.so delay=3000000
  60. # Check to make sure that the user is allowed to login
  61. auth requisite pam_nologin.so
  62. # Check to make sure that root is allowed to login
  63. # Disabled by default. You will need to create /etc/securetty
  64. # file for this module to function. See man 5 securetty.
  65. #auth required pam_securetty.so
  66. # Additional group memberships - disabled by default
  67. #auth optional pam_group.so
  68. # include the default auth settings
  69. auth include system-auth
  70. # check access for the user
  71. account required pam_access.so
  72. # include the default account settings
  73. account include system-account
  74. # Set default environment variables for the user
  75. session required pam_env.so
  76. # Set resource limits for the user
  77. session required pam_limits.so
  78. # Display date of last login - Disabled by default
  79. #session optional pam_lastlog.so
  80. # Display the message of the day - Disabled by default
  81. #session optional pam_motd.so
  82. # Check user's mail - Disabled by default
  83. #session optional pam_mail.so standard quiet
  84. # include the default session and password settings
  85. session include system-session
  86. password include system-password
  87. # End /etc/pam.d/login
  88. EOF
  89. cat > $PKG/etc/pam.d/passwd << "EOF"
  90. # Begin /etc/pam.d/passwd
  91. password include system-password
  92. # End /etc/pam.d/passwd
  93. EOF
  94. cat > $PKG/etc/pam.d/su << "EOF"
  95. # Begin /etc/pam.d/su
  96. # always allow root
  97. auth sufficient pam_rootok.so
  98. auth include system-auth
  99. # include the default account settings
  100. account include system-account
  101. # Set default environment variables for the service user
  102. session required pam_env.so
  103. # include system session defaults
  104. session include system-session
  105. # End /etc/pam.d/su
  106. EOF
  107. cat > $PKG/etc/pam.d/chage << "EOF"
  108. #Begin /etc/pam.d/chage
  109. # always allow root
  110. auth sufficient pam_rootok.so
  111. # include system defaults for auth account and session
  112. auth include system-auth
  113. account include system-account
  114. session include system-session
  115. # Always permit for authentication updates
  116. password required pam_permit.so
  117. # End /etc/pam.d/chage
  118. EOF
  119. for PROGRAM in chfn chgpasswd chpasswd chsh groupadd groupdel \
  120. groupmems groupmod newusers useradd userdel usermod
  121. do
  122. install -v -m644 $PKG/etc/pam.d/chage $PKG/etc/pam.d/${PROGRAM}
  123. sed -i "s/chage/$PROGRAM/" $PKG/etc/pam.d/${PROGRAM}
  124. done
  125. # Backup others
  126. [ -f $PKG/pam.d/other ] && install -v -m644 $PKG/etc/pam.d/other{,.orig}
  127. # Other
  128. #
  129. cat > $PKG/etc/pam.d/other << "EOF"
  130. # Begin /etc/pam.d/other
  131. auth required pam_warn.so
  132. auth required pam_deny.so
  133. account required pam_warn.so
  134. account required pam_deny.so
  135. password required pam_warn.so
  136. password required pam_deny.so
  137. session required pam_warn.so
  138. session required pam_deny.so
  139. # End /etc/pam.d/other
  140. EOF
  141. rm $PKG/usr/share/man/man8/nologin.8
  142. rm -f $PKG/etc/limits
  143. rm -f $PKG/etc/login.access
  144. mv $PKG/usr/sbin/* $PKG/usr/bin/
  145. rm -rf $PKG/usr/sbin