diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | config.def.h | 20 | ||||
-rw-r--r-- | nullshell.c | 12 |
5 files changed, 47 insertions, 6 deletions
@@ -1,2 +1,3 @@ nullshell +config.h README.html @@ -1,16 +1,27 @@ # nullshell - do nothing but print asterisks, can be used for login shell PREFIX := /usr +CP := cp CC := gcc MD := markdown INSTALL := install RM := rm CFLAGS += -O2 -Wall -Werror +VERSION := $(shell git describe --tags --long 2>/dev/null) +# this is just a fallback in case you do not use git but downloaded +# a release tarball... +ifeq ($(VERSION),) +VERSION := 0.0.1 +endif all: nullshell README.html -nullshell: nullshell.c - $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell +nullshell: nullshell.c config.h + $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell \ + -DVERSION="\"$(VERSION)\"" + +config.h: + $(CP) config.def.h config.h README.html: README.md $(MD) README.md > README.html @@ -1,9 +1,10 @@ nullshell ========= -**do nothing but print asterisks, can be used for login shell** +**do nothing but print keep alive characters, can be used for login shell** -This is a minimal program that does nothing but print asteriks every now +This is a minimal program that does nothing but print some characters +(namely version information and time&date string) every now and then. It is intended to be used for login shell with accounts accessible via secure shell that are used for secure tunneling but should not allow to execute commands. diff --git a/config.def.h b/config.def.h new file mode 100644 index 0000000..5d815d3 --- /dev/null +++ b/config.def.h @@ -0,0 +1,20 @@ +/* + * (C) 2013 by Christian Hesse <mail@eworm.de> + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#ifndef _CONFIG_H +#define _CONFIG_H + +/* this is the time to sleep between printing characters */ +#define SLEEPTIME 1 + +/* some text to be printed */ +#define URL "https://github.com/eworm-de/nullshell" +#define BANNER "Do-nothing-loop by nullshell " VERSION " (" URL ").\n" + +#endif /* _CONFIG_H */ + +// vim: set syntax=c: diff --git a/nullshell.c b/nullshell.c index 113edf7..da2236d 100644 --- a/nullshell.c +++ b/nullshell.c @@ -8,14 +8,17 @@ * by Mario A. Valdez-Ramirez (http://www.mariovaldez.net/) */ +#include <time.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#define SLEEPTIME 10 +#include "config.h" int main(int argc, char **argv) { + time_t now; char *ssh_connection, *ssh_client, *ssh_tty; + char * string = BANNER; /* read environment variables */ ssh_connection = getenv("SSH_CONNECTION"); @@ -37,8 +40,13 @@ int main(int argc, char **argv) { /* print an asterisk every SLEEPTIME seconds */ while (1) { sleep(SLEEPTIME); - putchar('*'); + putchar(*string); fflush(NULL); + if (*string == 0) { + time(&now); + string = ctime(&now); + } else + string++; } /* we should never get here.... */ |