summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-12-23 16:33:25 +0100
committerGravatar Christian Hesse <mail@eworm.de>2013-12-23 16:33:25 +0100
commitb8b8d7f7ebca5946723c127ff9bee1eeaa9a94e3 (patch)
treee332864aad47bd4da41008725e414f8035198c54
parent5b73c2ebfed7b3e0742db5ab96dcaa71447faf8c (diff)
downloadnullshell-b8b8d7f7ebca5946723c127ff9bee1eeaa9a94e3.tar.gz
nullshell-b8b8d7f7ebca5946723c127ff9bee1eeaa9a94e3.tar.zst
introduce config.h and add some fuzzy output text
-rw-r--r--.gitignore1
-rw-r--r--Makefile15
-rw-r--r--README.md5
-rw-r--r--config.def.h20
-rw-r--r--nullshell.c12
5 files changed, 47 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index a3543a2..a0b9981 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
nullshell
+config.h
README.html
diff --git a/Makefile b/Makefile
index 8071077..9b0c01a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README.md b/README.md
index 335ca12..eea5569 100644
--- a/README.md
+++ b/README.md
@@ -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.... */