Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/webmin/, app-admin/webmin/files/
Date: Sun, 14 Oct 2018 13:03:06
Message-Id: 1539522142.37700521dc61e1ca761f09d49def71eeafa0fb77.pacho@gentoo
1 commit: 37700521dc61e1ca761f09d49def71eeafa0fb77
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 14 12:24:17 2018 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 14 13:02:22 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=37700521
7
8 app-admin/webmin: Version bump (#600422 by PhobosK)
9
10 Closes: https://bugs.gentoo.org/600422
11 Closes: https://bugs.gentoo.org/596618
12 Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>
13 Package-Manager: Portage-2.3.51, Repoman-2.3.11
14
15 app-admin/webmin/Manifest | 2 +
16 app-admin/webmin/files/gentoo-setup | 438 +++++++++++++++++++++++++++++++++++
17 app-admin/webmin/webmin-1.881.ebuild | 314 +++++++++++++++++++++++++
18 3 files changed, 754 insertions(+)
19
20 diff --git a/app-admin/webmin/Manifest b/app-admin/webmin/Manifest
21 index d44939e7a89..47a2615820d 100644
22 --- a/app-admin/webmin/Manifest
23 +++ b/app-admin/webmin/Manifest
24 @@ -1,2 +1,4 @@
25 DIST webmin-1.791-minimal.tar.gz 2635024 BLAKE2B a817063c722586c99f19156733c2efbc87515498ae0238ba393c1f0a7e59726d1a6b4f797469128a75b8ab3b92d8a3fcfc2117a281a42e2a993c44d8ca0b8514 SHA512 e8e7b43865399e918ef017d4d710b21cc7ce2f6566056faa82d756be29f038e07a20055978531f8785639c78339970fbfeabd4a4aa1fa4b331f3a344a78954d2
26 DIST webmin-1.791.tar.gz 28800013 BLAKE2B 90bcb65131b559f5a0e45aea6cc2735269ddbc49e91604cc37cac0951423ef57c4e1e8496aff1105925f67bce1d2ea10392fa73ca3ed4d714d12f14c76da1e27 SHA512 4ba19f057ee70bc0a283753a6c190bbae15f0e2af1650ef1656c7b94e07a6750203ef3b7190f7abd544b25988446df6b174bf06191426893bd4224e54451e771
27 +DIST webmin-1.881-minimal.tar.gz 2827351 BLAKE2B b8ea9964147c09c91413fbdad3b6a0e5161497296bb33b614161e370ac1292ac9cdf752483835fb279aa70ba41eb09f2774d08caa58861049e467346ad0b64ff SHA512 5b855c5562a6eb6a8fd836e3bd1dcc30696b7f63776d0f8b5ee69f5e219c749210436315fe5fd8f811f4f19e02fe4d7d3cff451a831b085101081b97b8ce794d
28 +DIST webmin-1.881.tar.gz 28903876 BLAKE2B beaab3282ccbbe7716fe35e62ee93e64b636f420fa9235398954904b5e14888cdc4b0acd5126184dcdab59274d3e5b71a7997df3e73e18c55849b7197f024971 SHA512 eab1acb53aca5e947bb9fac1c08a32e9eeca2903bc19595fbc8e19895bda8f4c3432550c2a87cf8c2b577b223b97566b046b7c339bd8754266544f5777560cc7
29
30 diff --git a/app-admin/webmin/files/gentoo-setup b/app-admin/webmin/files/gentoo-setup
31 new file mode 100644
32 index 00000000000..680dfbb5303
33 --- /dev/null
34 +++ b/app-admin/webmin/files/gentoo-setup
35 @@ -0,0 +1,438 @@
36 +#!/bin/sh
37 +# gentoo-setup.sh
38 +#
39 +# Version 1.2
40 +#
41 +# A modified original Webmin setup.sh script to comply with Gentoo specifics
42 +#
43 +# Modification done by: PhobosK <phobosk@××××.net>
44 +#
45 +# This script runs after the webmin archive is installed, and in the pkg_config() phase.
46 +# It does setup the various config files of Webmin depending on if it is
47 +# a new install, an upgrade or a reset.
48 +
49 +LANG=
50 +export LANG
51 +
52 +if [ -z ${wadir} ]; then
53 + echo "You can't run this script outside of the 'emerge --config app-admin/webmin' command."
54 + exit 1
55 +fi
56 +
57 +# All things we do is from the Webmin install dir - $wadir
58 +cd $wadir
59 +
60 +
61 +# Are we hard resetting everything?
62 +# If yes, we do:
63 +# 1. Run the specific Webmin $wadir/run-uninstalls.pl
64 +# It runs all uninstall.pl files in every module's folder.
65 +# They delete all the set specific Webmin cron jobs.
66 +# If bumping you should go through these files using the command:
67 +# find . -name uninstall.pl -exec cat {} \; -print
68 +# 2. Delete the whole /etc/webmin content, keeping only the gentoo .keep_* files
69 +if [ "$reset" = "hard" ]; then
70 + echo "Running Webmin's specific uninstall procedures.. (Please ignore any possible errors)"
71 + (WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir LANG= "$wadir/run-uninstalls.pl")
72 + echo "..done"
73 + echo ""
74 +
75 + echo "Deleting the content of user's config folder: $config_dir .."
76 + find $config_dir ! -name '.keep_*' -delete 2>/dev/null
77 + echo "..done"
78 + echo ""
79 +fi
80 +
81 +
82 +# Are we soft resetting?
83 +# If yes we do:
84 +# - Delete the $config_dir/config file so we get new config values
85 +if [ "$reset" = "soft" ]; then
86 + echo "Deleting the user's $config_dir/config file.."
87 + if [ -f "$config_dir/config" ]; then
88 + rm -f "$config_dir/config"
89 + fi
90 + echo "..done"
91 + echo ""
92 +fi
93 +
94 +
95 +# Get all available modules of this version
96 +allmods=`echo */module.info | sed -e 's/\/module.info//g'`
97 +
98 +# Get current Webmin version
99 +ver=`cat "$wadir/version"`
100 +
101 +if [ -r "$config_dir/config" ]; then
102 + upgrading=1
103 +fi
104 +
105 +
106 +# Check if upgrading from an old version
107 +if [ "$upgrading" = 1 ]; then
108 + echo "Updating existant Webmin's config files.."
109 +
110 + # Get current var path
111 + if [ -r "$config_dir/var-path" ]; then
112 + _var_dir=`cat $config_dir/var-path`
113 + if [ -n ${_var_dir} ]; then
114 + var_dir=${_var_dir}
115 + fi
116 + fi
117 +
118 + # Get current perl path
119 + if [ -r "$config_dir/perl-path" ]; then
120 + _perl=`cat $config_dir/perl-path`
121 + if [ -n ${_perl} ]; then
122 + perl=${_perl}
123 + fi
124 + fi
125 +
126 + # Get old os name and version
127 + os_type=`grep "^os_type=" $config_dir/config | sed -e 's/os_type=//g'`
128 + os_version=`grep "^os_version=" $config_dir/config | sed -e 's/os_version=//g'`
129 + real_os_type=`grep "^real_os_type=" $config_dir/config | sed -e 's/real_os_type=//g'`
130 + real_os_version=`grep "^real_os_version=" $config_dir/config | sed -e 's/real_os_version=//g'`
131 +
132 + # Get port, ssl, no_ssl2, no_ssl3, ssl_redirect, no_sslcompression, ssl_honorcipherorder, no_tls1, no_tls1_1 and keyfile
133 + port=`grep "^port=" $config_dir/miniserv.conf | sed -e 's/port=//g'`
134 + ssl=`grep "^ssl=" $config_dir/miniserv.conf | sed -e 's/ssl=//g'`
135 + no_ssl2=`grep "^no_ssl2=" $config_dir/miniserv.conf | sed -e 's/no_ssl2=//g'`
136 + no_ssl3=`grep "^no_ssl3=" $config_dir/miniserv.conf | sed -e 's/no_ssl3=//g'`
137 + ssl_redirect=`grep "^ssl_redirect=" $config_dir/miniserv.conf | sed -e 's/ssl_redirect=//g'`
138 + ssl_honorcipherorder=`grep "^ssl_honorcipherorder=" $config_dir/miniserv.conf | sed -e 's/ssl_honorcipherorder=//g'`
139 + no_sslcompression=`grep "^no_sslcompression=" $config_dir/miniserv.conf | sed -e 's/no_sslcompression=//g'`
140 + no_tls1=`grep "^no_tls1=" $config_dir/miniserv.conf | sed -e 's/no_tls1=//g'`
141 + no_tls1_1=`grep "^no_tls1_1=" $config_dir/miniserv.conf | sed -e 's/no_tls1_1=//g'`
142 + keyfile=`grep "^keyfile=" $config_dir/miniserv.conf | sed -e 's/keyfile=//g'`
143 +
144 + # Update ACLs
145 + $perl "$wadir/newmods.pl" $config_dir $allmods
146 +
147 + # Update miniserv.conf with new root directory, mime types file and server info
148 + grep -v "^root=" $config_dir/miniserv.conf | grep -v "^mimetypes=" | grep -v "^server=" >$tempdir/$$.miniserv.conf
149 + mv $tempdir/$$.miniserv.conf $config_dir/miniserv.conf
150 + echo "root=$wadir" >> $config_dir/miniserv.conf
151 + echo "mimetypes=$wadir/mime.types" >> $config_dir/miniserv.conf
152 + echo "server=MiniServ/$ver" >> $config_dir/miniserv.conf
153 + grep logout= $config_dir/miniserv.conf >/dev/null
154 + if [ $? != "0" ]; then
155 + echo "logout=$config_dir/logout-flag" >> $config_dir/miniserv.conf
156 + fi
157 +
158 + # Remove old cache of module infos
159 + rm -f $config_dir/module.infos.cache
160 + echo "..done"
161 + echo ""
162 +else
163 + # Create webserver's new config files
164 + echo "Creating Webmin's new config files.."
165 +
166 + echo $perl > $config_dir/perl-path
167 + echo $var_dir > $config_dir/var-path
168 +
169 + # Create a totally new conf file
170 + cfile=$config_dir/miniserv.conf
171 + echo "port=$port" > $cfile
172 + echo "root=$wadir" >> $cfile
173 + echo "mimetypes=$wadir/mime.types" >> $cfile
174 + echo "addtype_cgi=internal/cgi" >> $cfile
175 + echo "realm=Webmin Server" >> $cfile
176 + echo "logfile=$var_dir/miniserv.log" >> $cfile
177 + echo "errorlog=$var_dir/miniserv.error" >> $cfile
178 + echo "pidfile=$pidfile" >> $cfile
179 + echo "logtime=168" >> $cfile
180 + echo "ppath=$ppath" >> $cfile
181 + echo "ssl=$ssl" >> $cfile
182 + echo "no_ssl2=$no_ssl2" >> $cfile
183 + echo "no_ssl3=$no_ssl3" >> $cfile
184 + echo "ssl_redirect=$ssl_redirect" >> $cfile
185 + echo "ssl_honorcipherorder=$ssl_honorcipherorder" >> $cfile
186 + echo "no_sslcompression=$no_sslcompression" >> $cfile
187 + echo "no_tls1=$no_tls1" >> $cfile
188 + echo "no_tls1_1=$no_tls1_1" >> $cfile
189 + echo "keyfile=$keyfile" >> $cfile
190 + echo "env_WEBMIN_CONFIG=$config_dir" >> $cfile
191 + echo "env_WEBMIN_VAR=$var_dir" >> $cfile
192 + echo "atboot=$atboot" >> $cfile
193 + echo "logout=$config_dir/logout-flag" >> $cfile
194 + echo "listen=10000" >> $cfile
195 + echo "denyfile=\\.pl\$" >> $cfile
196 + echo "log=1" >> $cfile
197 + echo "blockhost_failures=5" >> $cfile
198 + echo "blockhost_time=60" >> $cfile
199 + echo "syslog=1" >> $cfile
200 + echo "session=1" >> $cfile
201 + echo "premodules=WebminCore" >> $cfile
202 + echo "server=MiniServ/$ver" >> $cfile
203 +
204 + # Append package-specific info to config file.
205 + # miniserv-conf can be created by upstream or by us in src_install phase (see there).
206 + if [ -f "$wadir/miniserv-conf" ]; then
207 + cat "$wadir/miniserv-conf" >>$cfile
208 + fi
209 +
210 + # Create the default user allowed to login - root only
211 + login="root"
212 +
213 + if [ -r /etc/shadow ]; then
214 + #crypt=`grep "^root:" /etc/shadow | cut -f 2 -d :`
215 + crypt=x
216 + else
217 + crypt=`grep "^root:" /etc/passwd | cut -f 2 -d :`
218 + fi
219 +
220 + ufile=$config_dir/miniserv.users
221 + echo "$login:$crypt:0" > $ufile
222 + chmod 600 $ufile
223 +
224 +
225 + echo "userfile=$ufile" >> $cfile
226 + chmod 600 $cfile
227 + echo "..done"
228 + echo ""
229 +
230 + echo "Creating access control file.."
231 + afile=$config_dir/webmin.acl
232 + echo "$login: $allmods" > $afile
233 + chmod 600 $afile
234 + echo "..done"
235 + echo ""
236 +fi
237 +
238 +
239 +# Create start, stop, restart and reload Gentoo compliant Webmin scripts
240 +# We use sys-apps/openrc functions which is already pulled by sys-apps/baselayout
241 +# or systemctl if we run under systemd
242 +echo "Creating start and stop scripts.."
243 +rm -f $config_dir/{start,stop,restart,reload}
244 +
245 +# The start script in /etc/webmin (Gentoo compliant)
246 +cat <<END >>"$config_dir/start"
247 +#!/bin/sh
248 +
249 +if [ ! -f "${pidfile}" ]; then
250 + if [[ -d /run/systemd/system ]] ; then
251 + systemctl start webmin.service
252 + else
253 + rc-service --ifexists -- webmin start
254 + fi
255 +fi
256 +END
257 +
258 +# The stop script in /etc/webmin (Gentoo compliant)
259 +cat <<END >>"$config_dir/stop"
260 +#!/bin/sh
261 +
262 +if [[ -d /run/systemd/system ]] ; then
263 + systemctl stop webmin.service
264 +else
265 + rc-service --ifexists -- webmin --ifstarted stop
266 +fi
267 +END
268 +
269 +# The restart script in /etc/webmin (Gentoo compliant)
270 +cat <<END >>"$config_dir/restart"
271 +#!/bin/sh
272 +
273 +if [[ -d /run/systemd/system ]] ; then
274 + systemctl try-restart webmin.service
275 +else
276 + rc-service --ifexists -- webmin --ifstarted restart
277 +fi
278 +END
279 +
280 +# The reload script in /etc/webmin (Gentoo compliant)
281 +cat <<END >>"$config_dir/reload"
282 +#!/bin/sh
283 +
284 +if [[ -d /run/systemd/system ]] ; then
285 + systemctl reload-or-try-restart webmin.service
286 +else
287 + rc-service --ifexists -- webmin --ifstarted reload
288 +fi
289 +END
290 +
291 +chmod 755 $config_dir/{start,stop,restart,reload}
292 +echo "..done"
293 +echo ""
294 +
295 +
296 +if [ "$upgrading" = 1 ]; then
297 + echo "Updating other config files.."
298 +else
299 + echo "Copying other config files.."
300 +fi
301 +
302 +# This just copies and merges the Webmin's release config files, with user's in the /etc/webmin folder
303 +newmods=`$perl "$wadir/copyconfig.pl" "$os_type/$real_os_type" "$os_version/$real_os_version" "$wadir" $config_dir "" $allmods`
304 +if [ "$upgrading" != 1 ]; then
305 + # Store the OS and version
306 + echo "os_type=$os_type" >> $config_dir/config
307 + echo "os_version=$os_version" >> $config_dir/config
308 + echo "real_os_type=$real_os_type" >> $config_dir/config
309 + echo "real_os_version=$real_os_version" >> $config_dir/config
310 +
311 + # Turn on logging by default
312 + echo "log=1" >> $config_dir/config
313 +
314 + # Disallow unknown referers by default
315 + echo "referers_none=1" >>$config_dir/config
316 +else
317 + # one-off hack to set log variable in config from miniserv.conf
318 + grep log= $config_dir/config >/dev/null
319 + if [ "$?" = "1" ]; then
320 + grep log= $config_dir/miniserv.conf >> $config_dir/config
321 + grep logtime= $config_dir/miniserv.conf >> $config_dir/config
322 + grep logclear= $config_dir/miniserv.conf >> $config_dir/config
323 + fi
324 +
325 + # Disallow unknown referers if not set
326 + grep referers_none= $config_dir/config >/dev/null
327 + if [ "$?" != "0" ]; then
328 + echo "referers_none=1" >>$config_dir/config
329 + fi
330 +fi
331 +echo $ver > $config_dir/version
332 +echo "..done"
333 +echo ""
334 +
335 +# Set passwd_ fields in miniserv.conf from global config
336 +for field in passwd_file passwd_uindex passwd_pindex passwd_cindex passwd_mindex; do
337 + grep $field= $config_dir/miniserv.conf >/dev/null
338 + if [ "$?" != "0" ]; then
339 + grep $field= $config_dir/config >> $config_dir/miniserv.conf
340 + fi
341 +done
342 +grep passwd_mode= $config_dir/miniserv.conf >/dev/null
343 +if [ "$?" != "0" ]; then
344 + echo passwd_mode=0 >> $config_dir/miniserv.conf
345 +fi
346 +
347 +grep ssl_honorcipherorder= $config_dir/miniserv.conf >/dev/null
348 +if [ "$?" != "0" ]; then
349 + echo ssl_honorcipherorder=1 >> $config_dir/miniserv.conf
350 +fi
351 +
352 +# Disable SSL compression to defeat BEAST attack
353 +grep no_sslcompression= $config_dir/miniserv.conf >/dev/null
354 +if [ "$?" != "0" ]; then
355 + echo no_sslcompression=1 >> $config_dir/miniserv.conf
356 +fi
357 +
358 +# Tighten SSL security
359 +grep no_ssl2= $config_dir/miniserv.conf >/dev/null
360 +if [ "$?" != "0" ]; then
361 + echo no_ssl2=1 >> $config_dir/miniserv.conf
362 +fi
363 +
364 +grep no_ssl3= $config_dir/miniserv.conf >/dev/null
365 +if [ "$?" != "0" ]; then
366 + echo no_ssl3=1 >> $config_dir/miniserv.conf
367 +fi
368 +
369 +grep no_tls1= $config_dir/miniserv.conf >/dev/null
370 +if [ "$?" != "0" ]; then
371 + echo no_tls1=1 >> $config_dir/miniserv.conf
372 +fi
373 +
374 +grep no_tls1_1= $config_dir/miniserv.conf >/dev/null
375 +if [ "$?" != "0" ]; then
376 + echo no_tls1_1=1 >> $config_dir/miniserv.conf
377 +fi
378 +
379 +# Make Perl crypt MD5 the default
380 +grep md5pass= $config_dir/config >/dev/null
381 +if [ "$?" != "0" ]; then
382 + echo md5pass=1 >> $config_dir/config
383 +fi
384 +
385 +# Set a special theme if none was set before
386 +if [ "$theme" = "" ]; then
387 + theme=`cat "$wadir/defaulttheme" 2>/dev/null`
388 +fi
389 +oldthemeline=`grep "^theme=" $config_dir/config`
390 +oldtheme=`echo $oldthemeline | sed -e 's/theme=//g'`
391 +if [ "$theme" != "" ] && [ "$oldthemeline" = "" ] && [ -d "$wadir/$theme" ]; then
392 + themelist=$theme
393 +fi
394 +
395 +# Set a special overlay if none was set before
396 +if [ "$overlay" = "" ]; then
397 + overlay=`cat "$wadir/defaultoverlay" 2>/dev/null`
398 +fi
399 +if [ "$overlay" != "" ] && [ "$theme" != "" ] && [ -d "$wadir/$overlay" ]; then
400 + themelist="$themelist $overlay"
401 +fi
402 +
403 +# Apply the theme and maybe overlay
404 +if [ "$themelist" != "" ]; then
405 + echo "theme=$themelist" >> $config_dir/config
406 + echo "preroot=$themelist" >> $config_dir/miniserv.conf
407 +fi
408 +
409 +# If the old blue-theme is still in use, change it (new in 1.730)
410 +oldtheme=`grep "^theme=" $config_dir/config | sed -e 's/theme=//g'`
411 +if [ "$oldtheme" = "blue-theme" ]; then
412 + sed -i -e 's/theme=blue-theme/theme=gray-theme/g' $config_dir/config
413 + sed -i -e 's/preroot=blue-theme/preroot=gray-theme/g' $config_dir/miniserv.conf
414 +fi
415 +
416 +# Set the product field in the global config
417 +grep product= $config_dir/config >/dev/null
418 +if [ "$?" != "0" ]; then
419 + echo product=webmin >> $config_dir/config
420 +fi
421 +
422 +# If password delays are not specifically disabled, enable them
423 +grep passdelay= $config_dir/miniserv.conf >/dev/null
424 +if [ "$?" != "0" ]; then
425 + echo passdelay=1 >> $config_dir/miniserv.conf
426 +fi
427 +
428 +
429 +echo "Changing ownership and permissions.."
430 +# Make all config dirs non-world-readable
431 +for m in $newmods; do
432 + chown -R root:root $config_dir/$m
433 + chmod -R og-rw $config_dir/$m
434 +done
435 +
436 +# Make miniserv config files non-world-readable
437 +for f in miniserv.conf miniserv.users; do
438 + chown -R root:root $config_dir/$f
439 + chmod -R og-rw $config_dir/$f
440 +done
441 +chmod +r $config_dir/version
442 +
443 +# Fix up bad permissions from some older installs
444 +for m in ldap-client ldap-server ldap-useradmin mailboxes mysql postgresql servers virtual-server; do
445 + if [ -d "$config_dir/$m" ]; then
446 + chown root:root $config_dir/$m
447 + chmod og-rw $config_dir/$m
448 + chmod og-rw $config_dir/$m/config 2>/dev/null
449 + fi
450 +done
451 +echo "..done"
452 +echo ""
453 +
454 +
455 +# This executes all postinstall.pl for every module
456 +# If you do bump, you should look at the specific changes they do with this command in root folder:
457 +# find . -name postinstall.pl -exec cat {} \; -print
458 +# Generally they are safe to run 'cause they change only user's config in /etc/webmin
459 +# or setup some cron jobs
460 +if [ "$nopostinstall" = "" ]; then
461 + echo "Running postinstall scripts.. (Please ignore any possible errors)"
462 + (cd "$wadir" ; WEBMIN_CONFIG=$config_dir WEBMIN_VAR=$var_dir "$wadir/run-postinstalls.pl")
463 + echo "..done"
464 + echo ""
465 +fi
466 +
467 +# Enable background collection
468 +if [ "$upgrading" != 1 -a -r $config_dir/system-status/enable-collection.pl ]; then
469 + echo "Enabling background status collection.. (Please ignore any possible errors)"
470 + $config_dir/system-status/enable-collection.pl 5
471 + echo "..done"
472 + echo ""
473 +fi
474
475 diff --git a/app-admin/webmin/webmin-1.881.ebuild b/app-admin/webmin/webmin-1.881.ebuild
476 new file mode 100644
477 index 00000000000..28d8074d3a8
478 --- /dev/null
479 +++ b/app-admin/webmin/webmin-1.881.ebuild
480 @@ -0,0 +1,314 @@
481 +# Copyright 1999-2018 Gentoo Authors
482 +# Distributed under the terms of the GNU General Public License v2
483 +
484 +EAPI=6
485 +inherit pam ssl-cert systemd
486 +
487 +DESCRIPTION="A web-based Unix systems administration interface"
488 +HOMEPAGE="http://www.webmin.com/"
489 +SRC_URI="minimal? ( mirror://sourceforge/webadmin/${P}-minimal.tar.gz )
490 + !minimal? ( mirror://sourceforge/webadmin/${P}.tar.gz )"
491 +
492 +LICENSE="BSD GPL-2"
493 +SLOT="0"
494 +
495 +KEYWORDS="~amd64 ~x86"
496 +
497 +# NOTE: The ssl flag auto added by ssl-cert eclass is not used actually
498 +# because openssl is forced by dev-perl/Net-SSLeay
499 +IUSE="minimal +ssl mysql postgres ldap"
500 +REQUIRED_USE="minimal? ( !mysql !postgres !ldap )"
501 +
502 +# All the required perl modules can be found easily using (in Webmin's root src dir):
503 +# find . -name cpan_modules.pl -exec grep "::" {} \;
504 +# NOTE: If Webmin doesn't find the required perl modules, it offers(runtime) the user
505 +# to install them using the in-built cpan module, and this will mess up perl on the system
506 +# That's why some modules are forced without a use flag
507 +# NOTE: pam, ssl and dnssec-tools deps are forced for security and Gentoo compliance installation reasons
508 +DEPEND="virtual/perl-MIME-Base64
509 + virtual/perl-Socket
510 + virtual/perl-Sys-Syslog
511 + virtual/perl-Time-HiRes
512 + virtual/perl-Time-Local
513 + dev-perl/Authen-Libwrap
514 + dev-perl/IO-Tty
515 + dev-perl/MD5
516 + dev-perl/Net-SSLeay
517 + dev-perl/Authen-PAM
518 + dev-perl/Sys-Hostname-Long
519 + >=net-dns/dnssec-tools-1.13
520 + !minimal? (
521 + mysql? ( dev-perl/DBD-mysql )
522 + postgres? ( dev-perl/DBD-Pg )
523 + ldap? ( dev-perl/perl-ldap )
524 + dev-perl/XML-Generator
525 + dev-perl/XML-Parser
526 + )
527 +"
528 +RDEPEND="${DEPEND}"
529 +
530 +src_prepare() {
531 + default
532 +
533 + local perl="$( which perl )"
534 +
535 + # Remove the unnecessary and incompatible files
536 + rm -rf acl/Authen-SolarisRBAC-0.1*
537 + if ! use minimal ; then
538 + rm -rf {format,{bsd,hpux,sgi}exports,zones,rbac}
539 + rm -f mount/{free,net,open}bsd-mounts*
540 + rm -f mount/macos-mounts*
541 + fi
542 +
543 + # For security reasons remove the SSL certificate that comes with Webmin
544 + # We will create our own later
545 + rm -f miniserv.pem
546 +
547 + # Remove the Webmin setup scripts to avoid Webmin in runtime to mess up config
548 + # We will use our own later
549 + rm -f setup.{sh,pl}
550 +
551 + # Set the installation type/mode to Gentoo
552 + echo "gentoo" > install-type
553 +
554 + # Fix the permissions of the install files
555 + chmod -R og-w "${S}"
556 +
557 + # Since we should not modify any files after install
558 + # we set the perl path in all cgi and pl files here using Webmin's routines
559 + # The pl file is Prefix safe and works only on provided input, no other filesystem files
560 + ebegin "Fixing perl path in source files"
561 + (find "${S}" -name '*.cgi' -print ; find "${S}" -name '*.pl' -print) | $perl "${S}"/perlpath.pl $perl -
562 + eend $?
563 +}
564 +
565 +src_install() {
566 + # Create config dir and keep
567 + diropts -m0755
568 + dodir /etc/webmin
569 + keepdir /etc/webmin
570 +
571 + # Create install dir
572 + # Third party modules installed through Webmin go here too, so keep
573 + dodir /usr/libexec/webmin
574 + keepdir /usr/libexec/webmin
575 +
576 + # Copy our own setup script to installation folder
577 + insinto /usr/libexec/webmin
578 + newins "${FILESDIR}"/gentoo-setup gentoo-setup.sh
579 + fperms 0744 /usr/libexec/webmin/gentoo-setup.sh
580 +
581 + # This is here if we ever want in future ebuilds to add some specific
582 + # config values in the /etc/webmin/miniserv.conf
583 + # The format of this file should be the same as the one of miniserv.conf:
584 + # var=value
585 + #
586 + # Uncomment it if you use such file. Before that check if upstream
587 + # has this file in root dir too.
588 + #newins "${FILESDIR}/miniserv-conf" miniserv-conf
589 +
590 + # Create the log dir and keep
591 + diropts -m0700
592 + dodir /var/log/webmin
593 + keepdir /var/log/webmin
594 +
595 + # Create the init.d file and put the neccessary variables there
596 + newinitd "${FILESDIR}"/init.d.webmin webmin
597 + sed -i \
598 + -e "s:%exe%:${EROOT}usr/libexec/webmin/miniserv.pl:" \
599 + -e "s:%pid%:${EROOT}var/run/webmin.pid:" \
600 + -e "s:%conf%:${EROOT}etc/webmin/miniserv.conf:" \
601 + -e "s:%config%:${EROOT}etc/webmin/config:" \
602 + -e "s:%perllib%:${EROOT}usr/libexec/webmin:" \
603 + "${ED}etc/init.d/webmin" \
604 + || die "Failed to patch the webmin init file"
605 +
606 + # Create the systemd service file and put the neccessary variables there
607 + systemd_newunit "${FILESDIR}"/webmin.service webmin.service
608 + sed -i \
609 + -e "s:%exe%:${EROOT}usr/libexec/webmin/miniserv.pl:" \
610 + -e "s:%pid%:${EROOT}var/run/webmin.pid:" \
611 + -e "s:%conf%:${EROOT}etc/webmin/miniserv.conf:" \
612 + -e "s:%config%:${EROOT}etc/webmin/config:" \
613 + -e "s:%perllib%:${EROOT}usr/libexec/webmin:" \
614 + "${ED}$(_systemd_get_systemunitdir)/webmin.service" \
615 + || die "Failed to patch the webmin systemd service file"
616 +
617 + # Setup pam
618 + pamd_mimic system-auth webmin auth account session
619 +
620 + # Copy files to installation folder
621 + ebegin "Copying install files to destination"
622 + cp -pPR "${S}"/* "${ED}usr/libexec/webmin"
623 + eend $?
624 +}
625 +
626 +pkg_preinst() {
627 + # First stop service if running so Webmin to not messup our config
628 + ebegin "Stopping any running Webmin instance prior merging"
629 + if systemd_is_booted ; then
630 + systemctl stop webmin.service 2>/dev/null
631 + else
632 + rc-service --ifexists -- webmin --ifstarted stop
633 + fi
634 + eend $?
635 +}
636 +
637 +pkg_postinst() {
638 + # Run webmin_config first - non interactively
639 + export INTERACTIVE="no"
640 + webmin_config
641 + # Every next time webmin_config should be interactive
642 + INTERACTIVE="yes"
643 +
644 + ewarn
645 + ewarn "Bare in mind that not all Webmin modules are Gentoo tweaked and may have some issues."
646 + ewarn "Always be careful when using modules that modify init entries, do update of webmin, install CPAN modules etc."
647 + ewarn "To avoid problems, please before using any module, look at its configuration options first."
648 + ewarn "(Usually there is a link at top in the right pane of Webmin for configuring the module.)"
649 + ewarn
650 + if systemd_is_booted ; then
651 + elog "- To make Webmin start at boot time, run: 'systemctl enable webmin.service'"
652 + else
653 + elog "- To make Webmin start at boot time, run: 'rc-update add webmin default'"
654 + fi
655 + elog "- The default URL to connect to Webmin is: https://localhost:10000"
656 + elog "- The default user that can login is: root"
657 + elog "- To reconfigure Webmin in case of problems run 'emerge --config app-admin/webmin'"
658 +}
659 +
660 +pkg_prerm() {
661 + # First stop service if running - we do not want Webmin to mess up config
662 + ebegin "Stopping any running Webmin instance prior unmerging"
663 + if systemd_is_booted ; then
664 + systemctl stop webmin.service 2>/dev/null
665 + else
666 + rc-service --ifexists -- webmin --ifstarted stop
667 + fi
668 + eend $?
669 +}
670 +
671 +pkg_postrm() {
672 + # If removing webmin completely, remind the user for the Webmin's own cron jobs.
673 + if [[ ! ${REPLACED_BY_VERSION} ]]; then
674 + ewarn
675 + ewarn "You have uninstalled Webmin, so have in mind that all cron jobs scheduled"
676 + ewarn "by Webmin for its own modules, are left active and they will fail when Webmin is missing."
677 + ewarn "To fix this just disable them if you intend to use Webmin again,"
678 + ewarn "OR delete them if not."
679 + ewarn
680 + fi
681 +}
682 +
683 +pkg_config(){
684 + webmin_config
685 +}
686 +
687 +webmin_config(){
688 + # First stop service if running
689 + ebegin "Stopping any running Webmin instance"
690 + if systemd_is_booted ; then
691 + systemctl stop webmin.service 2>/dev/null
692 + else
693 + rc-service --ifexists -- webmin --ifstarted stop
694 + fi
695 + eend $?
696 +
697 + # Next set the default reset variable to 'none'
698 + # reset/_reset can be:
699 + # 'none' - does not reset anything, just upgrades if a conf is present
700 + # OR installs new conf if a conf is missing
701 + # 'soft' - deletes only $config_dir/config file and thus resetting most
702 + # conf values to their defaults. Keeps the specific Webmin cron jobs
703 + # 'hard' - deletes all files in $config_dir (keeping the .keep_* Gentoo file)
704 + # and thus resetting all Webmin. Deletes the specific Webmin cron jobs too.
705 + local _reset="none"
706 +
707 + # If in interactive mode ask user what should we do
708 + if [[ "${INTERACTIVE}" = "yes" ]]; then
709 + einfo
710 + einfo "Please enter the number of the action you would like to perform?"
711 + einfo
712 + einfo "1. Update configuration"
713 + einfo " (keeps old config options and adds the new ones)"
714 + einfo "2. Soft reset configuration"
715 + einfo " (keeps some old config options, the other options are set to default)"
716 + ewarn " All Webmin users will be reset"
717 + einfo "3. Hard reset configuration"
718 + einfo " (all options including module options are set to default)"
719 + ewarn " You will lose all Webmin configuration options you have done till now"
720 + einfo "4. Exit this configuration utility (default)"
721 + while [ "$correct" != "true" ] ; do
722 + read answer
723 + if [[ "$answer" = "1" ]] ; then
724 + _reset="none"
725 + correct="true"
726 + elif [[ "$answer" = "2" ]] ; then
727 + _reset="soft"
728 + correct="true"
729 + elif [[ "$answer" = "3" ]] ; then
730 + _reset="hard"
731 + correct="true"
732 + elif [ "$answer" = "4" -o "$answer" = "" ] ; then
733 + die "User aborted configuration."
734 + else
735 + echo "Answer not recognized. Enter a number from 1 to 4"
736 + fi
737 + done
738 +
739 + if [[ "$_reset" = "hard" ]]; then
740 + while [ "$sure" != "true" ] ; do
741 + ewarn "You will lose all Webmin configuration options you have done till now."
742 + ewarn "Are you sure you want to do this? (y/n)"
743 + read answer
744 + if [[ $answer =~ ^[Yy]([Ee][Ss])?$ ]] ; then
745 + sure="true"
746 + elif [[ $answer =~ ^[Nn]([Oo])?$ ]] ; then
747 + die "User aborted configuration."
748 + else
749 + echo "Answer not recognized. Enter 'y' or 'n'"
750 + fi
751 + done
752 + fi
753 + fi
754 +
755 + export reset=$_reset
756 +
757 + # Create ssl certificate for Webmin if there is not one in the proper place
758 + if [[ ! -e "${EROOT}etc/ssl/webmin/server.pem" ]]; then
759 + SSL_ORGANIZATION="${SSL_ORGANIZATION:-Webmin Server}"
760 + SSL_COMMONNAME="${SSL_COMMONNAME:-*}"
761 + install_cert "${EROOT}/etc/ssl/webmin/server"
762 + fi
763 +
764 + # Ensure all paths passed to the setup script use EROOT
765 + export wadir="${EROOT}usr/libexec/webmin"
766 + export config_dir="${EROOT}etc/webmin"
767 + export var_dir="${EROOT}var/log/webmin"
768 + export tempdir="${T}"
769 + export pidfile="${EROOT}var/run/webmin.pid"
770 + export perl="$( which perl )"
771 + export os_type='gentoo-linux'
772 + export os_version='*'
773 + export real_os_type='Gentoo Linux'
774 + export real_os_version='Any version'
775 + # Forcing 'ssl', 'no_ssl2', 'no_ssl3', 'ssl_redirect', 'no_sslcompression',
776 + # 'ssl_honorcipherorder', 'no_tls1' and 'no_tls1_1' for tightening security
777 + export ssl=1
778 + export no_ssl2=1
779 + export no_ssl3=1
780 + export ssl_redirect=1
781 + export ssl_honorcipherorder=1
782 + export no_sslcompression=1
783 + export no_tls1=1
784 + export no_tls1_1=1
785 + export keyfile="${EROOT}etc/ssl/webmin/server.pem"
786 + export port=10000
787 +
788 + export atboot=0
789 +
790 + einfo "Executing Webmin's configure script"
791 + $wadir/gentoo-setup.sh
792 +
793 + einfo "Configuration of Webmin done"
794 +}