<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.placenet.org/benoit/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Harvard Business School of Echec - Tag - linux</title>
  <link>http://www.placenet.org/benoit/index.php/</link>
  <atom:link href="http://www.placenet.org/benoit/index.php/feed/tag/linux/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>fr</language>
  <pubDate>Wed, 12 Nov 2008 14:03:18 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>ABI vs. API compatibility</title>
    <link>http://www.placenet.org/benoit/index.php/post/2008/04/22/ABI-vs-API-compatibility</link>
    <guid isPermaLink="false">urn:md5:e2c2591a8a58add53610f6031ffe1b7f</guid>
    <pubDate>Tue, 22 Apr 2008 08:39:00 +0200</pubDate>
    <dc:creator>Benoît Dejean</dc:creator>
        <category>GNOME</category>
        <category>gnome</category><category>libgtop</category><category>linux</category><category>memory</category>    
    <description>    &lt;h2&gt;glibtop_get_proc_mem&lt;/h2&gt;

&lt;p&gt;libgtop has a function &lt;code&gt;&lt;a href=&quot;http://svn.gnome.org/viewvc/libgtop/trunk/include/glibtop/procmem.h?view=markup&quot;&gt;glibtop_get_proc_mem&lt;/a&gt;&lt;/code&gt; to retrieve basic memory usage of a process. It fills a &lt;code&gt;struct glibtop_proc_mem&lt;/code&gt; which looks like:&lt;/p&gt;
&lt;pre&gt;
struct _glibtop_proc_mem
{
	guint64	flags;
	guint64 size;	
	guint64 vsize;
	guint64 resident;
	guint64 share;
	guint64 rss;
	guint64 rss_rlim;
};
&lt;/pre&gt;


&lt;p&gt;Yes, &lt;code&gt;size/vsize&lt;/code&gt; and &lt;code&gt;resident/rss&lt;/code&gt; look like duplicate. At least on the linux implementation, even if &lt;code&gt;size/vsize&lt;/code&gt; and &lt;code&gt;resident/rss&lt;/code&gt; come from &lt;code&gt;/proc/self/stat&lt;/code&gt; and &lt;code&gt;/proc/self/statm&lt;/code&gt;, you can see in &lt;code&gt;linux/fs/proc/{array,task_mmu}.c&lt;/code&gt; that they have the same values. So, it seems to me that the only unique members of &lt;code&gt;struct glibtop_proc_mem&lt;/code&gt; are &lt;code&gt;size&lt;/code&gt;, &lt;code&gt;resident&lt;/code&gt; and &lt;code&gt;share&lt;/code&gt; (ok there are also &lt;code&gt;flags&lt;/code&gt; which flags which members are filled and &lt;code&gt;rss_lim&lt;/code&gt;).&lt;/p&gt;


&lt;h2&gt;linux proportional set size&lt;/h2&gt;

&lt;p&gt;Linux 2.6.25 comes with a new stat in &lt;code&gt;/proc/self/smaps&lt;/code&gt; called &lt;code&gt;pss&lt;/code&gt; which is even smarter/accurate than &lt;code&gt;private_dirty&lt;/code&gt;. There's &lt;code&gt;glibtop_get_proc_map&lt;/code&gt; which currently have all the &lt;code&gt;smaps&lt;/code&gt; member but not this new &lt;code&gt;pss&lt;/code&gt;. So what is the smarter way to get this new &lt;code&gt;pss&lt;/code&gt; in libgtop without breaking everything ?&lt;/p&gt;

&lt;h3&gt;- break the ABI ?&lt;/h3&gt;

&lt;p&gt;I could simply extend &lt;code&gt;struct glibtop_proc_map&lt;/code&gt;. That would break the ABI, which i'm allowed to because libgtop is &lt;em&gt;desktop&lt;/em&gt;. But that's bad practice since packagers have to rebuild everything. That's a painful migration that may delay the adoption of newer versions of the library.&lt;/p&gt;

&lt;h3&gt;- break the API ?&lt;/h3&gt;

&lt;p&gt;What about cleaning up the &lt;code&gt;glibtop_proc_mem&lt;/code&gt; duplicate members, mark unused some of them and rename &lt;code&gt;rss&lt;/code&gt; to &lt;code&gt;pss&lt;/code&gt; while keeping it binary compatible ? That would make the API a bit more sensible. I've scanned the Debian/unstable archive and that would break the build 3-6 packages but i would be able to submit trivial patches to fix &lt;code&gt;glibtop_get_proc_mem&lt;/code&gt; usage. (And also add &lt;code&gt;glibtop_init();&lt;/code&gt; which are missing everywhere).&lt;/p&gt;

&lt;h3&gt;- hide &lt;code&gt;pss&lt;/code&gt; inside &lt;code&gt;rss&lt;/code&gt; ?&lt;/h3&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;So what's best ?&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>loc-srv</title>
    <link>http://www.placenet.org/benoit/index.php/post/2007/09/10/loc-srv</link>
    <guid isPermaLink="false">urn:md5:a7720603b6155abccdac86c28ee0961a</guid>
    <pubDate>Mon, 10 Sep 2007 22:44:00 +0200</pubDate>
    <dc:creator>Benoît Dejean</dc:creator>
        <category>iptables</category><category>linux</category>    
    <description>    &lt;p&gt;So this weekend, i used a DSL without any NAT, so my laptop was assigned a public IP by DHCP. My ulog log was spitting a lot, mainly on &lt;code&gt;tcp port loc-srv / 135&lt;/code&gt;. Instead of sending REJECT, i opened my iptables and started the following ruby program to actually open all these connections. When someone sends me a SYN, I reply politely.&lt;/p&gt;

&lt;pre&gt;
require 'socket'
require 'etc'

nobody = Etc.getpwnam('nobody')
loc_srv = Socket::getservbyname('loc-srv')

Dir.chroot('/var/run/empty')
Dir.chdir('/')

server = TCPServer.new(loc_srv)

Process::UID.change_privilege(nobody.uid)

print &amp;lt;&amp;lt;&amp;quot;EOF&amp;quot;
uid/euid #{Process.uid}/#{Process.euid}                                                                                                        
chrooted in #{Dir.pwd}                                                                                                                         
listening on address #{server.addr.inspect}                                                                                                    
EOF

clients = []

loop do
  begin
    client = server.accept_nonblock
  rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
    IO.select([server])
    next
  end

  # remember client so the connection stays opened                                                                                             
  clients &amp;lt;&amp;lt; client
  print &amp;quot;#{client.peeraddr.inspect} connected
&amp;quot;
end
&lt;/pre&gt;



&lt;p&gt;This script needs to be started with some privileges in order to bind on 135, but then it drops its priv and chroot to somewhere safe. That was very instructive, after ~10minutes, &lt;code&gt;ss | grep -c loc-srv&lt;/code&gt; was reporting more than 280 connections from ~80 differents hosts.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;What a storm. I'm definitely safe under my GNU+Linux umbrella &lt;img src=&quot;/benoit/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;And Ruby is fun &lt;img src=&quot;/benoit/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>