The Remains Of The Day http://gamito.blogs.sapo.pt/ The Remains Of The Day - SAPO Blogs Wed, 14 Nov 2007 16:22:22 GMT LiveJournal / SAPO Blogs http://gamito.blogs.sapo.pt/51402.html Wed, 14 Nov 2007 16:14:19 GMT Caixa Mágica e Mandriva gamito http://gamito.blogs.sapo.pt/51402.html <p>Devo dizer que acolho a notícia de a Caixa Mágica mudar a sua base de SuSE para Mandriva com a maior satisfação.<br /> <br /> Com efeito, a Mandriva é de longe a melhor distribuição Linux KDE <span style="font-style: italic;">based</span> que há.<br /> <span style="font-style: italic;">Let there be no doubt about it</span>.<br /> <br /> Agora bom, bom, era a Caixa Mágica ter um sistema&nbsp;de gestão de pacotes diferente do urpmi que na verdade é uma boa treta.<br /> <br /> Espero que a Caixa Mágica tenha artes para contornar/resolver esta questão.<br /> <br /> <span style="font-style: italic;">Nice move</span>, Paulo :)<br /> <br /> PS. O DarkLord da Caixa Mágica deixou em comentário que a distribuição não vai usar o urpmi, mas sim o <span class="txt">apt-rpm/Synaptic</span>.</p> <p>&nbsp;</p> <p><i>Nice move again</i>, Paulo :)<br /> <br /> <br /> <span style="font-family: Courier New;">A Ouvir: Eleventh Earl Of Mar, Genesis.</span><br style="font-family: Courier New;" /> <span style="font-family: Courier New;">YouTube: http://www.youtube.com/watch?v=9sNgU4cJV<wbr />P4</span></p> <p>&nbsp;</p> http://gamito.blogs.sapo.pt/51402.html 3 linux http://gamito.blogs.sapo.pt/49047.html Sat, 27 Oct 2007 20:49:32 GMT gFTP gamito http://gamito.blogs.sapo.pt/49047.html Esta recente vers&atilde;o do Mandriva, traz pela primeira vez o Filezilla em vez do gFTP como cliente de FTP.<br /><br />Ok, o Filezilla tem uma grande fama &mdash; especialmente em Windows, j&aacute; que &eacute; &agrave; borli&uacute; e legal &mdash; mas em Linux prefiro o velhinho gFTP.<br /><br />Como n&atilde;o havia um RPM para este Mandriva, v&aacute; de ./configure &amp;&amp; make &amp;&amp; make install.<br /><br />E aqui est&aacute; o bicharoco a fungar :)<br /><br /> <div style="text-align: center;"><img border="0" src="http://fotos.sapo.pt/azoigueiro/pic/000466wt" style="border-color: black;" alt="" /><br /><br /><br /> <div style="text-align: left;"><span style="font-family: Courier New;">A ouvir: Left Of Center, Suzanne Vega.</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">Youtube: http://www.youtube.com/watch?v=KFXftW3Uq<wbr />9E</span></div> </div> <p>&nbsp;</p> http://gamito.blogs.sapo.pt/49047.html 4 linux http://gamito.blogs.sapo.pt/46814.html Fri, 28 Sep 2007 12:33:19 GMT Não estão fartos disto ? gamito http://gamito.blogs.sapo.pt/46814.html De ter que premir a tecla y para copiar ficheiros com o mesmo nome ?<br /><br /><span style="font-family: Courier New;"># cp * /lixo</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/cert.pem'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/create-homedir'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/defaultdelivery'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/defaultdomain'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/defaultquota'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/dirmaker'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapbasedn'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapcluster'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapgid'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldaplocaldelivery'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldaplogin'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapmessagestore'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapobjectclass'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldappassword'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapserver'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/ldapuid'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/locals'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/Makefile'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/me'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/plusdomain'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/qmail-imapd.rules'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/qmail-pop3d.rules'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/qmail-qmqpd.rules'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/qmail-smtpd.rules'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/quotawarning'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/rcpthosts'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/signatures'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/tcp.smtp'? y</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cp: overwrite `/lixo/tcp.smtp.cdb'? y</span><br style="font-family: Courier New;" /><br />Bem, isto &eacute; porque o cp tem um <span style="font-style: italic;">alias</span> para o param&ecirc;tro -i (# man cp):<br /><br /><span style="font-family: Courier New;"># alias</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">alias cp='cp -i'</span><br style="font-family: Courier New;" /><br />Das duas uma: ou o removem, o que n&atilde;o &eacute; muito aconselh&aacute;vel, ou fazem:<br /><br /><span style="font-family: Courier New;"># \cp * /lixo</span><br /><br />Yap, o backslash faz toda a diferen&ccedil;a ;-)<br /><br /><br /><span style="font-family: Courier New;">A ouvir: On An Island, David Gilmour</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">YouTube: http://www.youtube.com/watch?v=SROK4biHO<wbr />Pk</span> <p>&nbsp;</p> 0 linux http://gamito.blogs.sapo.pt/46402.html Fri, 28 Sep 2007 12:02:52 GMT Naughty, naughty gamito http://gamito.blogs.sapo.pt/46402.html Era s&oacute; para dizer a estes curiosos <span style="font-style: italic;">wannabes </span>que n&atilde;o, n&atilde;o viram a minha <span style="font-style: italic;">home share</span> do Samba.<br /><br />De qualquer modo, basta uma linha no smb.conf para afastar a curiosidade:<br /><br /><span style="font-family: Courier New;">hosts allow = 192.168.0.100</span><br /><br />Lista de curiosos:<br /><br /><span style="font-family: Courier New;"># ls /var/log/samba/[^smbd*-a-z]*&nbsp; | cut -f5 -d '/' | cut -f1 -d '.'</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">carla-2000gzr9q</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">carlos-ir33ncm8</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">carlos</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">carlos</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">carlos-s6b9brdp</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">casa-7xtjzspqi8</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">casa</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">celeron</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cesar</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">chupapa-b1o4lc5</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cliente-5uvddox</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">comp</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">computador1</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">computador1</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">computername</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">contabilidade</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cpq28901672019</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">cracks</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">crack</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">eric</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">f-dvb8w73sf78t7</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">filipe-02i2d14a</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">flaviacg</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">helena</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">hermano</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">hnunes01</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">hnunes01</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">home-mt6or4k6l</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">house-pyldfzdzz</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">hvvm9xjz1wzhbkg</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">ibm558097x</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">individu-jid4ez</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">individu-jid4ez</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">ines</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">isabel</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jcpc-m4kqvro83u</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jcthc</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jcthc</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jesus-83txnx9u8</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jmrr-8rozz76apo</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">joao-cdqkfh3gfm</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jorge-0avyhq88a</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">jorge</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">levi-a5n4d52cfj</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">lobo-ee166pqgp0</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">loureiro</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">luis-95modnu830</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">luisa</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nat-7q46e74wygk</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">newton___</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">newton___</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nmbd</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nmbd</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nmbd</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nmbd</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nome-e3vucd6gwq</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nuno</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">nuno</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">o-c4f6hc8efdrzm</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">oscar</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">p40</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pandreia-5mbo1i</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">particul-u9ukxk</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">patrice</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pc1</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pc931196262726</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pc931196262726</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pc_iolanda</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pcmiudos</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pessoal-hanf015</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">posto1</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">privado-edadehn</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">pt-c</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">rakel</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">ricardo-mxokjho</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">richar-8d10ybcn</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">rita-39cm61gbeg</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">roubado</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">rozete-a7amtaee</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">rui-n5tfqykvyff</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">talentoaa</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">talentoaa</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">telmo</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">test-kk74z8p2oe</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">tiago</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">torvalds</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">torvalds</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">torvalds</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">torvalds</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">torvalds</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">user-penacho</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">usila-v3ggbctko</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">utilizad-sg66h6</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">xanita</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">x</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">yr3fp4mcbfipc43</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">A ouvir: Portobello Belle, Dire Straits</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">YouTube: http://www.youtube.com/watch?v=Jdbbt31ab<wbr />SU</span> <p>&nbsp;</p> 0 linux http://gamito.blogs.sapo.pt/45736.html Tue, 25 Sep 2007 14:02:25 GMT PHP chrooted gamito http://gamito.blogs.sapo.pt/45736.html Na sequ&ecirc;ncia do artigo anterior sobre como correr o MySQl num ambiente <span style="font-style: italic;">chrooted</span>, aqui vai a vez do PHP.<br /><br /><span style="font-family: Courier New;"># gzip -dc apache_1.3.47.tar.gz | tar xvf -</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># gzip -dc php-5.2.3.tar.gz | tar xvf -</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># gzip -dc mod_security_1.95.tar.gz | tar xvf -</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># cp mod_security_1.95/apache1/mod_security.c apache_1.3.37/src/modules/extra/</span><br /><br /><span style="font-family: Courier New;"># cd apache_1.3.37</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># ./configure --prefix=/usr/local/httpd</span><br style="font-family: Courier New;" /><br />Compilar o PHP:<br /><br /><span style="font-family: Courier New;"># cd ../php-5.3.2<br /># ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.37 --enable-safe-mode (etc. mais op&ccedil;&otilde;es)</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># make</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># make install</span><br style="font-family: Courier New;" /><span class="body"><code><span style="font-family: Courier New;"># cp php.ini-dist /usr/local/lib/php.ini</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># chown root:sys /usr/local/lib/php.ini</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># chmod 644 /usr/local/lib/php.ini</span><br /><br /></code></span>O Apache:<br /><br /><span style="font-family: Courier New;"># cd ../apache_1.3.37</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># ./configure --prefix=/usr/local/httpd --disable-module=all --server-uid=apache --server-gid=apache --enable-module=access --enable-module=log_config --enable-module=dir --enable-module=mime --enable-module=auth --activate-module=src/modules/extra/mod_<wbr />security --enable-module=security --activate-module=src/modules/php5/libph<wbr />p5.a</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># make</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># make install</span><br /><br /><br /><span style="font-family: Courier New;">#chown -R root:sys /usr/local/httpd</span><br /><br />Agora, prepara-se o ambiente <span style="font-style: italic;">chrooted </span>para o Apache com o m&oacute;dulo PHP:<br /><br /><span style="font-family: Courier New;"># cp /usr/local/mysql/lib/mysql/libmysqlclien<wbr />t.so.12 /chroot/httpd/usr/lib/</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># cp /usr/lib/libm.so.2 /chroot/httpd/usr/lib/</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># cp /usr/lib/libz.so.2 /chroot/httpd/usr/lib/</span><br /><br />Adicionamemte, temos que copiar o ficheiro de configura&ccedil;&atilde;o do PHP:<br /><br /><span style="font-family: Courier New;"># umask 022</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># mkdir -p /chroot/httpd/usr/local/lib</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># cp /usr/local/lib/php.ini /chroot/httpd/usr/local/lib/</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;"># mkdir </span><span class="body" style="font-family: Courier New;">/chroot/httpd/tmp</span><span style="font-family: Courier New;"><br /># chown -R root.root </span><span class="body" style="font-family: Courier New;">/chroot/httpd/tmp<br /># chmod 1777 /chroot/httpd/tmp<br /><br /></span><span class="body" style="font-family: Verdana;"><code><font size="3"># chroot /chroot/httpd /usr/local/httpd/bin/httpd<br /><br /># ln /tmp/mysql.sock /chroot/httpd/tmp/</font><br /><br /><span style="font-family: Verdana;">Configura&ccedil;&atilde;o do Apache para defesa contra </span><span style="font-style: italic; font-family: Verdana;">cross side scripting</span><span style="font-family: Verdana;"> e SQL </span><span style="font-style: italic; font-family: Verdana;">injection</span><span style="font-family: Verdana;">, atrav&eacute;s do mod_secutity:</span><br style="font-family: Verdana;" /><br /><font size="3">&lt;IfModule mod_security.c&gt;<br />&nbsp;AddHandler application/x-httpd-php .php<br /><br />&nbsp;SecAuditEngine On<br />&nbsp;SecAuditLog logs/audit_log<br />&nbsp;SecFilterScanPOST On<br />&nbsp;SecFilterEngine On<br /><br />&nbsp;SecFilterDefaultAction &quot;deny,log,status:500&quot;<br />&nbsp;SecFilter &quot;&lt;(.|\n)+&gt;&quot;<br /><br />&nbsp;SecFilter &quot;'&quot;<br />&nbsp;SecFilter &quot;\&quot;&quot;<br />&lt;/IfModule&gt;<br /><br /><br /><span style="font-family: Verdana;">Ok, para a pr&oacute;xima, explico como tornar o Apache </span><span style="font-style: italic; font-family: Verdana;">chrooted</span><span style="font-family: Verdana;">, ok ?</span><br style="font-family: Verdana;" /><br /><br />A ouvir: Just Good Friends, Fish.<br />YouTube: http://www.youtube.com/watch?v=ApxexrzQQ<wbr />as</font></code></span> <p style="font-family: Verdana;">&nbsp;</p> 0 linux http://gamito.blogs.sapo.pt/44641.html Sun, 23 Sep 2007 11:25:14 GMT MySQL :: It's the ctl, stupid gamito http://gamito.blogs.sapo.pt/44641.html Er... pois, o <span style="font-style: italic;">ctl file</span> normal do MySQL agora n&atilde;o funciona, por isso, aqui vai um para arrancar e parar o MySQL <span style="font-style: italic;">chrooted</span>.<br /><br /><span style="font-family: Courier New;">#!/bin/sh</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">CHROOT_MYSQL=/chroot/mysql</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;"></span><span style="font-family: Courier New;">SOCKET=/tmp/mysql.sock</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">MYSQLD=/usr/local/mysql/libexec/mysqld</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">PIDFILE=/usr/local/mysql/var/`hostname`.p<wbr />id</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">CHROOTUID=/usr/local/sbin/chrootuid</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">echo -n &quot; mysql&quot;</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">case &quot;$1&quot; in</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">start)</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: Courier New;">nohup ${CHROOTUID} ${CHROOT_MYSQL} mysql ${MYSQLD} &gt;/dev/null 2&gt;&amp;1 &amp;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep 5 &amp;&amp; ln ${CHROOT_MYSQL}/${SOCKET} </span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">stop)</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kill `cat ${CHROOT_MYSQL}/${PIDFILE}`</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rm -rf ${CHROOT_MYSQL}/${SOCKET}</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">*)</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;&quot;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;Usage: `basename $0` {start|stop}&quot; &gt;&amp;2</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit 64</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">esac</span><br style="font-family: Courier New;" /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">exit 0</span><br /><br /><br /><span style="font-family: Courier New;">A ouvir: Still Got The Blues, Gary Moore<br />YouTube: http://www.youtube.com/watch?v=wPA4KXKyV<wbr />jU<br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/44315.html Sun, 23 Sep 2007 11:06:40 GMT MySQL :: Just a little tighter, honey gamito http://gamito.blogs.sapo.pt/44315.html No seguimento do artigo sobre o MySQL em ambiente <span style="font-style: italic;">chrooted</span>, ainda h&aacute; mais algumas coisas que podem ser feitas para aumentar a sua seguran&ccedil;a, nomeadamente:<br /><br /> <ul> <li>Desabilitar o acesso remoto:<br /><br />Adicionar ao ficheiro /etc/my.cnf, na sec&ccedil;&atilde;o [mysqld], a linha<br /><br /><span style="font-family: Courier New;">skip-networking</span><br /><br />Se, mesmo assim, for necess&aacute;rio o acesso remoto ao MySQL, por exemplo para efectuar um <span style="font-style: italic;">backup</span>, pode utilizar-se o SSH:<br /><br /><span style="font-family: Courier New;"># ssh mysqlserver /usr/local/mysql/bin/mysqldump -A &gt; backup.sql<br /></span><br /></li> <li>Desabilitar a utiliza&ccedil;&atilde;o do comando LOAD DATA LOCAL INFILE:<br /><br />Adicionar ao /etc/my.cnf a linha<br /><br /><span style="font-family: Courier New;">set-variable=local-infile=0<br /></span><br /></li> <li>Remover a base de dados <span style="font-style: italic;">test</span>, bem como todos os <span style="font-style: italic;">users</span>, excepto o <span style="font-style: italic;">root</span>:<br /><br /><span style="font-family: Courier New;">mysql&gt; drop database test;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">mysql&gt; use mysql;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">mysql&gt; delete from db;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">mysql&gt; delete from user where not (host=&quot;localhost&quot; and user=&quot;root&quot;);</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">mysql&gt; flush privileges;<br /></span><br /></li> <li>Agora, alterar o nome do administrador do MySQL (<span style="font-style: italic;">root</span>) para outro:<br /><br /><span style="font-family: Courier New;">mysql&gt; update user set user=&quot;mydbadmin&quot; where user=&quot;root&quot;;</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">mysql&gt; flush privileges;</span></li> </ul> <br /><span style="font-family: Courier New;">A ouvir: Come Away With Me, Norah Jones<br />YouTube: http://www.youtube.com/watch?v=aBKcKQHZX<wbr />ks<br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/43938.html Sat, 22 Sep 2007 23:28:53 GMT MySQL chrooted gamito http://gamito.blogs.sapo.pt/43938.html Uma coisa que eu costumo fazer sempre nos servidores que instalo &eacute; &quot;chrootar&quot; o MySQL e aplicar-lhe alguns truques (que ficam para outro artigo) para o tornar o mais seguro poss&iacute;vel.<br /><br />Vou assumir um MySQL instalado tal como <a href="http://gamito.blogs.sapo.pt/27665.html">neste artigo que escrevi anteriormente</a> e a funcionar perfeitamente. Para o verificar, executar:<br /><br /># mysql -p<br /><br />Para tudo estar bem, deve aparecer o seguinte:<span class="body"> <pre>mysql&gt; <span style="font-weight: bold;">show databases;</span><br />+----------+<br />| Database |<br />+----------+<br />| mysql |<br />| test |<br />+----------+<br />2 rows in set (0.00 sec)<span class="body"><pre>mysql&gt; <span style="font-weight: bold;">quit;</span></pre> </span><span style="font-family: Verdana;">Adiante para o chroot...<br /><br />&Eacute; necess&aacute;rio criar a seguinte estrutura de direct&oacute;rios:<br /></span><span class="body"><code><br /><font size="3"># mkdir -p /chroot/mysql/dev<br /># mkdir -p /chroot/mysql/etc<br /># mkdir -p /chroot/mysql/tmp<br /># mkdir -p /chroot/mysql/var/tmp<br /># mkdir -p /chroot/mysql/usr/local/mysql/libexec<br /># mkdir -p /chroot/mysql/usr/local/mysql/share/mysql/english</font></code></span><font size="3"><br /></font><br /><span style="font-family: Verdana;">Os direitos de acesso a estes direct&oacute;rios devem ser os seguintes:</span><br /><br /><span class="body"><code><font size="3"># chown -R root:sys /chroot/mysql<br /># chmod -R 755 /chroot/mysql<br /># chmod 1777 /chroot/mysql/tmp</font><br /><br /><span style="font-family: Verdana;">Agora, t&ecirc;m que ser copiados alguns ficheiros para esta estrutura de direct&oacute;rios:</span><br /></code></span><span class="body"><code><br /><font size="3"># cp /usr/local/mysql/libexec/mysqld<br />&nbsp;/chroot/mysql/usr/local/mysql/libexec/<br /># cp /usr/local/mysql/share/mysql/english/errmsg.sys<br />&nbsp;/chroot/mysql/usr/local/mysql/share/mysql/english/<br /># cp /etc/hosts /chroot/mysql/etc/<br /># cp /etc/host.conf /chroot/mysql/etc/<br /># cp /etc/resolv.conf /chroot/mysql/etc/<br /># cp /etc/group /chroot/mysql/etc/<br /># cp /etc/master.passwd /chroot/mysql/etc/passwords<br /># cp /etc/my.cnf /chroot/mysql/etc/</font></code></span><br /><br /><span style="font-family: Verdana;">Dos ficheiros </span><span class="body"><span style="font-family: Verdana;">/chroot/mysql/etc/passwords e /chroot/mysql/etc/group,<br />removem-se todas as linhas, excepto as respeitantes ao MySQL.</span><em style="font-family: Verdana;"><br /><br /></em><span style="font-family: Verdana;">Tem que ser criado um device file especial para o /dev/null:</span></span><span class="body"> <pre><font size="3"># mknod /chroot/mysql/dev/null c 2 2<br /># chown root:sys /chroot/mysql/dev/null<br /># chmod 666 /chroot/mysql/dev/null</font><br /><br /><span style="font-family: Verdana;">E copiar a base de dados dos previl&eacute;gios do MySQL:</span><br /><span class="body"><code><br /><font size="3"># cp -R /usr/local/mysql/var/ /chroot/mysql/usr/local/mysql/var<br /># chown -R mysql:mysql /chroot/mysql/usr/local/mysql/var</font></code></span></pre> </span><span style="font-family: Verdana;">O MySQL est&aacute; pronto a ser executado num ambiente chrooted:</span><br /><br /><font size="3"># <span class="body"><code>chrootuid /chroot/mysql mysql /usr/local/mysql/libexec/mysqld &amp;</code></span></font></pre> </span>Bem, quando tiver pachorra, escrevo um artigo sobre como correr o Apache tamb&eacute;m em ambiente chrooted e como integrar com o PHP e o MySQL de modo a fazer um todo coerente.<br /><br /><br /><span style="font-family: Courier New;">A ouvir: Yet Another Movie, Pink Floyd<br />YouTube: http://www.youtube.com/watch?v=Ep9RTAmH5<wbr />Rw<br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/43555.html Sat, 22 Sep 2007 23:11:21 GMT BASH, stdout e stderr gamito http://gamito.blogs.sapo.pt/43555.html Precisei de fazer um script (backup.sh) corrido pelo <span style="font-style: italic;">cron daemon</span> fazendo com o que o rsync&nbsp; gerasse o maior n&uacute;mero de informa&ccedil;&atilde;o poss&iacute;vel dos respectivos <span style="font-style: italic;">logs </span>(-vv) para um ficheiro &ndash; /var/log/rsync.backup.log<br /><br />Os <span style="font-style: italic;">logs </span>precisavam de combinar o <span style="font-style: italic;">stdout </span>e o <span style="font-style: italic;">stderr</span>, portanto:<br /><br /><span style="font-family: Courier New;"># backup.sh &gt;&gt; /var/log/backup.log 2&gt;&amp;1</span><br /><br />Contudo, apenas queria que o <span style="font-style: italic;">output </span>do <span style="font-style: italic;">stderr </span>fosse para o <span style="font-style: italic;">cron</span>, para em caso de erro, me ser enviado em e-mail.<br /><br />Ent&atilde;o:<br /><br /><span style="font-family: Courier New;"># (./backup.sh &gt; /var/log/backup.log) 2&gt;&amp;1 | tee -a /var/log/backup.log</span><br style="font-family: Courier New;" /><br />o que propaga o stderr para o cron e a restante tralha do <span style="font-style: italic;">stdout </span>para o ficheiro de logs :)<br /><br />Agora s&oacute; me falta organizar a informa&ccedil;&atilde;o, &eacute; uma chatice que o <span style="font-style: italic;">stdout </span>e o <span style="font-style: italic;">stderr </span>n&atilde;o sejam sincronizados.<br /><br /><br /><span style="font-family: Courier New;">A ouvir: Sorrow, Pink Floyd<br />YouTube: http://www.youtube.com/watch?v=njQtAC6EH<wbr />8E<br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/43509.html Fri, 21 Sep 2007 16:29:06 GMT 4 kb stack ou 8kb stack gamito http://gamito.blogs.sapo.pt/43509.html O valor por omiss&atilde;o para o <span style="font-style: italic;">stack size</span> no Linux s&atilde;o 8 kb.<br />Note-se que este &eacute; o valor para o <span style="font-style: italic;">kernel stack</span>, n&atilde;o para o <span style="font-style: italic;">user-space stack</span>.<br /><br />Contudo, na configura&ccedil;&atilde;o do Kernel, este valor pode ser alterado para 4kb, na sec&ccedil;&atilde;o <span style="font-style: italic;">Kernel hacking</span>:<br /><br /> <div style="text-align: center;"><img border="0" src="http://fotos.sapo.pt/azoigueiro/pic/0003f893" style="border-color: black;" alt="" /><br /><br /><img border="0" src="http://fotos.sapo.pt/azoigueiro/pic/0003gdb5" style="border-color: black;" alt="" /></div> <br />Em que ficamos ent&atilde;o ? Qual o melhor valor para o <span style="font-style: italic;">read/write size</span> ?<br /><br />V&aacute;rias opera&ccedil;&otilde;es requerem ou s&atilde;o mais eficientes quando lidam com tamanhos m&uacute;ltiplos do <span style="font-style: italic;">block size</span>.<br /> <pre wrap="" style="font-family: Verdana;">Diferentes opera&ccedil;&otilde;es podem envolver diferentes <span style="font-style: italic;">block sizes</span>; e.g. a <span style="font-style: italic;">page size</span> da RAM n&atilde;o &eacute; necessariamente<br />a mesma da do <span style="font-style: italic;">block size</span> do disco, portanto, opera&ccedil;&otilde;es<br />que envolvam c&oacute;pia de dados entre disco e RAM<br />devem idealmente usar valores que sejam m&uacute;ltiplos de ambos (i.e. um m&uacute;ltiplo do maior dos dois).<br /><br />Tamb&eacute;m, a <span style="font-style: italic;">page size</span> da RAM pode variar entre arquitecturas de<br /> CPU, enquanto que o <span style="font-style: italic;">block size</span> dos discos pode variar com <br />os <span style="font-style: italic;">filesystems </span>utilizados ou mesmo em diferentes parti&ccedil;&otilde;es<br />&nbsp;do mesmo <span style="font-style: italic;">filesystem</span>.<br /><br />Quaisquer tamanhos relevantes, podem ser obtidos via uma <br />macro <span style="font-style: italic;">standard </span>ou atrav&eacute;s do sysconf() ou fo [f]pathconf().<br /><br />Quanto a <span style="font-style: italic;">networking</span>, n&atilde;o opera em blocos, portanto, n&atilde;o interessa.<br /><br /><br /><span style="font-family: Courier New;">A ouvir: This Is The Sea - Waterboys<br />YouTube: http://www.youtube.com/watch?v=gTTKcrbQog8<br style="font-family: Verdana;" /><br /></span></pre> 0 linux http://gamito.blogs.sapo.pt/43260.html Fri, 21 Sep 2007 12:42:29 GMT A funny guy... gamito http://gamito.blogs.sapo.pt/43260.html in qmail's mailing list:<br /><br /><span style="font-family: Courier New;">&quot;Hi, </span><br style="font-family: Courier New;" /> <br style="font-family: Courier New;" /><span style="font-family: Courier New;">I want to send emails using Qmail server in asp.Net Webapplication (windows platform).Is it possible to migrate Qmail in windows&nbsp; platform.Can you please assist me on the same.Your reply&nbsp; would be more than appreciated. </span><br style="font-family: Courier New;" /> <br style="font-family: Courier New;" /><span style="font-family: Courier New;">Thanks in Advance.</span><br style="font-family: Courier New;" /><span style="font-family: Courier New;">*******************&quot;</span><br style="font-family: Courier New;" /><br /><br style="font-family: Courier New;" /><span style="font-family: Courier New;">A ouvir: Hoochie Coochie Man, Eric Clapton<br />YouTube: http://www.youtube.com/watch?v=4z4fxDOd7<wbr />IE<br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/42788.html Fri, 21 Sep 2007 12:32:24 GMT Truques, Minas e Alçapões :: II gamito http://gamito.blogs.sapo.pt/42788.html Fazer um rsync para <span style="font-style: italic;">backup </span>de dados, por exemplo, com SSH &eacute; muito simples.<br /><br />Temos que ter a nossa chave p&uacute;blica no servidor remoto.<br /><br />Suponhamos que tenho que fazer um <span style="font-style: italic;">backup </span>dos meus e-mails:<br /><br /><span style="font-family: Courier New;"># /usr/bin/rsync -azq -e &quot;ssh -i /root/rsync/chave-mirror-rsync&quot;&nbsp;&nbsp; gamito@192.168.0.102/var/spool/mail/gami<wbr />to/ /var/spool/mail/gamito/<br /><br /><br />A ouvir: Sorrow, Pink Floyd<br />YouTube: </span><span style="font-family: Courier New;">http://www.youtube.com/watch?v=njQtAC6EH<wbr></wbr>8E</span><br /><span style="font-family: Courier New;"><br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/42709.html Fri, 21 Sep 2007 11:25:41 GMT Truques, Minas e Alçapões :: I gamito http://gamito.blogs.sapo.pt/42709.html J&aacute; me aconteceu, num <span style="font-style: italic;">script </span>em BASH, ter que atribuir uma <span style="font-style: italic;">password </span>a um user <span style="font-style: italic;">sem </span>interac&ccedil;&atilde;o com o teclado.<br /><br />&Eacute; muito simples de fazer e podem experimentar na vossa consola:<br /><br /><span style="font-family: Courier New;"># echo gamito:segredo | chpasswd<br /><br /><br />A ouvir: Shine On You Crazy Diamond, Pink Floyd<br />YouTube: http://www.youtube.com/watch?v=vyqgjCKm9<wbr />nQ<br /><br /><br /></span> 0 linux http://gamito.blogs.sapo.pt/42475.html Thu, 20 Sep 2007 17:16:32 GMT Logs do mrtg gamito http://gamito.blogs.sapo.pt/42475.html Se se instalar&nbsp; o mrtg e se se execut&aacute;-lo como &eacute; normal de 5 em 5 minutos atrav&eacute;s do <span style="font-style: italic;">cron daemon</span>, vai inserir duas linhas &ndash; uma para <span style="font-style: italic;">login </span>e outra para <span style="font-style: italic;">logout </span>&ndash; no ficheiro /var/log/messages, enchendo-o de lixo.<br /><br />A solu&ccedil;&atilde;o &eacute; passar esses <span style="font-style: italic;">logs </span>do mrtg para um ficheiro separado, por exemplo, auth.<br /><br /> <pre style="font-family: Verdana;" id="line84">Editar o ficheiro /etc/syslog.conf e mudar a linha:<br /><br />*.info;mail.none;authpriv.none;cron.none /var/log/messages<br /><br />para:<br /><br />*.info;auth.none;mail.none;authpriv.none;cron.none /var/log/messages<br /><br />Adicionar a linha:<br />auth.* /var/log/auth<br /><br />Conv&eacute;m fazer tamb&eacute;m o <span style="font-style: italic;">logrotate </span>do ficheiro auth:<br />Editar o ficheiro /etc/logrotate.d/syslog e adicionar no topo a linha:<br /><br />/var/log/auth<br /><br />Gravar o ficheiro e efectuar um <span style="font-style: italic;">restart </span>ao servi&ccedil;o <span style="font-style: italic;">syslogd</span>:<br /><br /><span style="font-family: Courier New;"># /etc/init.d/syslog restart</span></pre> <br />Done :) 0 linux