Bug 217438

Summary: kernelshark: QLocalSocket::connectToServer: Connection refused
Product: Tools Reporter: Vitaly Chikunov (vt)
Component: Trace-cmd/KernelsharkAssignee: Default virtual assignee for Trace-cmd and kernelshark (tools_tracecmd_kernelshark)
Status: NEW ---    
Severity: normal CC: y.karadz
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Vitaly Chikunov 2023-05-12 23:28:33 UTC
In ALT we have `TMPDIR` set for all users (including root) to `/tmp/.private/$USER`, this is intended to improve security as these dirs are completely isolated (by o-rwx permissions) for each user.

As a consequence `KSCapture` socket is created in user's dir (such as `/tmp/.private/vt/KSCapture`) and `pkexec`'d `kshark-record` tries to connect to `/tmp/.private/root/KSCapture` which does not exist, and this causes Capture error:
```
QLocalSocket::connectToServer: Connection refused
(maybe KernelShark GUI is not open)
```

I wonder what is best solution would be to solve this problem (and not extremely familiar with `QLocalSocket` either). Do you have any suggestions?

Previously I was changing these calls:

  src/KsCaptureDialog.cpp:624:    socket->connectToServer("KSCapture", QIODevice::WriteOnly);
  src/KsMainWindow.cpp:1523:      _captureLocalServer.listen("KSCapture");

to use "/tmp/KSCapture", since `/tmp` is expected there anyway.
Comment 1 Yordan Karadzhov 2023-05-17 17:44:13 UTC
Hi Vitaly,

This sounds to me more like a very user-specific corner-case. Note that the Capture dialog is meant to be more like a simplistic introduction tool for new users. If you want to do something more advanced you betere user directly trace-cmd and later open the file in kernelshark.

cheers,
Y.