<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pamiętnik programisty &#187; linux</title>
	<atom:link href="http://piotr.doniec.eu/devlog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://piotr.doniec.eu/devlog</link>
	<description></description>
	<lastBuildDate>Wed, 28 Dec 2011 23:52:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>GMail as relayhost in Postfix &#8211; without certs</title>
		<link>http://piotr.doniec.eu/devlog/2011/12/gmail-as-realyhost-in-postfix-without-certs/</link>
		<comments>http://piotr.doniec.eu/devlog/2011/12/gmail-as-realyhost-in-postfix-without-certs/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 23:23:04 +0000</pubDate>
		<dc:creator>pejotr</dc:creator>
				<category><![CDATA[Inne]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[problem-rozwiazanie]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://piotr.doniec.eu/devlog/?p=643</guid>
		<description><![CDATA[There are many articles describing how to setup GMail as a relayhost in Postfix mail server. Most of them involve creating local CA certificate and generation of client certificate. There is absolutely no need to! Just think, how GMail would be able to validate your own certificate created by your own CA available only on [...]]]></description>
			<content:encoded><![CDATA[<p>There are many articles describing how to setup GMail as a relayhost in Postfix mail server. Most of them involve creating local CA certificate and generation of client certificate. There is absolutely no need to! Just think, how GMail would be able to validate your own certificate created by your own CA available only on your local drive? What would be a purpose?</p>
<p>To make Postfix work with GMail you just need to add these lines to main.cf:<br />
<code><br />
relayhost = [smtp.gmail.com]:587</p>
<p># SASL<br />
smtp_sasl_auth_enable=yes<br />
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd</p>
<p># TLS<br />
smtp_use_tls = yes<br />
smtp_tls_CAfile=/etc/pki/tls/cert.pem  # CentOS path<br />
smtp_tls_loglevel=2<br />
smtp_sasl_tls_security_options = noanonymous<br />
tls_random_source = dev:/dev/urandom<br />
</code></p>
<p>And put just one line in sasl_passwd<br />
<code><br />
[smtp.gmail.com]:587  username@gmail.com:password<br />
</code></p>
<p>After issuing following commands a connection between GMail and Postfix should work fine. You can test it using <code>mail</code> or <code>sendmail</code> program:<br />
<code><br />
$ postmap hash:/etc/postfix/sasl_passwd<br />
$ /etc/init.d/postfix restart<br />
$ mail test@example.com<br />
Subject: Test main<br />
Test message<br />
.<br />
Cc:<br />
</code></p>
<p>You should have something like this in your /var/log/maillog file:<br />
<code><br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: setting up TLS connection to smtp.gmail.com<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: certificate verification depth=2 subject=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority<br />
<strong>Dec 29 00:49:48 localhost postfix/smtp[5942]: verify return: 1</strong><br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: certificate verification depth=1 subject=/C=US/O=Google Inc/CN=Google Internet Authority<br />
<strong>Dec 29 00:49:48 localhost postfix/smtp[5942]: verify return: 1</strong><br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: certificate verification depth=0 subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com<br />
<strong>Dec 29 00:49:48 localhost postfix/smtp[5942]: verify return: 1</strong><br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 read server certificate A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:error in SSLv3 read server key exchange A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:error in SSLv3 read server key exchange A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 read server done A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 write client key exchange A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 write change cipher spec A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 write finished A<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 flush data<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:error in SSLv3 read finished A<br />
Dec 29 00:49:48 localhost last message repeated 3 times<br />
Dec 29 00:49:48 localhost postfix/smtp[5942]: SSL_connect:SSLv3 read finished A<br />
<strong>Dec 29 00:49:48 localhost postfix/smtp[5942]: Verified: subject_CN=smtp.gmail.com, issuer=Google Internet Authority</strong><br />
<strong>Dec 29 00:49:48 localhost postfix/smtp[5942]: TLS connection established to smtp.gmail.com: TLSv1 with cipher RC4-SHA (128/128 bits)</strong><br />
Dec 29 00:49:50 localhost postfix/smtp[5942]: 955CE3D48A06: to=
<piotr@example.com>, relay=smtp.gmail.com[74.125.79.108]:587, delay=2.2, delays=0.12/0.03/0.9/1.2, dsn=2.0.0, status=sent (250 2.0.0 OK 1325116190 t59sm126911139eeh.10)<br />
Dec 29 00:49:50 localhost postfix/qmgr[5923]: 955CE3D48A06: removed<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.doniec.eu/devlog/2011/12/gmail-as-realyhost-in-postfix-without-certs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problem with timestamps in libnetfilter_queue solved</title>
		<link>http://piotr.doniec.eu/devlog/2010/12/problem-with-timestamps-in-libnetfilter_queue-solved/</link>
		<comments>http://piotr.doniec.eu/devlog/2010/12/problem-with-timestamps-in-libnetfilter_queue-solved/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 21:45:09 +0000</pubDate>
		<dc:creator>pejotr</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programowanie]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[tricky]]></category>

		<guid isPermaLink="false">http://piotr.doniec.eu/devlog/?p=561</guid>
		<description><![CDATA[My BSc Thesis is to implement steganography algorithm that use VoIP packets as a transport. The main aim is to modify delay of RTP packets without noticeable impact on transmission quality. I create hidden channel by sending two packets that average delay is 20ms. For example if we send 1 packet 10ms after previous and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://piotr.doniec.eu/devlog/wp-content/uploads/2010/12/netfilter-logo2.png"><img src="http://piotr.doniec.eu/devlog/wp-content/uploads/2010/12/netfilter-logo2.png" alt="" title="netfilter-logo2" width="265" height="72" class="alignleft size-full wp-image-576" /></a>My BSc Thesis is to implement steganography algorithm that use VoIP packets as a transport. The main aim is to modify delay of RTP packets without noticeable impact on transmission quality. I create hidden channel by sending two packets that average delay is 20ms. For example if we send 1 packet 10ms after previous and second 30ms after first the average delay is 20ms. Calling parties will not notice so small difference, but software should recognize such situation as sending the bit with value 1. When we want to send bit 0 we can just switch delays, then first packet will be sent after 30ms and another 10ms later. The time the packet was received is very important for Receiver. The network can add a random delay but Receiver should still be able to collect all sent bits.<br />
For implementation I used libnetfilter_queue and iptables. This two powerful tools are more than enough for my need. Everything was fine until and got to point where I had to read packet delay. Although libnetfilter_queue provide function for reading timestamp when packet was queued (nfq_get_timestamp) it&#8217;s not working without additional tweaks. For kernel performance reason timestamping network packets is by default disabled. After digging through kernel source I found functions responsible from toggling this setting, it&#8217;s a net_enable_timestamp() and net_disable_timestamp(). I had no idea how to execute each of them but MarkR from stackoverflow.org helped me. There is no need to enable timestamping globally for all packets instead it can be enabled for particular socket by using setsockopt. The call sequence is then setsockopt() -> sock_setsockopt() -> sock_enable_timestamp(&#8230;) -> net_enable_timestamp(). It is possible to get file descriptor connected with particular queue and treat it as it would be socket. This means that following code is valid and can be used to enable timestamping incoming packets:</p>
<pre class="brush: cpp">
int ena = 1;
if( setsockopt(queuefd, SOL_SOCKET, SO_TIMESTAMP, &amp;ena, sizeof(ena)) )
{
    SYS_LOG(E_WARNING, &quot;Unable to enable timestamping&quot;);
}
</pre>
<p>and then in queue handle function:</p>
<pre class="brush: cpp">
int handle_queue(struct nfq_q_handle *pQh, struct nfgenmsg *pNfmsg, struct nfq_data *pNfa, void *pData)
{
    struct nfqnl_msg_packet_hdr *ph;
    struct timeval tv;
    int id;

    ph = nfq_get_msg_packet_hdr(pNfa);
    if(ph)
    {
        id = ntohl(ph-&gt;packet_id);
    }

    nfq_get_timestamp(pNfa, &amp;tv);
    /* do sth. with read timestamp */

    return nfq_set_verdict(pQh, id, NF_ACCEPT, 0, NULL);
}
</pre>
<p>This is a solution for a issue, that as far as i know, have not been solved since this post:<br />
&#8222;So far the biggest issues I&#8217;ve run into are that marking doesn&#8217;t work in 2.6.15 (I think it should in 2.6.16), and I can&#8217;t seem to ever read the timestamp for a packet, no matter  hat hook it comes in on.  I&#8217;ve just been using gettimeofday for that for now.&#8221;<br />
<a href="http://lists.netfilter.org/pipermail/netfilter-devel/2006-February/023490.html">http://lists.netfilter.org/pipermail/netfilter-devel/2006-February/023490.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.doniec.eu/devlog/2010/12/problem-with-timestamps-in-libnetfilter_queue-solved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ustawienie sieci wewnętrznej VirtualBox</title>
		<link>http://piotr.doniec.eu/devlog/2010/11/ustawienie-sieci-wewnetrznej-virtualbox/</link>
		<comments>http://piotr.doniec.eu/devlog/2010/11/ustawienie-sieci-wewnetrznej-virtualbox/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 22:18:17 +0000</pubDate>
		<dc:creator>pejotr</dc:creator>
				<category><![CDATA[Inne]]></category>
		<category><![CDATA[common error]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[virtual]]></category>
		<category><![CDATA[wirtualność]]></category>

		<guid isPermaLink="false">http://piotr.doniec.eu/devlog/?p=556</guid>
		<description><![CDATA[Korzystając z okazji że pozbywam się Oracle VirtualBox na rzecz VM Player&#8217;a wrzucam stworzony przeze mnie dawno dawno filmik pokazujący w jaki sposób stworzyć sieć wewnętrzną w VirtualBox wraz z automatycznym przydzielaniem adresów. Przedstawiona przykładzie systemu Windows XP i QNX. Enjoy. www.youtube.com/watch?v=iDzcELJisHs]]></description>
			<content:encoded><![CDATA[<p>Korzystając z okazji że pozbywam się Oracle VirtualBox na rzecz VM Player&#8217;a wrzucam stworzony przeze mnie dawno dawno filmik pokazujący w jaki sposób stworzyć sieć wewnętrzną w VirtualBox wraz z automatycznym przydzielaniem adresów. Przedstawiona przykładzie systemu Windows XP i QNX. Enjoy.<br />
<center><span class="youtube">
<iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="295" src="http://www.youtube.com/embed/iDzcELJisHs?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;modestbranding=1&amp;loop=&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" frameborder="0" allowfullscreen></iframe>
</span><p><a href="http://www.youtube.com/watch?v=iDzcELJisHs&fmt=18">www.youtube.com/watch?v=iDzcELJisHs</a></p></center></p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.doniec.eu/devlog/2010/11/ustawienie-sieci-wewnetrznej-virtualbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Karta X100P i Kernel Panic</title>
		<link>http://piotr.doniec.eu/devlog/2009/09/karta-x100p-i-kernel-panic/</link>
		<comments>http://piotr.doniec.eu/devlog/2009/09/karta-x100p-i-kernel-panic/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 10:14:43 +0000</pubDate>
		<dc:creator>pejotr</dc:creator>
				<category><![CDATA[VoIP]]></category>
		<category><![CDATA[dahdi]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[x100p]]></category>
		<category><![CDATA[zaptel]]></category>

		<guid isPermaLink="false">http://piotr.doniec.eu/devlog/?p=262</guid>
		<description><![CDATA[Mimo nowych wersji zarówno Trixboxa i Astersika, problem nadaj pozostaje. Po skonfigurowaniu karty, w czasie wyłączania systemu kernel dostaje zadyszki o czym informuje znienawidzonym komunikatem &#8222;KERNEL PANIC&#8221;. Od ostatniego wpisu na ten temat ( jeszcze na stary blogu, który trafił szlag podczas aktualizacji WP) trochę się zmieniło. Nie ma już co szukać pliku KXXZaptel, bo [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://piotr.doniec.eu/devlog/wp-content/uploads/2009/09/x100p-300x209.jpg" alt="Karta x100p" title="Karta x100p" width="300" height="209" class="alignleft size-medium wp-image-265" />Mimo nowych wersji zarówno Trixboxa i Astersika, problem nadaj pozostaje. Po skonfigurowaniu karty, w czasie wyłączania systemu kernel dostaje zadyszki o czym informuje znienawidzonym komunikatem &#8222;KERNEL PANIC&#8221;. Od ostatniego wpisu na ten temat ( jeszcze na stary blogu, który trafił szlag podczas aktualizacji WP) trochę się zmieniło. Nie ma już co szukać pliku KXXZaptel, bo znalezienie go oznacza że nasz system jest lekko zacofany &#8211; Zaptel jest obecnie znany jako DAHDI. Również zawartość odpowiedniego pliku jest lekko inna, ale mimo wszystko można problem rozwiązać.<br />
Co należy zrobić to w /etc/rc6.d odnaleźć plik KXXdahdi, u mnie jest to K92dahdi i zakomentować poniższy fragment, okolice linii 235:</p>
<blockquote><p>
# Unload drivers<br />
#shutdown_dynamic<br />
#echo -n &#8222;Unloading DAHDI hardware modules: &#8221;<br />
#if unload_module dahdi; then<br />
#       echo &#8222;done&#8221;<br />
#else<br />
#       echo &#8222;error&#8221;<br />
#fi<br />
#if [ "$LOCKFILE" != '' ]; then<br />
#       [ $RETVAL -eq 0 ] &#038;&#038; rm -f $LOCKFILE<br />
#fi
</p></blockquote>
<p>i zamykanie systemu zaczyna działać jak należy. Może sam problem nie jest zbyt uciążliwy gdyż działający serwer VoIP nie jest często resetowany. Ale zabawa zaczyna się gdy zaistnieje potrzeba przeprowadzenia takiej operacji zdalnie&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://piotr.doniec.eu/devlog/2009/09/karta-x100p-i-kernel-panic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

