Package: falselogin
Version: 0.3-2
Severity: wishlist
Hi falselogin maintainer/developer.
I've found your program useful but i needed a way to specify the wait
parameter for the login shell. Since it isn't possible to specify any
parameter in the /etc/passwd file, i've patched falselogin 0.3-2 to read
this parameter from falselogin.conf.
Now during the conffile parsing, if it is encountered a line starting
with "wait=", then it is evaluated like the --wait argument (in fact
i've reused that code) and that line in not printed.
To maintain the patch simple, i've removed the readArgs() function (not
really useful, since it's used only once), putting its code directly
inside main(), and added the variable "wait", which contain the seconds
to wait or -1 if we want the user to press ENTER.
Since the conffile is evaluated first, the command line arguments has
higher precedence.
Regards.
Cesare.
--- debian/falselogin.c 2006-08-24 06:23:17.000000000 +0200
+++ v02/falselogin.c 2007-10-28 12:47:13.000000000 +0100
@@ -37,7 +37,6 @@
#define MAIL_LEN 50
// Function definitions
-int readArgs (char *argv[]);
int countMail (char userName[]);
int main (int argc, char *argv[]) {
@@ -49,6 +48,7 @@
struct utsname u_name; // this holds the u_name
size_t max_buf = MAXLEN_BUF; // maximum buffer length
int ok = 0; // lame control (see passwd filling)
+ long wait = 0; // seconds (negative to wait for ENTER)
temp = malloc(MAXLEN_BUF); // initial allocation (could happen later)
// thou shalt not cast
@@ -101,6 +101,16 @@
// buffer which is 1024 bytes long, so only 1023
// characters will be allowed.
+ // Search for a wait parameter
+
+ if ( !strncmp(temp, "wait=", 5) ) {
+ if ( !strncmp(temp+5, "enter", 5) )
+ wait = -1;
+ else if ( atol(temp+5) > 0 )
+ wait = atol(temp+5);
+ continue;
+ }
+
// Substitutions using passwd and uname structs
if (strstr (temp, "%user%") != NULL)
@@ -158,7 +168,14 @@
// Now we can check the arguments
if (argc > 2) {
- if (readArgs(argv) == 255) {
+ // Supersedes the eventual wait value in the conf file
+ if ( !strncmp(argv[1], "--wait", 6) || !strncmp(argv[1], "-w", 2) ) {
+ if ( !strncmp(argv[2], "enter", 5) )
+ wait = -1;
+ else if ( atol(argv[2]) > 0 )
+ wait = atol(argv[2]);
+ }
+ else {
printf("Unknown arguments were given\n");
}
}
@@ -167,6 +184,13 @@
exit(EXIT_FAILURE);
}
+ // Wait for some time or the user to press ENTER.
+ // If no wait where specified it doesn't wait (0 sec).
+ if (wait >= 0)
+ sleep(wait);
+ else
+ while (getchar() != '\n');
+
// Bye-bye if we don't have arguments
exit(EXIT_SUCCESS);
}
@@ -190,16 +214,3 @@
return total;
}
-
-int readArgs (char *argv[]) {
- if ( !strncmp(argv[1], "--wait", 6) || !strncmp(argv[1], "-w", 2) ) {
- if ( !strncmp(argv[2], "enter", 5) )
- while (getchar() != '\n');
- else if ( atol(argv[2]) > 0 )
- sleep(atol(argv[2]));
- }
- else {
- return 255;
- }
- return 1;
-}