diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 28 | ||||
-rw-r--r-- | config.def.h | 11 | ||||
-rw-r--r-- | nullshell.c | 26 |
4 files changed, 48 insertions, 19 deletions
@@ -15,7 +15,7 @@ LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie # this is just a fallback in case you do not use git but downloaded # a release tarball... -VERSION := 0.0.7 +VERSION := 0.0.8 all: nullshell README.html @@ -1,6 +1,10 @@ nullshell ========= +[](https://github.com/eworm-de/nullshell/stargazers) +[](https://github.com/eworm-de/nullshell/network) +[](https://github.com/eworm-de/nullshell/watchers) + **do nothing but print keep alive characters, can be used for login shell** This is a minimal program that does nothing but print some characters @@ -9,13 +13,17 @@ 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. +*Use at your own risk*, pay attention to +[license and warranty](#license-and-warranty), and +[disclaimer on external links](#disclaimer-on-external-links)! + Requirements ------------ To compile and run `nullshell` you need: * nothing (this is plain C) -* [markdown](https://daringfireball.net/projects/markdown/) (HTML documentation) +* [markdown ↗️](https://daringfireball.net/projects/markdown/) (HTML documentation) Additionally it is expected to have `make` and a C compiler around to successfully compile. @@ -60,6 +68,21 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU General Public License](COPYING.md) for more details. +Disclaimer on external links +---------------------------- + +Our website contains links to the websites of third parties ("external +links"). As the content of these websites is not under our control, we +cannot assume any liability for such external content. In all cases, the +provider of information of the linked websites is liable for the content +and accuracy of the information provided. At the point in time when the +links were placed, no infringements of the law were recognisable to us. +As soon as an infringement of the law becomes known to us, we will +immediately remove the link in question. + +> 💡️ **Hint**: All external links are marked with an arrow pointing +> diagonally in an up-right (or north-east) direction (↗️). + ### Upstream URL: @@ -68,3 +91,6 @@ URL: Mirror: [eworm.de](https://git.eworm.de/cgit.cgi/nullshell/) [GitLab.com](https://gitlab.com/eworm-de/nullshell#nullshell) + +--- +[⬆️ Go back to top](#top) diff --git a/config.def.h b/config.def.h index 0c4de18..4a42bde 100644 --- a/config.def.h +++ b/config.def.h @@ -1,5 +1,5 @@ /* - * (C) 2013-2024 by Christian Hesse <mail@eworm.de> + * (C) 2013-2025 by Christian Hesse <mail@eworm.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +19,14 @@ #ifndef _CONFIG_H #define _CONFIG_H -/* this is the time to sleep between printing characters */ -#define SLEEPTIME 1 +/* this is the time to sleep (in milli-seconds) between printing characters */ +#define SLEEPTIME 1000 + +/* this is the number of line between banner appears */ +#define BANNERCONST 20 /* some text to be printed */ -#define URL "https://github.com/eworm-de/nullshell" +#define URL "https://nullshell.eworm.de/" #define BANNER "Do-nothing-loop by nullshell " VERSION ",\n" \ "compiled on " __DATE__ " " __TIME__ ".\n" \ "Visit homepage: " URL "\n" diff --git a/nullshell.c b/nullshell.c index 9218c18..d053f8d 100644 --- a/nullshell.c +++ b/nullshell.c @@ -1,5 +1,5 @@ /* - * (C) 2013-2024 by Christian Hesse <mail@eworm.de> + * (C) 2013-2025 by Christian Hesse <mail@eworm.de> * * Based on ideas from Sleep Dummy Shell (SleepShell) * by Mario A. Valdez-Ramirez (http://www.mariovaldez.net/) @@ -40,22 +40,20 @@ void sig_callback(int signal) { int main(int argc, char **argv) { time_t now; - uint8_t start; + uint8_t lines = BANNERCONST; char *ssh_connection, *ssh_client, *ssh_tty; char * string = BANNER; - /* get the start time and calculate modulo */ - time(&now); - start = (now / 30) % 30; - /* read environment variables */ ssh_connection = getenv("SSH_CONNECTION"); ssh_client = getenv("SSH_CLIENT"); ssh_tty = getenv("SSH_TTY"); /* register signal callbacks */ - signal(SIGTERM, sig_callback); - signal(SIGINT, sig_callback); + struct sigaction act = { 0 }; + act.sa_handler = sig_callback; + sigaction(SIGINT, &act, NULL); + sigaction(SIGTERM, &act, NULL); /* clear the screen and set cursor to the top left * see 'man 4 console_codes' for details */ @@ -69,17 +67,19 @@ int main(int argc, char **argv) { printf("Terminal: %s\n", ssh_tty); } - /* print an character every SLEEPTIME seconds */ + /* print a character every SLEEPTIME milli-seconds */ while (1) { - sleep(SLEEPTIME); + usleep(SLEEPTIME * 1000); putchar(*string); fflush(NULL); if (*string == 0) { - time(&now); - if ((now / 30) % 30 != start) + if (lines-- > 0) { + time(&now); string = ctime(&now); - else + } else { string = BANNER; + lines = BANNERCONST; + } } else string++; } |