commit 8f4c0f2a8ef86942c4c147f82c5eeb2bd4107f9a
Author: sin <[email protected]>
Date:   Tue Apr 22 16:35:24 2014 +0100

    Add random replies for failed password attempts in su(1)

diff --git a/su.c b/su.c
index 2b5f0bf..9beb7d0 100644
--- a/su.c
+++ b/su.c
@@ -8,11 +8,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <time.h>
 #include "config.h"
 #include "util.h"
 
 extern char **environ;
 
+static const char *randreply(void);
 static char *msetenv(const char *, const char *);
 static void dologin(struct passwd *);
 
@@ -53,6 +55,8 @@ main(int argc, char *argv[])
        else
                usage();
 
+       srand(time(NULL));
+
        errno = 0;
        spw = getspnam(usr);
        if (errno)
@@ -63,7 +67,7 @@ main(int argc, char *argv[])
        switch (spw->sp_pwdp[0]) {
        case '!':
        case '*':
-               eprintf("Denied
");
+               eprintf("Denied.
");
        case '$':
                break;
        default:
@@ -83,7 +87,7 @@ main(int argc, char *argv[])
                        eprintf("crypt:");
 
                if (strcmp(cryptpass, spw->sp_pwdp) != 0)
-                       eprintf("Denied
");
+                       eprintf(randreply());
        }
 
        errno = 0;
@@ -122,6 +126,26 @@ main(int argc, char *argv[])
        return (errno == ENOENT) ? 127 : 126;
 }
 
+static const char *
+randreply(void)
+{
+       static const char *replies[] = {
+               "Time flies like an arrow, fruit flies like a banana.
",
+               "Denied.
",
+               "You type like a dairy farmer.
",
+               "CChheecckk yyoouurr dduupplleexx sswwiittcchh..
",
+               "I met a girl with 12 nipples, it sounds weird dozen tit?
",
+               "Here I am, brain the size of a planet and they ask me to keep 
hashing rubbish.
",
+               "Clones are people two.
",
+               "Your mom is an interesting su response.
",
+               "no.
",
+               "Your mom forgot to null-terminate???B?33??Abort (core dumped)
",
+               "A fool-proof method for sculpting an elephant: first, get a 
huge block of marble; then you chip away everything that doesn't look like an 
elephant.
",
+               "Bloating .data for fun and profit.
",
+       };
+       return replies[rand() % LEN(replies)];
+}
+
 static char *
 msetenv(const char *name, const char *value)
 {


Reply via email to