coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Various tests give illusory results


From: Jim Meyering
Subject: Re: Various tests give illusory results
Date: Tue, 14 Aug 2012 18:05:06 +0200

Ondrej Oprala wrote:
...
> Subject: [PATCH] tests: Add error checking for root-only tests running
>  setuidgid
>
> * NEWS: Mention the fix.
> * tests/init.cfg: Modify the require_root_ function to check
> for setuidgid calls and proper permissions.
> ---
>  NEWS           |  6 ++++++
>  tests/init.cfg | 19 +++++++++++++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/NEWS b/NEWS
> index 46d0a41..173f861 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -7,6 +7,12 @@ GNU coreutils NEWS                                    -*- 
> outline -*-
>    certain options like -a, -l, -t and -x.
>    [This bug was present in "the beginning".]
>
> +** Bug fixes
> +
> +  root-only tests now properly check for permissions of dummy
> +  user $NON_ROOT_USERNAME before trying to run binaries from the
> +  src dir.

If mentioned in NEWS at all, this would go in an "Improved tests"
category, not under "Bug fixes", since the problem arises only for those
rare people who:

  - run the root-only tests, and
  - do not following the instructions in README


> diff --git a/tests/init.cfg b/tests/init.cfg
> index 4ff5ad4..2d0fe10 100644
> --- a/tests/init.cfg
> +++ b/tests/init.cfg
> @@ -341,11 +341,30 @@ or use the shortcut target of the toplevel Makefile,
>    fi
>  }
>
> +setuidgid_has_perm_()
> +{
> +  local rm_version=$(
> +    setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version |
> +    sed -n 'ls/.* //p'
> +  )
> +  case "_${rm_version}_" in
> +      _$PACKAGE_VERSION}_) ;;

Missing "{" ?

         _${PACKAGE_VERSION}_) ;;

> +      *) return 1;;
> +  esac
> +}
> +
>  require_root_()
>  {
>    uid_is_privileged_ || skip_ "must be run as root"
>    NON_ROOT_USERNAME=${NON_ROOT_USERNAME=nobody}
>    NON_ROOT_GROUP=${NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)}
> +
> +  #if test contains a setuidgid call...
> +  grep '^[ ]*setuidgid' "../$0"
> +  if [ "$?" = "0" ]; then
> +    setuidgid_has_perm_ ||
> +    skip_ "user $NON_ROOT_USERNAME lacks execute permissions"
> +  fi
>  }

I would prefer to write that as

     grep '^[ ]*setuidgid' "../$0" \
       && { setuidgid_has_perm_ \
              || skip_ "user $NON_ROOT_USERNAME lacks permissions"; }

Also, please add this line to the end of the commit log
acknowledging Bernhard's improvements:

Improved-by: Bernhard Voelker



reply via email to

[Prev in Thread] Current Thread [Next in Thread]