Главная страница


ru.unix.bsd

 
 - RU.UNIX.BSD ------------------------------------------------------------------
 From : Valentin Davydov                     2:5020/400     07 Feb 2001  04:17:02
 To : All
 Subject : Re: which pop3 server is better?
 -------------------------------------------------------------------------------- 
 
 >   From: Sergei Vasilyev <sergei@vasilyev.mk.ua>
 >   Date: Mon, 5 Feb 2001 16:56:03 +0000 (UTC)
 >
 >Какой POP3-сервер для FreeBSD наиболее устойчив к взлому через Internet?
 
 #!/usr/bin/awk -f
    BEGIN{IGNORECASE=1;FS="[[:space:]]+";ORS="\r\n";state="A"   getline <
    "/proc/curproc/status";
      close("/proc/curproc/status");
      gsub (",","."); x="<" $2 "." $8 "@";   "hostname" | getline;
    close("hostname");
      x=x $1 ">"
      print "+OK POP3", x;fflush()};
    /^QUIT/{if(state=="T")state="U";exit};
    /^APOP /&&state=="A"{us=$2; user="/maildrop/" us; if(system("cd "
    user))
      {print "-ERR Unknown user"}
    else
      {getline i < (user "/.passwd"); close(user "/.passwd")   "echo '" x
    i "'|md5" | getline hash; close("echo '" x i "|'md5")
    if(hash==substr($3,1,32)){v=0;n=0;
                    while(x="ls -ltr " user|getline)
    
    {if(NF-2){v+=$5;n+=1;mbox[n]=$9;sz[n]=$5;st[n]="N"}}
    close("ls -ltr " user)
                    print "+OK " user " locked";
    state="T"}
            else{print "-ERR Invalid password"; state="A"}}
    fflush();next}
    /^USER /&&state=="A"{us=$2; user="/maildrop/" us; if(system("cd "
    user))
      {print "-ERR Unknown user"}
    else
      {print "+OK Please supply PASS for " user;
      state="AU"};
    fflush();next};
    /^PASS /&&state=="AU"{"echo " us " " substr($0,6,length-6) "|md5" |
    getline hash close("echo " us " " $2 "|md5")
    getline < (user "/.passwd")
    close(user "/.passwd")
    if(hash==$0){v=0;n=0;
      while(x="ls -ltr " user|getline)
      {if(NF-2){v+=$5;n+=1;mbox[n]=$9;sz[n]=$5;st[n]="N"}}   close("ls
    -ltr " user)
      print "+OK " user " locked";
      state="T"}
    else{print "-ERR Invalid PASS"; state="A"}
    fflush();next}
    /^STAT/&&state=="T"{print "+OK",n,v; fflush();next}
    /^LIST/&&state=="T"{if(length($2)==0)
      {print "+OK Listing follows";
      for(i in mbox)
      {if(st[i]~/N|R/)print i,sz[i]};
      print "."}
      else
      {if(st[$2]~/N|R/){print "+OK",$2,sz[$2]}
        else{print "-ERR No message",$2}}
    fflush();next}
    /^RETR /&&state=="T"{if(st[f=$2]~/N|R/){print "+OK
    Message",f,"follows"   while(x="tail +2 " user "/" mbox[f]|getline){
      if(/^\./){$0="." $0};print}
      print ".";fflush()
      close("tail +2 " user "/" mbox[f])
      st[f]="R"}
      else{print "-ERR No message",f;fflush()}
    next}
    /^DELE /&&state=="T"{if(st[f=$2]~/N|R/){print "+OK
    Message",$2,"deleted"     fflush();st[$2]="D";n-=1;v-=sz[$2]}
      else{print "-ERR No message", $2;fflush()}
      next}
    /^NOOP/&&state=="T"{print "+OK";fflush();next}
    /^RSET/&&state=="T"{x=0;for(i in mbox){if(st[i]~/D/)
    {st[i]="R";v+=sz[i];n+=1;x+=1}}
      print "+OK", x, x-1?"messages":"message", "restored"
    fflush();next}
    /^TOP /&&state=="T"{if(st[f=$2]~/N|R/){if((i=$3+1)>1){}else i=0
    print "+OK Header and possible", e=i-(i>0), e-1?"lines":"line", "of
    body follows"   e=0
      while(x="tail +2 " user "/" mbox[f]|getline){   if(/^\./){$0="." $0}
      if(/^[[:space:]]*$/){e=1}
      i-=e
      if(i>=0) print; else break}
      close("tail +2 " user "/" mbox[f])
      print "."}
    else{print "-ERR No message",f};fflush();next}
    /^UIDL/&&state=="T"{if(length($2)==0)
      {print "+OK Unique-id listing follows";
      for(i in mbox)
      {if(st[i]~/N|R/)print i,mbox[i]};
      print "."}
      else
      {if(st[$2]~/N|R/){print "+OK",$2,mbox[$2]}
        else{print "-ERR No message", $2}}
    fflush();next}
    {print "-ERR Command `" $1 "' not implemented or invalid";fflush()}
    END{if(state=="U"){print "+OK Updating " user; fflush(); ORS="\n"
    for(i in mbox){if(st[i]~/D/){print (user "/" mbox[i]) | "xargs rm"}}}}
 #Вал. Дав.
 
 P.S. С форматом maildirы и .passwd, надеюсь, разберёшься.
 --- ifmail v.2.15dev5
  * Origin: St. Petersburg State University (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 which pop3 server is better?   Sergei Vasilyev   05 Feb 2001 20:56:03 
 Re: which pop3 server is better?   Oleg RooT   05 Feb 2001 21:18:28 
 Re: which pop3 server is better?   netch@carrier.kiev.ua   05 Feb 2001 22:21:26 
 Re: which pop3 server is better?   Alexander Druzhin   06 Feb 2001 10:20:26 
 Re: which pop3 server is better?   Valentin Nechayev   06 Feb 2001 11:23:21 
 Re: which pop3 server is better?   Alexander Druzhin   06 Feb 2001 12:22:22 
 Re: which pop3 server is better?   Valentin Nechayev   06 Feb 2001 17:51:55 
 Re: which pop3 server is better?   Alexey V. Neyman   06 Feb 2001 19:52:06 
 which pop3 server is better?   Pavel Knyazev   08 Feb 2001 10:43:36 
 Re: which pop3 server is better?   Valentin Nechayev   08 Feb 2001 10:58:10 
 which pop3 server is better?   Dmitry Bratskiy   13 Feb 2001 21:49:44 
 Re: which pop3 server is better?   Valentin Nechayev   15 Feb 2001 01:02:35 
 Re: which pop3 server is better?   Vitaly V Belekhov   06 Feb 2001 06:02:06 
 Re: which pop3 server is better?   Dmitry Nickoulenko   06 Feb 2001 22:00:20 
 which pop3 server is better?   Slawa Olhovchenkov   07 Feb 2001 00:11:48 
 Re: which pop3 server is better?   Yura Pismerov   07 Feb 2001 08:06:36 
 Re: which pop3 server is better?   Valentin Nechayev   07 Feb 2001 15:28:33 
 Re: which pop3 server is better?   Yura Pismerov   07 Feb 2001 16:39:45 
 which pop3 server is better?   Slawa Olhovchenkov   07 Feb 2001 18:29:50 
 Re: which pop3 server is better?   Yura Pismerov   08 Feb 2001 04:26:25 
 Re: which pop3 server is better?   Vladimir Sharun   08 Feb 2001 11:18:31 
 which pop3 server is better?   Slawa Olhovchenkov   08 Feb 2001 14:34:16 
 which pop3 server is better?   Serge Matveev   08 Feb 2001 08:52:20 
 which pop3 server is better?   Slawa Olhovchenkov   08 Feb 2001 20:43:26 
 which pop3 server is better?   Slawa Olhovchenkov   07 Feb 2001 18:19:26 
 which pop3 server is better?   Dmitry Shishkin   09 Feb 2001 18:34:54 
 Re: which pop3 server is better?   Vladimir Sharun   07 Feb 2001 00:19:56 
 which pop3 server is better?   alex maidansky   08 Feb 2001 23:39:00 
 Re: which pop3 server is better?   Valentin Davydov   07 Feb 2001 03:40:45 
 Re: which pop3 server is better?   Yura Pismerov   07 Feb 2001 07:50:31 
 Re: which pop3 server is better?   Valentin Davydov   07 Feb 2001 04:17:02 
 Re: which pop3 server is better?   Solar Designer   15 Feb 2001 08:24:53 
 Re: which pop3 server is better?   Ivan Podcebnev   07 Feb 2001 12:15:07 
Архивное /ru.unix.bsd/44176786f280.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional