Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run pbench other than root user #89

Open
akrzos opened this issue Oct 6, 2015 · 9 comments
Open

Run pbench other than root user #89

akrzos opened this issue Oct 6, 2015 · 9 comments
Labels
Agent Backlog enhancement tools Of and related to the operation and behavior of various tools (iostat, sar, etc.)

Comments

@akrzos
Copy link

akrzos commented Oct 6, 2015

While working on getting pbench to run from a user which doesn't exist on other remote nodes, I was able to get a tool to register however pbench now displays there is an additional host named "root".

Ideally, I could set what user to run the tool under.

[stack@manager ~]$ register-tool --name=mpstat [email protected]
[[email protected]]Package pbench-sysstat-11.1.2-32.el7.centos.x86_64 already installed and latest version
[[email protected]]mpstat tool is now registered in group default
[stack@manager ~]$ list-tools
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
ssh: Could not resolve hostname root: Name or service not known
default: root[],192.0.2.12[],192.0.2.11[]
@akrzos
Copy link
Author

akrzos commented Oct 6, 2015

As a work around you can setup the user ssh's config file:

/home/stack/.ssh/config

hostname 192.0.2.12
user root

This forces the stack user to be root on the remote machine in the above example which allows tools to be correctly registered. Make sure you set permissions correctly on .ssh/config

@ndokos
Copy link
Member

ndokos commented Oct 6, 2015

Can you post your tools.$group file after you ran 'register-tool'?

@ndokos
Copy link
Member

ndokos commented Oct 6, 2015

Some more errors from akrzos:

After Rally task start.
/opt/pbench-agent/util-scripts/sysinfo-dump: line 36: pushd: /var/log/libvirt: Permission denied
/opt/pbench-agent/util-scripts/sysinfo-dump: line 38: pushd: /etc/libvirt: Permission denied
tar: overcloud-controller-0/block-params.log: time stamp 2015-10-06 13:51:56 is 854.132324512 s in the future
tar: overcloud-controller-0/libvirt/log: time stamp 2015-10-06 13:51:56 is 854.131651662 s in the future

@akrzos
Copy link
Author

akrzos commented Oct 7, 2015

The time in the future is a non-issue, apparently OSPd doesn't have ntp setup and that is fixed. However the permissions issue I can't seem to solve without breaking other things.

I tried to run sudo user-benchmark ... this is met with user-benchmark not found, in which case you must edit your sudoers file and change the secure_path line to match:
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/opt/pbench-agent/util-scripts:/opt/pbench-agent/bench-scripts

Now the issue becomes my user-benchmark script really needs to run as user stack and source the correct environment, thus the benchmark can't be run now. I might have to resort to start/stop tool scripts since I can sudo those without impacting the actual benchmarking tool (Rally) then.

@ndokos
Copy link
Member

ndokos commented Oct 7, 2015

Try something like this:

sudo -u stack bash -c 'source /etc/profile.d/pbench-agent.sh; user-benchmark ....'

You may have to add the uid of the invoker to the appropriate group (usually "wheel" on RH/Fedora/CentOS).

Does this work for you?

@ndokos
Copy link
Member

ndokos commented Apr 6, 2016

This is from some mail that I exchanced with Alex, added here for future reference:

Alex has been trying to do this and has been running into problems. The
basic ones are:

o ownership of /var/lib/pbench-agent - that's where the results
directory is created.

o ownership of /opt/pbench-agent/id_rsa - that needs to be readable in
order for move-results to succeed - the way it's installed, it's
owned by pbench.pbench with mode 600. I think it needs to be 600,
so the only solution seems to be to change the owner or use multiple sudo
invocations: an outer one to user "pbench" to allow user-benchmark to
get at the key file and an inner one to user "stack" (e.g.) to run the
script.

o collect-sysinfo problems - I get the following:

,----
| + collect-sysinfo --group=default
| --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_12:52:24
| end
| Collecting system information
| /opt/pbench-agent/util-scripts/sysinfo-dump: line 36: pushd: /var/log/libvirt: Permission denied
| /opt/pbench-agent/util-scripts/sysinfo-dump: line 38: pushd: /etc/libvirt: Permission denied
`----

There are a couple of methods we could use to address these problems:

o per-user config file in e.g. ~/.config/pbench-agent/pbench-agent.conf

That can override /var/lib/pbench-agent as the default run directory,
resolving the first problem.

o Add the user to the pbench group - that would resolve the second
problem.

o Run collect-sysinfo under sudo - that would require that mods be
made to /etc/sudoers (e.g. allowing %wheel no-password sudo privileges
and adding the user to the "wheel" group).

As an experiment, I let the wheel group do anything in /etc/sudoers,
added the pbench user (in addition to my own user id) to the "wheel"
group and added a "stack" user with no special privileges.

With those (or similar) modifications, I can run the following script[fn:1]:

#! /bin/bash

sudo -u stack bash -c 'echo $PATH; id; sleep 10'

under a somewhat modified user-benchmark with the following output (I've annotated
part of the output using the markup '##### here is an annotation'):

#### running user-benchmark under user pbench solves the id_rsa ownership problem here.

#### Note also that sudo resets the path, so we need to source /etc/profile.d/pbench-agent.sh explicitly.

$ sudo -u pbench bash -c '. /etc/profile.d/pbench-agent.sh; user-benchmark --config=akrzos -- /tmp/my-user-benchmark-script'

+ id      #### added to user-benchmark for debugging purposes - running as pbench.
uid=1001(pbench) gid=1001(pbench) groups=1001(pbench),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

+ export benchmark config

#### in this case, I chowned /var/lib/pbench-agent to pbench.pbench, but config file is probably better.
+ metadata-log --group=default --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31 beg
+ start-tools --group=default --iteration=1 --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31/1/reference-result
+ echo 'Running /tmp/my-user-benchmark-script'
Running /tmp/my-user-benchmark-script
+ log '[user-benchmark] Running /tmp/my-user-benchmark-script'
++ timestamp
+++ date +%Y%m%d_%H:%M:%S.%N
++ echo 20151007_13:03:32.145484021
+ debug_date=20151007_13:03:32.145484021
+ echo '[info][20151007_13:03:32.145484021] [user-benchmark] Running /tmp/my-user-benchmark-script'
+ /tmp/my-user-benchmark-script
+ tee /var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31/1/reference-result/result.txt

#### the sudo inside the script resets the PATH - the script has to fix that if necessary
/sbin:/bin:/usr/sbin:/usr/bin
#### the sudo -u stack inside the script is effective
uid=1002(stack) gid=1002(stack) groups=1002(stack) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

+ stop-tools --group=default --iteration=1 --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31/1/reference-result
/opt/pbench-agent/tool-scripts/perf: line 139: kill: (18265) - No such process
+ postprocess-tools --group=default --iteration=1 --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31/1/reference-result

#### and the sudo here is a mod to user-benchmark - needs to be careful with quoting, but it is effective.
+ sudo bash -c 'source /etc/profile.d/pbench-agent.sh; collect-sysinfo --group=default --dir=/var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31 end'
Collecting system information

+ rmdir /var/lib/pbench-agent/user-benchmark_akrzos_2015-10-07_13:03:31/1/reference-result/.running

So it looks possible and without too many modifications.

Thoughts?

Footnotes:

[fn:1] I could not get the quoting right - that's why I created the
script.

@ndokos
Copy link
Member

ndokos commented Apr 6, 2016

Currently, the private key file is installed with mode 640 and ownership pbench.pbench. If you add a user to the pbench group, then that user can read the key file. This does not work for the pbench user itself though:

Permissions 0640 for '/opt/pbench-agent/id_rsa' are too open.

It does work with any other user in the pbench group.

@ndokos
Copy link
Member

ndokos commented Jul 26, 2016

Issue #300 (opened by mistake and now closed) is the same issue.

@ashishkamra ashishkamra self-assigned this Oct 23, 2017
@ashishkamra ashishkamra added this to the V0.47 milestone Oct 23, 2017
@ashishkamra
Copy link
Member

need further investigation

@ndokos ndokos modified the milestones: V0.47, V0.49 Jan 10, 2018
@ndokos ndokos modified the milestones: V0.49, v0.51 May 14, 2018
@portante portante modified the milestones: v0.51, v0.52 Jul 16, 2018
@portante portante modified the milestones: v0.52, v0.53, v0.54 Aug 16, 2018
@portante portante modified the milestones: v0.54, v0.55 Sep 11, 2018
@portante portante removed this from the v0.55 milestone Jan 25, 2019
@portante portante added this to the v0.56 milestone Jan 25, 2019
@portante portante modified the milestones: v0.56, v0.57 Feb 6, 2019
@portante portante modified the milestones: v0.57, v0.58 Mar 8, 2019
@portante portante modified the milestones: v0.58, v0.59 Apr 16, 2019
@portante portante modified the milestones: v0.59, v0.60 Apr 29, 2019
@portante portante modified the milestones: v0.60, v0.61 May 24, 2019
@portante portante removed this from the v0.61 milestone Jul 8, 2019
@portante portante added Agent tools Of and related to the operation and behavior of various tools (iostat, sar, etc.) Backlog labels Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Backlog enhancement tools Of and related to the operation and behavior of various tools (iostat, sar, etc.)
Projects
None yet
Development

No branches or pull requests

4 participants