first commit

This commit is contained in:
augustin64 2024-08-06 10:26:06 +02:00
commit fc95f21311
4 changed files with 42 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
fwled

10
Makefile Normal file
View File

@ -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

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# fwled
```bash
make install
fwled power green
fwled power auto
```

23
main.c Normal file
View File

@ -0,0 +1,23 @@
#define _POSIX_C_SOURCE 200112L
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
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;
}