<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Papel Clepôncio &#187; Software Livre</title>
	<atom:link href="http://www.wish4web.com.br/blog/theflockers/category/software-livre/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wish4web.com.br/blog/theflockers</link>
	<description>Ejaculação precoce...de idéias</description>
	<pubDate>Sun, 23 Oct 2011 03:36:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mais um encurtador de URL!</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2011/06/27/mais-um-encurtador-de-url/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2011/06/27/mais-um-encurtador-de-url/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 02:37:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cultura]]></category>

		<category><![CDATA[Programação]]></category>

		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[encurtador]]></category>

		<category><![CDATA[links]]></category>

		<category><![CDATA[shortener]]></category>

		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=224</guid>
		<description><![CDATA[Estava buscando por um encurtador de link alternativo e encontrei o SQIZ.IN. Bem legal! Indico!
http://sqiz.in
]]></description>
			<content:encoded><![CDATA[<p>Estava buscando por um encurtador de link alternativo e encontrei o SQIZ.IN. Bem legal! Indico!</p>
<p><a href="http://sqiz.in">http://sqiz.in</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2011/06/27/mais-um-encurtador-de-url/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mobilidade e Produtividade com Group-Office</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2011/06/04/mobilidade-e-produtividade-com-group-office/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2011/06/04/mobilidade-e-produtividade-com-group-office/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 18:54:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[android]]></category>

		<category><![CDATA[bean]]></category>

		<category><![CDATA[calendar]]></category>

		<category><![CDATA[group]]></category>

		<category><![CDATA[group-office]]></category>

		<category><![CDATA[groupoffice]]></category>

		<category><![CDATA[groupware]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[mobile]]></category>

		<category><![CDATA[mobilidade]]></category>

		<category><![CDATA[office]]></category>

		<category><![CDATA[vanilla]]></category>

		<category><![CDATA[vanilla bean]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=207</guid>
		<description><![CDATA[É comum que muitas empresas procurem soluções para aumentar sua produtividade. Não somente o aumento da produtividade, mas também a diminuição de desperdícios de tempo e recursos, podem definir os players que se manterão fortes no mercado. Para que isso aconteça, é importante sempre ter ferramentas que auxiliem nesse processo. É uma certeza que todos [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">É comum que muitas empresas procurem soluções para aumentar sua produtividade. Não somente o aumento da produtividade, mas também a diminuição de desperdícios de tempo e recursos, podem definir os players que se manterão fortes no mercado. Para que isso aconteça, é importante sempre ter ferramentas que auxiliem nesse processo. É uma certeza que todos os seus funcionários são responsáveis por isso, então é muito importante que todos tenham total controle sobre o seu dia-a-dia, e o gestor possa ter acesso aos dados gerados por esses funcionários.</p>
<p style="text-align: justify;"><a href="http://www.vanillabean.com.br/groupoffice/"><img class="alignleft" title="Group-Office" src="http://www.vanillabean.com.br/groupoffice/images/banner.jpg" alt="" width="644" height="314" /></a></p>
<p>Uma ferramenta ótima ferramenta que conheci é o <strong>Group-Office</strong>. Esta ferramenta lhe dá total controle sobre sua rotina, desde controlando o seu calendário, até o gerenciamento de um projeto, sem falar dos e-mails e do gerenciamento de arquivos.</p>
<p style="text-align: justify;">Para as empresas que necessitam de Mobilidade, o Group-Office possui integração total com Celulares que utilizem <strong>ActiveSync</strong>, com <strong>iPhone</strong> e <strong>Android</strong>.</p>
<p style="text-align: justify;">O <strong>Group-Office</strong> possuí duas versões, a <strong>OpenSource</strong> que pode ser baixada gratuitamente e também a versão <strong>Professional</strong>, que oferece todos os módulos (incluindo o <strong>SyncML</strong> e o <strong>ActiveSync</strong>) e tem um custo baixo de aquisição, em relação aos concorrentes, como o Zimbra, por exemplo.</p>
<p style="text-align: justify;">Para conhecer mais sobre o <strong>Group-Office</strong> acesse: <a href="http://www.group-office.com/">http://www.group-office.com/ </a></p>
<p style="text-align: justify;">Se você gostou do <strong>Group-Office</strong> mas precisa de consultoria para instalação, entre em contato com o pessoal da <a href="http://www.vanillabean.com.br"><strong>Vanilla Bean</strong></a> e peça um orçamento.  <a href="http://www.vanillabean.com.br/groupoffice/">http://www.vanillabean.com.br/groupoffice/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2011/06/04/mobilidade-e-produtividade-com-group-office/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Usando 3G da TIM direto via pppd</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2011/05/22/usando-3g-da-tim-direto-via-pppd/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2011/05/22/usando-3g-da-tim-direto-via-pppd/#comments</comments>
		<pubDate>Mon, 23 May 2011 02:56:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[3g]]></category>

		<category><![CDATA[pppd]]></category>

		<category><![CDATA[tim]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=186</guid>
		<description><![CDATA[Post rápido, já que não posto nada há tempos. Testei no Ubuntu, mas deve funcionar em outras distros, que usam /etc/ppp como diretório de configuração do pppd.
Crie o arquivo /etc/ppp/peers/tim3g com a seguinte configuração:

user &#34;tim&#34;
connect &#34;/usr/sbin/chat -v -V -t15 -f /etc/ppp/tim3g-chat&#34;
/dev/ttyUSB3
115200
noipdefault
usepeerdns
defaultroute
noauth

Crie também o arquivo /etc/ppp/tim3g-chat, que é são onde os comandos AT estarão configurados no padrão [...]]]></description>
			<content:encoded><![CDATA[<p>Post rápido, já que não posto nada há tempos. Testei no Ubuntu, mas deve funcionar em outras distros, que usam /etc/ppp como diretório de configuração do pppd.</p>
<p>Crie o arquivo /etc/ppp/peers/tim3g com a seguinte configuração:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">user <span style="color: #ff0000;">&quot;tim&quot;</span>
<span style="color: #000066;">connect</span> <span style="color: #ff0000;">&quot;/usr/sbin/chat -v -V -t15 -f /etc/ppp/tim3g-chat&quot;</span>
<span style="color: #339933;">/</span>dev<span style="color: #339933;">/</span>ttyUSB3
<span style="color: #cc66cc;">115200</span>
noipdefault
usepeerdns
defaultroute
noauth</pre></div></div>

<p>Crie também o arquivo /etc/ppp/tim3g-chat, que é são onde os comandos AT estarão configurados no padrão de discagem do 3G da tim:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="">''</span> <span style="">'ATZ'</span>
<span style="">'OK'</span> <span style="">'ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2 +FCLASS=0'</span>
<span style="">'OK'</span> <span style="">'AT+CGDCONT=1,&quot;IP&quot;,&quot;tim.br&quot;'</span>
<span style="">'OK'</span> <span style="">'ATD*99***1#'</span>
CONNECT <span style="">''</span></pre></div></div>

<div>Para conectar:</div>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">machine<span style="color: #666666; font-style: italic;"># pppd call tim3g</span></pre></div></div>

<p>Pronto! Se quiser compartilhar a internet:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">sysctl net.ipv4.ip_forward<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
iptables <span style="color: #339933;">-</span>t nat <span style="color: #339933;">-</span>A POSTROUTING <span style="color: #339933;">-</span>o ppp0 <span style="color: #339933;">-</span><span style="color: #000066;">s</span> SUA_REDE <span style="color: #339933;">-</span>j MASQUERADE</pre></div></div>

<div>Valeu!</div>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2011/05/22/usando-3g-da-tim-direto-via-pppd/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Slides da minha palestra sobre Arquitetura de serviços de diretório com OpenLDAP pela Locaweb na LinuxCon 2010</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2010/08/31/slides-da-minha-palestra-sobre-arquitetura-de-servicos-de-diretorio-com-openldap-pela-locaweb-na-linuxcon-2010/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2010/08/31/slides-da-minha-palestra-sobre-arquitetura-de-servicos-de-diretorio-com-openldap-pela-locaweb-na-linuxcon-2010/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 00:57:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[arquitetura]]></category>

		<category><![CDATA[disponibilidade]]></category>

		<category><![CDATA[escalabilidade]]></category>

		<category><![CDATA[ldap]]></category>

		<category><![CDATA[LDAP OpenLDAP replicação N-Way Multimaster]]></category>

		<category><![CDATA[linuxcon]]></category>

		<category><![CDATA[openldap]]></category>

		<category><![CDATA[pcache]]></category>

		<category><![CDATA[slapo-pcache]]></category>

		<category><![CDATA[x500]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=177</guid>
		<description><![CDATA[Arquitetura, disponibilidade e escalabilidade de serviços de diretório
View more presentations from theflockers.

]]></description>
			<content:encoded><![CDATA[<div style="width:425px" id="__ss_5101965"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/theflockers/open-ldap-linuxconworking" title="Open ldap linuxcon_working">Arquitetura, disponibilidade e escalabilidade de serviços de diretório</a></strong><object id="__sse5101965" width="485" height="415"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=openldaplinuxconworking-100831193903-phpapp02&#038;stripped_title=open-ldap-linuxconworking" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5101965" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=openldaplinuxconworking-100831193903-phpapp02&#038;stripped_title=open-ldap-linuxconworking" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/theflockers">theflockers</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2010/08/31/slides-da-minha-palestra-sobre-arquitetura-de-servicos-de-diretorio-com-openldap-pela-locaweb-na-linuxcon-2010/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Efetuando Cache de suas consultas LDAP</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2010/05/27/efetuando-cache-de-suas-consultas-ldap/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2010/05/27/efetuando-cache-de-suas-consultas-ldap/#comments</comments>
		<pubDate>Thu, 27 May 2010 04:00:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[ldap]]></category>

		<category><![CDATA[openldap]]></category>

		<category><![CDATA[pcache]]></category>

		<category><![CDATA[slapo-pcache]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=145</guid>
		<description><![CDATA[Há bastante tempo tenho trabalhado com serviço de diretório, especificamente com o OpenLDAP. Quando criando um novo ambiente, no geral minhas preocupações são: redundância e performance das aplicações. Pensando nisso, sempre procurei manter meu backup em dia e diversos slaves como forma de redundância e para permitir que as aplicações não sofram com problemas de [...]]]></description>
			<content:encoded><![CDATA[<p>Há bastante tempo tenho trabalhado com serviço de diretório, especificamente com o <strong>OpenLDAP</strong>. Quando criando um novo ambiente, no geral minhas preocupações são: <em>redundância e performance das aplicações</em>. Pensando nisso, sempre procurei manter meu backup em dia e diversos slaves como forma de redundância e para permitir que as aplicações não sofram com problemas de performance for falta de ajustes finos, latência de rede, inacessibilidade ou por questões relacionadas à escalabilidade. </p>
<p>De fato, essa fórmula sempre funcionou como esperado, mas o excesso de réplicas torna o ambiente praticamente inadministrável conforme o número de Slaves aumenta, e é óbvio que queremos que nossa aplicação seja escalável. Em um modelo deste tipo, escalar a aplicação também significa precisar de mais slaves.</p>
<p>A boa notícia é que o OpenLDAP possui um módulo chamado “<strong>pcache</strong>” que elimina esta necessidade absurda de milhões de réplicas dentro da sua estrutura.</p>
<p>O conceito é simples. Ao invés de replicar todo o diretório, o pcache armazena somente os resultados das pesquisas efetuadas e pelo tempo necessário. Uma consulta que não está em cache é respondida pelo Master (ou Slave, preferívelmente) e a que está em cache é respondida localmente. </p>
<h3>Arquitetura com OpenLDAP Proxy Cache</h3>
<p>A partir deste ponto, vou mostrar um exemplo de arquitetura física ignorando qualquer melhoria relacionada ao modelo utilizado dentro do diretório. Meu intuito é somente mostrar o funcionamento do “slapo-pcache”. </p>
<p>Exemplo simples de arquitetura :</p>
<p><img src="http://www.wish4web.com.br/blog/theflockers/wp-content/uploads/2010/05/text3215-7-300x234.png" alt="text3215-7" title="text3215-7" width="300" height="234" class="aligncenter size-medium wp-image-154" /></p>
<p>Como é possível ver, existe a possibilidade de que a própria máquina de aplicação seja o cache. Desta forma a latência de rede já é eliminada pois a consulta é local. Digamos que é possível economizar alguns bons milisegundos (ou até segundos) para cada consulta efetuada. Obviamente, quando iniciar o serviço pela primeira vez, o seu diretório Slave vai receber uma carga maior, mas a curto prazo, essa carga deve diminuir. O Master por sua vez, será somente utilizado para gravações e algumas leituras.</p>
<p>A configuração do “slapo-pcache” é bastante simples, mas é necessário que você saiba exatamente todas os tipo de consultas que serão efetuadas no seu diretório. No geral, sempre sabemos quais queries serão efetuadas, salvo se seu diretório for aberto.</p>
<p><strong>Instalação</strong></p>
<p>A instalação é bem simples. Pode ser instalado através do gerenciador da sua distro, ou pelo conhecido trio “./configure”, “make”, “make install”. </p>
<p>Para o Red Hat, é necessário instalar o pacote openldap-servers-overlays e no caso de haver necessidade do compilação, são necessários os seguintes parâmetros “&#8211;backend-ldap” e “–overlay-pcache”.</p>
<p><strong>Configuração</strong></p>
<p>A configuração de um LDAP Cache é muito simples. A cada sessão, irei explicar qual é a função do ítem de configuração</p>
<p><strong>slapd.conf</strong></p>
<p>Primeiramente incluímos todos os “schemas” requeridos pelo diretório, pois caso não existirem, o OpenLDAP não consegue persistir o resultado das consultas, fazendo o cache ser ineficaz.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Schema files</span>
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>core.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>corba.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>cosine.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>inetorgperson.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>misc.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>mail.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>nis.schema
include      <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>openldap<span style="color: #339933;">/</span>schema<span style="color: #339933;">/</span>openldap.schema</pre></div></div>

<p>É necessário carregar o módulo explicitamente. Em algumas distribuições é desnecessário fazer isso. Mas na dúvida, faça.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># modules</span>
moduleload      pcache</pre></div></div>

<p>Estes níveis de log, mostram sobre as consultas efetuadas no diretório. Para saber os outros níveis, verifique a documentação do OpenLDAP.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># log information</span>
loglevel        stats stats2</pre></div></div>

<p>Esta é a sessão relacionada aos backends necessários para efetuar o cache. Observe que o Backend primário utilizado aqui é o “ldap”, ou seja, a consulta feita no cache é repassada para as “uri” definidas.  O “suffix” precisa ser o mesmo do seu diretório. O “rootdn” pode ser diferente.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">database        ldap
suffix          <span style="color: #ff0000;">&quot;dc=mydomain,dc=com”
uri             “ldap://200.x.x.x ldap://200.x.x.y”
rootdn          &quot;</span>cn<span style="color: #339933;">=</span>manager<span style="color: #339933;">,</span>dc<span style="color: #339933;">=</span>mydomain<span style="color: #339933;">,</span>dc<span style="color: #339933;">=</span>com”</pre></div></div>

<p>Aqui vemos a configuração do Cache. O Overlay pcache está sendo inicializado. Os valores do parâmetro proxycache são, respectivamente: tipo do backend; número de entradas no cache; número de attribute sets; número máximo de entradas; período de “consistency check”.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># slapo-pcache configuration</span>
overlay         pcache
proxycache      bdb <span style="color: #cc66cc;">100000</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">1000</span> <span style="color: #cc66cc;">100</span></pre></div></div>

<p>Os “proxyAttrset”, são os attribute sets que serão retornados pelas consultas. No exemplo abaixo, minha consulta de número 0 retorna mailHost e rfc822MailAlias, enquanto minha consulta 1 retorna somente a existência de determinado attributo.<br />
Estes “proxyAttrsets” serão utilizados pelas “proxyTemplates” a fim de consolidar o cache. Neles constam as templates das consultas que serão efetuadas, o id do attribute set e o TTL.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">proxyAttrset    0 mailHost rfc822MailAlias
proxyAttrset    <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">1.1</span>
proxyTemplate   <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #009900;">&#40;</span>uid<span style="color: #339933;">=</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>associatedDomain<span style="color: #339933;">=</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>mailHost<span style="color: #339933;">=</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 0 <span style="color: #cc66cc;">3600</span>
proxyTemplate   <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #009900;">&#40;</span>uid<span style="color: #339933;">=</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>associatedDomain<span style="color: #339933;">=</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">3600</span></pre></div></div>

<p>E enfim, o tamanho total do cache (preferivelmente o mesmo do cache do overlay), o diretório onde será armazenado o cache e por último, os indexes.<br />
Um ponto importante. Não abuse de indexes, eles são necessários, mas o excesso de índices inúteis podem gerar problemas de performance. Sempre olhe seus logs. Se faltar algum índice, constará em seus logs.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">cachesize       <span style="color: #cc66cc;">100000</span>
directory       <span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>db<span style="color: #339933;">/</span>openldap<span style="color: #339933;">-</span>cache
<span style="color: #000066;">index</span>           uid<span style="color: #339933;">,</span>cn pres<span style="color: #339933;">,</span>eq
<span style="color: #000066;">index</span>           objectClass<span style="color: #339933;">,</span>associatedDomain<span style="color: #339933;">,</span>mailHost eq</pre></div></div>

<p>A configuração do pcache é realmente simples. Uma vez que você sabe exatamente as queries que são feitas no seu diretório, seu cache será eficaz.<br />
Outros tunings podem ser aplicados, mas não no slapd.conf, mas sim no DB_CONFIG no diretório de seu database.</p>
<p>Normalmente para um cache, costumo criar dois segmentos de memória para cache e um número maior de “lockers”, pois em ambientes de alto volume de consultas, um número baixo de “lockers” pode significar gargalo. Também deixo os transaction logs em auto-remove. Como trata-se de um cache, não existe utilidade nenhuma em preservá-los.</p>
<p><strong>DB_CONFIG</strong></p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">set_flags DB_LOG_AUTOREMOVE
set_cachesize 0 <span style="color: #cc66cc;">2073741824</span> <span style="color: #cc66cc;">2</span>
set_lk_max_locks <span style="color: #cc66cc;">3000</span>
set_lk_max_objects <span style="color: #cc66cc;">1500</span>
set_lk_max_lockers <span style="color: #cc66cc;">1500</span></pre></div></div>

<p>Basicamente, esta é uma configuração padrão para um cache. Como já dito, ele pode rodar diretamente e sua máquina de aplicação ou em separado mas fique atento para não confundir problemas de configuração nos “clients” com problemas de performance do cache. Um bom exemplo, é utilizar seu “base dn” diferente do que foi configurado no server. Todos os índices criados, só funcionarão corretamente se as consultas forem feitas na base correta, caso contrário, você terá problemas gigantes com deadlocks.</p>
<p>Espero que este artigo possa ajudar quando for arquitetar sua próxima instalação. Claro que em ambientes maiores será necessário um número maior de caches e slaves, bem como a redundância de seu Master. Em meu próximo POST sobre LDAP, mostrarei como montar um ambiente com Hot Standby. Até!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2010/05/27/efetuando-cache-de-suas-consultas-ldap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Escrevendo um servidor HTTPS em Python</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2010/05/04/escrevendo-um-servidor-https-em-python/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2010/05/04/escrevendo-um-servidor-https-em-python/#comments</comments>
		<pubDate>Tue, 04 May 2010 03:19:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programação]]></category>

		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=130</guid>
		<description><![CDATA[Dia desses precisei de um servidor HTTP para implementar algumas funcionalidades que eu precisava. Verificando os que já conhecia, percebi que seria bastente trabalhoso escrever módulos para WebServers como o Lighttpd, Apache ou o Nginx, mesmo apesar deste último ser um pouco mais fácil. Procurei então alguma linguagem interpretada para fazer o que eu precisava.
Pesquisei [...]]]></description>
			<content:encoded><![CDATA[<p>Dia desses precisei de um servidor HTTP para implementar algumas funcionalidades que eu precisava. Verificando os que já conhecia, percebi que seria bastente trabalhoso escrever módulos para WebServers como o Lighttpd, Apache ou o Nginx, mesmo apesar deste último ser um pouco mais fácil. Procurei então alguma linguagem interpretada para fazer o que eu precisava.</p>
<p>Pesquisei bastante em Ruby como o fazê-lo, mas não me senti &#8220;seduzido&#8221; pelas Libs de Ruby que construiam HTTP Servers, e também há aquela velha questão do Ruby ser mono thread. Pesquisei algo relacionado ao Perl mas infelizmente é uma linguagem que não me sinto à vontade para fazer alguma coisa, e sinceramente não gosto muito. No final, acabei escolhendo escrevê-lo em <strong>Python</strong>, pois devo confessar que existem muitas facilidades devido milhares de modulos embutidos na linguagem em sua instalação padrão.</p>
<p>Uma delas é o <strong>BaseHTTPServer</strong>, que constrói facilmente um servidor HTTP básico mas extermamente extensível.</p>
<p>O intuito deste POST é mostrar a facilidade com que se constrói um HTTPServer em Python e ainda por cima, adicionar a camada SSL por cima dele.</p>
<p>Escrevendo seu HTTP Server básico com SSL</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #dc143c;">user</span>@host ~$ vim secureServer.<span style="color: black;">py</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">BaseHTTPServer</span> <span style="color: #ff7700;font-weight:bold;">import</span> HTTPServer, BaseHTTPRequestHandler
<span style="color: #ff7700;font-weight:bold;">import</span> ssl
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> classHandler<span style="color: black;">&#40;</span>BaseHTTPRequestHandler<span style="color: black;">&#41;</span>: <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
server_addr = <span style="color: black;">&#40;</span>127.0.0.1, <span style="color: #ff4500;">443</span><span style="color: black;">&#41;</span>
httpd = HTTPServer<span style="color: black;">&#40;</span>server_addr, classHandler<span style="color: black;">&#41;</span>
httpd.<span style="color: #dc143c;">socket</span> = ssl.<span style="color: black;">wrap_socket</span><span style="color: black;">&#40;</span>httpd.<span style="color: #dc143c;">socket</span>,  \
    certfile=<span style="color: #483d8b;">'cert.pem'</span>, server_side=<span style="color: #008000;">True</span>, \
    ssl_version=ssl.<span style="color: black;">PROTOCOL_SSLv23</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
        httpd.<span style="color: black;">handle_request</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Viram que simples? Mas para este pequeno protótipo  funcionar corretamente, é preciso criar um certificado SSL. Como é somente teste, vou criar um &#8220;self signed&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">user<span style="color: #0000ff;">@host</span> <span style="color: #339933;">~</span>$ openssl req <span style="color: #339933;">-</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #339933;">-</span>x509 <span style="color: #339933;">-</span>days <span style="color: #cc66cc;">365</span> <span style="color: #339933;">-</span>nodes <span style="color: #339933;">-</span>out cert.pem <span style="color: #339933;">-</span>keyout cert.pem
&nbsp;
Generating a <span style="color: #cc66cc;">1024</span> bit RSA private key
..........................................................<span style="color: #339933;">++++++</span>
.......................<span style="color: #339933;">++++++</span>
writing <span style="color: #000000; font-weight: bold;">new</span> private key to <span style="">'cert.pem'</span>
<span style="color: #339933;">-----</span>
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name <span style="color: #b1b100;">or</span> a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value<span style="color: #339933;">,</span>
If you enter <span style="">'.'</span><span style="color: #339933;">,</span> the field will be left blank.
<span style="color: #339933;">-----</span>
Country Name <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span> letter code<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span>AU<span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>BR
State <span style="color: #b1b100;">or</span> Province Name <span style="color: #009900;">&#40;</span>full name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span>Some<span style="color: #339933;">-</span>State<span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>São Paulo
Locality Name <span style="color: #009900;">&#40;</span>eg<span style="color: #339933;">,</span> city<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>SP
Organization Name <span style="color: #009900;">&#40;</span>eg<span style="color: #339933;">,</span> company<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span>Internet Widgits Pty Ltd<span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>Leandro LTDA
Organizational Unit Name <span style="color: #009900;">&#40;</span>eg<span style="color: #339933;">,</span> section<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>Mail
Common Name <span style="color: #009900;">&#40;</span>eg<span style="color: #339933;">,</span> YOUR name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>localhost
Email Address <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>leandro<span style="color: #0000ff;">@localhost</span></pre></div></div>

<p>Pronto, agora é só testar com o openssl client.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">user<span style="color: #0000ff;">@host</span> <span style="color: #339933;">~</span>$ openssl s_client <span style="color: #339933;">-</span>host localhost <span style="color: #339933;">-</span>port <span style="color: #cc66cc;">443</span>
CONNECTED<span style="color: #009900;">&#40;</span>00000003<span style="color: #009900;">&#41;</span>
depth<span style="color: #339933;">=</span>0 <span style="color: #339933;">/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
verify error<span style="color: #339933;">:</span>num<span style="color: #339933;">=</span><span style="color: #cc66cc;">18</span><span style="color: #339933;">:</span>self signed certificate
verify <span style="color: #000066;">return</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span>
depth<span style="color: #339933;">=</span>0 <span style="color: #339933;">/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
verify <span style="color: #000066;">return</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span>
<span style="color: #339933;">---</span>
Certificate chain
 0 <span style="color: #000066;">s</span><span style="color: #339933;">:/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
   i<span style="color: #339933;">:/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
<span style="color: #339933;">---</span>
Server certificate
<span style="color: #339933;">-----</span><span style="color: #000000; font-weight: bold;">BEGIN</span> CERTIFICATE<span style="color: #339933;">-----</span>
MIIDijCCAvOgAwIBAgIJAKY1XzcnjUW3MA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD
VQQGEwJCUjETMBEGA1UECBQKU8OjbyBQYXVsbzELMAkGA1UEBxMCU1AxFTATBgNV
BAoTDExlYW5kcm8gTFREQTENMAsGA1UECxMETWFpbDESMBAGA1UEAxMJbG9jYWxo
b3N0MSAwHgYJKoZIhvcNAQkBFhFsZWFuZHJvQGxvY2FsaG9zdDAeFw0xMDAxMjEw
MTQ0MThaFw0xMTAxMjEwMTQ0MThaMIGLMQswCQYDVQQGEwJCUjETMBEGA1UECBQK
U8OjbyBQYXVsbzELMAkGA1UEBxMCU1AxFTATBgNVBAoTDExlYW5kcm8gTFREQTEN
MAsGA1UECxMETWFpbDESMBAGA1UEAxMJbG9jYWxob3N0MSAwHgYJKoZIhvcNAQkB
FhFsZWFuZHJvQGxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
yCX09Doe3bfFwrmGjAA3cDOUC47vuOVUkWzlnkX2e7nWN7J13amFHtBFXG2YunEs
wPEm5VZMMtjq5fhmKdcw<span style="color: #339933;">+</span>y6U2Lf6iS1Q5vEutuY<span style="color: #339933;">/</span>L2XbHlzctMFbasqkuVO8H0oB
Lqg9zTuRfx<span style="color: #339933;">/</span>BJ7BmhrWZMKYMYbP<span style="color: #339933;">/</span>PbFGejMrhMUzcp0CAwEAAaOB8zCB8DAdBgNV
HQ4EFgQU6s23dwSaSIO2CRXnzSqRCfbJLyQwgcAGA1UdIwSBuDCBtYAU6s23dwSa
SIO2CRXnzSqRCfbJLyShgZGkgY4wgYsxCzAJBgNVBAYTAkJSMRMwEQYDVQQIFApT
w6NvIFBhdWxvMQswCQYDVQQHEwJTUDEVMBMGA1UEChMMTGVhbmRybyBMVERBMQ0w
CwYDVQQLEwRNYWlsMRIwEAYDVQQDEwlsb2NhbGhvc3QxIDAeBgkqhkiG9w0BCQEW
EWxlYW5kcm9AbG9jYWxob3N0ggkApjVfNyeNRbcwDAYDVR0TBAUwAwEB<span style="color: #339933;">/</span>zANBgkq
hkiG9w0BAQUFAAOBgQCl6<span style="color: #339933;">+</span>gzbq4gQfE<span style="color: #339933;">/</span>W5NYCX1S<span style="color: #339933;">/</span>bsNFaGaDoSr8nzibF<span style="color: #339933;">++</span>3NeI
CjgtDciimmSb330AJE1GSC9xqvLF86LV2wvIw3W6eR7<span style="color: #339933;">+</span>YYgGfoPv2eOnGO<span style="color: #339933;">/</span>djsKM
<span style="color: #339933;">/</span>0MvPoUjJPfP9k2RftyYQMaKPMXGtGGCWnlm6bUade9wq4BdBYkKRp42Rb83qQ<span style="color: #339933;">==</span>
<span style="color: #339933;">-----</span>END CERTIFICATE<span style="color: #339933;">-----</span>
subject<span style="color: #339933;">=/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
issuer<span style="color: #339933;">=/</span>C<span style="color: #339933;">=</span>BR<span style="color: #339933;">/</span>ST<span style="color: #339933;">=</span>S\xC3\xA3o Paulo<span style="color: #339933;">/</span>L<span style="color: #339933;">=</span>SP<span style="color: #339933;">/</span>O<span style="color: #339933;">=</span>Leandro LTDA<span style="color: #339933;">/</span>OU<span style="color: #339933;">=</span>Mail<span style="color: #339933;">/</span>CN<span style="color: #339933;">=</span>localhost<span style="color: #339933;">/</span>emailAddress<span style="color: #339933;">=</span>leandro<span style="color: #0000ff;">@localhost</span>
<span style="color: #339933;">---</span>
No client certificate CA names sent
<span style="color: #339933;">---</span>
SSL handshake has <span style="color: #000066;">read</span> <span style="color: #cc66cc;">1072</span> bytes <span style="color: #b1b100;">and</span> written <span style="color: #cc66cc;">316</span> bytes
<span style="color: #339933;">---</span>
New<span style="color: #339933;">,</span> TLSv1<span style="color: #339933;">/</span>SSLv3<span style="color: #339933;">,</span> Cipher is AES256<span style="color: #339933;">-</span>SHA
Server public key is <span style="color: #cc66cc;">1024</span> bit
Compression<span style="color: #339933;">:</span> NONE
Expansion<span style="color: #339933;">:</span> NONE
SSL<span style="color: #339933;">-</span>Session<span style="color: #339933;">:</span>
    Protocol  <span style="color: #339933;">:</span> TLSv1
    Cipher    <span style="color: #339933;">:</span> AES256<span style="color: #339933;">-</span>SHA
    Session<span style="color: #339933;">-</span>ID<span style="color: #339933;">:</span> 0DF03B0D70244E8A4E357504AEB010FCCBF02977E1B530FC8E2F47057AB5D949
    Session<span style="color: #339933;">-</span>ID<span style="color: #339933;">-</span>ctx<span style="color: #339933;">:</span>
    Master<span style="color: #339933;">-</span>Key<span style="color: #339933;">:</span> 5E124A87C6BAE38AFF3CA2F78EBDB9A989E988B005AB596D7FCF7D93B48D7FD1C4F1FCAEA325DC48137D0EBC23DDBB4A
    Key<span style="color: #339933;">-</span>Arg   <span style="color: #339933;">:</span> None
    Start Time<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1264038343</span>
    Timeout   <span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span> <span style="color: #009900;">&#40;</span>sec<span style="color: #009900;">&#41;</span>
    Verify <span style="color: #000066;">return</span> code<span style="color: #339933;">:</span> <span style="color: #cc66cc;">18</span> <span style="color: #009900;">&#40;</span>self signed certificate<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">---</span></pre></div></div>

<p>Pronto, seu HTTPServer com SSL está funcionando. Obviamente, nenhum dos métodos está sendo implementado, mas isto é facilmente de se fazer. O BaseHTTPServer, por padrão não implementa nenhum método, sendo assim, para facilitar você pode extender o SimpleHTTPServer que já implementa os métodos <strong>do_GET</strong> e <strong>do_HEAD</strong>, a única coisa que é necessário fazer é implementar os outros método desejado, como<strong> do_POST</strong>, <strong>do_PUT</strong>, <strong>do_DELETE</strong>, etc.  Verifique a documentação!</p>
<p>É isso aí galera!! </p>
<p>Referencias</p>
<p>http://docs.python.org/library/ssl.html<br />
http://docs.python.org/library/basehttpserver.html</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2010/05/04/escrevendo-um-servidor-https-em-python/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Replicação Multi-Master no OpenLDAP 2.4</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2009/11/15/replicacao-multi-master-no-openldap-24/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2009/11/15/replicacao-multi-master-no-openldap-24/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 02:47:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[LDAP OpenLDAP replicação N-Way Multimaster]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=113</guid>
		<description><![CDATA[As versões mais antigas, era possível efetuar a replicação somente via slurpd e na configuração Master para N Slaves. Com o lançamento da versão 2.4, o OpenLDAP passou a proporcionar diversas formas de replicação, como Mirror Mode, N-Way Multimaster e ainda Master-Slave.
Este pequeno tutorial, explica de forma rápida a configuração para Alta-disponibilidade (N-Way Multimaster) para [...]]]></description>
			<content:encoded><![CDATA[<p>As versões mais antigas, era possível efetuar a replicação somente via <i>slurpd</i> e na configuração Master para N Slaves. Com o lançamento da versão 2.4, o OpenLDAP passou a proporcionar diversas formas de replicação, como Mirror Mode, N-Way Multimaster e ainda Master-Slave.</p>
<p>Este pequeno tutorial, explica de forma rápida a configuração para Alta-disponibilidade (N-Way Multimaster) para OpenLDAP 2.4, que sempre foi uma das principais solicitações da comunidade.</p>
<h2>Configurando do Slapd</h2>
<p>Fazer o setup manual do slapd.conf, ex:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># schemas</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/core.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/corba.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/cosine.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/inetorgperson.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/misc.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/nis.schema&quot;</span>
include <span style="color: #ff0000;">&quot;/usr/loca/etc/openldap/schema/openldap.schema&quot;</span>
&nbsp;
moduleload back_bdb
&nbsp;
database bdb
suffix   <span style="color: #ff0000;">&quot;ou=Mail, o=Teste&quot;</span>
rootdn   <span style="color: #ff0000;">&quot;cn=root, ou=Mail, o=Teste&quot;</span>
rootpw
directory <span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>db<span style="color: #339933;">/</span>openldap<span style="color: #339933;">-</span>data
&nbsp;
<span style="color: #666666; font-style: italic;"># Indexes</span>
<span style="color: #000066;">index</span> objectClass eq
<span style="color: #000066;">index</span> cn<span style="color: #339933;">,</span>uid<span style="color: #339933;">,</span>associatedDomain eq</pre></div></div>

<p>Feita a configuração básica, é necessário converter o arquivo de configuração para o novo &#8220;estilo&#8221; de configuração para o OpenLDAP 2.4. Isto pode ser feito com o commando slaptest.</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">root<span style="color: #666666; font-style: italic;"># mkdir /usr/local/etc/openldap/slapd.d/</span>
root<span style="color: #666666; font-style: italic;"># slaptest -f /usr/local/etc/openldap/slapd.conf -F /usr/local/etc/openldap/slapd.d/</span></pre></div></div>

<p>Serão gerados os arquivos de configuração da versão 2.4 do OpenLDAP.</p>
<p>É necessário também alterar os seguintes arquivos adicionando os seguintes atributos (em todos os nós):</p>
<p>Em /usr/local/etc/openldap/slapd.d/cn=config.ldif:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># alterar o número para cada nó</span>
olcServerID<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span></pre></div></div>

<p>e</p>
<p>Em /usr/local/etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">olcRootPW<span style="color: #339933;">:</span> <span style="color: #009999;">&lt;senha&gt;</span></pre></div></div>

<p>A partir daí, o serviço deve ser iniciado.</p>
<h2>Configurando a replicação</h2>
<p>Com o novo tipo de configuração, tudo deve ser feito via arquivos LDIF e alterados na database cn=config do OpenLDAP, via ldapmodify.</p>
<p>Crie o um arquivo setup.ldif com o seguinte conteúdo:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">dn<span style="color: #339933;">:</span> cn<span style="color: #339933;">=</span>config
changetype<span style="color: #339933;">:</span> modify
replace<span style="color: #339933;">:</span> olcServerID
olcServerID<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span> ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server1&gt;</span>
olcServerID<span style="color: #339933;">:</span> <span style="color: #cc66cc;">2</span> ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server2&gt;</span>
dn<span style="color: #339933;">:</span> olcOverlay<span style="color: #339933;">=</span>syncprov<span style="color: #339933;">,</span>olcDatabase<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>0<span style="color: #009900;">&#125;</span>config<span style="color: #339933;">,</span>cn<span style="color: #339933;">=</span>config
changetype<span style="color: #339933;">:</span> add
objectClass<span style="color: #339933;">:</span> olcOverlayConfig
objectClass<span style="color: #339933;">:</span> olcSyncProvConfig
olcOverlay<span style="color: #339933;">:</span> syncprov
&nbsp;
dn<span style="color: #339933;">:</span> olcDatabase<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>0<span style="color: #009900;">&#125;</span>config<span style="color: #339933;">,</span>cn<span style="color: #339933;">=</span>config
changetype<span style="color: #339933;">:</span> modify
add<span style="color: #339933;">:</span> olcSyncRepl
olcSyncRepl<span style="color: #339933;">:</span> rid<span style="color: #339933;">=</span>001 provider<span style="color: #339933;">=</span>ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server1&gt;</span> binddn<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=config&quot;</span> bindmethod<span style="color: #339933;">=</span>simple
credentials<span style="color: #339933;">=</span>secret searchbase<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=config&quot;</span> type<span style="color: #339933;">=</span>refreshAndPersist
retry<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;5 5 300 5&quot;</span> timeout<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
olcSyncRepl<span style="color: #339933;">:</span> rid<span style="color: #339933;">=</span>002 provider<span style="color: #339933;">=</span>ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server2&gt;</span> binddn<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=config&quot;</span> bindmethod<span style="color: #339933;">=</span>simple
credentials<span style="color: #339933;">=</span>secret searchbase<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=config&quot;</span> type<span style="color: #339933;">=</span>refreshAndPersist
retry<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;5 5 300 5&quot;</span> timeout<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
<span style="color: #339933;">-</span>
add<span style="color: #339933;">:</span> olcMirrorMode
olcMirrorMode<span style="color: #339933;">:</span> TRUE</pre></div></div>

<p>Adicionar ao diretório</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">root<span style="color: #666666; font-style: italic;"># ldapmodify -x -D&quot;cn=config&quot; -w  -f setup.ldif</span></pre></div></div>

<p>Isto fará a replicação da database &#8220;cn=config&#8221;. Fazer o mesmo processo no LDAP SLAVE.<br />
Replicando a base de dados &#8220;ou=Mail,o=Teste&#8221;.</p>
<p>A base de dados cn=config, é importante pois desta forma, todos os nós serão configurados automaticamente, quando for feito o setup para a replicação da base &#8220;ou=Mail,o=Teste&#8221;, que possui os dados importantes.</p>
<p>Criar um arquivos data.ldif:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">dn<span style="color: #339933;">:</span> olcDatabase<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span>bdb<span style="color: #339933;">,</span>cn<span style="color: #339933;">=</span>config
changetype<span style="color: #339933;">:</span> modify
add<span style="color: #339933;">:</span> olcMirrorMode<span style="color: #339933;">:</span>
olcMirrorMode<span style="color: #339933;">:</span> TURE
add<span style="color: #339933;">:</span> olcLimits
olcLimits<span style="color: #339933;">:</span> dn.exact<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=root,ou=Mail,o=Teste&quot;</span> <span style="color: #000066;">time</span>.soft<span style="color: #339933;">=</span>unlimited <span style="color: #000066;">time</span>.hard<span style="color: #339933;">=</span>unlimited size.soft<span style="color: #339933;">=</span>unlimited size.hard<span style="color: #339933;">=</span>unlimited
<span style="color: #666666; font-style: italic;">#replica 1</span>
add<span style="color: #339933;">:</span> olcSyncRepl
olcSyncRepl<span style="color: #339933;">:</span> rid<span style="color: #339933;">=</span>003 provider<span style="color: #339933;">=</span>ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server1&gt;</span> binddn<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=root,ou=Mail,o=Teste&quot;</span>
bindmethod<span style="color: #339933;">=</span>sinple credentials<span style="color: #339933;">=</span>secret searchbase<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;ou=Mail,o=Teste&quot;</span>
type<span style="color: #339933;">=</span>refreshOnly interval<span style="color: #339933;">=</span>00<span style="color: #339933;">:</span>00<span style="color: #339933;">:</span>00<span style="color: #339933;">:</span><span style="color: #cc66cc;">10</span> retry<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;5 5 300 5&quot;</span> timeout<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
<span style="color: #666666; font-style: italic;">#replica 2</span>
add<span style="color: #339933;">:</span> olcSyncRepl
olcSyncRepl<span style="color: #339933;">:</span> rid<span style="color: #339933;">=</span>004 provider<span style="color: #339933;">=</span>ldap<span style="color: #339933;">://</span><span style="color: #009999;">&lt;server2&gt;</span> binddn<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;cn=root,ou=Mail,o=Teste&quot;</span>
bindmethod<span style="color: #339933;">=</span>sinple credentials<span style="color: #339933;">=</span>secret searchbase<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;ou=Mail,o=Teste&quot;</span>
type<span style="color: #339933;">=</span>refreshOnly interval<span style="color: #339933;">=</span>00<span style="color: #339933;">:</span>00<span style="color: #339933;">:</span>00<span style="color: #339933;">:</span><span style="color: #cc66cc;">10</span> retry<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;5 5 300 5&quot;</span> timeout<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Habilita o syncprov</span>
dn<span style="color: #339933;">:</span> olcOverlay<span style="color: #339933;">=</span>syncprov<span style="color: #339933;">,</span> olcDatabase<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span>bdb<span style="color: #339933;">,</span>cn<span style="color: #339933;">=</span>config
changetype<span style="color: #339933;">:</span> add
objectClass<span style="color: #339933;">:</span> olcOverLayConfig
objectClass<span style="color: #339933;">:</span> olcSyncProvConfig
olcOverlay<span style="color: #339933;">:</span> syncprov</pre></div></div>

<p>Feito isso, adicionar os dados no Diretório:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;">root<span style="color: #666666; font-style: italic;"># ldapmodify -x -D&quot;cn=config&quot; -w  -f data.ldif</span></pre></div></div>

<p>Pronto! Está funcionando!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2009/11/15/replicacao-multi-master-no-openldap-24/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IMAP Proxy</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2009/06/30/imap-proxy/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2009/06/30/imap-proxy/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 23:20:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=106</guid>
		<description><![CDATA[IMAP Proxy
Parece óbvio, mas poucos se lembram da possibilidade, de &#8220;cachear&#8221; as conexões IMAP em uma única, a fim de diminuir as requisições IMAP vindas por HTTP (webmails, em específico), pois como o HTTP é um protocolo &#8220;stateless&#8221;, ou seja, não mantém uma conexão persistente e automaticamente cada REQUEST é uma nova conexão IMAP em [...]]]></description>
			<content:encoded><![CDATA[<h1>IMAP Proxy</h1>
<p>Parece óbvio, mas poucos se lembram da possibilidade, de &#8220;cachear&#8221; as conexões IMAP em uma única, a fim de diminuir as requisições IMAP vindas por HTTP (webmails, em específico), pois como o HTTP é um protocolo &#8220;stateless&#8221;, ou seja, não mantém uma conexão persistente e automaticamente cada REQUEST é uma nova conexão IMAP em seu servidor.</p>
<p>Para resolver isto, existe a solução de Proxy IMAP. Existem alguns software para isto, mas no momento estou usando o &#8220;imapproxy&#8221; que pode ser baixado no site do projeto, www.imapproxy.org.</p>
<p>O software é extremamente simples e intuitivo, não precisando de mais de 10 minutos pra entender e colocar no ar.</p>
<p>A característica principal do software é manter uma conexão única por usuário. Ele mantém as credenciais enviadas pelo client cacheadas e uma conexão persistente com o servidor IMAP.</p>
<h2><strong>Instalação</strong></h2>
<p>Baixe o software no site do projeto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">user <span style="color: #339933;">~/</span> $ wget http<span style="color: #339933;">://</span>www.imapproxy.org<span style="color: #339933;">/</span>downloads<span style="color: #339933;">/</span>up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6.tar.gz</pre></td></tr></table></div>

<p><span style="color: #ff0000;"><strong>O imapproxy depende de ncurses para compilar, então, baixe-o e instale-o!</strong></span></p>
<p>Compile-o e instale-o, ou então busque o pacote da sua distro.</p>
<p>Para os Slackers de plantão:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">user <span style="color: #339933;">:~</span>$ tar xvzf up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6.tar.gz
user <span style="color: #339933;">:~</span>$ cd up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6<span style="color: #339933;">/</span>
user <span style="color: #339933;">:~/</span>up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6$ .<span style="color: #339933;">/</span>configure <span style="color: #339933;">--</span>prefix<span style="color: #339933;">=/</span>usr <span style="color: #339933;">--</span>sysconfdir<span style="color: #339933;">=/</span>etc <span style="color: #339933;">--</span>localstatedir<span style="color: #339933;">=/</span>var
user <span style="color: #339933;">:~/</span>up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6$ make
user <span style="color: #339933;">:~/</span>up<span style="color: #339933;">-</span>imapproxy<span style="color: #339933;">-</span>1.2.6$ sudo make install</pre></td></tr></table></div>

<p>Instalado, a configuração é extremamente simples, mas vou explicar algumas delas.<br />
O arquivo de configuração de acordo com nossa instalação estará em /etc/imapproxy.conf.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">server_hostname 200.x.x.x  <span style="color: #666666; font-style: italic;"># Este será o servidor de destino</span>
cache_size <span style="color: #cc66cc;">100</span> <span style="color: #666666; font-style: italic;"># Número de conexões máximas que poderão ser &quot;proxyadas&quot;</span>
listen_port <span style="color: #cc66cc;">143</span> <span style="color: #666666; font-style: italic;"># Onde o imapproxy escutará as conexões</span>
<span style="color: #666666; font-style: italic;"># listen_address 127.0.0.1 # Neste caso se indefinido (comentado), irá escutar todas os endereços.</span>
server_port <span style="color: #cc66cc;">1143</span> <span style="color: #666666; font-style: italic;"># Porta do servidor de destino, neste caso, estou usando o IMAP em uma porta diferente.</span>
cache_expiration_time <span style="color: #cc66cc;">300</span> <span style="color: #666666; font-style: italic;"># Tempo do cache em segundos</span>
proc_username mail <span style="color: #666666; font-style: italic;"># Usuário que irá rodar o processo do imapproxy</span></pre></td></tr></table></div>

<p>Para configuração básica (provavelmente a maioria dos casos), estes parâmetros serão os utilizados, mas existem alguns poucos a mais que poderão ser alterados de acordo com a necessidade.</p>
<p>Para iniciar o serviço é somente executar o daemon:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">user <span style="color: #339933;">~</span>$ sudo imapproxy</pre></td></tr></table></div>

<p>Pronto, seu IMAP Proxy está no ar!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2009/06/30/imap-proxy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Os atuais MDAs e as linguagens de filtragem de e-mail (parte 3)</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2009/04/20/os-atuais-mdas-e-as-linguagens-de-filtragem-de-e-mail-parte-3/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2009/04/20/os-atuais-mdas-e-as-linguagens-de-filtragem-de-e-mail-parte-3/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 03:21:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programação]]></category>

		<category><![CDATA[Software Livre]]></category>

		<category><![CDATA[Dovecot Cyrus Sieve RFC 3028 5228 5229 5429]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/?p=22</guid>
		<description><![CDATA[Continuando minha série de Posts sobre linguagens de filtragem de e-mail, escrevo enfim, sobre o Sieve, que é de longe, a mais importante das linguagens de filtragem, devido sua simplicidade, facilidade de aprendizado, e por ser um padrão de linguagem para filtragem de correio.

Assim como nos outros Posts sobre linguagens de filtragem de correio, este [...]]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom: 0in;"><img class="alignleft size-medium wp-image-94" title="sieve375x375" src="http://www.wish4web.com.br/blog/theflockers/wp-content/uploads/2009/04/sieve375x375-300x271.jpg" alt="sieve375x375" width="163" height="148" />Continuando minha série de Posts sobre linguagens de filtragem de e-mail, escrevo enfim, sobre o Sieve, que é de longe, a mais importante das linguagens de filtragem, devido sua simplicidade, facilidade de aprendizado, e por ser um padrão de linguagem para filtragem de correio.</p>
<p><br/></p>
<p style="margin-bottom: 0in;">Assim como nos outros Posts sobre linguagens de filtragem de correio, este último também não tem intenção nenhuma de ensinar como configurá-los em seus servidores, mas sim, falar sobre a linguagem e mostrar alguns exemplos de scripts.<strong></strong></p>
<p><br/></p>
<h3 style="margin-bottom: 0in;"><strong>Sieve: Uma linguagem para filtragem de correio</strong></h3>
<p style="margin-bottom: 0in;">Sieve é uma linguagem de scripts para filtragem de correio eletrônico que, dentre todas conhecidas, é a única que segue um padrão de implementação. Este padrão foi inicialmente definido na RFC3028 e atualizado pelas RFCs 5228, 5229 e 5429, ou seja, qualquer software de correio, pode criar sua própria implementação, e o mesmo script DEVE funcionar em qualquer um destes servidores.</p>
<p><br/></p>
<p style="margin-bottom: 0in;">Existem diversas implementações do padrão, mas as mais conhecidas pela comunidade Open-Source são sem dúvida, as implementações feitas pelo Cyrus IMAP Server e pelo Dovecot. Este segundo, usa o mesmo interpretador Sieve do Cyrus IMAP. A partir da versão 1.2 (ainda em Release Candidate) do Dovecot, o interpretador Sieve foi totalmente re-escrito.</p>
<p><br/></p>
<p style="margin-bottom: 0in;">A linguagem Sieve suporta a maioria das features que as outras linguagens já mostradas aqui, com uma exceção, que é a execução de comandos de sistema (vide Courier maildropfilter). O fato de não existir esta feature não deixa a linguagem mais fraca, mas sim mais segura, pois uma das razões que contribuiram para criação do padrão, é definir uma forma segura da manipulação de scripts pelo próprio usuário.</p>
<p><br/></p>
<h3 style="margin-bottom: 0in;">Sieve Scripts</h3>
<p style="margin-bottom: 0in;">Agora que já sabemos um pouco sobre a linguagem Sieve, vamos conhecer o que é possível fazer, e como podemos usar a linguagem Sieve para nos auxiliar.</p>
<p style="margin-bottom: 0in;">A maioria das features do Sieve, podem ser incluídas em seu script através do comando “require”, assim, é possível que você carregue somente as funções que vai utilizar, agilizando o parsing do script.</p>
<p style="margin-bottom: 0in;">Outro ponto importante é que a linguagem suporta internacionalização, ou seja, você pode escrever seus scripts em UTF-8. Nota que também existem extensões para o Sieve que também possuem RFCs relacionadas.  Aqui, falaremos sobre algumas extensões, como “fileinto”, “vacation” e “regex”.</p>
<p><br/></p>
<h3>Exemplos de scripts:</h3>
<p style="margin-bottom: 0in;">Consideremos nossa mensagem de correio:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;">From<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Spammer&quot;</span><span style="color: #339933;">&lt;</span>spammer<span style="color: #339933;">@</span>viagra<span style="color: #339933;">.</span>com<span style="color: #339933;">&gt;</span>
<span style="color: #990000;">Date</span><span style="color: #339933;">:</span> Sun<span style="color: #339933;">,</span> Apr <span style="color: #cc66cc;">19</span> <span style="color: #cc66cc;">2009</span>  <span style="color: #cc66cc;">18</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">36</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">49</span> <span style="color: #339933;">-</span><span style="color: #208080;">0300</span>
X<span style="color: #339933;">-</span>Spam<span style="color: #339933;">-</span>Flag<span style="color: #339933;">:</span> Yes
Subject<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> SPAM <span style="color: #009900;">&#93;</span> Testando um script Sieve
&nbsp;
Que tal testarmos alguns Sieve Scripts?</pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">Vamos testar as seguintes simples condições, que são plausíveis no dia-a-dia:</p>
<p><br/></p>
<blockquote>
<ol>
<li>Verificar se a mensagem tem a tag [ SPAM ] e escolher uma ação a tomar;</li>
<li>Auto-resposta;</li>
<li>Verificar tamanho da mensagem e escolher uma ação a tomar;</li>
<li>Verificar o remetente da mensagem e escolher uma ação a tomar;</li>
</ol>
</blockquote>
<p><br/></p>
<h4>1. Verificar se a mensagem tem a tag [ SPAM ] e escolher uma ação a tomar (descartar ou movê-la para uma outra pasta);</h4>
<p style="margin-bottom: 0in;">O primeiro passo é carregar os plugins a serem usados:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #009900;">&#91;</span>“fileinto”<span style="color: #339933;">,</span> “regex”<span style="color: #009900;">&#93;</span>;</pre></div></div>

<p style="margin-bottom: 0in;">Logo após, verificamos se a mensagem pussui tag SPAM ou o header “X-Spam-Flag: Yes”. Exemplificarei os dois casos:</p>
<p><br/></p>
<p style="margin-bottom: 0in;">Pelo header:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #990000;">header</span> <span style="color: #339933;">:</span>contains “X<span style="color: #339933;">-</span>Spam<span style="color: #339933;">-</span>Flag” “Yes” <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># move para a pasta SPAM</span>
    fileinto “SPAM”;
    discard;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">Pelo Assunto via regex:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #990000;">header</span> <span style="color: #339933;">:</span>regex “subject” “\<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#41;</span>?SPAM<span style="color: #009900;">&#40;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#41;</span>?\<span style="color: #009900;">&#93;</span>” <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># neste exemplo, quero descartar a mensagem.</span>
    discard;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<h4>2. Auto-resposta de Férias</h4>
<p style="margin-bottom: 0in;">Novamente, o primeiro passo é carregar os plugins:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #009900;">&#91;</span>“fileinto”<span style="color: #339933;">,</span> “vacation”<span style="color: #339933;">,</span> “regex”<span style="color: #009900;">&#93;</span>;</pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">Caso a mensagem for da lista “Postfix-BR”, não enviaremos a auto-resposta, mas armazenaremos em uma pasta específica.</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #990000;">header</span> <span style="color: #339933;">:</span>regex “list<span style="color: #339933;">-</span>id” “Grupo<span style="color: #339933;">.*</span>Postfix<span style="color: #339933;">.*</span>Brasil” <span style="color: #009900;">&#123;</span>
    fileinto <span style="color: #0000ff;">&quot;Listas&quot;</span>;
    stop;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># não enviará novamente para o mesmo remetente mais de uma vez</span>
    <span style="color: #666666; font-style: italic;"># até que se cumpra o período de 30 dias de férias.</span>
    <span style="color: #666666; font-style: italic;"># Seu script tem que estar em UTF-8, por causa da acentuação</span>
         vacation <span style="color: #339933;">:</span>days <span style="color: #cc66cc;">30</span>
                 “Estou de férias<span style="color: #339933;">.</span> Envie novamente para fulano<span style="color: #339933;">@</span>ciclano<span style="color: #339933;">.</span>com”;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">Auto-resposta sempre que receber um e-mail:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;">vacation <span style="color: #339933;">:</span>subject “Recebido” “Sua mensagem foi recebida com sucesso”;</pre></div></div>

<p><br/></p>
<h4>3. Verificar tamanho da mensagem e escolher uma ação a tomar</h4>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> “fileinto”;
&nbsp;
<span style="color: #b1b100;">if</span> size <span style="color: #339933;">:</span>over 5M <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># salva na pasta BigMessages</span>
    fileinto “BigMessages”;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<h4>4. Verificar o remetente da mensagem e escolher uma ação a tomar</h4>
<p style="margin-bottom: 0in;">Neste exemplo, todas as mensagens vindas de “spammer@viagra.com&#8221; ou “Spammer” recebam a flag “Junk” e também a flag \\Deleted:</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;imapflags&quot;</span>;
&nbsp;
<span style="color: #b1b100;">if</span> addres <span style="color: #339933;">:</span>matches “from” “spammer<span style="color: #339933;">@</span>viagra<span style="color: #339933;">.</span>com” <span style="color: #009900;">&#123;</span>
    setflag <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>Deleted&quot;</span>;
    addflag “Junk”;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">ou</p>
<p><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;imapflags&quot;</span>;
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #990000;">header</span> <span style="color: #339933;">:</span>matches “from” “Spammer” <span style="color: #009900;">&#123;</span>
    setflag <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>Deleted&quot;</span>;
    addflag “Junk”;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><br/></p>
<p style="margin-bottom: 0in;">Enfim, estes foram alguns simplíssimos exemplos de uso do Sieve. Espero que este pequeno Post te abra o “apetite” por esta pequena, mas eficiente linguagem de filtragem, que cresce a cada dia mais, e em breve, prevalecerá na maioria dos MTAs conhecidos do mercado.</p>
<p><br/></p>
<p style="margin-bottom: 0in;">Em breve, farei outro Post falando sobre o Dovecot ManageSieve, que é uma ótima ferramenta para gerenciar scripts Sieve e também detalharei como implementá-lo.</p>
<p><br/></p>
<p style="margin-bottom: 0in;">Até lá!</p>
<p><br/></p>
<h3>Referências</h3>
<p>http://wiki.dovecot.org/LDA/Sieve: <a href="http://wiki.dovecot.org/LDA/Sieve">http://wiki.dovecot.org/LDA/Sieve</a></p>
<p>RFCs 3028, 5228, 5229 e 5429: <a href="http://ietfreport.isoc.org/rfc/rfc3028.txt">http://ietfreport.isoc.org/rfc/rfc3028.txt</a>, <a href="http://ietfreport.isoc.org/rfc/rfc5228.txt">http://ietfreport.isoc.org/rfc/rfc5228.txt</a>, <a href="http://ietfreport.isoc.org/rfc/rfc5229.txt">http://ietfreport.isoc.org/rfc/rfc5229.txt</a>, <a href="http://ietfreport.isoc.org/rfc/rfc5429.txt">http://ietfreport.isoc.org/rfc/rfc5429.txt</a></ol>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2009/04/20/os-atuais-mdas-e-as-linguagens-de-filtragem-de-e-mail-parte-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Postfix + SASL2 + Courier-IMAP + QUOTA + PostgreSQL HOW-TO (deprecated)</title>
		<link>http://www.wish4web.com.br/blog/theflockers/2009/03/10/deprecated-postfix-sasl2-courier-imap-quota-postgresql-how-to/</link>
		<comments>http://www.wish4web.com.br/blog/theflockers/2009/03/10/deprecated-postfix-sasl2-courier-imap-quota-postgresql-how-to/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 02:04:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Software Livre]]></category>

		<guid isPermaLink="false">http://www.wish4web.com.br/blog/theflockers/archives/21</guid>
		<description><![CDATA[
Calma lá! Eu concordo que colocar que algo é depreciado já no título é um tanto quanto bizarro, mas acreditem, este artigo é.
Escrevi este artigo em 2004 e após um crash no servidor onde estava hospedado, este artigo ficou perdido  por um bom tempo. Poisé, e hoje, buscando por este artigo, o encontrei na íntegra [...]]]></description>
			<content:encoded><![CDATA[<p style="padding: 5px; float: left"><img src="http://www.postfix.org/postfix-br.gif" /></p>
<p>Calma lá! Eu concordo que colocar que algo é depreciado já no título é um tanto quanto bizarro, mas acreditem, este artigo é.</p>
<p>Escrevi este artigo em 2004 e após um crash no servidor onde estava hospedado, este artigo ficou perdido  por um bom tempo. Poisé, e hoje, buscando por este artigo, o encontrei na íntegra no site <a href="http://www.extmail.org/forum/viewthread.php?action=printable&amp;tid=928">Extmail.org</a>. Fiquei bastante feliz, mas ao reler, vi que uma série de coisas não se compatibilizam com o que penso hoje.</p>
<p>Apesar disso, acho importante que esteja no ar pois muitas coisas deste artigo ainda se aplicam na prática, lógico que com algumas atualizações de software.</p>
<p>Acho importante também que eu esclareça as coisas que não acredito mais em relação a implementação que descrevi no artigo, e caberá a você pensar se vale a pena utilizá-lo.</p>
<blockquote><p>1. Não acredito no uso de banco de dados relacionais como consulta para o Postfix. Bancos de dados relacionais são mais lentos, criam uma dependência perigosa e desnecessária externa e de forma mais clara, foram concebidos com outro propósito, não este. Use <strong>LDAP</strong> no lugar. É simples, rápido e existe para justamente este fim.</p>
<p>2. Apesar de ainda  considerar o <strong>Courier-IMAP</strong> uma boa solução, hoje prefiro utilizar o <strong>Dovecot</strong> como servidor de POP3 e IMAP. É extremamente mais rápido, muito mais flexível e trabalha tanto com MBOX quanto com MAILDIR, fora a questão dos plugins disponíveis (LDA e Sieve, por exemplo) e sua implementação de autenticação SASL que é facilmente integrada com o Postfix, sem necessidades de Patches.</p>
<p>3. SASL. Expliquei em poucas palavras no tópico 2. Creio que a explicação seja suficiente.</p>
<p>4. Sobre a questão da Quota, não sou a favor de adicionar Patches de terceiros no Postfix. Hoje já existem diversas opções para implementar este comportamento. Novamente, o dovecot LDA te fornece esta funcionalidade.</p></blockquote>
<p>Por ora, acredito que estes ítens já são claro o suficiente e mostram exatamente minha opinião hoje, mas muitos por algum motivo precisam utilizar o conjunto que entitula este Post. Sendo assim, boa leitura!</p>
<p>&#8212; Artigo publicado em 26/04/2004, linkado em http://www.postfix.org/non-english.html (quebrado) &#8212;</p>
<p><strong>Postfix + SASL2 + Courier-IMAP + QUOTA + PostgreSQL HOW-TO</strong></p>
<p>Este HOW-TO Foi escrito para auxiliar os Administradores que necessitam instalar um mailserver com suporte a domínios virtuais. Decidi usar o PostgreSQL como Banco de dados, pois este agrega uma série de funções mais complexas, e pensando que a instalação do servidor não é a única parte do processo. Talvez o administrador não queira usar  somente um gerenciador de  Domínios virtuais, e sim, fazer o controle do seu provedor inteiro dentro do PostgreSQL, via seu próprio &#8220;ISP Manager&#8221;. Lógicamente, é necessário uma máquina bem parruda para faze-lo, mas acredito que seja uma boa solução no que diz respeito à domínios virtuais.</p>
<p>Infelizmente, ainda não pude adicionar ao HOW-TO, nada relacionado à filtragem de mensagens, pois o maildrop não dá suporte ao PostgreSQL.<br />
Consta também neste HOW-TO a implementação de soft quota para controle das caixas postais. O controle é feito pelo próprio postfix, mas necessita a aplicação de um patch.</p>
<p>Para Administração simples dos domínios, iniciei o desenvolvimento do Post-MailAdmin, que é baseado no ótimo PostfixAdmin, que gerencia os domínios virtuais no MySQL.</p>
<p>Iniciando o Processo</p>
<p>Instale o PostgreSQL (Faça download da ultima versão, ou baixe para sua distribuição)<br />
Mais informações sobre o PostgreSQL aqui:<br />
Baixe o cyrus-sasl e o patch para Crypt passwords.</p>
<p>O programa:</p>
<p>ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/</p>
<p>O patch</p>
<p>http://frost.ath.cx/software/cyrus-sasl-patches/</p>
<p>Descompacte o software, aplique o Patch, compile e instale o programa:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># tar xvzf cyrus-sasl-2.*.*.tar.gz</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># cd cyrus-sasl-2.*.*/</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># patch -p0 &amp;lt;../cyrus-sasl-2.1.17-checkpw.c.patch</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># ./configure --enable-login --enable-plain --enable-sql --with-pgsql=PATH-PARA-O-PGSQL</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># make install</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span><span style="color: #009900;">&#93;</span> <span style="color: #666666; font-style: italic;"># ln -s /usr/local/lib/sasl2 /usr/lib/sasl2</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># *** Não deixe de fazer isto, pois o cyrus-sasl não dá suporte à passwords crypt . Se está usando o sasl da sua distribuição, remova-o e instale a partir dos fontes***</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Crie o arquivo /usr/lib/sasl2/smtpd.conf com o seguinte conteúdo:</span>
&nbsp;
pwcheck_method<span style="color: #339933;">:</span> auxprop
auxprop_plugin<span style="color: #339933;">:</span> sql
allowanonymouslogin<span style="color: #339933;">:</span> <span style="color: #000066;">no</span>
allowplaintext<span style="color: #339933;">:</span> yes
mech_list<span style="color: #339933;">:</span> PLAIN LOGIN
srp_mda<span style="color: #339933;">:</span> md5
&nbsp;
srvtab<span style="color: #339933;">:</span> <span style="color: #339933;">/</span>dev<span style="color: #339933;">/</span>null
opiekeys<span style="color: #339933;">:</span> <span style="color: #339933;">/</span>dev<span style="color: #339933;">/</span>null
&nbsp;
password_format<span style="color: #339933;">:</span> <span style="color: #000066;">crypt</span>
&nbsp;
sql_engine<span style="color: #339933;">:</span> pgsql
sql_user<span style="color: #339933;">:</span> postfix
sql_passwd<span style="color: #339933;">:</span> postfix
sql_hostnames<span style="color: #339933;">:</span> localhost
sql_database<span style="color: #339933;">:</span> postfix
sql_select<span style="color: #339933;">:</span> SELECT password FROM mailbox WHERE username <span style="color: #339933;">=</span> <span style="">'%u@%r'</span> AND domain <span style="color: #339933;">=</span> <span style="">'%r'</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># Baixe a ultima versão estável do Postfix:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># wget ftp://ftp.matrix.com.br/pub/postfix/official/postfix-*.tar.gz</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># tar xvjf postfix-*.tar.gz</span></pre></td></tr></table></div>

<p>Baixe o patch para controle de quotas referente a versão que você baixou do postfix:<br />
http://web.onda.com.br/nadal/</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># gunzip postfix-*-trash.patch.gz</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># patch -p0 &amp;lt;postfix-*-trash.patch</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># cd postfix-*/</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make tidy</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make -f Makefile.init makefiles 'CCARGS=-DHAS_PGSQL -I/usr/local/pgsql/include -DUSE_SASL_AUTH -I/usr/local/include' 'AUXLIBS=-L/usr/local/pgsql/lib -lpq -L/usr/local/lib/sasl2 -lsasl2'</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># (Altere o caminho dos headers e das libs conforme a sua instalação do postgre e sasl2)</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make install  #Se houver algum erro relacionado à sasl2, coloque o path &quot;/usr/lib&quot; em /etc/ld.so.conf</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Inicie o PostgreSQL:</span>
<span style="color: #666666; font-style: italic;"># Se for baseado no Red Hat:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># service postgresql start</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># su - postgres</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Caso contrário:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># su - postgres</span>
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span><span style="color: #000066;">local</span><span style="color: #339933;">/</span>pgsql<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>initdb <span style="color: #339933;">-</span>D <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span><span style="color: #000066;">local</span><span style="color: #339933;">/</span>pgsql<span style="color: #339933;">/</span>data
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ postmaster <span style="color: #339933;">-</span>D <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span><span style="color: #000066;">local</span><span style="color: #339933;">/</span>pgsql<span style="color: #339933;">/</span>data <span style="color: #339933;">&amp;</span>gt;postgresql.<span style="color: #000066;">log</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">&amp;</span>gt;&amp;amp;<span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;</span>amp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Crie o usuário a database e o user postfix:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ createdb postfix
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ createuser postfix
&nbsp;
<span style="color: #666666; font-style: italic;">#Tabelas no PostgreSQL</span>
&nbsp;
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span> $ psql postfix <span style="color: #339933;">-</span>U postfix
&nbsp;
<span style="color: #666666; font-style: italic;"># Caso não logar, descomente no /usr/local/pgsql/data/pg_hba.conf a linha abaixo (use isto, somente se o BD postfix, for para uso exclusivo do usuário postfix, e só para localhost), pois assim localmente, o usuário postfix do PostgreSQL não precisa de senha:</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># TYPE  DATABASE  IP_ADDRESS  MASK  AUTH_TYPE  AUTH_ARGUMENT</span>
<span style="color: #666666; font-style: italic;"># local postfix seu_ip sua_mascara trust</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Outro detalhe, é habilitar o PostgreSQL a escutar os pedidos de conexão.</span>
<span style="color: #666666; font-style: italic;"># Edite o postgresql.conf e habilite as linhas:</span>
&nbsp;
tcpip_socket <span style="color: #339933;">=</span> true
port <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5432</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Logue no Postgre, crie as tabelas e dê permissão.</span>
&nbsp;
<span style="color: #009900;">&#91;</span> postgres<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span> $ psql postfix <span style="color: #339933;">-</span>U postfix
&nbsp;
CREATE TABLE <span style="color: #ff0000;">&quot;admin&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;username&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;password&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;modified&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean default true<span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;admin_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON admin TO postfix;
&nbsp;
CREATE TABLE <span style="color: #ff0000;">&quot;alias&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;address&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;goto&quot;</span> text NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;domain&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;modified&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean default true<span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;alias_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON alias TO postfix;
CREATE TABLE <span style="color: #ff0000;">&quot;domain&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;domain&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;description&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;aliases&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="">'0'</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;mailboxes&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="">'0'</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;maxquota&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="">'0'</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;modified&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean default true<span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;domain_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;domain&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON domain TO postfix;
&nbsp;
CREATE TABLE <span style="color: #ff0000;">&quot;domain_admins&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;username&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;domains&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean default true<span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;domain_admins_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON domain_admins TO postfix;
&nbsp;
CREATE TABLE <span style="color: #ff0000;">&quot;mailbox&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;username&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;password&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;name&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;maildir&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;quota&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="">'0'</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;domain&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;modified&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean DEFAULT <span style="">'t'</span><span style="color: #339933;">::</span><span style="color: #006600;">bool</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;home&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> DEFAULT <span style="">'/var/spool/virtual/'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;uid&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;gid&quot;</span> numeric<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>0<span style="color: #009900;">&#41;</span> DEFAULT <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;mailbox_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON mailbox TO postfix;
&nbsp;
CREATE TABLE <span style="color: #ff0000;">&quot;vacation&quot;</span> <span style="color: #009900;">&#40;</span>
<span style="color: #ff0000;">&quot;email&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;subject&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;body&quot;</span> text<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;cache&quot;</span> text NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;domain&quot;</span> character varying<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span> NOT NULL<span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;created&quot;</span> timestamp<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> with <span style="color: #000066;">time</span> zone DEFAULT <span style="">'1999-04-23 01:05:06'</span><span style="color: #339933;">,</span>
<span style="color: #ff0000;">&quot;active&quot;</span> boolean default true<span style="color: #339933;">,</span>
Constraint <span style="color: #ff0000;">&quot;vacation_key&quot;</span> Primary Key <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;email&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
GRANT ALL ON vacation TO postfix;
&nbsp;
<span style="color: #666666; font-style: italic;"># De &quot;q&quot; para sair do psql</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Configuração do Postfix para utilizar usuários Virtuais.</span>
<span style="color: #666666; font-style: italic;"># Lembre-se que esta configuração é para os usuários virtuais, seu postfix já tem que possuir as configurações default!</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Adicione ao /etc/passwd:</span>
&nbsp;
vuser<span style="color: #339933;">:</span>x<span style="color: #339933;">:</span><span style="color: #cc66cc;">200</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">200</span><span style="color: #339933;">::/</span>var<span style="color: #339933;">/</span>spool<span style="color: #339933;">/</span>virtual<span style="color: #339933;">:/</span>bin<span style="color: #339933;">/</span>false
&nbsp;
<span style="color: #666666; font-style: italic;"># Adicione ao /etc/group:</span>
&nbsp;
vgroup<span style="color: #339933;">:</span>x<span style="color: #339933;">:</span><span style="color: #cc66cc;">200</span><span style="color: #339933;">:</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Crie o diretório e dê permissão:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># mkdir /var/spool/virtual</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># chown 200:200 /var/spool/virtual</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Crie os seguintes arquivos com os seguintes conteúdos:</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /etc/postfix/pgsql_virtual_domains_maps.cf</span>
&nbsp;
user <span style="color: #339933;">=</span> postfix
password <span style="color: #339933;">=</span> postfix
dbname <span style="color: #339933;">=</span> postfix
table <span style="color: #339933;">=</span> domain
select_field <span style="color: #339933;">=</span> domain
where_field <span style="color: #339933;">=</span> domain
additional_conditions <span style="color: #339933;">=</span> <span style="color: #b1b100;">and</span> active <span style="color: #339933;">=</span> true
&nbsp;
<span style="color: #666666; font-style: italic;"># ==========================</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /etc/postfix/pgsql_virtual_mailbox_maps.cf</span>
&nbsp;
user <span style="color: #339933;">=</span> postfix
password <span style="color: #339933;">=</span> postfix
dbname <span style="color: #339933;">=</span> postfix
table <span style="color: #339933;">=</span> mailbox
select_field <span style="color: #339933;">=</span> maildir
where_field <span style="color: #339933;">=</span> username
additional_conditions <span style="color: #339933;">=</span> <span style="color: #b1b100;">and</span> active <span style="color: #339933;">=</span> true
&nbsp;
<span style="color: #666666; font-style: italic;"># ==========================</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /etc/postfix/pgsql_virtual_mailbox_size.cf</span>
&nbsp;
user <span style="color: #339933;">=</span> postfix
password <span style="color: #339933;">=</span> postfix
dbname <span style="color: #339933;">=</span> postfix
table <span style="color: #339933;">=</span> mailbox
select_field <span style="color: #339933;">=</span> quota
where_field <span style="color: #339933;">=</span> username
additional_conditions <span style="color: #339933;">=</span> <span style="color: #b1b100;">and</span> active <span style="color: #339933;">=</span> true
&nbsp;
<span style="color: #666666; font-style: italic;"># ==========================</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /etc/postfix/pgsql_virtual_alias_maps.cf</span>
&nbsp;
user <span style="color: #339933;">=</span> postfix
password <span style="color: #339933;">=</span> postfix
dbname <span style="color: #339933;">=</span> postfix
table <span style="color: #339933;">=</span> alias
select_field <span style="color: #339933;">=</span> <span style="color: #000066;">goto</span>
where_field <span style="color: #339933;">=</span> address
additional_conditions <span style="color: #339933;">=</span> <span style="color: #b1b100;">and</span> active <span style="color: #339933;">=</span> true
&nbsp;
<span style="color: #666666; font-style: italic;"># Edite o arquivo /etc/postfix/main.cf e adicione as seguintes configurações:</span>
<span style="color: #666666; font-style: italic;"># Lembrando novamente que estou supondo que você já fez a configuração básica do mesmo.</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># PGSQL</span>
virtual_uid_maps <span style="color: #339933;">=</span> static<span style="color: #339933;">:</span><span style="color: #cc66cc;">200</span>
virtual_gid_maps <span style="color: #339933;">=</span> static<span style="color: #339933;">:</span><span style="color: #cc66cc;">200</span>
virtual_mailbox_base <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>spool<span style="color: #339933;">/</span>virtual
virtual_mailbox_domains <span style="color: #339933;">=</span> pgsql<span style="color: #339933;">:/</span>etc<span style="color: #339933;">/</span>postfix<span style="color: #339933;">/</span>pgsql_virtual_domains_maps.cf
virtual_mailbox_maps <span style="color: #339933;">=</span> pgsql<span style="color: #339933;">:/</span>etc<span style="color: #339933;">/</span>postfix<span style="color: #339933;">/</span>pgsql_virtual_mailbox_maps.cf
virtual_alias_maps <span style="color: #339933;">=</span> pgsql<span style="color: #339933;">:/</span>etc<span style="color: #339933;">/</span>postfix<span style="color: #339933;">/</span>pgsql_virtual_alias_maps.cf
virtual_mailbox_limit <span style="color: #339933;">=</span> <span style="color: #cc66cc;">51200000</span>
virtual_transport <span style="color: #339933;">=</span> virtual
&nbsp;
<span style="color: #666666; font-style: italic;"># SASL2</span>
smtpd_sasl_auth_enable <span style="color: #339933;">=</span> yes
smtpd_recipient_restrictions <span style="color: #339933;">=</span> permit_sasl_authenticated
reject_unauth_destination<span style="color: #339933;">,</span> permit_mynetworks
smtpd_sasl_application_name <span style="color: #339933;">=</span> smtpd
broken_sasl_auth_clients <span style="color: #339933;">=</span> yes
&nbsp;
<span style="color: #666666; font-style: italic;"># QUOTA</span>
virtual_mailbox_limit_inbox <span style="color: #339933;">=</span> <span style="color: #000066;">no</span>
virtual_mailbox_limit_maps <span style="color: #339933;">=</span> pgsql<span style="color: #339933;">:/</span>etc<span style="color: #339933;">/</span>postfix<span style="color: #339933;">/</span>pgsql_virtual_mailbox_size.cf
virtual_mailbox_limit_override <span style="color: #339933;">=</span> yes
virtual_maildir_extended <span style="color: #339933;">=</span> yes
virtual_create_maildirsize <span style="color: #339933;">=</span> yes
virtual_mailbox_limit <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100000000</span></pre></td></tr></table></div>

<p>Simples teste:</p>
<p>Primeiro insira alguma coisa nas tabelas</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">INSERT INTO mailbox <span style="color: #009900;">&#40;</span>username<span style="color: #339933;">,</span>password<span style="color: #339933;">,</span>name<span style="color: #339933;">,</span>maildir<span style="color: #339933;">,</span>quota<span style="color: #339933;">,</span>domain<span style="color: #009900;">&#41;</span> <span style="color: #000066;">values</span> <span style="color: #009900;">&#40;</span><span style="">'teste@dominio.com.br'</span><span style="color: #339933;">,</span><span style="">'$1$Fi8IP53B$3yeGqD1Cnax.f.yAkLiAd1'</span><span style="color: #339933;">,</span><span style="">'name'</span><span style="color: #339933;">,</span><span style="">'teste@dominio.com.br/'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1048576</span><span style="color: #339933;">,</span><span style="">'dominio.com.br'</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>Insira a senha criptografada!</p>
<p>A SENHA NESTE CASO É a palavra teste e quota é de 1MB</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;">INSERT INTO domain <span style="color: #009900;">&#40;</span>domain<span style="color: #339933;">,</span>description<span style="color: #339933;">,</span>aliases<span style="color: #339933;">,</span>mailboxes<span style="color: #339933;">,</span>maxquota<span style="color: #009900;">&#41;</span> <span style="color: #000066;">values</span> <span style="color: #009900;">&#40;</span><span style="">'dominio.com.br'</span><span style="color: #339933;">,</span><span style="">'Domínio Virtual'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;</pre></td></tr></table></div>

<p>Reinicie o Postfix:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># postfix stop; postfix start</span>
<span style="color: #666666; font-style: italic;"># Dê um telnet no host:</span>
&nbsp;
<span style="color: #009900;">&#91;</span>root<span style="color: #0000ff;">@server</span><span style="color: #339933;">~/</span><span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># telnet localhost 25</span>
Trying 127.0.0.1...
Connected to localhost.
Escape character is <span style="">'^]'</span>.
<span style="color: #cc66cc;">220</span> server.domain.com.br ESMTP Postfix <span style="color: #009900;">&#40;</span>2.1.0<span style="color: #009900;">&#41;</span>
MAIL FROM<span style="color: #339933;">:</span> teste<span style="color: #0000ff;">@dominio</span>.com.br
<span style="color: #cc66cc;">250</span> Ok
RCPT TO<span style="color: #339933;">:</span> teste<span style="color: #0000ff;">@dominio</span>.com.br
<span style="color: #cc66cc;">250</span> Ok
DATA
<span style="color: #cc66cc;">354</span> End data with <span style="color: #339933;">&amp;</span>lt;CR<span style="color: #339933;">&amp;</span>gt;&amp;lt;LF<span style="color: #339933;">&amp;</span>gt;.<span style="color: #339933;">&amp;</span>lt;CR<span style="color: #339933;">&amp;</span>gt;&amp;lt;LF<span style="color: #339933;">&amp;</span>gt;
teste
.
<span style="color: #cc66cc;">250</span> Ok<span style="color: #339933;">:</span> queued as 7B41F4665A
quit
<span style="color: #cc66cc;">221</span> Bye
Connection closed by foreign host.
<span style="color: #009900;">&#91;</span>root<span style="color: #0000ff;">@server</span><span style="color: #339933;">~/</span><span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># cd /var/spool/virtual;ls -la</span>
drwxr<span style="color: #339933;">-</span>xr<span style="color: #339933;">-</span>x   <span style="color: #cc66cc;">3</span>   vuser  vgroup   <span style="color: #cc66cc;">4096</span> Abr <span style="color: #cc66cc;">26</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">18</span> .
drwxr<span style="color: #339933;">-</span>xr<span style="color: #339933;">-</span>x   <span style="color: #cc66cc;">11</span>  root  root    <span style="color: #cc66cc;">4096</span> Abr <span style="color: #cc66cc;">26</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">44</span> ..
drwx<span style="color: #339933;">------</span>   <span style="color: #cc66cc;">5</span>   vuser  vgroup   <span style="color: #cc66cc;">4096</span> Abr <span style="color: #cc66cc;">26</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">18</span> teste<span style="color: #0000ff;">@dominio</span>.com.br
<span style="color: #009900;">&#91;</span>root<span style="color: #0000ff;">@server</span><span style="color: #339933;">~/</span><span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;">#</span></pre></td></tr></table></div>

<p>Quando a mensagem chegar, será criado um arquivo chamado maildirsize dentro do diretório do usuário, que controlará a cota deste usuário virtual.</p>
<p>Courier-IMAP</p>
<p>Baixe o Courier-IMAP em http://www.courier-mta.org/download.php</p>
<p>Descompacte-o como usuário normal</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #009900;">&#91;</span> tanga_frouxa<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ tar xfjv courier<span style="color: #339933;">-</span>imap<span style="color: #339933;">-</span>3.0.3.20040424.tar.bz2
&nbsp;
<span style="color: #666666; font-style: italic;"># Antes de iniciar o processo, certifique-se que existem os diretórios ou links /usr/include/pgsql e /usr/lib/pgsql, pois, se não existirem, pode acontecer de o courier-imap não ser compilado com suporte à PostgreSQL.</span>
&nbsp;
<span style="color: #009900;">&#91;</span> tanga_frouxa<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ .<span style="color: #339933;">/</span>configure <span style="color: #339933;">--</span>with<span style="color: #339933;">-</span>redhat <span style="color: #339933;">--</span>enable<span style="color: #339933;">-</span>workarounds<span style="color: #339933;">-</span>for<span style="color: #339933;">-</span>imap<span style="color: #339933;">-</span>client<span style="color: #339933;">-</span>bugs <span style="color: #666666; font-style: italic;"># O --with-redhat somente se vc está usando Red Hat linux.</span>
<span style="color: #009900;">&#91;</span> tanga_frouxa<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span>$ make
&nbsp;
<span style="color: #666666; font-style: italic;"># E como root:</span>
&nbsp;
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span>
<span style="color: #009900;">&#91;</span> root<span style="color: #0000ff;">@server</span><span style="color: #339933;">/~</span> <span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># make install-configure</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Configuração:</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># /usr/lib/courier-imap/etc/authdaemonrc</span>
&nbsp;
authmodulelist<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;authpgsql authpam&quot;</span>
authmodulelistorig<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;authpgsql authpam&quot;</span>
daemons<span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span>  <span style="color: #666666; font-style: italic;"># Aumente este valor caso tiver muitos &quot;clientes IMAP&quot;</span>
version<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;&quot;</span>
authdaemonvar<span style="color: #339933;">=/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>courier<span style="color: #339933;">-</span>imap<span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>authdaemon
&nbsp;
<span style="color: #666666; font-style: italic;"># /usr/lib/courier-imap/etc/authpgsqlrc</span>
<span style="color: #666666; font-style: italic;"># É provável que ele exista com o nome de authpgsqlrc.dist.</span>
&nbsp;
PGSQL_HOST localhost
PGSQL_PORT <span style="color: #cc66cc;">5432</span>
PGSQL_USERNAME postfix
PGSQL_PASSWORD postfix
PGSQL_DATABASE postfix
PGSQL_USER_TABLE mailbox
PGSQL_CRYPT_PWFIELD password
PGSQL_UID_FIELD uid
PGSQL_GID_FIELD gid
PGSQL_LOGIN_FIELD username
PGSQL_HOME_FIELD home
PGSQL_NAME_FIELD name
PGSQL_MAILDIR_FIELD maildir
&nbsp;
<span style="color: #666666; font-style: italic;"># Inicie o Courier-IMAP:</span>
&nbsp;
<span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>courier<span style="color: #339933;">-</span>imap<span style="color: #339933;">/</span>libexec<span style="color: #339933;">/</span>imapd.rc start
&nbsp;
<span style="color: #666666; font-style: italic;"># Dê um telnet no host:</span>
&nbsp;
<span style="color: #009900;">&#91;</span>root<span style="color: #0000ff;">@server</span><span style="color: #339933;">~/</span><span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;"># telnet localhost 110</span>
Trying 127.0.0.1...
Connected to localhost.
Escape character is <span style="">'^]'</span>.
<span style="color: #339933;">+</span>OK Hello there.
user teste<span style="color: #0000ff;">@dominio</span>.com.br
<span style="color: #339933;">+</span>OK Password required.
pass teste
<span style="color: #339933;">+</span>OK logged in.
list
<span style="color: #339933;">+</span>OK POP3 clients that break here<span style="color: #339933;">,</span> they violate STD53.
<span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">1051</span>
<span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">442</span>
<span style="color: #cc66cc;">3</span> <span style="color: #cc66cc;">505</span>
<span style="color: #cc66cc;">4</span> <span style="color: #cc66cc;">13516</span>
<span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">27389</span>
.
quit
<span style="color: #339933;">+</span>OK Bye<span style="color: #339933;">-</span>bye.
Connection closed by foreign host.
<span style="color: #009900;">&#91;</span>root<span style="color: #0000ff;">@server</span><span style="color: #339933;">~/</span><span style="color: #009900;">&#93;</span><span style="color: #666666; font-style: italic;">#</span></pre></td></tr></table></div>

<p>Pronto agora é só Instalar o Post-MailAdmin para adicionar e remover os usuários. Assim que possível, coloco a parte de anti-vírus no Postfix.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Bibliografia</p>
<p>Postfix Website: http://www.postfix.org<br />
Pelas quotas, agradeço à Marco Máximo pelo seu HOW-TO no Link http://www.linuxit.com.br/section-viewarticle-78.html<br />
SASL2: http://www.gfxcafe.com/Mail%20Howto.htm / http://frost.ath.cx/software/cyrus-sasl-patches/</p>
<p>Autor Leandro Mendes - 26/04/2004<br />
Atualizado em: 12/07/2004</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wish4web.com.br/blog/theflockers/2009/03/10/deprecated-postfix-sasl2-courier-imap-quota-postgresql-how-to/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

