summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-08-26 03:27:31 -0500
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-08-26 03:27:31 -0500
commit5b723a9da5b94d3a99225f43c7dafcffa1f7676b (patch)
tree829b2cb71ee90b5346d9f8a36bdba9c55e921a5b
parent1e023da47a5d0248808e33fb5feac18df6df3585 (diff)
downloadsegfault-5b723a9da5b94d3a99225f43c7dafcffa1f7676b.tar.gz
segfault-5b723a9da5b94d3a99225f43c7dafcffa1f7676b.zip
fixed the rand() seeding to use pid too so bots started in the same second don't generate the same random nick.
made shell use pkill stuff instead of kill `pgrep stuff`
-rw-r--r--segfault.c24
-rwxr-xr-xshell2
2 files changed, 16 insertions, 10 deletions
diff --git a/segfault.c b/segfault.c
index 5df074a..5f1499b 100644
--- a/segfault.c
+++ b/segfault.c
@@ -51,6 +51,7 @@ char *tailmode_to_txt(int mode) {
struct user *myuser;
char locked_down;
+char pid[6];
char mode_magic;
char trigger_char;
int start_time;
@@ -165,7 +166,7 @@ char *format_magic(int fd,char *from,struct user *user,char *orig_fmt,char *arg)
if(fmt[i] == '%') {
i++;
switch(fmt[i]) {
- case 'n':case 'h':case 'u':case 'f':case 's':case 'm':case '%'://when adding new format things add here and...
+ case 'p':case 'n':case 'h':case 'u':case 'f':case 's':case 'm':case '%'://when adding new format things add here and...
c++;
}
}
@@ -177,14 +178,15 @@ char *format_magic(int fd,char *from,struct user *user,char *orig_fmt,char *arg)
if(fmt[i] == '%') {
i++;
switch(fmt[i]) {
- case 'n':case 'h':case 'u':case 'f':case 's':case 'm':case '%'://here.
+ case 'p':case 'n':case 'h':case 'u':case 'f':case 's':case 'm':case '%'://here.
args[c]=((fmt[i]=='u')?user->nick:
((fmt[i]=='n')?user->name:
((fmt[i]=='h')?user->host:
((fmt[i]=='f')?from:
- ((fmt[i]=='m')?myuser->nick://and here.
- ((fmt[i]=='s')?arg:"%"
- ))))));
+ ((fmt[i]=='p')?pid:
+ ((fmt[i]=='m')?myuser->nick://and here.
+ ((fmt[i]=='s')?arg:"%"
+ )))))));
fmt[i-1]=0;
notargs[c]=strdup(fmt+j);
sz+=strlen(args[c]);
@@ -404,9 +406,7 @@ void c_changetail(int fd,char *from,char *line) {
}
void startup_stuff(int fd) {
- mywrite(fd,"OPER g0d WAFFLEIRON\r\n");
- mywrite(fd,"JOIN #cmd\r\n");
- c_leettail(fd,"#cmd","22./scripts/startup",myuser);
+ c_leettail(fd,myuser->nick,"22./scripts/startup",myuser);
}
void debug_time(int fd,char *from,char *msg) {
@@ -936,6 +936,11 @@ void message_handler(int fd,char *from,struct user *user,char *msg,int redones)
else if(!strncmp(msg,"!linelimit",10) && (!msg[10] || msg[10] == ' ')) {
c_linelimit(fd,from,*(msg+10)?msg+11:0);
}
+ else if(!strncmp(msg,"!nick ",6) && msg[6]) {
+ free(myuser->nick);
+ myuser->nick=strdup(msg+6);
+ irc_nick(fd,myuser->nick);
+ }
else if(!strncmp(msg,"!tailunlock ",12)) {
c_tailunlock(fd,from,msg+12);
}
@@ -1069,7 +1074,7 @@ void line_handler(int fd,char *line) {//this should be built into the libary?
s,t,u);
if(!user->name && s) { //server message
if(!strcmp(s,"433")) {//nick already used.
- srand(time(NULL));
+ srand(time(NULL)*getpid());
myuser->nick[strlen(myuser->nick)-3]=(rand()%10)+'0';
myuser->nick[strlen(myuser->nick)-2]=(rand()%10)+'0';
myuser->nick[strlen(myuser->nick)-1]=(rand()%10)+'0';
@@ -1131,6 +1136,7 @@ int main(int argc,char *argv[]) {
myuser->nick=strdup(argc>1?argv[1]:NICK);
myuser->name="I_dunno";
myuser->host="I_dunno";
+ snprintf(pid,6,"%d",getpid());
printf("starting segfault...\n");
if(!getuid() || !geteuid()) {
s=getenv("seguser");
diff --git a/shell b/shell
index 32b6c2b..2d98edf 100755
--- a/shell
+++ b/shell
@@ -1,6 +1,6 @@
#!/bin/sh
#this is to keep stale tails from hanging around...
-kill `pgrep -P 1 -f "tail -f /home/segfault/files/cmd_in"`
+pkill -P 1 -f "tail -f /home/segfault/files/cmd_in"
mkdir -p /home/segfault/files
mkfifo /home/segfault/files/cmd_in
mkfifo /home/segfault/files/cmd_out