From fc95f2131128906739fff8b14b1fe96dd2ea9846 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Tue, 6 Aug 2024 10:26:06 +0200 Subject: [PATCH] first commit --- .gitignore | 1 + Makefile | 10 ++++++++++ README.md | 8 ++++++++ main.c | 23 +++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2b24e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +fwled \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75b9345 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +fwled: main.c + gcc --std=c99 main.c -o fwled + sudo chown root fwled + sudo chmod u+s fwled + +install: fwled + sudo mv fwled /usr/bin/ + +clean: + rm -f fwled \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f8a5688 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# fwled + +```bash +make install + +fwled power green +fwled power auto +``` \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..de31f5b --- /dev/null +++ b/main.c @@ -0,0 +1,23 @@ +#define _POSIX_C_SOURCE 200112L +#include +#include +#include +#include + + +int main(int argc, char* argv[]) { + char *args[argc+3]; + args[0] = "fw-ectool"; + args[1] = "led"; + + for (int i=0; i < argc; i++) { + args[i+2] = argv[i+1]; + } + args[argc+2] = NULL; + + seteuid(0); + setuid(0); + execvp("fw-ectool", args); + + return 0; +} \ No newline at end of file