ngircd: Add support for GLOBAL_PASSWORD
authorW. Trevor King <wking@tremily.us>
Sat, 1 Mar 2014 05:44:28 +0000 (21:44 -0800)
committerW. Trevor King <wking@tremily.us>
Sat, 1 Mar 2014 17:09:09 +0000 (09:09 -0800)
We need to disable PAM support at compile time to get this working,
because with PAM compiled in global password are broken until 485d0ae
(Use server password when PAM is compiled in but disabled, 2014-02-27,
[1]).  485d0ae landed after ngIRCd v21, so it will probably be in the
next release after that.  Once that lands in Gentoo's Portage tree, we
can re-enable PAM.

[1]: http://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git;a=commit;h=485d0aec813db9966922f17aae044df2d82b0b67

ngircd/Dockerfile.template
ngircd/README.md
ngircd/setup-ngircd-config-from-environment.sh

index ff97fa3aca926b07b63b0c16bbbc33594a8b719b..1a23fafb0fb6653c1b593ae4a0c7bcc48d4abdaa 100644 (file)
@@ -26,6 +26,7 @@ FROM ${NAMESPACE}/gentoo-syslog:${TAG}
 MAINTAINER ${MAINTAINER}
 #VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
 RUN echo 'net-irc/ngircd ~amd64' >> /etc/portage/package.accept_keywords
+RUN echo 'net-irc/ngircd -pam' >> /etc/portage/package.use
 RUN emerge -v net-irc/ngircd
 RUN eselect news read new
 RUN rc-update add ngircd default
index 749728870b49c6aa9d6c921dc611cb006577c073..01cc1b280e68c6d41a429a669f96c534ffb90432 100644 (file)
@@ -28,6 +28,9 @@ and the [unencrypted port][6667]:
     >   …
     >   -p 6667:6667 -p 6697:6697 wking/ngircd
 
+You can optionally set a `GLOBAL_PASSWORD` environment variable to
+require a global password for all client connections.
+
 [ngIRCd]: http://ngircd.barton.de/
 [TLS]: http://en.wikipedia.org/wiki/Transport_Layer_Security
 [volume-mount]: http://docs.docker.io/en/latest/use/working_with_volumes/
index c957f40ed4a1c40f37d576845239f681e1f9e578..f3544710c35d8723a14bb5b01c3aab0090e59fe3 100755 (executable)
 #        EMAIL="admin@example.net" INFO="testing, testing" \
 #        setup-ngircd-config-from-environment
 
+ENVSUBST='
+       ${HOSTNAME}
+       ${DESCRIPTION}
+       ${LOCATION}
+       ${EMAIL}
+       ${INFO}
+       '
+
+if [ -n "${GLOBAL_PASSWORD}" ]
+then
+       ENVSUBST="${ENVSUBST} \${GLOBAL_PASSWORD}"
+       # In lines matching '# Global password' or the two succeeding lines,
+       # replace ';Password = .*' with 'Password = ${GLOBAL_PASSWORD}'
+       sed -i '/# Global password/,+2 s/;Password = .*/Password = ${GLOBAL_PASSWORD}/' /etc/ngircd/ngircd.conf
+fi
+
 HOSTNAME=$(hostname -f) \
-       envsubst '
-               ${HOSTNAME}
-               ${DESCRIPTION}
-               ${LOCATION}
-               ${EMAIL}
-               ${INFO}
-               ' \
-               < /etc/ngircd/ngircd.conf > /tmp/ngircd.conf &&
+       envsubst "${ENVSUBST}" < /etc/ngircd/ngircd.conf > /tmp/ngircd.conf &&
 mv /tmp/ngircd.conf /etc/ngircd/ngircd.conf
 
 if [ "${SSL}" = 'yes' ]