public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8
@ 2021-08-12  9:54 Rolf Eike Beer
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12  9:54 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 76c612f026f..6b04cbf7792 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -4,11 +4,11 @@
 # @ECLASS: qmail.eclass
 # @MAINTAINER:
 # Rolf Eike Beer <eike@sf-mail.de>
-# @SUPPORTED_EAPIS: 6 7
+# @SUPPORTED_EAPIS: 7 8
 # @BLURB: common qmail functions
 
 case ${EAPI:-0} in
-	[67]) ;;
+	[78]) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group
  2021-08-12  9:54 [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8 Rolf Eike Beer
@ 2021-08-12  9:55 ` Rolf Eike Beer
  2021-08-12 11:13   ` Ulrich Mueller
                     ` (3 more replies)
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() Rolf Eike Beer
                   ` (2 subsequent siblings)
  3 siblings, 4 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12  9:55 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 3743 bytes --]

This also fixes qmail_supervise_install_one when called from outside of
qmail_src_install.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 6b04cbf7792..6ed026a1d9d 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -73,7 +73,7 @@ is_prime() {
 
 dospp() {
 	insinto "${QMAIL_HOME}"/plugins/
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -o root -g root -m 0755
 	newins $1 ${2:-$(basename $1)}
 }
 
@@ -86,8 +86,8 @@ dosupervise() {
 	local runfile=${2:-${service}} logfile=${3:-${service}-log}
 	[[ -z "${service}" ]] && die "no service given"
 
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	diropts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -o root -g root -m 0755
+	diropts -o root -g root -m 0755
 
 	dodir ${SUPERVISE_DIR}/${service}{,/log}
 	fperms +t ${SUPERVISE_DIR}/${service}{,/log}
@@ -192,12 +192,12 @@ qmail_base_install() {
 qmail_config_install() {
 	einfo "Installing stock configuration files"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -o root -g root -m 644
 	doins "${GENQMAIL_S}"/control/{conf-*,defaultdelivery}
 
 	einfo "Installing configuration sanity checker and launcher"
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -o root -g root -m 644
 	doins "${GENQMAIL_S}"/control/qmail-config-system
 
 	declare -F qmail_config_install_hook >/dev/null && \
@@ -254,9 +254,9 @@ qmail_maildir_install() {
 	done
 
 	einfo "Setting up default maildirs in the account skeleton"
-	diropts -o root -g "${GROUP_ROOT}" -m 755
+	diropts -o root -g root -m 755
 	insinto /etc/skel
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -o root -g root -m 644
 	newins "${GENQMAIL_S}"/control/defaultdelivery .qmail.sample
 	"${MAILDIRMAKE}" "${D}"/etc/skel/.maildir
 	keepdir /etc/skel/.maildir/{cur,new,tmp}
@@ -268,7 +268,7 @@ qmail_maildir_install() {
 qmail_tcprules_install() {
 	dodir "${TCPRULES_DIR}"
 	insinto "${TCPRULES_DIR}"
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -o root -g root -m 0644
 	doins "${GENQMAIL_S}"/tcprules/Makefile.qmail
 	doins "${GENQMAIL_S}"/tcprules/tcp.qmail-*
 	use ssl && use pop3 || rm -f "${D}${TCPRULES_DIR}"/tcp.qmail-pop3sd
@@ -276,7 +276,7 @@ qmail_tcprules_install() {
 
 qmail_supervise_install_one() {
 	dosupervise ${1}
-	diropts -o qmaill -g "${GROUP_ROOT}" -m 755
+	diropts -o qmaill -g root -m 755
 	keepdir /var/log/qmail/${1}
 }
 
@@ -301,7 +301,7 @@ qmail_supervise_install() {
 qmail_spp_install() {
 	einfo "Installing qmail-spp configuration files"
 	insinto "${QMAIL_HOME}"/control/
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -o root -g root -m 0644
 	doins "${GENQMAIL_S}"/spp/smtpplugins
 
 	einfo "Installing qmail-spp plugins"
@@ -321,16 +321,16 @@ qmail_ssl_install() {
 
 	einfo "Installing SSL Certificate creation script"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -o root -g root -m 0644
 	doins "${GENQMAIL_S}"/ssl/servercert.cnf
 
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -o root -g root -m 0755
 	doins "${GENQMAIL_S}"/ssl/mkservercert
 
 	einfo "Installing RSA key generation cronjob"
 	insinto /etc/${CRON_FOLDER}
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -o root -g root -m 0755
 	doins "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh
 
 	keepdir "${QMAIL_HOME}"/control/tlshosts
@@ -340,7 +340,6 @@ qmail_ssl_install() {
 }
 
 qmail_src_install() {
-	export GROUP_ROOT="$(id -gn root)"
 	qmail_base_install
 	qmail_config_install
 	qmail_man_install
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime()
  2021-08-12  9:54 [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8 Rolf Eike Beer
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
@ 2021-08-12  9:55 ` Rolf Eike Beer
  2021-08-12 11:25   ` Ulrich Mueller
  2021-08-12 15:25   ` [gentoo-dev] [PATCH 3/3] " Rolf Eike Beer
  2021-08-13  7:47 ` [gentoo-dev] [PATCH 4/3] qmail.eclass: remove needless keepdirs Rolf Eike Beer
  2021-08-13 10:44 ` [gentoo-dev] [PATCH 5/3] qmail.eclass: retire qmail_tcprules_fixup() Rolf Eike Beer
  3 siblings, 2 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12  9:55 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1881 bytes --]

The previous algorithm would scan for all primes for a given number, which
takes needlessly long.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 51 ++++++++++++++++-----------------------------
 1 file changed, 18 insertions(+), 33 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 6ed026a1d9d..6ea27249c63 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -29,46 +29,31 @@ GENQMAIL_S="${WORKDIR}"/genqmail-${GENQMAIL_PV}
 QMAIL_SPP_F=qmail-spp-${QMAIL_SPP_PV}.tar.gz
 QMAIL_SPP_S="${WORKDIR}"/qmail-spp-${QMAIL_SPP_PV}
 
-# @FUNCTION: primes
-# @USAGE: <min> <max>
+# @FUNCTION: is_prime
+# @USAGE: <number>
 # @DESCRIPTION:
-# Prints a list of primes between min and max inclusive
-# Note: this functions gets very slow when used with large numbers.
-primes() {
-	local min=${1} max=${2}
-	local result= primelist=2 i p
+# Checks wether a number is a valid prime number for queue split
+is_prime() {
+	local number=${1} i
+
+	if [[ ${number} < 7 ]]; then
+		# too small
+		return 0
+	fi
 
-	[[ ${min} -le 2 ]] && result="${result} 2"
+	if [[ $[number % 2] == 0 ]]; then
+		return 1
+	fi
 
-	for ((i = 3; i <= max; i += 2))
+	# let i run up to the square root of number
+	for ((i = 3; i * i <= number; i += 2))
 	do
-		for p in ${primelist}
-		do
-			[[ $[i % p] == 0 || $[p * p] -gt ${i} ]] && \
-				break
-		done
-		if [[ $[i % p] != 0 ]]
-		then
-			primelist="${primelist} ${i}"
-			[[ ${i} -ge ${min} ]] && \
-				result="${result} ${i}"
+		if [[ $[number % i ] == 0 ]]; then
+			return 1
 		fi
 	done
 
-	echo ${result}
-}
-
-# @FUNCTION: is_prima
-# @USAGE: <number>
-# @DESCRIPTION:
-# Checks wether a number is a prime number
-is_prime() {
-	local number=${1} i
-	for i in $(primes ${number} ${number})
-	do
-		[[ ${i} == ${number} ]] && return 0
-	done
-	return 1
+	return 0
 }
 
 dospp() {
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
@ 2021-08-12 11:13   ` Ulrich Mueller
  2021-08-12 14:03     ` Rolf Eike Beer
  2021-08-12 15:22   ` [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query " Rolf Eike Beer
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 22+ messages in thread
From: Ulrich Mueller @ 2021-08-12 11:13 UTC (permalink / raw
  To: Rolf Eike Beer; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

>>>>> On Thu, 12 Aug 2021, Rolf Eike Beer wrote:

>  dospp() {
>  	insinto "${QMAIL_HOME}"/plugins/
> -	insopts -o root -g "${GROUP_ROOT}" -m 0755
> +	insopts -o root -g root -m 0755

install defaults to root anyway, so why are explicit -o and -g needed
here? (Same applies below, of course.)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime()
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() Rolf Eike Beer
@ 2021-08-12 11:25   ` Ulrich Mueller
  2021-08-12 15:25     ` Rolf Eike Beer
  2021-08-12 15:25   ` [gentoo-dev] [PATCH 3/3] " Rolf Eike Beer
  1 sibling, 1 reply; 22+ messages in thread
From: Ulrich Mueller @ 2021-08-12 11:25 UTC (permalink / raw
  To: Rolf Eike Beer; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1370 bytes --]

>>>>> On Thu, 12 Aug 2021, Rolf Eike Beer wrote:

> -# @FUNCTION: primes
> -# @USAGE: <min> <max>
> +# @FUNCTION: is_prime
> +# @USAGE: <number>
>  # @DESCRIPTION:
> -# Prints a list of primes between min and max inclusive
> -# Note: this functions gets very slow when used with large numbers.
> -primes() {
> -	local min=${1} max=${2}
> -	local result= primelist=2 i p
> +# Checks wether a number is a valid prime number for queue split
> +is_prime() {
> +	local number=${1} i
> +
> +	if [[ ${number} < 7 ]]; then
> +		# too small
> +		return 0
> +	fi

So e.g. all numbers between 100 and 699 qualify as primes? I doubt that
this is what was intended. :)

>  
> -	[[ ${min} -le 2 ]] && result="${result} 2"
> +	if [[ $[number % 2] == 0 ]]; then
> +		return 1
> +	fi
>  
> -	for ((i = 3; i <= max; i += 2))
> +	# let i run up to the square root of number
> +	for ((i = 3; i * i <= number; i += 2))
>  	do
> -		for p in ${primelist}
> -		do
> -			[[ $[i % p] == 0 || $[p * p] -gt ${i} ]] && \
> -				break
> -		done
> -		if [[ $[i % p] != 0 ]]
> -		then
> -			primelist="${primelist} ${i}"
> -			[[ ${i} -ge ${min} ]] && \
> -				result="${result} ${i}"
> +		if [[ $[number % i ] == 0 ]]; then
> +			return 1
>  		fi
>  	done
>  
> -	echo ${result}
> -}

This function asks for a unit test in eclass/tests/.

Ulrich

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group
  2021-08-12 11:13   ` Ulrich Mueller
@ 2021-08-12 14:03     ` Rolf Eike Beer
  0 siblings, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12 14:03 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

Am Donnerstag, 12. August 2021, 13:13:23 CEST schrieb Ulrich Mueller:
> >>>>> On Thu, 12 Aug 2021, Rolf Eike Beer wrote:
> >  dospp() {
> >  
> >  	insinto "${QMAIL_HOME}"/plugins/
> > 
> > -	insopts -o root -g "${GROUP_ROOT}" -m 0755
> > +	insopts -o root -g root -m 0755
> 
> install defaults to root anyway, so why are explicit -o and -g needed
> here? (Same applies below, of course.)

I suspected that, but at the end I was just following bad examples:

 git grep 'insopts\s\+.*-[og]\s\+root'

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
  2021-08-12 11:13   ` Ulrich Mueller
@ 2021-08-12 15:22   ` Rolf Eike Beer
  2021-08-12 17:39     ` Michael Orlitzky
  2021-08-14  9:36   ` [gentoo-dev] [PATCH 2/3 v3] " Rolf Eike Beer
  2021-08-14 11:34   ` [gentoo-dev] [PATCH 2/3 v4] " Rolf Eike Beer
  3 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12 15:22 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 3594 bytes --]

The default owner is root:root anyway. This also fixes
qmail_supervise_install_one() when called from outside of qmail_src_install().

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 6b04cbf7792..40130a502cb 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -73,7 +73,7 @@ is_prime() {
 
 dospp() {
 	insinto "${QMAIL_HOME}"/plugins/
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
 	newins $1 ${2:-$(basename $1)}
 }
 
@@ -86,8 +86,8 @@ dosupervise() {
 	local runfile=${2:-${service}} logfile=${3:-${service}-log}
 	[[ -z "${service}" ]] && die "no service given"
 
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	diropts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
+	diropts -m 0755
 
 	dodir ${SUPERVISE_DIR}/${service}{,/log}
 	fperms +t ${SUPERVISE_DIR}/${service}{,/log}
@@ -192,12 +192,12 @@ qmail_base_install() {
 qmail_config_install() {
 	einfo "Installing stock configuration files"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	doins "${GENQMAIL_S}"/control/{conf-*,defaultdelivery}
 
 	einfo "Installing configuration sanity checker and launcher"
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	doins "${GENQMAIL_S}"/control/qmail-config-system
 
 	declare -F qmail_config_install_hook >/dev/null && \
@@ -254,9 +254,9 @@ qmail_maildir_install() {
 	done
 
 	einfo "Setting up default maildirs in the account skeleton"
-	diropts -o root -g "${GROUP_ROOT}" -m 755
+	diropts -m 755
 	insinto /etc/skel
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	newins "${GENQMAIL_S}"/control/defaultdelivery .qmail.sample
 	"${MAILDIRMAKE}" "${D}"/etc/skel/.maildir
 	keepdir /etc/skel/.maildir/{cur,new,tmp}
@@ -268,7 +268,7 @@ qmail_maildir_install() {
 qmail_tcprules_install() {
 	dodir "${TCPRULES_DIR}"
 	insinto "${TCPRULES_DIR}"
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/tcprules/Makefile.qmail
 	doins "${GENQMAIL_S}"/tcprules/tcp.qmail-*
 	use ssl && use pop3 || rm -f "${D}${TCPRULES_DIR}"/tcp.qmail-pop3sd
@@ -276,7 +276,7 @@ qmail_tcprules_install() {
 
 qmail_supervise_install_one() {
 	dosupervise ${1}
-	diropts -o qmaill -g "${GROUP_ROOT}" -m 755
+	diropts -o qmaill -g root -m 755
 	keepdir /var/log/qmail/${1}
 }
 
@@ -301,7 +301,7 @@ qmail_supervise_install() {
 qmail_spp_install() {
 	einfo "Installing qmail-spp configuration files"
 	insinto "${QMAIL_HOME}"/control/
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/spp/smtpplugins
 
 	einfo "Installing qmail-spp plugins"
@@ -321,16 +321,16 @@ qmail_ssl_install() {
 
 	einfo "Installing SSL Certificate creation script"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/ssl/servercert.cnf
 
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
 	doins "${GENQMAIL_S}"/ssl/mkservercert
 
 	einfo "Installing RSA key generation cronjob"
 	insinto /etc/${CRON_FOLDER}
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
 	doins "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh
 
 	keepdir "${QMAIL_HOME}"/control/tlshosts
@@ -340,7 +340,6 @@ qmail_ssl_install() {
 }
 
 qmail_src_install() {
-	export GROUP_ROOT="$(id -gn root)"
 	qmail_base_install
 	qmail_config_install
 	qmail_man_install
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime()
  2021-08-12 11:25   ` Ulrich Mueller
@ 2021-08-12 15:25     ` Rolf Eike Beer
  0 siblings, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12 15:25 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

Am Donnerstag, 12. August 2021, 13:25:09 CEST schrieb Ulrich Mueller:
> >>>>> On Thu, 12 Aug 2021, Rolf Eike Beer wrote:
> > -# @FUNCTION: primes
> > -# @USAGE: <min> <max>
> > +# @FUNCTION: is_prime
> > +# @USAGE: <number>
> > 
> >  # @DESCRIPTION:
> > -# Prints a list of primes between min and max inclusive
> > -# Note: this functions gets very slow when used with large numbers.
> > -primes() {
> > -	local min=${1} max=${2}
> > -	local result= primelist=2 i p
> > +# Checks wether a number is a valid prime number for queue split
> > +is_prime() {
> > +	local number=${1} i
> > +
> > +	if [[ ${number} < 7 ]]; then
> > +		# too small
> > +		return 0
> > +	fi
> 
> So e.g. all numbers between 100 and 699 qualify as primes? I doubt that
> this is what was intended. :)

Nope.

> This function asks for a unit test in eclass/tests/.

Indeed, that would uncover that it had to be "return 1" above.

The eclass guide at https://devmanual.gentoo.org/eclass-writing/index.html 
doesn't mention these tests with any words, not even how to run them.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 3/3] qmail.eclass: simplify is_prime()
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() Rolf Eike Beer
  2021-08-12 11:25   ` Ulrich Mueller
@ 2021-08-12 15:25   ` Rolf Eike Beer
  1 sibling, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-12 15:25 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 3166 bytes --]

The previous algorithm would scan for all primes for a given number, which
takes needlessly long.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass   | 51 +++++++++++++++---------------------------
 eclass/tests/qmail.sh | 52 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 33 deletions(-)
 create mode 100755 eclass/tests/qmail.sh

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 40130a502cb..9f644dd74c8 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -29,46 +29,31 @@ GENQMAIL_S="${WORKDIR}"/genqmail-${GENQMAIL_PV}
 QMAIL_SPP_F=qmail-spp-${QMAIL_SPP_PV}.tar.gz
 QMAIL_SPP_S="${WORKDIR}"/qmail-spp-${QMAIL_SPP_PV}
 
-# @FUNCTION: primes
-# @USAGE: <min> <max>
+# @FUNCTION: is_prime
+# @USAGE: <number>
 # @DESCRIPTION:
-# Prints a list of primes between min and max inclusive
-# Note: this functions gets very slow when used with large numbers.
-primes() {
-	local min=${1} max=${2}
-	local result= primelist=2 i p
+# Checks wether a number is a valid prime number for queue split
+is_prime() {
+	local number=${1} i
+
+	if [[ ${number} -lt 7 ]]; then
+		# too small
+		return 1
+	fi
 
-	[[ ${min} -le 2 ]] && result="${result} 2"
+	if [[ $[number % 2] == 0 ]]; then
+		return 1
+	fi
 
-	for ((i = 3; i <= max; i += 2))
+	# let i run up to the square root of number
+	for ((i = 3; i * i <= number; i += 2))
 	do
-		for p in ${primelist}
-		do
-			[[ $[i % p] == 0 || $[p * p] -gt ${i} ]] && \
-				break
-		done
-		if [[ $[i % p] != 0 ]]
-		then
-			primelist="${primelist} ${i}"
-			[[ ${i} -ge ${min} ]] && \
-				result="${result} ${i}"
+		if [[ $[number % i ] == 0 ]]; then
+			return 1
 		fi
 	done
 
-	echo ${result}
-}
-
-# @FUNCTION: is_prima
-# @USAGE: <number>
-# @DESCRIPTION:
-# Checks wether a number is a prime number
-is_prime() {
-	local number=${1} i
-	for i in $(primes ${number} ${number})
-	do
-		[[ ${i} == ${number} ]] && return 0
-	done
-	return 1
+	return 0
 }
 
 dospp() {
diff --git a/eclass/tests/qmail.sh b/eclass/tests/qmail.sh
new file mode 100755
index 00000000000..3520ed2a9d5
--- /dev/null
+++ b/eclass/tests/qmail.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Copyright 2020-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+source tests-common.sh
+
+inherit qmail
+
+# some numbers are blocked because they are to small even if prime
+test_low_numbers() {
+	tbegin "low numbers"
+
+	for i in $(seq 0 6); do
+		if is_prime ${i}; then
+			return tend 1 "${i} badly accepted"
+		fi
+	done
+
+	tend 0
+}
+
+# test a given number for being prime
+check_prime_number() {
+	# use factor from coreutils to count the factors
+	if [[ $(factor $1 | cut -d: -f2 | wc -w) == 1 ]]; then
+		return $(is_prime $1)
+	else
+		return $(is_prime $1 && false || true)
+	fi
+}
+
+test_primes() {
+	tbegin "factorizations from ${1} to ${2}"
+
+	for i in $(seq ${1:?} ${2:?}); do
+		if ! check_prime_number $i; then
+			tend 1 "${i} returned bad factorization"
+			return 1
+		fi
+	done
+
+	tend 0
+}
+
+test_low_numbers
+test_primes 7 99
+for i in $(seq 100 100 1000); do
+	test_primes $i $((i + 99))
+done
+
+texit
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-12 15:22   ` [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query " Rolf Eike Beer
@ 2021-08-12 17:39     ` Michael Orlitzky
  2021-08-13  7:17       ` Rolf Eike Beer
  0 siblings, 1 reply; 22+ messages in thread
From: Michael Orlitzky @ 2021-08-12 17:39 UTC (permalink / raw
  To: gentoo-dev

On Thu, 2021-08-12 at 17:22 +0200, Rolf Eike Beer wrote:
> The default owner is root:root anyway.
> 

This is only true of you don't call insopts earlier with some other
value. I see "insopts -o root -g qmail -m 700" in there so you might
want to double check.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-12 17:39     ` Michael Orlitzky
@ 2021-08-13  7:17       ` Rolf Eike Beer
  2021-08-13  9:06         ` Ulrich Mueller
  0 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-13  7:17 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

Am Donnerstag, 12. August 2021, 19:39:08 CEST schrieb Michael Orlitzky:
> On Thu, 2021-08-12 at 17:22 +0200, Rolf Eike Beer wrote:
> > The default owner is root:root anyway.
> 
> This is only true of you don't call insopts earlier with some other
> value. I see "insopts -o root -g qmail -m 700" in there so you might
> want to double check.

Not my day.

Ok, given that there are several places that change users and groups and the 
subfunctions are not always called it would be very few places where I can 
remove the root:root (about 3) and be sure that everything works. For that 
reason I would just keep them all and go back to the initial patch 2.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 4/3] qmail.eclass: remove needless keepdirs
  2021-08-12  9:54 [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8 Rolf Eike Beer
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() Rolf Eike Beer
@ 2021-08-13  7:47 ` Rolf Eike Beer
  2021-08-14 11:47   ` [gentoo-dev] [PATCH 4/3 v2] " Rolf Eike Beer
  2021-08-13 10:44 ` [gentoo-dev] [PATCH 5/3] qmail.eclass: retire qmail_tcprules_fixup() Rolf Eike Beer
  3 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-13  7:47 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

Adding an extra keep file in the intermediate /var/qmail is never necessary,
and the binary directory is filled by the installation anyway.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 4aeba918ed4..5fbfdd6af75 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -136,8 +136,8 @@ qmail_spp_src_compile() {
 qmail_base_install() {
 	einfo "Setting up basic directory hierarchy"
 	diropts -o root -g qmail -m 755
-	keepdir "${QMAIL_HOME}"/{,bin,control}
-	keepdir "${QMAIL_HOME}"/users
+	dodir "${QMAIL_HOME}"/{,bin}
+	keepdir "${QMAIL_HOME}"/{control,users}
 	diropts -o alias -g qmail -m 755
 	keepdir "${QMAIL_HOME}"/alias
 
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-13  7:17       ` Rolf Eike Beer
@ 2021-08-13  9:06         ` Ulrich Mueller
  2021-08-13 10:31           ` Rolf Eike Beer
  0 siblings, 1 reply; 22+ messages in thread
From: Ulrich Mueller @ 2021-08-13  9:06 UTC (permalink / raw
  To: Rolf Eike Beer; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

>>>>> On Fri, 13 Aug 2021, Rolf Eike Beer wrote:

> Am Donnerstag, 12. August 2021, 19:39:08 CEST schrieb Michael Orlitzky:
>> On Thu, 2021-08-12 at 17:22 +0200, Rolf Eike Beer wrote:
>> > The default owner is root:root anyway.
>> 
>> This is only true of you don't call insopts earlier with some other
>> value. I see "insopts -o root -g qmail -m 700" in there so you might
>> want to double check.

> Not my day.

> Ok, given that there are several places that change users and groups
> and the subfunctions are not always called it would be very few places
> where I can remove the root:root (about 3) and be sure that everything
> works. For that reason I would just keep them all and go back to the
> initial patch 2.

I believe the method of choice would be to execute the offending
insopts/doins pair in a subshell, i.e. put a ( ) pair around them.

Ulrich

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-13  9:06         ` Ulrich Mueller
@ 2021-08-13 10:31           ` Rolf Eike Beer
  2021-08-14 10:43             ` David Seifert
  0 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-13 10:31 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]

Am Freitag, 13. August 2021, 11:06:09 CEST schrieb Ulrich Mueller:
> >>>>> On Fri, 13 Aug 2021, Rolf Eike Beer wrote:
> > Am Donnerstag, 12. August 2021, 19:39:08 CEST schrieb Michael Orlitzky:
> >> On Thu, 2021-08-12 at 17:22 +0200, Rolf Eike Beer wrote:
> >> > The default owner is root:root anyway.
> >> 
> >> This is only true of you don't call insopts earlier with some other
> >> value. I see "insopts -o root -g qmail -m 700" in there so you might
> >> want to double check.
> > 
> > Not my day.
> > 
> > Ok, given that there are several places that change users and groups
> > and the subfunctions are not always called it would be very few places
> > where I can remove the root:root (about 3) and be sure that everything
> > works. For that reason I would just keep them all and go back to the
> > initial patch 2.
> 
> I believe the method of choice would be to execute the offending
> insopts/doins pair in a subshell, i.e. put a ( ) pair around them.

I will just do it the other way: explicitly reset it to defaults in the 2 
functions that actually set something special.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 5/3] qmail.eclass: retire qmail_tcprules_fixup()
  2021-08-12  9:54 [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8 Rolf Eike Beer
                   ` (2 preceding siblings ...)
  2021-08-13  7:47 ` [gentoo-dev] [PATCH 4/3] qmail.eclass: remove needless keepdirs Rolf Eike Beer
@ 2021-08-13 10:44 ` Rolf Eike Beer
  3 siblings, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-13 10:44 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 2669 bytes --]

This has been in all ebuilds since the move of the portage tree to git, so
everyone should have already moved the files.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass                        | 22 ----------------------
 mail-mta/netqmail/netqmail-1.06-r14.ebuild |  4 ----
 mail-mta/notqmail/notqmail-1.08-r3.ebuild  |  4 ----
 mail-mta/notqmail/notqmail-9999.ebuild     |  4 ----
 4 files changed, 34 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index c25950cc303..7f4d1f77e42 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -374,28 +374,6 @@ qmail_rootmail_fixup() {
 	chown -R alias:qmail "${ROOT}${QMAIL_HOME}"/alias/.maildir 2>/dev/null
 }
 
-qmail_tcprules_fixup() {
-	mkdir -p "${TCPRULES_DIR}"
-	local POP_FILES=
-	use pop3 && POP_FILES="pop3 pop3.cdb"
-	for f in {smtp,qmtp,qmqp}{,.cdb} ${POP_FILES}; do
-		old="/etc/tcp.${f}"
-		new="${TCPRULES_DIR}/tcp.qmail-${f}"
-		fail=0
-		if [[ -f "${old}" && ! -f "${new}" ]]; then
-			einfo "Moving ${old} to ${new}"
-			cp "${old}" "${new}" || fail=1
-		else
-			fail=1
-		fi
-		if [[ "${fail}" = 1 && -f "${old}" ]]; then
-			eerror "Error moving ${old} to ${new}, be sure to check the"
-			eerror "configuration! You may have already moved the files,"
-			eerror "in which case you can delete ${old}"
-		fi
-	done
-}
-
 qmail_tcprules_build() {
 	for f in tcp.qmail-{smtp,qmtp,qmqp,pop3,pop3s}; do
 		# please note that we don't check if it exists
diff --git a/mail-mta/netqmail/netqmail-1.06-r14.ebuild b/mail-mta/netqmail/netqmail-1.06-r14.ebuild
index aef1ed5b4dd..e1f20404872 100644
--- a/mail-mta/netqmail/netqmail-1.06-r14.ebuild
+++ b/mail-mta/netqmail/netqmail-1.06-r14.ebuild
@@ -173,10 +173,6 @@ pkg_postinst() {
 	elog
 }
 
-pkg_preinst() {
-	qmail_tcprules_fixup
-}
-
 pkg_config() {
 	# avoid some weird locale problems
 	export LC_ALL=C
diff --git a/mail-mta/notqmail/notqmail-1.08-r3.ebuild b/mail-mta/notqmail/notqmail-1.08-r3.ebuild
index 382f241e719..6afc55ac3bd 100644
--- a/mail-mta/notqmail/notqmail-1.08-r3.ebuild
+++ b/mail-mta/notqmail/notqmail-1.08-r3.ebuild
@@ -173,10 +173,6 @@ pkg_postinst() {
 	elog
 }
 
-pkg_preinst() {
-	qmail_tcprules_fixup
-}
-
 pkg_config() {
 	# avoid some weird locale problems
 	export LC_ALL=C
diff --git a/mail-mta/notqmail/notqmail-9999.ebuild b/mail-mta/notqmail/notqmail-9999.ebuild
index 8673f74908f..224aaed0628 100644
--- a/mail-mta/notqmail/notqmail-9999.ebuild
+++ b/mail-mta/notqmail/notqmail-9999.ebuild
@@ -168,10 +168,6 @@ pkg_postinst() {
 	elog
 }
 
-pkg_preinst() {
-	qmail_tcprules_fixup
-}
-
 pkg_config() {
 	# avoid some weird locale problems
 	export LC_ALL=C
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 2/3 v3] qmail.eclass: remove magic to query root group
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
  2021-08-12 11:13   ` Ulrich Mueller
  2021-08-12 15:22   ` [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query " Rolf Eike Beer
@ 2021-08-14  9:36   ` Rolf Eike Beer
  2021-08-14 10:52     ` Ulrich Mueller
  2021-08-14 11:34   ` [gentoo-dev] [PATCH 2/3 v4] " Rolf Eike Beer
  3 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-14  9:36 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 4045 bytes --]

The default owner is root:root anyway, so just make sure other settings do not
leak outside from the places where it is actually used. This also fixes
qmail_supervise_install_one() when called from outside of qmail_src_install().

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 6b04cbf7792..c4f0b98ab30 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -73,7 +73,7 @@ is_prime() {
 
 dospp() {
 	insinto "${QMAIL_HOME}"/plugins/
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
 	newins $1 ${2:-$(basename $1)}
 }
 
@@ -86,8 +86,8 @@ dosupervise() {
 	local runfile=${2:-${service}} logfile=${3:-${service}-log}
 	[[ -z "${service}" ]] && die "no service given"
 
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	diropts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
+	diropts -m 0755
 
 	dodir ${SUPERVISE_DIR}/${service}{,/log}
 	fperms +t ${SUPERVISE_DIR}/${service}{,/log}
@@ -185,6 +185,10 @@ qmail_base_install() {
 	insopts -o qmailq -g qmail -m 4711
 	doins qmail-queue
 
+	# reset to default
+	insopts -o root -g root -m 644
+	diropts -o root -g root -m 755
+
 	declare -F qmail_base_install_hook >/dev/null && \
 		qmail_base_install_hook
 }
@@ -192,12 +196,12 @@ qmail_base_install() {
 qmail_config_install() {
 	einfo "Installing stock configuration files"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	doins "${GENQMAIL_S}"/control/{conf-*,defaultdelivery}
 
 	einfo "Installing configuration sanity checker and launcher"
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	doins "${GENQMAIL_S}"/control/qmail-config-system
 
 	declare -F qmail_config_install_hook >/dev/null && \
@@ -254,9 +258,9 @@ qmail_maildir_install() {
 	done
 
 	einfo "Setting up default maildirs in the account skeleton"
-	diropts -o root -g "${GROUP_ROOT}" -m 755
+	diropts -o root -g root -m 755
 	insinto /etc/skel
-	insopts -o root -g "${GROUP_ROOT}" -m 644
+	insopts -m 644
 	newins "${GENQMAIL_S}"/control/defaultdelivery .qmail.sample
 	"${MAILDIRMAKE}" "${D}"/etc/skel/.maildir
 	keepdir /etc/skel/.maildir/{cur,new,tmp}
@@ -268,7 +272,7 @@ qmail_maildir_install() {
 qmail_tcprules_install() {
 	dodir "${TCPRULES_DIR}"
 	insinto "${TCPRULES_DIR}"
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/tcprules/Makefile.qmail
 	doins "${GENQMAIL_S}"/tcprules/tcp.qmail-*
 	use ssl && use pop3 || rm -f "${D}${TCPRULES_DIR}"/tcp.qmail-pop3sd
@@ -276,8 +280,10 @@ qmail_tcprules_install() {
 
 qmail_supervise_install_one() {
 	dosupervise ${1}
-	diropts -o qmaill -g "${GROUP_ROOT}" -m 755
+	diropts -o qmaill -g root -m 755
 	keepdir /var/log/qmail/${1}
+	# reset to default
+	diropts -o root -g root
 }
 
 qmail_supervise_install() {
@@ -301,7 +307,7 @@ qmail_supervise_install() {
 qmail_spp_install() {
 	einfo "Installing qmail-spp configuration files"
 	insinto "${QMAIL_HOME}"/control/
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/spp/smtpplugins
 
 	einfo "Installing qmail-spp plugins"
@@ -321,16 +327,15 @@ qmail_ssl_install() {
 
 	einfo "Installing SSL Certificate creation script"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
+	insopts -m 0644
 	doins "${GENQMAIL_S}"/ssl/servercert.cnf
 
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
+	insopts -m 0755
 	doins "${GENQMAIL_S}"/ssl/mkservercert
 
 	einfo "Installing RSA key generation cronjob"
 	insinto /etc/${CRON_FOLDER}
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
 	doins "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh
 
 	keepdir "${QMAIL_HOME}"/control/tlshosts
@@ -340,7 +345,6 @@ qmail_ssl_install() {
 }
 
 qmail_src_install() {
-	export GROUP_ROOT="$(id -gn root)"
 	qmail_base_install
 	qmail_config_install
 	qmail_man_install
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query root group
  2021-08-13 10:31           ` Rolf Eike Beer
@ 2021-08-14 10:43             ` David Seifert
  0 siblings, 0 replies; 22+ messages in thread
From: David Seifert @ 2021-08-14 10:43 UTC (permalink / raw
  To: gentoo-dev

On Fri, 2021-08-13 at 12:31 +0200, Rolf Eike Beer wrote:
> Am Freitag, 13. August 2021, 11:06:09 CEST schrieb Ulrich Mueller:
> > > > > > > On Fri, 13 Aug 2021, Rolf Eike Beer wrote:
> > > Am Donnerstag, 12. August 2021, 19:39:08 CEST schrieb Michael
> > > Orlitzky:
> > > > On Thu, 2021-08-12 at 17:22 +0200, Rolf Eike Beer wrote:
> > > > > The default owner is root:root anyway.
> > > > 
> > > > This is only true of you don't call insopts earlier with some
> > > > other
> > > > value. I see "insopts -o root -g qmail -m 700" in there so you
> > > > might
> > > > want to double check.
> > > 
> > > Not my day.
> > > 
> > > Ok, given that there are several places that change users and
> > > groups
> > > and the subfunctions are not always called it would be very few
> > > places
> > > where I can remove the root:root (about 3) and be sure that
> > > everything
> > > works. For that reason I would just keep them all and go back to
> > > the
> > > initial patch 2.
> > 
> > I believe the method of choice would be to execute the offending
> > insopts/doins pair in a subshell, i.e. put a ( ) pair around them.
> 
> I will just do it the other way: explicitly reset it to defaults in
> the 2 
> functions that actually set something special.

Please us subshells instead, it makes local reasoning about the side-
effects much easier.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3 v3] qmail.eclass: remove magic to query root group
  2021-08-14  9:36   ` [gentoo-dev] [PATCH 2/3 v3] " Rolf Eike Beer
@ 2021-08-14 10:52     ` Ulrich Mueller
  2021-08-14 11:11       ` Rolf Eike Beer
  0 siblings, 1 reply; 22+ messages in thread
From: Ulrich Mueller @ 2021-08-14 10:52 UTC (permalink / raw
  To: Rolf Eike Beer; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 687 bytes --]

>>>>> On Sat, 14 Aug 2021, Rolf Eike Beer wrote:

> The default owner is root:root anyway, so just make sure other settings do not
> leak outside from the places where it is actually used. This also fixes
> qmail_supervise_install_one() when called from outside of qmail_src_install().

Looking at this patch again, I wonder about two points in general:

- diropts -m 0755 shouldn't be necessary. 0775 is dodir's default, and I
  don't see any diropts with another -m option in the eclass.

- insinto ...; insopts -m 0755; doins ... presumably indicates that the
  wrong tool is used, i.e. it should be exeinto ...; doexe ... instead.
  doexe already defaults to file mode 0755.

Ulrich

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3 v3] qmail.eclass: remove magic to query root group
  2021-08-14 10:52     ` Ulrich Mueller
@ 2021-08-14 11:11       ` Rolf Eike Beer
  2021-08-14 11:54         ` Ulrich Mueller
  0 siblings, 1 reply; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-14 11:11 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

Am Samstag, 14. August 2021, 12:52:15 CEST schrieb Ulrich Mueller:
> >>>>> On Sat, 14 Aug 2021, Rolf Eike Beer wrote:
> > The default owner is root:root anyway, so just make sure other settings do
> > not leak outside from the places where it is actually used. This also
> > fixes qmail_supervise_install_one() when called from outside of
> > qmail_src_install().
> Looking at this patch again, I wonder about two points in general:
> 
> - diropts -m 0755 shouldn't be necessary. 0775 is dodir's default, and I
>   don't see any diropts with another -m option in the eclass.
> 
> - insinto ...; insopts -m 0755; doins ... presumably indicates that the
>   wrong tool is used, i.e. it should be exeinto ...; doexe ... instead.
>   doexe already defaults to file mode 0755.

You are absolutely right. I suspect the code simply predates those helpers, 
I'm going to clean this up. It will often not reduce the amount of calls as 
there are several things that get installed with different group and 
permissions.

Sadly the docs at https://devmanual.gentoo.org/function-reference/install-functions/ do not show the defaults, is there a better place to looks at?

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 2/3 v4] qmail.eclass: remove magic to query root group
  2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
                     ` (2 preceding siblings ...)
  2021-08-14  9:36   ` [gentoo-dev] [PATCH 2/3 v3] " Rolf Eike Beer
@ 2021-08-14 11:34   ` Rolf Eike Beer
  3 siblings, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-14 11:34 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 7053 bytes --]

The default owner is root:root anyway, so just make sure other settings do not
leak outside from the places where it is actually used. Use more appropiate
install helpers at several places. This also fixes qmail_supervise_install_one()
when called from outside of qmail_src_install().

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 87 ++++++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 45 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 6b04cbf7792..be31dccc101 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -72,9 +72,8 @@ is_prime() {
 }
 
 dospp() {
-	insinto "${QMAIL_HOME}"/plugins/
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	newins $1 ${2:-$(basename $1)}
+	exeinto "${QMAIL_HOME}"/plugins/
+	newexe ${1} ${2:-$(basename ${1})}
 }
 
 # @FUNCTION: dosupervise
@@ -86,17 +85,14 @@ dosupervise() {
 	local runfile=${2:-${service}} logfile=${3:-${service}-log}
 	[[ -z "${service}" ]] && die "no service given"
 
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	diropts -o root -g "${GROUP_ROOT}" -m 0755
-
 	dodir ${SUPERVISE_DIR}/${service}{,/log}
 	fperms +t ${SUPERVISE_DIR}/${service}{,/log}
 
-	insinto ${SUPERVISE_DIR}/${service}
-	newins ${runfile} run
+	exeinto ${SUPERVISE_DIR}/${service}
+	newexe ${runfile} run
 
-	insinto ${SUPERVISE_DIR}/${service}/log
-	newins ${logfile} run
+	exeinto ${SUPERVISE_DIR}/${service}/log
+	newexe ${logfile} run
 }
 
 # @FUNCTION: qmail_set_cc
@@ -149,41 +145,45 @@ qmail_spp_src_compile() {
 }
 
 qmail_base_install() {
+	# subshell to not leak the install options
+	(
 	einfo "Setting up basic directory hierarchy"
-	diropts -o root -g qmail -m 755
+	diropts -o root -g qmail
 	keepdir "${QMAIL_HOME}"/{,bin,control}
 	keepdir "${QMAIL_HOME}"/users
-	diropts -o alias -g qmail -m 755
+	diropts -o alias -g qmail
 	keepdir "${QMAIL_HOME}"/alias
 
 	einfo "Adding env.d entry for qmail"
 	doenvd "${GENQMAIL_S}"/conf/99qmail
 
 	einfo "Installing all qmail software"
-	insinto "${QMAIL_HOME}"/bin
+	exeinto "${QMAIL_HOME}"/bin
 
-	insopts -o root -g qmail -m 755
-	doins bouncesaying condredirect config-fast datemail except forward maildir2mbox \
+	exeopts -o root -g qmail
+	doexe bouncesaying condredirect config-fast datemail except forward maildir2mbox \
 		maildirmake mailsubj predate preline qbiff \
 		qmail-{inject,qmqpc,qmqpd,qmtpd,qread,qstat,smtpd,tcpok,tcpto,showctl} \
 		qreceipt sendmail tcp-env
 
 	# obsolete tools, install if they are still present
 	for i in elq maildirwatch pinq qail qsmhook; do
-		[[ -x ${i} ]] && doins ${i}
+		[[ -x ${i} ]] && doexe ${i}
 	done
 
-	use pop3 && doins qmail-pop3d
+	use pop3 && doexe qmail-pop3d
 
-	insopts -o root -g qmail -m 711
-	doins qmail-{clean,getpw,local,pw2u,remote,rspawn,send} splogger
-	use pop3 && doins qmail-popup
+	exeopts -o root -g qmail -m 711
+	doexe qmail-{clean,getpw,local,pw2u,remote,rspawn,send} splogger
+	use pop3 && doexe qmail-popup
 
-	insopts -o root -g qmail -m 700
-	doins qmail-{lspawn,newmrh,newu,start}
+	exeopts -o root -g qmail -m 700
+	doexe qmail-{lspawn,newmrh,newu,start}
 
-	insopts -o qmailq -g qmail -m 4711
-	doins qmail-queue
+	exeopts -o qmailq -g qmail -m 4711
+	doexe qmail-queue
+
+	)
 
 	declare -F qmail_base_install_hook >/dev/null && \
 		qmail_base_install_hook
@@ -192,12 +192,10 @@ qmail_base_install() {
 qmail_config_install() {
 	einfo "Installing stock configuration files"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 644
 	doins "${GENQMAIL_S}"/control/{conf-*,defaultdelivery}
 
 	einfo "Installing configuration sanity checker and launcher"
 	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 644
 	doins "${GENQMAIL_S}"/control/qmail-config-system
 
 	declare -F qmail_config_install_hook >/dev/null && \
@@ -224,7 +222,6 @@ qmail_man_install() {
 
 qmail_sendmail_install() {
 	einfo "Installing sendmail replacement"
-	diropts -m 755
 	dodir /usr/sbin /usr/lib
 
 	dosym "${QMAIL_HOME}"/bin/sendmail /usr/sbin/sendmail
@@ -235,12 +232,21 @@ qmail_sendmail_install() {
 }
 
 qmail_maildir_install() {
+	# subshell to not leak the install options
+	(
 	# use the correct maildirmake
 	# the courier-imap one has some extensions that are nicer
 	MAILDIRMAKE="${D}${QMAIL_HOME}/bin/maildirmake"
 	[[ -e /usr/bin/maildirmake ]] && \
 		MAILDIRMAKE="/usr/bin/maildirmake"
 
+	einfo "Setting up default maildirs in the account skeleton"
+	diropts -m 700
+	insinto /etc/skel
+	newins "${GENQMAIL_S}"/control/defaultdelivery .qmail.example
+	"${MAILDIRMAKE}" "${D}"/etc/skel/.maildir
+	keepdir /etc/skel/.maildir/{cur,new,tmp}
+
 	einfo "Setting up the default aliases"
 	diropts -o alias -g qmail -m 700
 	"${MAILDIRMAKE}" "${D}${QMAIL_HOME}"/alias/.maildir
@@ -253,13 +259,7 @@ qmail_maildir_install() {
 		fi
 	done
 
-	einfo "Setting up default maildirs in the account skeleton"
-	diropts -o root -g "${GROUP_ROOT}" -m 755
-	insinto /etc/skel
-	insopts -o root -g "${GROUP_ROOT}" -m 644
-	newins "${GENQMAIL_S}"/control/defaultdelivery .qmail.sample
-	"${MAILDIRMAKE}" "${D}"/etc/skel/.maildir
-	keepdir /etc/skel/.maildir/{cur,new,tmp}
+	)
 
 	declare -F qmail_maildir_install_hook >/dev/null && \
 		qmail_maildir_install_hook
@@ -268,7 +268,6 @@ qmail_maildir_install() {
 qmail_tcprules_install() {
 	dodir "${TCPRULES_DIR}"
 	insinto "${TCPRULES_DIR}"
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
 	doins "${GENQMAIL_S}"/tcprules/Makefile.qmail
 	doins "${GENQMAIL_S}"/tcprules/tcp.qmail-*
 	use ssl && use pop3 || rm -f "${D}${TCPRULES_DIR}"/tcp.qmail-pop3sd
@@ -276,8 +275,11 @@ qmail_tcprules_install() {
 
 qmail_supervise_install_one() {
 	dosupervise ${1}
-	diropts -o qmaill -g "${GROUP_ROOT}" -m 755
+	# subshell to not leak the install options
+	(
+	diropts -o qmaill -g root
 	keepdir /var/log/qmail/${1}
+	)
 }
 
 qmail_supervise_install() {
@@ -301,7 +303,6 @@ qmail_supervise_install() {
 qmail_spp_install() {
 	einfo "Installing qmail-spp configuration files"
 	insinto "${QMAIL_HOME}"/control/
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
 	doins "${GENQMAIL_S}"/spp/smtpplugins
 
 	einfo "Installing qmail-spp plugins"
@@ -321,17 +322,14 @@ qmail_ssl_install() {
 
 	einfo "Installing SSL Certificate creation script"
 	insinto "${QMAIL_HOME}"/control
-	insopts -o root -g "${GROUP_ROOT}" -m 0644
 	doins "${GENQMAIL_S}"/ssl/servercert.cnf
 
-	insinto "${QMAIL_HOME}"/bin
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	doins "${GENQMAIL_S}"/ssl/mkservercert
+	exeinto "${QMAIL_HOME}"/bin
+	doexe "${GENQMAIL_S}"/ssl/mkservercert
 
 	einfo "Installing RSA key generation cronjob"
-	insinto /etc/${CRON_FOLDER}
-	insopts -o root -g "${GROUP_ROOT}" -m 0755
-	doins "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh
+	exeinto /etc/${CRON_FOLDER}
+	doexe "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh
 
 	keepdir "${QMAIL_HOME}"/control/tlshosts
 
@@ -340,7 +338,6 @@ qmail_ssl_install() {
 }
 
 qmail_src_install() {
-	export GROUP_ROOT="$(id -gn root)"
 	qmail_base_install
 	qmail_config_install
 	qmail_man_install
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [gentoo-dev] [PATCH 4/3 v2] qmail.eclass: remove needless keepdirs
  2021-08-13  7:47 ` [gentoo-dev] [PATCH 4/3] qmail.eclass: remove needless keepdirs Rolf Eike Beer
@ 2021-08-14 11:47   ` Rolf Eike Beer
  0 siblings, 0 replies; 22+ messages in thread
From: Rolf Eike Beer @ 2021-08-14 11:47 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

Adding an extra keep file in the intermediate /var/qmail is never necessary,
and the binary directory is filled by the installation anyway.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
---
 eclass/qmail.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass
index 86a299ca60d..9abe0548194 100644
--- a/eclass/qmail.eclass
+++ b/eclass/qmail.eclass
@@ -134,8 +134,8 @@ qmail_base_install() {
 	(
 	einfo "Setting up basic directory hierarchy"
 	diropts -o root -g qmail
-	keepdir "${QMAIL_HOME}"/{,bin,control}
-	keepdir "${QMAIL_HOME}"/users
+	dodir "${QMAIL_HOME}"/bin
+	keepdir "${QMAIL_HOME}"/{control,users}
 	diropts -o alias -g qmail
 	keepdir "${QMAIL_HOME}"/alias
 
-- 
2.26.2


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3 v3] qmail.eclass: remove magic to query root group
  2021-08-14 11:11       ` Rolf Eike Beer
@ 2021-08-14 11:54         ` Ulrich Mueller
  0 siblings, 0 replies; 22+ messages in thread
From: Ulrich Mueller @ 2021-08-14 11:54 UTC (permalink / raw
  To: Rolf Eike Beer; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

>>>>> On Sat, 14 Aug 2021, Rolf Eike Beer wrote:

> Sadly the docs at
> https://devmanual.gentoo.org/function-reference/install-functions/
> do not show the defaults,

Hm, it says "mode 0755" for doexe, but nothing for doins and dodir.
This should be improved indeed.

> is there a better place to looks at?

Either PMS at https://projects.gentoo.org/pms/8/pms.html#x1-12900012.3.9
or the ebuild(5) man page.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-08-14 11:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-12  9:54 [gentoo-dev] [PATCH 1/3] qmail.eclass: support EAPI 8 Rolf Eike Beer
2021-08-12  9:55 ` [gentoo-dev] [PATCH 2/3] qmail.eclass: hardcode root group Rolf Eike Beer
2021-08-12 11:13   ` Ulrich Mueller
2021-08-12 14:03     ` Rolf Eike Beer
2021-08-12 15:22   ` [gentoo-dev] [PATCH 2/3] qmail.eclass: remove magic to query " Rolf Eike Beer
2021-08-12 17:39     ` Michael Orlitzky
2021-08-13  7:17       ` Rolf Eike Beer
2021-08-13  9:06         ` Ulrich Mueller
2021-08-13 10:31           ` Rolf Eike Beer
2021-08-14 10:43             ` David Seifert
2021-08-14  9:36   ` [gentoo-dev] [PATCH 2/3 v3] " Rolf Eike Beer
2021-08-14 10:52     ` Ulrich Mueller
2021-08-14 11:11       ` Rolf Eike Beer
2021-08-14 11:54         ` Ulrich Mueller
2021-08-14 11:34   ` [gentoo-dev] [PATCH 2/3 v4] " Rolf Eike Beer
2021-08-12  9:55 ` [gentoo-dev] [PATCH 3/5] qmail.eclass: simplify is_prime() Rolf Eike Beer
2021-08-12 11:25   ` Ulrich Mueller
2021-08-12 15:25     ` Rolf Eike Beer
2021-08-12 15:25   ` [gentoo-dev] [PATCH 3/3] " Rolf Eike Beer
2021-08-13  7:47 ` [gentoo-dev] [PATCH 4/3] qmail.eclass: remove needless keepdirs Rolf Eike Beer
2021-08-14 11:47   ` [gentoo-dev] [PATCH 4/3 v2] " Rolf Eike Beer
2021-08-13 10:44 ` [gentoo-dev] [PATCH 5/3] qmail.eclass: retire qmail_tcprules_fixup() Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox