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

debian-test run as which user?



I just ran into a problem with debian-test.

I have set up devscripts on my machine to make debpkg (a dpkg wrapper)
setuid root.  So I run the new debit script, which happily installs
the package, but then the debian-test fails, because it is prefaced by
su -c nobody.

What I would prefer would be for the tests to make no assumption as to
whether they are being run as root or as nobody or as any other user.
If they need to be run as root, they should use the line:

testroot || { echo "These tests must be run as root!">&2; exit 1; }

where testroot is defined in functions.sh to be something like

testroot() {
  test `id -u` -eq 0
}

Then if the tests need to run as a specific user, they can do:
if [ `id -u` -ne `id -u required_user` ]; then
   testroot || {
      echo "These tests must be run as root or required_user">&2; exit 1;
   }
   su required_user -c 'command'
else
   command
fi

   Julian

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
        Debian GNU/Linux Developer,  see http://www.debian.org/~jdg


Reply to: