Skip to content

Commit

Permalink
fixup! wip windows: no uname support atm
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Oct 25, 2023
1 parent e2d4d51 commit 590b82f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions userspace/falco/app/actions/print_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.

#ifndef _WIN32
#include <sys/utsname.h>
#else
#include <windows.h>
#endif

#include "actions.h"
Expand All @@ -43,20 +45,54 @@ falco::app::run_result falco::app::actions::print_support(falco::app::state& s)
struct utsname sysinfo;
std::string cmdline;

#ifndef _WIN32
if(uname(&sysinfo) != 0)
{
return run_result::fatal(std::string("Could not uname() to find system info: ") + strerror(errno));
}
#else
OSVERSIONINFO osvi;
SYSTEM_INFO sysInfo;
TCHAR computerName[256];
DWORD size = sizeof(computerName);

osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if(!GetVersionEx(&osvi) || !GetComputerName(computerName, &size) || !GetSystemInfo(&sysInfo))
{
return run_result::fatal(std::string("Could not get system info: ") + strerror(errno));
}
#endif

const falco::versions_info infos(s.offline_inspector);
support["version"] = infos.falco_version;
support["engine_info"] = infos.as_json();

#ifndef _WIN32
support["system_info"]["sysname"] = sysinfo.sysname;
support["system_info"]["nodename"] = sysinfo.nodename;
support["system_info"]["release"] = sysinfo.release;
support["system_info"]["version"] = sysinfo.version;
support["system_info"]["machine"] = sysinfo.machine;
#else
support["system_info"]["sysname"] = "Windows"
support["system_info"]["nodename"] = computerName;
support["system_info"]["release"] = osvi.dwMajorVersion;
support["system_info"]["version"] = osvi.dwMinorVersion;

switch (sysInfo.wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64:
support["system_info"]["machine"] = "x86_64";
break;
case PROCESSOR_ARCHITECTURE_ARM:
support["system_info"]["machine"] = "ARM";
break;
case PROCESSOR_ARCHITECTURE_INTEL:
support["system_info"]["machine"] = "i386";
break;
default:
support["system_info"]["machine"] = "unknown";

#endif
support["cmdline"] = s.cmdline;
support["config"] = read_file(s.options.conf_filename);
support["rules_files"] = nlohmann::json::array();
Expand Down

0 comments on commit 590b82f

Please sign in to comment.