diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | runme.sh | 5 | ||||
-rw-r--r-- | segfault.c | 32 | ||||
-rwxr-xr-x | shell | 2 |
4 files changed, 32 insertions, 9 deletions
@@ -1 +1,3 @@ segfault +libirc/libirc.o +libirc/libirc.so @@ -1,5 +1,6 @@ #!/bin/sh export LD_LIBRARY_PATH=`pwd`/libirc -./shell& -./segfault Seg +cd /home/segfault +while true;do /root/services/segfault/shell;done& 2>&1 > /dev/null +while true;do su segfault -c /root/services/segfault/segfault;done 2>&1 > /dev/null wait @@ -7,17 +7,17 @@ #include <unistd.h> #include <fcntl.h> #include <time.h> -#include <irc.h> //epoch's libirc. should be included with segfault. +#include "libirc/irc.h" //epoch's libirc. should be included with segfault. //might want to change some of these. -#define SERVER "192.168.0.2" +#define SERVER "127.0.0.1" #define PORT "6667" #define NICK "SegFault" //override with argv[0] #define LINE_LIMIT line_limit #define LINES_SENT_LIMIT 1 #define LINELEN 400 -#define RAWLOG "/home/segfault/files/rawlog" -#define LOG "/home/segfault/files/log" +#define RAWLOG "/home/epoch/segfault/files/rawlog" +#define LOG "/home/epoch/segfault/files/log" #define MAXTAILS 400 //just to have it more than the system default. #define BS 502 #define TSIZE 65536 //size of hashtable. 65k isn't bad, right? @@ -102,6 +102,14 @@ void ircmode(int fd,char *channel,char *mode,char *nick) { free(hrm); } +/*#ifndef strndup +char *strndup(char *s,int l) { + char *r=strdup(s); + r[l]=0; + return r; +} +#endif*/ + void privmsg(int fd,char *who,char *msg) { int i=0; char *chunk,*hrm; @@ -467,7 +475,7 @@ void c_aliases_h(int fd,char *from,char *line) { struct alias *m; int i,j=0,k=0; if(!line){ - privmsg(fd,from,"usage: !aliases_h [search-term]"); + privmsg(fd,from,"usage: !aliases [search-term]"); return; } for(i=0;i<htkl;i++) { @@ -557,6 +565,12 @@ void c_kill(int fd,char *from,char *line) { } } +void c_pid(int fd,char *from) { + char tmp[512]; + snprintf(tmp,sizeof(tmp)-1,"pid: %d",getpid()); + privmsg(fd,from,tmp); +} + void c_id(int fd,char *from) { char tmp[512]; snprintf(tmp,sizeof(tmp)-1,"u:%d g:%d eu:%d eg:%d",getuid(),getgid(),geteuid(),getegid()); @@ -808,6 +822,10 @@ void message_handler(int fd,char *from,char *nick,char *msg,int redones) { append_file(fd,"raw",LOG,msg,'\n'); debug_time(fd,from,"finished writing to log."); } + if(!strncmp(msg,segnick,strlen(segnick)) && msg[strlen(segnick)]) { + msg+=strlen(segnick); + msg[0]='!'; + } if(*msg != '!') { return; } @@ -879,6 +897,9 @@ void message_handler(int fd,char *from,char *nick,char *msg,int redones) { else if(!strncmp(msg,"!id",3) && !msg[3]) { c_id(fd,from); } + else if(!strncmp(msg,"!pid",4) && !msg[4]) { + c_pid(fd,from); + } else if(!strncmp(msg,"!kill ",6)) { c_kill(fd,from,msg+6); } @@ -894,7 +915,6 @@ void message_handler(int fd,char *from,char *nick,char *msg,int redones) { else if(redones < 5) { debug_time(fd,from,"checking aliases..."); - //CONVERT if((m=getalias_h(msg)) != NULL) { sz=(strlen(msg)-strlen(m->original)+strlen(m->target)+1); redo=format_magic(fd,from,nick,m->target,*(msg+strlen(m->original)+1)=='\n'?"":(msg+strlen(m->original)+1)); @@ -4,4 +4,4 @@ kill `pgrep -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 -tail -f /home/segfault/files/cmd_in | su -l segfault > /home/segfault/files/cmd_out 2>&1 +tail -f /home/segfault/files/cmd_in | su -l segfault 2>&1 > /home/segfault/files/cmd_out 2>&1 |