Added getOSName function to internal API

This commit is contained in:
Kevin Haubris
2022-05-03 18:54:22 -05:00
parent 14459ee7f0
commit bf1637d4f7
4 changed files with 30 additions and 6 deletions
+9 -2
View File
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/utsname.h>
#include "beacon_api.h"
@@ -8,8 +9,14 @@
int run_uname(void){
struct utsname values;
int retcode = 0;
retcode = uname(&values);
BeaconPrintf(CALLBACK_OUTPUT, "%s %s %s %s %s\n", values.sysname, values.nodename, values.release, values.version, values.machine);
char* osversion = getOSName();
if (strcmp("lin", osversion)==0){
retcode = uname(&values);
BeaconPrintf(CALLBACK_OUTPUT, "%s %s %s %s %s\n", values.sysname, values.nodename, values.release, values.version, values.machine);
}
else{
BeaconPrintf(CALLBACK_OUTPUT, "Not supported\n");
}
return 0;
}
+1
View File
@@ -55,4 +55,5 @@ uint32_t swap_endianess(uint32_t indata);
char* BeaconGetOutputData(int *outsize);
char** getEnviron(void);
char* getOSName(void);
#endif
+3 -2
View File
@@ -13,8 +13,8 @@ typedef struct beacon_function{
void* function;
} beacon_function_t;
extern beacon_function_t BeaconInternalMapping[17];
#define BEACONINTERNALMAPPINGCOUNT 16
extern beacon_function_t BeaconInternalMapping[18];
#define BEACONINTERNALMAPPINGCOUNT 17
void* internalFunctionLookup(char* symbolName);
/* Structures as is in beacon.h */
@@ -63,4 +63,5 @@ uint32_t swap_endianess(uint32_t indata);
char* BeaconGetOutputData(int *outsize);
char** getEnviron(void);
char* getOSName(void);
#endif
+17 -2
View File
@@ -33,7 +33,7 @@ extern char** environ;
/* Data Parsing */
beacon_function_t BeaconInternalMapping[17] = {
beacon_function_t BeaconInternalMapping[18] = {
{"BeaconDataParse", (void*)BeaconDataParse},
{"BeaconDataInt", (void*)BeaconDataInt},
{"BeaconDataShort", (void*)BeaconDataShort},
@@ -49,7 +49,8 @@ beacon_function_t BeaconInternalMapping[17] = {
{"BeaconPrintf", (void*)BeaconPrintf},
{"BeaconOutput", (void*)BeaconOutput},
{"BeaconIsAdmin", (void*)BeaconIsAdmin},
{"getEnviron", (void*)getEnviron}
{"getEnviron", (void*)getEnviron},
{"getOSName", (void*)getOSName}
};
@@ -57,6 +58,20 @@ char** getEnviron(void){
return environ;
}
char* getOSName(void){
#ifdef __APPLE__
return "apple";
#elif __FreeBSD__
return "freebsd";
#elif __OpenBSD__
return "openbsd";
#elif __linux__
return "lin";
#else
return "unk";
#endif
}
#ifdef _WIN32
/* A hacky compatible dlsym function for use on windows systems.
* TODO: Implement a internal function lookup function for all OS's that