defining GNU_SOURCE due to asprintf
added missing sys/stat.h for umask()
removed unused var