MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / str

Method str

src/common/platforminfo.cpp:81–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81const std::string PlatformInfo::str() const
82{
83 std::string os_name{};
84
85 if (proxy)
86 {
87 try
88 {
89 os_name = proxy->GetProperty<std::string>(hostname1_tgt,
90 "OperatingSystemCPEName");
91 }
92 catch (const DBus::Exception &)
93 {
94 // Ignore errors; os_name will be empty
95 }
96
97 if (os_name.empty())
98 {
99 try
100 {
101 os_name = proxy->GetProperty<std::string>(hostname1_tgt,
102 "OperatingSystemPrettyName");
103 }
104 catch (const DBus::Exception &)
105 {
106 // Ignore errors, os_name will be empty in this case
107 }
108 }
109 }
110
111 // uname() fallback when D-Bus calls fails
112 if (os_name.empty())
113 {
114 struct utsname info = {};
115 if (uname(&info) < 0)
116 {
117 throw PlatformInfoException(
118 "Error retrieving platform information");
119 }
120
121 os_name = std::string("generic:") + std::string(info.sysname) + "/"
122 + std::string(info.release) + "/" + std::string(info.version)
123 + "/" + std::string(info.machine);
124 }
125 return os_name;
126}

Callers 15

eventMethod · 0.45
AuthorizeMethod · 0.45
cb_restartMethod · 0.45
connectMethod · 0.45
initialize_clientMethod · 0.45
fetch_configurationMethod · 0.45
set_overridesMethod · 0.45
start_backend_processMethod · 0.45
tun_builder_set_layerMethod · 0.45
tun_builder_set_mtuMethod · 0.45

Calls 2

emptyMethod · 0.45

Tested by

no test coverage detected