Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged

2017-11-21 Thread Francesco Riosa
On 11/20/17 05:09, hero...@gentoo.org wrote:
[...]
> diff --git a/eclass/user.eclass b/eclass/user.eclass
> index 86bcd282479..76a622df698 100644
> --- a/eclass/user.eclass
> +++ b/eclass/user.eclass
> @@ -103,6 +103,10 @@ egetent() {
>  # Default uid is (pass -1 for this) next available, default shell is
>  # /bin/false, default homedir is /dev/null, and there are no default groups.
>  enewuser() {
> + if [[ ${EUID} != 0 ]] ; then
> + einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
maybe ewarn() is more appropriate than einfo()?
Just in case it's executed outside the scope of prefix

[...]



Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged

2017-11-19 Thread M. J. Everitt
On 20/11/17 03:38, hero...@gentoo.org wrote:
> From: Benda Xu 
>
> Thanks MJ, how about "Unprivileged to execute"? Less bytes.
>
>   enewgroup and enewuser does not apply when executed as a normal
>   user, e.g. under Gentoo Prefix.
> ---
>  eclass/user.eclass | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/eclass/user.eclass b/eclass/user.eclass
> index 86bcd282479..8ff06935277 100644
> --- a/eclass/user.eclass
> +++ b/eclass/user.eclass
> @@ -103,6 +103,10 @@ egetent() {
>  # Default uid is (pass -1 for this) next available, default shell is
>  # /bin/false, default homedir is /dev/null, and there are no default groups.
>  enewuser() {
> + if [[ ${EUID} != 0 ]] ; then
> + einfo "Unprivileged to execute ${FUNCNAME[0]}"
> + return 0
> + fi
>   _assert_pkg_ebuild_phase ${FUNCNAME}
>  
>   # get the username
> @@ -262,6 +266,10 @@ enewuser() {
>  # do the rest.  You may specify the gid for the group or allow the group to
>  # allocate the next available one.
>  enewgroup() {
> + if [[ ${EUID} != 0 ]] ; then
> + einfo "Unprivileged to execute ${FUNCNAME[0]}"
> + return 0
> + fi
>   _assert_pkg_ebuild_phase ${FUNCNAME}
>  
>   # get the group
That's rather strange English .. perhaps "Unprivileged: cannot execute..."

MJE



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-dev] [RFC, PATCH] user.eclass: gracefully return when unprivileged.

2017-11-19 Thread M. J. Everitt
On 20/11/17 03:25, hero...@gentoo.org wrote:
> From: Benda Xu 
>
>   enewgroup and enewuser does not apply when executed as a normal
>   user, e.g. under Gentoo Prefix.
> ---
>  eclass/user.eclass | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/eclass/user.eclass b/eclass/user.eclass
> index 86bcd282479..82ccc1100ac 100644
> --- a/eclass/user.eclass
> +++ b/eclass/user.eclass
> @@ -103,6 +103,10 @@ egetent() {
>  # Default uid is (pass -1 for this) next available, default shell is
>  # /bin/false, default homedir is /dev/null, and there are no default groups.
>  enewuser() {
> + if [[ ${EUID} != 0 ]] ; then
> + einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
> + return 0
> + fi
>   _assert_pkg_ebuild_phase ${FUNCNAME}
>  
>   # get the username
> @@ -262,6 +266,10 @@ enewuser() {
>  # do the rest.  You may specify the gid for the group or allow the group to
>  # allocate the next available one.
>  enewgroup() {
> + if [[ ${EUID} != 0 ]] ; then
> + einfo "Donot have enough privilege to execute ${FUNCNAME[0]}"
> + return 0
> + fi
>   _assert_pkg_ebuild_phase ${FUNCNAME}
>  
>   # get the group
s/Donot have enough privilege/Insufficient privileges/ or "Needs root"

MJE



signature.asc
Description: OpenPGP digital signature