0

I want to use Intel Pin Tool to instrument open-ssh server. I do not know any way to do that other than following command.

$PIN_HOME/pin -t somepintool.so -- /usr/sbin/sshd

So, mainly I want to know how to use pin tool to instrument a service using systemctl, however, as I do not see any way for that, I can handle this if I know how to stop the sshd service without using systemctl.

My own thought was to kill sshd process. Is it a good idea? Any other suggestion?

Thank you in advance.

0

If you have two services that shouldn't run at the same time, consider adding a Conflicts= entry in the [Unit] section of your test service:

Conflicts=

A space-separated list of unit names. Configures negative requirement dependencies. If a unit has a Conflicts= setting on another unit, starting the former will stop the latter and vice versa. Note that this setting is independent of and orthogonal to the After= and Before= ordering dependencies.

If a unit A that conflicts with a unit B is scheduled to be started at the same time as B, the transaction will either fail (in case both are required part of the transaction) or be modified to be fixed (in case one or both jobs are not a required part of the transaction). In the latter case, the job that is not the required will be removed, or in case both are not required, the unit that conflicts will be started and the unit that is conflicted is stopped.

So this may work (not tested):

pin-sshd.service

[Unit]
Description=Pin debugging of sshd (copied from sshd.service)
After=syslog.target network.target auditd.service
Conflicts=sshd.service

[Service]
ExecStart=/path/to/pin -t somepintool.so -- /usr/sbin/sshd -D -e

[Install]
WantedBy=multi-user.target

This way systemd can do the work of making sure you don't have both services running and show do the stopping and starting correctly. Most of the services I see that use this have Conflicts=shutdown.target, so it appears it's usually used for making sure services finish before shutdown occurs, but there's nothing preventing you from using this for other purposes!

0

I’m not sure I understand why killing sshd without using systemctl would help here, however, there’s nothing stopping you from telling systemd to use pin when starting sshd; run

sudo systemctl edit ssh.service

or

sudo systemctl edit sshd.service

(depending on which file you have — Debian derivatives use ssh.service, Fedora and RHEL derivatives use `sshd.service), and enter

[Service]
ExecStart=/path/to/pin -t somepintool.so -- /usr/sbin/sshd -D $SSHD_OPTS

Then restart sshd...

The override will be stored in a snippet called /etc/systemd/system/ssh(d?).service.d/override.conf; deleting that will restore the default sshd definition.

  • Did you mean sshd.service? And what happens when I stop the service you think? – masec Mar 4 '18 at 0:10
  • I am saying killing sshd without systemctl because with systemctl I cannot stop that once I start it using pin tool. – masec Mar 4 '18 at 0:18
  • No, I mean ssh.service. Are you by any chance trying to do this while connected to the system using SSH? – Stephen Kitt Mar 4 '18 at 9:54
  • Some distributions name the service running the sshd daemon to sshd.service because of the name of the daemon, others use ssh.service because it provides the SSH service. I think this is one of the differences between Linux distributions with Fedora/RedHat roots and the ones with Debian/Ubuntu roots. – telcoM Mar 5 '18 at 17:18
  • Ah right, thanks @telcoM! I hadn’t checked on Fedora or RHEL (but have done so now). – Stephen Kitt Mar 5 '18 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.