Hide Forgot
Description of problem: By default all tests in beaker are run as user root, however it is not always required. Many test cases could/should be tested as ordinary user but it is not done because with current BeakerLib functions it is not really comfortable: 1. create a user 2. set the environment 3. since permanently swiths to that user by su is not an option here, every command has to run through su/sudo etc Goal: If there was a simple/easy way how to switch to ordinary user, run commands and BeakerLib functions, collect the result log files, etc. it would significantly improve the test efficiency. How to do: Just an idea (I did not investigate yet how it could be implemented): 1. BeakerLib function: rlUserStart [username]/rlUserEnd [username] [file, ...] - the user could be transparently created and destroyed, if username not given, generate a random - all commands between these functions would run as the new user - in ideal case these functions could be even nested (switch between more users) - created log files collected when the user is destroyed, saved in working directory, set the rights, etc Any ideas are welcomed; a brainstorming session could help to collect the ideas: the point is to make the usage as simple as possible so people start to use it
The 'run whole test' as user is a Beaker harness thing, maybe a tortilla wrapper. I presume some RFEs for report-result and other beaker harness API pieces would be needed to allow running them as non-root. That is definitely not a BeakerLib material. The 'run parts of the test' as different user is a different story. There is a RFE hanging somewhere around for something like a 'rlRunAsUser', which is the approach I personally like and it mimics the use-case I usually encounter when writing tests. An option is to rewrite rlRun to accept a -u 'user' arg. The proposal seems quite hard to implement to me (after all, the test is just a bash script), and I do not see a benefit over the simple rlRunAsUser approach.
If there were something like 'rlRunAsUser', this RFE would not be created. I agree that it could be easier to implement something like 'rlRunAsUser', however run a block of commands as different user is more comfortable, but this is a detail. The main point for me is to have at least something that would make the life easier, if it is 'rlRunAsUser', so be but I haven't found such a RFE.