Add random replies for failed password attempts in su(1)
This commit is contained in:
parent
0e6d7ca286
commit
8f4c0f2a8e
28
su.c
28
su.c
@ -8,11 +8,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
|
static const char *randreply(void);
|
||||||
static char *msetenv(const char *, const char *);
|
static char *msetenv(const char *, const char *);
|
||||||
static void dologin(struct passwd *);
|
static void dologin(struct passwd *);
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
srand(time(NULL));
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
spw = getspnam(usr);
|
spw = getspnam(usr);
|
||||||
if (errno)
|
if (errno)
|
||||||
@ -63,7 +67,7 @@ main(int argc, char *argv[])
|
|||||||
switch (spw->sp_pwdp[0]) {
|
switch (spw->sp_pwdp[0]) {
|
||||||
case '!':
|
case '!':
|
||||||
case '*':
|
case '*':
|
||||||
eprintf("Denied\n");
|
eprintf("Denied.\n");
|
||||||
case '$':
|
case '$':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -83,7 +87,7 @@ main(int argc, char *argv[])
|
|||||||
eprintf("crypt:");
|
eprintf("crypt:");
|
||||||
|
|
||||||
if (strcmp(cryptpass, spw->sp_pwdp) != 0)
|
if (strcmp(cryptpass, spw->sp_pwdp) != 0)
|
||||||
eprintf("Denied\n");
|
eprintf(randreply());
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -122,6 +126,26 @@ main(int argc, char *argv[])
|
|||||||
return (errno == ENOENT) ? 127 : 126;
|
return (errno == ENOENT) ? 127 : 126;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
randreply(void)
|
||||||
|
{
|
||||||
|
static const char *replies[] = {
|
||||||
|
"Time flies like an arrow, fruit flies like a banana.\n",
|
||||||
|
"Denied.\n",
|
||||||
|
"You type like a dairy farmer.\n",
|
||||||
|
"CChheecckk yyoouurr dduupplleexx sswwiittcchh..\n",
|
||||||
|
"I met a girl with 12 nipples, it sounds weird dozen tit?\n",
|
||||||
|
"Here I am, brain the size of a planet and they ask me to keep hashing rubbish.\n",
|
||||||
|
"Clones are people two.\n",
|
||||||
|
"Your mom is an interesting su response.\n",
|
||||||
|
"no.\n",
|
||||||
|
"Your mom forgot to null-terminate???B?33??Abort (core dumped)\n",
|
||||||
|
"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.\n",
|
||||||
|
"Bloating .data for fun and profit.\n",
|
||||||
|
};
|
||||||
|
return replies[rand() % LEN(replies)];
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
msetenv(const char *name, const char *value)
|
msetenv(const char *name, const char *value)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user