Repository: conan-io/conan-center-index

Issue:
[package] dbus/1.12.20: cannot connect to system bus on linux
# dbus/1.12.20 cannot connect to the system bus on linux
The system bus socket in improperly configured (see log) when dbus/1.12.20 is built. This makes any connection attempt to the system bus impossible.

### Package and Environment Details
  * Package Name/Version: **dbus/1.12.20**
  * Operating System+version: **Linux Ubuntu 20.04**
  * Compiler+version: **GCC 9**
  * Docker image: **n/a**
  * Conan version: **conan 1.46.2**
  * Python version: **Python 3.8.10**


### Conan profile
```
Configuration for profile default:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++11
build_type=Release
[options]
[conf]
[build_requires]
[env]
```


### Steps to reproduce
Minimal Example:

conanfile.txt:
```
[requires]
dbus/1.12.20
qt/5.15.2

[options]
qt:shared=True
qt:with_dbus=True

[generators]
CMakeDeps
CMakeToolchain
VirtualRunEnv
```

CMakeLists.txt:
```cmake
cmake_minimum_required(VERSION 3.15)
project(dbus-test)

find_package(Qt5 REQUIRED COMPONENTS DBus)
add_executable(dbus-test main.cpp)
target_link_libraries(dbus-test Qt5::DBus)
```

main.cpp:
```cpp
#include <iostream>

#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>

int main(int argc, char**argv) {
    QDBusConnection connection = QDBusConnection::systemBus();

    std::cout << "Is connected? " << connection.isConnected()
        << "\nError: \"" << connection.lastError().message().toStdString() << "\"\n";

    return 0;
}
```

1. run `mkdir build && cd build && conan install .. --build=missing`
2. run `cmake -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake ..`
3. run `make`
4. run `source conanrun.sh`
5. run `./dbus-test`

Expected output:
```
Is connected? 1
Error: ""
```
Actual output:
```
Is connected? 0
Error: "Socket name too long
"
```

**Note** that running `dbus-test` outside of the conan runenv will produce the expected behavior, as the system dbus library is used (as seen by `ldd dbus-test`).

### Logs (Include/Attach if Applicable)
[log.txt](https://github.com/conan-io/conan-center-index/files/8470511/log.txt)





Discussion:

Resolving patch:
diff --git a/recipes/dbus/1.x.x/conanfile.py b/recipes/dbus/1.x.x/conanfile.py
--- a/recipes/dbus/1.x.x/conanfile.py
+++ b/recipes/dbus/1.x.x/conanfile.py
@@ -16,10 +16,14 @@ class DbusConan(ConanFile):
 
     settings = "os", "arch", "compiler", "build_type"
     options = {
+        "system_socket": "ANY",
+        "system_pid_file": "ANY",
         "with_x11": [True, False],
         "with_glib": [True, False],
     }
     default_options = {
+        "system_socket": "",
+        "system_pid_file": "",
         "with_x11": False,
         "with_glib": False,
     }
@@ -71,6 +75,11 @@ def _configure_autotools(self):
             args.append("--with-systemdsystemunitdir=%s" % os.path.join(self.package_folder, "lib", "systemd", "system"))
             args.append("--with-systemduserunitdir=%s" % os.path.join(self.package_folder, "lib", "systemd", "user"))
 
+            if str(self.options.system_socket) is not "":
+                args.append("--with-system-socket=%s" % self.options.system_socket)
+            if str(self.options.system_pid_file) is not "":
+                args.append("--with-system-pid-file=%s" % self.options.system_pid_file)
+
             args.append("--disable-launchd")
             args.append("--disable-systemd")
 


Test patch: