popa3d-1.0.2-r1.ebuild 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=4
  4. inherit eutils toolchain-funcs user
  5. #
  6. # Mailbox format is determined by the 'mbox' and 'maildir'
  7. # system USE flags.
  8. #
  9. # Mailbox path configuration denoted by the system USE
  10. # flags.
  11. #
  12. # USE flag 'maildir' denotes ~/.maildir
  13. # USE flag 'mbox' denotes /var/mail/username
  14. #
  15. # You can overwrite this by setting the POPA3D_HOME_MAILBOX
  16. # environmental variable (see below) before emerge.
  17. #
  18. # Environmental variables.
  19. #
  20. # POPA3D_HOME_MAILBOX
  21. #
  22. # Overwrite the local user mailbox path. For example
  23. # if you want qmail-styled ~/Mailbox you can set it
  24. # to "Mailbox". For the traditional (although not in
  25. # gentoo Maildir) set it to "Maildir".
  26. #
  27. # POPA3D_VIRTUAL_ONLY
  28. #
  29. # Set this field to "YES" if you dont want local users
  30. # to have POP access. Setting this makes the POPA3D_HOME_MAILBOX
  31. # variable effectively useless.
  32. #
  33. # POPA3D_VIRTUAL_HOME_PATH
  34. #
  35. # Set this field to the base virtual home path. For more information
  36. # read the virtual guide here: https://forums.gentoo.org/viewtopic.php?t=82386
  37. #
  38. ######
  39. # 12/07/2005 - port001
  40. # Version 1.0 introduced some increased default values for a number of
  41. # configuration paramaters. These values are way too high for most systems.
  42. MAX_SESSIONS=100 # Default is 500
  43. MAX_SESSIONS_PER_SOURCE=10 # Default is 50
  44. MAX_MAILBOX_MESSAGES=100000 # Default is 2097152
  45. MAX_MAILBOX_OPEN_BYTES=100000000 # Default is 2147483647
  46. MAX_MAILBOX_WORK_BYTES=150000000 # Default is 2147483647
  47. ######
  48. IUSE="pam mbox +maildir"
  49. DESCRIPTION="A security oriented POP3 server"
  50. HOMEPAGE="http://www.openwall.com/popa3d/"
  51. SRC_URI="http://www.openwall.com/popa3d/${P}.tar.gz
  52. mirror://gentoo/popa3d-0.6.3-vname-2.diff.gz
  53. maildir? ( mirror://gentoo/popa3d-0.5.9-maildir-2.diff.gz )"
  54. LICENSE="Openwall"
  55. SLOT="0"
  56. KEYWORDS="amd64 ppc sparc x86"
  57. DEPEND=">=sys-apps/sed-4
  58. pam? ( >=sys-libs/pam-0.72
  59. >=net-mail/mailbase-0.00-r8[pam] )"
  60. RDEPEND="${DEPEND}"
  61. REQUIRED_USE="^^ ( maildir mbox )"
  62. pkg_setup() {
  63. echo
  64. ewarn
  65. ewarn "You can customize this ebuild with environmental variables."
  66. ewarn "If you don't set any I'll assume sensible defaults."
  67. ewarn
  68. ewarn "See inside this ebuild for details."
  69. ewarn
  70. echo
  71. enewgroup popa3d
  72. enewuser popa3d -1 -1 -1 popa3d
  73. }
  74. src_prepare(){
  75. epatch "${DISTDIR}"/popa3d-0.6.3-vname-2.diff.gz
  76. use maildir && epatch "${DISTDIR}"/popa3d-0.5.9-maildir-2.diff.gz
  77. }
  78. src_compile() {
  79. sed -i \
  80. -e "s:^\(#define MAX_SESSIONS\) .*$:\1 ${MAX_SESSIONS}:" \
  81. -e "s:^\(#define MAX_SESSIONS_PER_SOURCE\).*$:\1 ${MAX_SESSIONS_PER_SOURCE}:" \
  82. -e "s:^\(#define MAX_MAILBOX_MESSAGES\).*$:\1 ${MAX_MAILBOX_MESSAGES}:" \
  83. -e "s:^\(#define MAX_MAILBOX_OPEN_BYTES\).*$:\1 ${MAX_MAILBOX_OPEN_BYTES}:" \
  84. -e "s:^\(#define MAX_MAILBOX_WORK_BYTES\).*$:\1 ${MAX_MAILBOX_WORK_BYTES}:" \
  85. params.h || die "sed on params.h failed (1)"
  86. if use maildir ; then
  87. einfo "Mailbox format is: MAILDIR."
  88. if [[ -z ${POPA3D_HOME_MAILBOX} ]] ; then
  89. POPA3D_HOME_MAILBOX=".maildir"
  90. fi
  91. else
  92. einfo "Mailbox format is: MAILBOX."
  93. fi
  94. if [[ -n ${POPA3D_HOME_MAILBOX} ]] ; then
  95. einfo "Mailbox path: ~/${POPA3D_HOME_MAILBOX}"
  96. sed -i \
  97. -e "s:^\(#define MAIL_SPOOL_PATH.*\)$://\1:" \
  98. -e "s:^\(#define HOME_MAILBOX_NAME\).*$:\1 \"${POPA3D_HOME_MAILBOX}\":" \
  99. params.h || die "sed on params.h failed (2)"
  100. else
  101. einfo "Mailbox path: /var/mail/username"
  102. fi
  103. if [[ ${POPA3D_VIRTUAL_ONLY} = "YES" ]] ; then
  104. einfo "Virtual only, no local system users"
  105. sed -i -e "s:^\(#define VIRTUAL_ONLY\).*$:\1 1:" \
  106. params.h || die "sed on param.h failed (2.5)"
  107. fi
  108. if [[ -n ${POPA3D_VIRTUAL_HOME_PATH} ]] ; then
  109. einfo "Virtual home path set to: ${POPA3D_VIRTUAL_HOME_PATH}"
  110. sed -i \
  111. -e "s:^\(#define VIRTUAL_HOME_PATH\).*$:\1 \"$POPA3D_VIRTUAL_HOME_PATH\":" \
  112. params.h || die "sed on params.h failed (3)"
  113. fi
  114. if [[ ${POPA3D_VIRTUAL_ONLY} = "YES" ]] ; then
  115. einfo "Authentication method: Virtual."
  116. elif use pam ; then
  117. einfo "Authentication method: PAM."
  118. LIBS="${LIBS} -lpam"
  119. sed -i \
  120. -e "s:^\(#define AUTH_SHADOW\)[[:blank:]].*$:\1 0:" \
  121. -e "s:^\(#define AUTH_PAM\)[[:blank:]].*$:\1 1:" \
  122. params.h || die "sed on params.h failed (4)"
  123. else
  124. einfo "Authentication method: Shadow."
  125. fi
  126. sed -i \
  127. -e "s:^\(#define POP_STANDALONE\).*$:\1 1:" \
  128. -e "s:^\(#define POP_VIRTUAL\).*$:\1 1:" \
  129. -e "s:^\(#define VIRTUAL_VNAME\).*$:\1 1:" \
  130. params.h || die "sed on params.h failed (5)"
  131. sed -i \
  132. -e '/^CC =/d' \
  133. -e '/^CFLAGS =/d' \
  134. -e '/^LDFLAGS =/d' \
  135. Makefile || die "Makefile cleaning failed"
  136. emake LIBS="${LIBS} -lcrypt" \
  137. CFLAGS="${CFLAGS}" \
  138. LDFLAGS="${LDFLAGS}" \
  139. CC=$(tc-getCC)
  140. }
  141. src_install() {
  142. into /usr
  143. dosbin popa3d
  144. doman popa3d.8
  145. dodoc DESIGN INSTALL CHANGES VIRTUAL CONTACT
  146. diropts -m 755
  147. dodir /var/empty
  148. keepdir /var/empty
  149. newinitd "${FILESDIR}"/popa3d-initrc popa3d
  150. if use pam ; then
  151. dodir /etc/pam.d/
  152. dosym /etc/pam.d/pop /etc/pam.d/popa3d
  153. fi
  154. }