This fixes the issue that the new firmware recreates the whole
gpio file structure on unexport/export so the ownership of all
files is root:root and the gpio group is dropped.
Because of this all unexport is removed from the calling scripts
and a setup script is added that needs to be invoked once after
startup.
its not needed because OS is responsible to cleanup
mem allocated by terminating process, but its still
a good manner to explicitly free everything that gets
allocated...
yes this is "noise" if it terminates but neither does
harm to feel being responsible to clean up everything
ourselves. :)
at least valgrind is silently happy :P :D
nitpicking and better c standard compliant code
let us...
...use the proper main(void) signature.
...use variable names which speak for their semantic content not their type, as types are explicitly declared.
...use perror() to signal the correct errno message upon error.
...move the password out of the running code, so we can change and find it easily.
...use exit() as it's a linear CLI tool, which can and should exit on certain failure/error states.
...decouple error handling from business logic. (e.g. getline() error handling and strcmp() for password check).
...not free() at the end of the program as it **is** and should **never** be necessary, since the OS **must** handle this.
memleak bugfix + cleanup + Makefile
- memleak bugfix as free() was missing
- dont call malloc() manually (the old way getline() always called realloc() anyway because of the way the malloc() was written [did not allocate enought memory for the string])
- small minor cleanup
- adding simple Makefile to build door challenge
- therefor if the program gets extended, its unlikly that
someone will forget to call free()
- also this gets rid of copy-paste free() calls (which look stupid)
- adding missing free() calls
- dont malloc ourselves as getline() also does a malloc
(and anyway called realloc before if the size_t was
smaller then the actual len(input-line) to behaviour
is the same!)