<?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>tolaris.comtolaris.com &#187; </title>
	<atom:link href="http://www.tolaris.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tolaris.com</link>
	<description>When the going gets tough, the tough sniff packets.</description>
	<lastBuildDate>Mon, 20 May 2013 22:50:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Enable swap on Nas4Free</title>
		<link>http://www.tolaris.com/2013/05/18/enable-swap-on-nas4free/</link>
		<comments>http://www.tolaris.com/2013/05/18/enable-swap-on-nas4free/#comments</comments>
		<pubDate>Sat, 18 May 2013 19:54:17 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[freenas]]></category>
		<category><![CDATA[iscsi]]></category>
		<category><![CDATA[nas4free]]></category>
		<category><![CDATA[nfs]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2329</guid>
		<description><![CDATA[I recently built a storage server (SAN/NAS/whatever) with Nas4Free on a Supermicro 6037R-E1R16N. If you&#8217;ve ever built a SAN, you&#8217;ve seen one of these. Lots of disks in a ZFS array, with a filesystem exported via NFS or a volume exported via iSCSI. After almost a month of operation, I discovered that Nas4Free defaults to [...]]]></description>
				<content:encoded><![CDATA[<p>I recently built a storage server (SAN/NAS/whatever) with <a href="http://www.nas4free.org/">Nas4Free</a> on a <a href="http://www.supermicro.nl/products/system/3u/6037/ssg-6037r-e1r16n.cfm">Supermicro 6037R-E1R16N</a>. If you&#8217;ve ever built a SAN, you&#8217;ve seen one of these. Lots of disks in a <a href="http://en.wikipedia.org/wiki/ZFS">ZFS</a> array, with a filesystem exported via NFS or a volume exported via iSCSI. After almost a month of operation, I discovered that Nas4Free defaults to having no swap space. And this means your storage server will not be stable.</p>
<p><span id="more-2329"></span><a href="http://www.urbandictionary.com/define.php?term=tl%3Bdr">tl;dr</a>? Here&#8217;s how to fix it:</p>
<ol>
<li>Login to the Nas4Free web interface.</li>
<li>Navigate to &#8220;Disks&#8221; -> &#8220;ZFS&#8221; -> &#8220;Volumes&#8221;.</li>
<li>Create a ZFS Volume called &#8220;swap&#8221;. For size, &#8220;2x RAM&#8221; is the standard. Otherwise use defaults.</li>
<li>Navigate to &#8220;System&#8221; -> &#8220;Advanced&#8221; -> &#8220;Swap&#8221;.</li>
<li>Set &#8220;Type&#8221; to &#8220;Device&#8221;, and &#8220;Device&#8221; to &#8220;/dev/zvol/tank/swap&#8221;, where &#8220;tank&#8221; is your ZFS pool name and &#8220;swap&#8221; is the name of the volume you just created as a swap device.</li>
</ol>
<p>If you don&#8217;t already have ZFS configured, first create your ZFS pool as normal. Then follow the above steps.</p>
<p>Nas4Free allows you to install &#8220;embedded&#8221; or &#8220;full&#8221; software installations. I chose &#8220;embedded&#8221;, because this makes upgrades very easy, and it is simple to install this way on a USB flash device. This means you can dedicate all SATA ports to ZFS storage and not the operating system. With the embedded installation, Nas4Free does not create a swap space. Which means it&#8217;s up to the user to do this. It&#8217;s possible this isn&#8217;t an issue on the &#8220;full&#8221; installation. I don&#8217;t know; I haven&#8217;t tried it.</p>
<p>Why is swap necessary? After all, if you have a large amount of RAM, you shouldn&#8217;t need swap. And if you use ZFS, you should always have a large amount of RAM. That&#8217;s the ideal situation, but in practice it doesn&#8217;t work. Why? Because ZFS uses any available memory for cache.</p>
<div id="attachment_2330" class="wp-caption alignnone" style="width: 863px"><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/05/freebsd-zfs-kernel-memory.png"><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/05/freebsd-zfs-kernel-memory.png" alt="Memory usage with ZFS on FreeBSD." width="853" height="284" class="size-full wp-image-2330" /></a><p class="wp-caption-text">Memory usage with ZFS on FreeBSD.</p></div>
<p>Under FreeBSD, this is called <a href="http://forums.freebsd.org/showthread.php?t=17229">wired memory</a>. When ZFS uses wired memory as cache, it should be reclaimed for other uses when it&#8217;s needed. That&#8217;s certainly what happens under Linux, where disk (read) cache is reported as &#8220;Cache memory&#8221; in the above graph.</p>
<p>I have found this isn&#8217;t the case in practice. Instead, when memory gets tight, FreeBSD kills processes it <em>really</em> shouldn&#8217;t:</p>
<p></p><pre class="crayon-plain-tag">Apr 30 12:49:45 san1 kernel: pid 69430 (istgt), uid 0, was killed: out of swap space</pre><p></p>
<p>That&#8217;s right. Run ZFS for long enough with no swap, and eventually your iSCSI daemon will be killed. Which means your SAN isn&#8217;t accessible any longer. It could also kill the NFS server if you are using the userspace NFS daemon, which is what Nas4Free does.</p>
<p><a href="http://www.freenas.org/">FreeNAS</a>, <del datetime="2013-05-20T22:48:49+00:00">from which Nas4Free is forked</del> a <a href="http://wiki.nas4free.org/doku.php">similarly-named commercial product</a>, doesn&#8217;t have this problem. It defaults to using a certain amount of each disk for swap, which means the average user simply won&#8217;t see this problem. This may be a moot point, since the average user in this situation should be a highly-trained engineer. But it happened to me, and I&#8217;m documenting it here so it doesn&#8217;t happen to you.</p>
<p>Thanks to the fine people of the <a href="http://forums.nas4free.org/viewtopic.php?f=57&#038;t=3926&#038;p=20486">Nas4Free forums</a> for providing additional information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/05/18/enable-swap-on-nas4free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pascale&#8217;s new Raspberry Pi</title>
		<link>http://www.tolaris.com/2013/04/08/pascales-new-raspberry-pi/</link>
		<comments>http://www.tolaris.com/2013/04/08/pascales-new-raspberry-pi/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 06:45:21 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pascale]]></category>
		<category><![CDATA[raspberrypi]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2285</guid>
		<description><![CDATA[This weekend Pascale and I replaced the children&#8217;s Ubuntu PC with a Raspberry Pi. Pascale is my oldest daughter, now 4.5 years old. Pascale loves the Raspberry Pi logo, and calls the new computer &#8220;Raspberry Pi &#8230; Pi Pi Pi!&#8221; I installed Raspbian on the SD card the night before. The next morning, we sat [...]]]></description>
				<content:encoded><![CDATA[<p>This weekend Pascale and I replaced the children&#8217;s Ubuntu PC with a Raspberry Pi. Pascale is my oldest daughter, now 4.5 years old.</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/04/Pascale-Raspberry-Pi.jpg"><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/04/Pascale-Raspberry-Pi-1024x768.jpg" alt="Pascale with Raspberry Pi" width="500" height="375" class="alignnone size-large wp-image-2286" /></a></p>
<p>Pascale loves the <a href="http://upload.wikimedia.org/wikipedia/en/c/cb/Raspberry_Pi_Logo.svg">Raspberry Pi logo</a>, and calls the new computer &#8220;Raspberry Pi &#8230; Pi Pi Pi!&#8221; I installed Raspbian on the SD card the night before. The next morning, we sat down together with all the parts and cables. We watched the <a href="https://www.youtube.com/watch?v=wyHudYAOVRY">video</a> and assembled the enclosure together. Then Pascale figured out all where all the cables go and how they snap in. We&#8217;re still waiting for the HDMI-to-DVI cable to connect it to the screen on her table, so we tested it on the TV.</p>
<p><span id="more-2285"></span>We bought the parts on eBay. Here are the details:</p>
<ol>
<li><a href="http://www.adafruit.com/products/998">Raspberry Pi model B 512MB RAM</a></li>
<li><a href="http://www.adafruit.com/products/859">Adafruit Pi Box</a>, a clear acrylic enclosure</li>
<li>16 GB SD card with the latest <a href="http://www.raspbian.org/">Raspbian</a></li>
</ol>
<p>We already had the peripherals:</p>
<ol>
<li><a href="http://www.amazon.co.uk/GMYLE-Super-Keyboard-Windows-Vista/dp/B0046L9KUA">GMYLE Super Slim USB 2.0 Mini Keyboard</a></li>
<li><a href="http://www.sweex.com/en/assortiment/input/optical-mice/MI055/awards_reviews/">Sweex MI055 Mini Optical USB Mouse</a>, Green</li>
<li><a href="http://www.viewsonic.com.au/products/ppspecs.php?id=161">ViewSonic VX715</a> display with DVI and VGA inputs</li>
</ol>
<p>Tomorrow, we&#8217;ll figure out <a href="http://blog.christosoft.de/2012/08/flash-on-the-raspberry-pi/">Flash on the Raspberry Pi</a>, so she can visit her <a href="http://www.poissonrouge.com/children.php">favourite website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/04/08/pascales-new-raspberry-pi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QuickSSHd (Dropbear/SSH) won&#8217;t run under Android Jelly Bean</title>
		<link>http://www.tolaris.com/2013/04/07/quicksshd-dropbearssh-wont-run-under-android-jelly-bean/</link>
		<comments>http://www.tolaris.com/2013/04/07/quicksshd-dropbearssh-wont-run-under-android-jelly-bean/#comments</comments>
		<pubDate>Sun, 07 Apr 2013 15:08:11 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2273</guid>
		<description><![CDATA[I run SSHd on my Android phone. This means I can copy files via wireless SFTP, and back it up with BackupPC. It beats using USB or Dropbox. With Android 4.1 and up (Jelly Bean), the default umask for files has changed from &#8220;000&#8243; (users/programs can write to nearly any file) to &#8220;077&#8243; (users/programs can [...]]]></description>
				<content:encoded><![CDATA[<p>I run SSHd on my Android phone. This means I can copy files via wireless SFTP, and back it up with BackupPC. It beats using USB or Dropbox. With Android 4.1 and up (Jelly Bean), the default umask for files has changed from &#8220;000&#8243; (users/programs can write to nearly any file) to &#8220;077&#8243; (users/programs can only write to files they own). This is better, but meanwhile many Android programs expect the old behaviour. <a href="https://play.google.com/store/apps/details?id=com.teslacoilsw.quicksshd">QuickSSHd</a> (a 99p Android <a href="https://matt.ucc.asn.au/dropbear/dropbear.html">dropbear</a> SSH server) is <a href="http://code.google.com/p/android/issues/detail?id=35993">one of them</a>.</p>
<p><span id="more-2273"></span>This is really just a user interface bug. QuickSSHd is still starting dropbear, it just can&#8217;t read the server PID file to verify that it is running. The workaround is to rename the &#8220;dropbear&#8221; binary in /data/data/com.teslacoilsw.quicksshd/dropbear/, and replace it with a script which adjusts the umask before calling the real dropbear.</p>
<p>So start QuickSSHd once, and ignore the appearance that it&#8217;s not running. Then login as root (or use su in a terminal) and run:</p>
<p></p><pre class="crayon-plain-tag">cd /data/data/com.teslacoilsw.quicksshd/dropbear/
cp -a dropbear dropbear.real
cat &gt; dropbear &lt;&lt; END_OF_LINE
#!/system/bin/sh
umask 000
/data/data/com.teslacoilsw.quicksshd/dropbear/dropbear.real &quot;$@&quot;
END_OF_LINE</pre><p></p>
<p>The <code>cp -a</code> ensures that the new dropbear script is owned by the right user and have the right permissions. If not, you will need to use chown and chmod to fix it. The right user/group will be different on each Android device, and the permissions should be the same as the original dropbear (now dropbear.real).</p>
<p>After applying this fix, you will need to reboot your phone, or kill the running dropbear using <code>ps</code> and <code>kill</code>. After that, QuickSSHd should work as normal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/04/07/quicksshd-dropbearssh-wont-run-under-android-jelly-bean/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ownCloud client fails to sync compressed files</title>
		<link>http://www.tolaris.com/2013/03/21/owncloud-client-fails-to-sync-compressed-files/</link>
		<comments>http://www.tolaris.com/2013/03/21/owncloud-client-fails-to-sync-compressed-files/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 20:02:47 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[owncloud]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2246</guid>
		<description><![CDATA[I recently added a few new files (.tar.gz archives) to the ownCloud folder on my desktop PC. The next morning I discovered that my laptop couldn&#8217;t sync them. The ownCloud client (Csync) displayed: Csync processing step propagate failed Starting the client with &#8220;owncloud --logwindow&#8221; produced this message: [crayon-51a06ee234def/] After some digging, I discovered: It only [...]]]></description>
				<content:encoded><![CDATA[<p>I recently added a few new files (.tar.gz archives) to the ownCloud folder on my desktop PC. The next morning I discovered that my laptop couldn&#8217;t sync them. The ownCloud client (Csync) displayed:</p>
<p><code>Csync processing step propagate failed</code></p>
<p>Starting the client with &#8220;<code>owncloud --logwindow</code>&#8221; produced this message:</p>
<p><span id="more-2246"></span></p><pre class="crayon-plain-tag">03-18 06:36:43:712 _csync_propagation_file_visitor: FAIL NEW: Documents/stuff.tgz
03-18 06:36:43:712 csync_propagate: Propagation for remote replica took 15.26 seconds visiting 497 files.
03-18 06:36:43:712  #### ERROR during  cysnc_reconcile :  &quot;CSync processing step propagate failed.&lt;br/&gt;
Backend Message: Could not read response body: connection was closed by server&quot;</pre><p></p>
<p>After <a href="https://github.com/owncloud/mirall/issues/272">some digging</a>, I discovered:</p>
<ol>
<li>It only happens with Apache, and not with Nginx.</li>
<li>It happens with Csync 1.2.0 and up, but not Csync 1.1.x.</li>
<li>It happens after upgrading to ownCloud 4.5, and may not affect ownCloud 4.1.</li>
<li>It only happens if you add compressed files, including at least zip and tar.gz.</li>
</ol>
<p>Possible solutions include downgrading Csync or switching web servers, but you don&#8217;t really want to do that. The easy workaround is to disable the &#8220;Archive support&#8221; plugin and force ownCloud to recalculate the file cache.</p>
<ol>
<li>Disable Archive support</li>
<ol>
<li>Login to the ownCloud web interface</li>
<li>Click &#8220;Settings&#8221; -> &#8220;Apps&#8221;</li>
<li>Select &#8220;Archive support&#8221;</li>
<li>Press &#8220;Disable&#8221;</li>
</ol>
<li>Force ownCloud to regenerate the file cache</li>
<ol>
<li>In ownCloud, click &#8220;Files&#8221;</li>
<li>In Firefox, go to the Firefox or Tools Menu</li>
<li>Select &#8220;Web Developer&#8221; -> &#8220;Web Console&#8221; to open a Javascript console</li>
<li>Type &#8220;scanFiles(true)&#8221; and hit Enter</li>
</ol>
</ol>
<p>After that, Csync should synchronise your compressed files correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/03/21/owncloud-client-fails-to-sync-compressed-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rm: cannot remove `/run/user/root/gvfs&#8217;: Is a directory</title>
		<link>http://www.tolaris.com/2013/03/10/rm-cannot-remove-runuserrootgvfs-is-a-directory/</link>
		<comments>http://www.tolaris.com/2013/03/10/rm-cannot-remove-runuserrootgvfs-is-a-directory/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 21:16:00 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linuxmint]]></category>
		<category><![CDATA[nadia]]></category>
		<category><![CDATA[quantal]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2231</guid>
		<description><![CDATA[A few months ago, I moved to Linux Mint 14 &#8220;nadia&#8221;, which is based on Ubuntu 12.10 &#8220;quantal quetzal&#8221;. I sometimes see this error after running a commmand with sudo: [crayon-51a06ee2352a5/] This happens because the root user has started a gvfsd daemon, which mounts a virtual filesystem on that directory. The root user should never [...]]]></description>
				<content:encoded><![CDATA[<p>A few months ago, I moved to Linux Mint 14 &#8220;nadia&#8221;, which is based on Ubuntu 12.10 &#8220;quantal quetzal&#8221;. I sometimes see this error after running a commmand with sudo:</p>
<p></p><pre class="crayon-plain-tag">rm: cannot remove `/run/user/root/gvfs': Is a directory</pre><p></p>
<p>This happens because the root user has started a <code>gvfsd</code> daemon, which mounts a virtual filesystem on that directory. The root user should never run GNOME, so it should never need gvfsd. But something in Ubuntu 12.10 starts one sometimes.</p>
<p><span id="more-2231"></span>You can work around it by <a href="http://askubuntu.com/questions/233668/rm-cannot-remove-run-user-root-gvfs-is-a-directory">unmounting this directory</a>. However, I prefer the more direct approach of killing root&#8217;s gvfsd.</p>
<p>First create a shell script:</p>
<p></p><pre class="crayon-plain-tag">sudo tee /usr/local/bin/kill-root-gvfsd &gt; /dev/null &lt;&lt; ENDOFLINE
#!/bin/sh
killall -u root gvfsd 2&gt;/dev/null
exit 0
ENDOFLINE
sudo chmod 755 /usr/local/bin/kill-root-gvfsd</pre><p></p>
<p>* Like my tee trick? Sudo is great, but I hate not being able to use shell redirects.</p>
<p>Running this script will kill root&#8217;s gvfsd daemon. You can run this script whenever the problem happens. But since the issue is random, and since I never want to see it again, I&#8217;ll use cron to run it periodically.</p>
<p></p><pre class="crayon-plain-tag">sudo tee /etc/cron.d/kill-root-gvfsd &gt; /dev/null &lt;&lt; ENDOFLINE
0,30 * * * * root [ -x /usr/local/bin/kill-root-gvfsd ] &amp;&amp; /usr/local/bin/kill-root-gvfsd
ENDOFLINE</pre><p></p>
<p>Now gvfsd will stay dead. Or at least never live longer than 30 minutes.</p>
<p>This is a hack. A good solution would be to find out why gvfsd starts and run this script afterward. A better solution would be to find a way to prevent root from starting gvfsd at all. As always, suggestions are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/03/10/rm-cannot-remove-runuserrootgvfs-is-a-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better Cacti memory usage graphs</title>
		<link>http://www.tolaris.com/2013/02/28/better-cacti-memory-usage-graphs/</link>
		<comments>http://www.tolaris.com/2013/02/28/better-cacti-memory-usage-graphs/#comments</comments>
		<pubDate>Thu, 28 Feb 2013 22:39:37 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cacti]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2199</guid>
		<description><![CDATA[Cacti is a wonderful tool, but many of the default graphs are ugly. Worse, the &#8220;ucd/net Memory Usage&#8221; graph is totally useless. It displays memory which is free, or dedicated to cache or buffers. But it doesn&#8217;t display the actual used memory or total. And it uses the wrong base, assuming there are 1000 bytes [...]]]></description>
				<content:encoded><![CDATA[<p>Cacti is a wonderful tool, but many of the default graphs are ugly. Worse, the &#8220;ucd/net Memory Usage&#8221; graph is totally useless. It displays memory which is free, or dedicated to cache or buffers. But it doesn&#8217;t display the actual used memory or total. And it uses the wrong base, assuming there are 1000 bytes in a kilobyte of memory. I can&#8217;t imagine why this graph template is even included with Cacti by default. So, I set out to make a better one.</p>
<p><span id="more-2199"></span>Here is the default graph:</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/default_memory_usage.png"><img class="aligncenter size-none wp-image-2201" alt="default_memory_usage" src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/default_memory_usage.png" width="853" height="256" />
<p style="text-align: center;">(Click to embiggen)</p>
<p></a></p>
<p>The implementation for &#8220;used memory&#8221; in the SNMP OID is inconsistent across devices. But you can fetch &#8220;total memory&#8221;, and do the math:</p>
<p>Used memory = Total &#8211; (Free + Cache + Buffers)</p>
<p>Many people have used this method to make better memory usage templates. <a href="http://www.eric-a-hall.com/software/cacti-netsnmp-memory/">Eric A. Hall</a> made a much prettier graph, but it relies on an external script to fetch the data and do the math. This is unnecessary, and (slightly) slower than using Cacti CDEF functions. <a href="http://hans.fugal.net/blog/2009/01/10/sensible-graphs-with-cacti/">Hans Fugal</a> used CDEF functions, but his graphs use an eye-searing colour scheme. He also uses the wrong base; there are 1024 bytes in a kilobyte of RAM, not 1000 as in hard drives or network data rate.</p>
<p>Here are mine:</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/memory_usage.png"><img class="aligncenter size-full wp-image-2202" alt="memory_usage" src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/memory_usage.png" width="853" height="283" /></a></p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/swap_usage.png"><img class="aligncenter size-full wp-image-2203" alt="swap_usage" src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/swap_usage.png" width="853" height="255" /></a></p>
<p>My implementation uses Eric Hall&#8217;s colour scheme and Hans Fugal&#8217;s CDEF method, but graphs real memory and swap as two separate graphs. It also uses the correct unit base of 1024. These graphs are also intended for Linux. Unix operating systems won&#8217;t report Buffers or Cache, but they&#8217;ll graph correctly as long as they report Free and Total.</p>
<p>Downloads:</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/cacti_graph_template__ucdnet_-_memory_usage_real.xml">cacti_graph_template__ucdnet_-_memory_usage_real.xml</a></p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/cacti_graph_template__ucdnet_-_memory_usage_swap.xml">cacti_graph_template__ucdnet_-_memory_usage_swap.xml</a></p>
<p>Only after making my own did I discover <a href="http://freeccnp-cacti.blogspot.co.uk/2012/07/memory-usage-linux-graph-template-work.html">fmangeant</a>&#8216;s graphs. These use the CDEF method and correct base, although I&#8217;m not fond of the colours. The &#8220;Memory Usage Unix&#8221; graph would be useful if your device doesn&#8217;t report Buffers or Cache and you don&#8217;t want to see zero values on your graph.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/02/28/better-cacti-memory-usage-graphs/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Science project: measuring USB current</title>
		<link>http://www.tolaris.com/2013/02/08/science-project-measuring-usb-current/</link>
		<comments>http://www.tolaris.com/2013/02/08/science-project-measuring-usb-current/#comments</comments>
		<pubDate>Fri, 08 Feb 2013 15:30:38 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2156</guid>
		<description><![CDATA[My friend Soren recently gave me a Super Power Bank, a nifty portable Lithium battery pack with two USB ports for charging devices on the go. The Super Power Bank has a 6600 mAh battery with two USB ports for charging devices; one providing 1.0 A, the other 2.1 A. He asked me a question: [...]]]></description>
				<content:encoded><![CDATA[<p>My friend <a href="http://www.linkedin.com/in/sorenr">Soren</a> recently gave me a <a href="http://richardsolo.com/superpowerbank.aspx#.URTOppGadZo">Super Power Bank</a>, a nifty portable Lithium battery pack with two USB ports for charging devices on the go. The Super Power Bank has a 6600 mAh battery with two USB ports for charging devices; one providing 1.0 A, the other 2.1 A. He asked me a question: do my devices charge faster on the 2.1 A port? Down the rabbit hole I flew.</p>
<p><span id="more-2156"></span>Here is a disorienting upside-down shot of the Super Power Bank so you can read the technical details:</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/Super-Power-Bank.jpg"><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/Super-Power-Bank-1024x768.jpg" alt="Super Power Bank" width="500" height="375" class="aligncenter size-large wp-image-2161" /></a></p>
<p>I knew I could answer Soren&#8217;s question by simply measuring the recharge time between known points (say, 10% to full) on first one port, then the other. But where&#8217;s the fun in that? I wanted to understand why and how some USB devices exceed the 500 mA limitation of USB 2.0 ports.</p>
<p>So, here is the USB test harness I built:</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/usb_tap_1.jpg"><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/usb_tap_1-1024x768.jpg" alt="usb_tap_1" width="500" height="375" class="aligncenter size-large wp-image-2158" /></a></p>
<p>This is a 50x35x20 mm project box from Maplin. Through it runs a common 1m USB type A male to type A female cable, typically called a &#8220;USB extension lead&#8221;. In the project box I&#8217;ve installed six <a href="http://uk.rs-online.com/web/p/2-mm-test-plugs-sockets/1029276/">2mm test sockets</a> in various colours. I cut and soldered the wires to the test sockets, and maintained the earth connection between the outer plug shields. These are wired as so:</p>
<table border=0 cellpadding=3>
<tr>
<th>USB pin</th>
<th>Wire colour</th>
<th>Socket colour</th>
<th>Name</th>
<th>Description</th>
<th>Notes</th>
</tr>
<tr>
<td>1</td>
<td>Red</td>
<td>Red</td>
<td>VCC</td>
<td>Power +5 V</td>
<td>Two sockets in series</td>
</tr>
<tr>
<td>2</td>
<td>White</td>
<td>Yellow</td>
<td>D-</td>
<td>Data -</td>
<td>One socket in parallel</td>
</tr>
<tr>
<td>3</td>
<td>Green</td>
<td>Blue</td>
<td>D+</td>
<td>Data +</td>
<td>One socket in parallel</td>
</tr>
<tr>
<td>4</td>
<td>Black</td>
<td>Black</td>
<td>GND</td>
<td>Power Ground</td>
<td>Two sockets in series</td>
</tr>
</table>
<p></p>
<p>I&#8217;m interested in measuring the current and voltage of the power pins, so there are two sockets in series for each line. To measure current you must insert your multimeter in series. However, these series sockets interrupt the power flow, so to actually use the cable I must bridge the gap with a test lead or multimeter. I&#8217;m only interested in voltage of the data pins, so there is one socket for each line, in parallel. I&#8217;m also interested in shorting the data pins, as some USB devices apparently take that as a sign they can draw more than 500 mA (PC motherboard data pins would never be shorted). To do this, I can use the blue test lead to bridge between the yellow and blue sockets.</p>
<p>Here is the USB test harness in use, not charging a bluetooth keyboard (it has a full battery):</p>
<p><a href="http://www.tolaris.com/blog/wp-content/uploads/2013/02/usb_tap_2.jpg"><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/02/usb_tap_2.jpg" alt="usb_tap_2" width="1632" height="1224" class="aligncenter size-full wp-image-2159" /></a></p>
<p>Testing with my multimeter, I learned that the Super Power Bank does not short the data pins. Instead, it outputs different DC voltages. Both ports output 0.64 V on the data pins when idle. Under load, the 1.0 A port outputs 1.92 V, and the 2.1 A port outputs 2.35 V. There doesn&#8217;t appear to be a standard for this, although <a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus#Charging_ports_and_accessory_charging_adapters">Wikipedia has some ideas</a>. The Super Power Bank doesn&#8217;t actually begin charging a device until you press its charge button. The power pins, as expected, show 0 V when not charging, and +5 VDC after you press the button.</p>
<p>When you connect a USB device to charge and press the button, the device seems to negotiate for a moment before drawing current. My HTC Desire HD draws about 0.2 A at first, then if it needs charging this jumps to 0.45 A. This is regardless of which port (1.0 or 2.1 A) I use. If the data pins are shorted, however, it instead draws 0.54-0.58 A.</p>
<p>With the help of <a href="http://hoppycollie.com/">Travis</a>, I tested various Android devices charging behaviours. All devices had at least partially discharged batteries. All results show Amperes at 5 VDC, as measured by my multimeter&#8217;s inline 10A circuit. Tests were performed on each port of the Super Power Bank, with data pins either normal or shorted.</p>
<p><!--</p>
<p>http://tablegen.nfshost.com/index.py?numrows_previous=8&#038;numcols_previous=6&#038;numrows=8&#038;numcols=6&#038;cell=Device&#038;cell=Manufacturer&#038;cell=1.0+A%2C+normal+data&#038;cell=1.0+A%2C+data+shorted&#038;cell=2.1+A%2C+normal+data&#038;cell=2.1+A%2C+data+shorted&#038;cell=Desire+HD&#038;cell=HTC&#038;cell=0.45&#038;cell=0.58&#038;cell=0.45&#038;cell=0.54&#038;cell=Galaxy+Nexus&#038;cell=Google%2FSamsung&#038;cell=0.44&#038;cell=0.58&#038;cell=0.44&#038;cell=0.58&#038;cell=Nexus+S&#038;cell=Google%2FSamsung&#038;cell=0.45&#038;cell=0.50&#038;cell=0.45&#038;cell=0.55&#038;cell=Nexus+7&#038;cell=Google%2FAsus&#038;cell=0.43&#038;cell=0.43&#038;cell=0.43&#038;cell=0.43&#038;cell=Nexus+4&#038;cell=Google%2FLG&#038;cell=0.50&#038;cell=0.50&#038;cell=0.55&#038;cell=0.55&#038;cell=Nook+Color&#038;cell=Barnes+%26+Noble&#038;cell=0.46&#038;cell=0.46&#038;cell=0.46&#038;cell=0.46&#038;cell=iPhone+5&#038;cell=Apple&#038;cell=0.52&#038;cell=0.52&#038;cell=0.57&#038;cell=0.57&#038;headers=1&#038;gentable=Generate+HTML+for+Table</p>
<p>--></p>
<p><em>Update 2013-02-11:</em> Gathered Nook Color and iPhone 5 data.</p>
<table border=0 cellpadding=3>
<tbody>
    <!-- Results table headers --></p>
<tr>
<th>Device</th>
<th>Manufacturer</th>
<th>1.0 A, normal data</th>
<th>1.0 A, data shorted</th>
<th>2.1 A, normal data</th>
<th>2.1 A, data shorted</th>
</tr>
<tr>
<td>Desire HD</td>
<td>HTC</td>
<td>0.45</td>
<td>0.58</td>
<td>0.45</td>
<td>0.54</td>
</tr>
<tr>
<td>Galaxy Nexus</td>
<td>Google/Samsung</td>
<td>0.44</td>
<td>0.58</td>
<td>0.44</td>
<td>0.58</td>
</tr>
<tr>
<td>Nexus S</td>
<td>Google/Samsung</td>
<td>0.45</td>
<td>0.50</td>
<td>0.45</td>
<td>0.55</td>
</tr>
<tr>
<td>Nexus 7</td>
<td>Google/Asus</td>
<td>0.43</td>
<td>0.43</td>
<td>0.43</td>
<td>0.43</td>
</tr>
<tr>
<td>Nexus 4</td>
<td>Google/LG</td>
<td>0.50</td>
<td>0.50</td>
<td>0.55</td>
<td>0.55</td>
</tr>
<tr>
<td>Nook Color</td>
<td>Barnes &#038; Noble</td>
<td>0.46</td>
<td>0.46</td>
<td>0.46</td>
<td>0.46</td>
</tr>
<tr>
<td>iPhone 5</td>
<td>Apple</td>
<td>0.52</td>
<td>0.52</td>
<td>0.57</td>
<td>0.57</td>
</tr>
</tbody>
</table>
<p></p>
<p>Conclusions:</p>
<ul>
<li>Some devices (Nexus 7, Nook Color) don&#8217;t exceed 500 mA even if the port indicates it can provide more.</li>
<li>The Desire HD, Galaxy Nexus, and Nexus S all accept shorted data pins as permission to draw more than 500 mA.</li>
<li>The Nexus 4 and iPhone 5 accept data pin voltage of at least 2.35 V as permission to draw more than 500 mA.</li>
</ul>
<p>I gave the USB test harness to Soren today, at the moment this post is scheduled to appear on my blog. Surprise, Soren! Thanks for the cool toy and for the inspiration to <a href="http://www.youtube.com/watch?v=Y6ljFaKRTrI">do science</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/02/08/science-project-measuring-usb-current/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Non-localhost dnsmasq breaks DNS on Ubuntu 12.10</title>
		<link>http://www.tolaris.com/2013/02/01/non-localhost-dnsmasq-breaks-dns-on-ubuntu-12-10/</link>
		<comments>http://www.tolaris.com/2013/02/01/non-localhost-dnsmasq-breaks-dns-on-ubuntu-12-10/#comments</comments>
		<pubDate>Fri, 01 Feb 2013 08:44:51 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dnsmasq]]></category>
		<category><![CDATA[linuxmint]]></category>
		<category><![CDATA[quantal]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2122</guid>
		<description><![CDATA[I recently upgraded to Linux Mint 14 &#8220;nadia&#8221;, which is based on Ubuntu 12.10. I use dnsmasq as a local DHCP server and DNS resolver for virtual machines. Installing dnsmasq on Linux Mint 14 broke host DNS resolution. The issue is easily reproducible: stop dnsmasq, DNS stops working. Start dnsmasq, and it works again. The [...]]]></description>
				<content:encoded><![CDATA[<p>I recently upgraded to Linux Mint 14 &#8220;nadia&#8221;, which is based on Ubuntu 12.10. I use dnsmasq as a local DHCP server and DNS resolver for <a href="http://www.tolaris.com/2012/05/16/using-host-networking-and-nat-with-virtualbox-v2-0/">virtual machines</a>. Installing dnsmasq on Linux Mint 14 broke host DNS resolution. The issue is easily reproducible: stop dnsmasq, DNS stops working. Start dnsmasq, and it works again.</p>
<p><span id="more-2122"></span><strong>The Solution</strong></p>
<p>For the &#8220;tl;dr&#8221; crowd, here&#8217;s the solution. Add the following undocumented variable to /etc/default/dnsmasq:</p>
<p></p><pre class="crayon-plain-tag">DNSMASQ_EXCEPT=lo</pre><p></p>
<p>And restart dnsmasq:</p>
<p></p><pre class="crayon-plain-tag">service dnsmasq restart</pre><p></p>
<p><strong>The Problem</strong></p>
<p>Using your own dnsmasq server has been difficult since Ubuntu 12.04, because <a href="http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/">network manager runs a local dnsmasq resolver</a> on localhost. The solution, to add <code>bind-interfaces</code> to dnsmasq.conf, is <a href="http://www.tolaris.com/2012/05/16/using-host-networking-and-nat-with-virtualbox-v2-0/#bind-interfaces">documented here</a>. As of Ubuntu 12.10, this is now done by default in <code>/etc/dnsmasq.d/network-manager</code>.</p>
<p>However, Ubuntu 12.10 introduces a new problem. The <code>/etc/init.dnsmasq</code> script registers 127.0.0.1 as a resolver with resolvconf, which manages the DNS server list in /etc/resolv.conf. It does this <em>regardless</em> of the configured listening interfaces in the dnsmasq configuration. So even if you aren&#8217;t listening on localhost, it&#8217;ll tell resolvconf that it is. This wasn&#8217;t a problem before, since the dnsmasq instance started by network manager listens on 127.0.0.1. But as of Ubuntu 12.10, network manager&#8217;s dnsmasq listens on 127.0.1.1. So when then dnsmasq init script starts, it tells resolvconf that a DNS server exists on 127.0.0.1 <em>even though it doesn&#8217;t</em>. Then resolvconf chooses that as the best choice resolver, and <strong>poof</strong> &#8211; no DNS.</p>
<p>This is only a problem if you run an instance of dnsmasq which does not listen on localhost, as I describe in <a href="http://www.tolaris.com/2012/05/16/using-host-networking-and-nat-with-virtualbox-v2-0/">Using host networking and NAT with VirtualBox, v2.0</a>.</p>
<p>The best solution is to add real support for updating resolvconf to dnsmasq. Barring that, someone should fix /etc/init.d/dnsmasq to be more careful about what it tells resolvconf. However, my solution works just fine. It forces /etc/init.d/dnsmasq not to inform resolvconf that it is available to answer DNS on localhost. This keeps DHCP and DNS for your virtual machines separate from DNS for the host operating system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/02/01/non-localhost-dnsmasq-breaks-dns-on-ubuntu-12-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running nmap as an unprivileged user</title>
		<link>http://www.tolaris.com/2013/01/24/running-nmap-as-an-unprivileged-user/</link>
		<comments>http://www.tolaris.com/2013/01/24/running-nmap-as-an-unprivileged-user/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 20:59:53 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2076</guid>
		<description><![CDATA[In another post, I talked about running Wireshark and other sniffing programs as an unprivileged user. You can do the same with Nmap, but it&#8217;s a little more tricky. WARNING: This is dangerous. The Nmap Scripting Engine (NSE) allows scripts to sniff the network, change firewall roules and interface configuration, or exploit vulnerabilities including on [...]]]></description>
				<content:encoded><![CDATA[<p>In <a href="http://www.tolaris.com/2013/01/23/sniffing-with-wireshark-as-an-unprivileged-user/">another post</a>, I talked about running Wireshark and other sniffing programs as an unprivileged user. You can do the same with <a href="http://nmap.org/">Nmap</a>, but it&#8217;s a little more tricky.</p>
<p><strong>WARNING:</strong> This is dangerous. The Nmap Scripting Engine (NSE) allows scripts to sniff the network, change firewall roules and interface configuration, or exploit vulnerabilities including on localhost. It&#8217;s possible, especially with elevated capabilities, for a clever person to use Nmap and NSE to escalate to full root privileges. If you do not understand these risks, do not do this.</p>
<p><span id="more-2076"></span>Nmap can perform much of its functionality as a normal user, so it checks if it has permissions to perform certain actions before falling back to safer behaviours. For instance, performing a TCP SYN scan (<code>-sS</code>) requires opening raw sockets. If this fails and if the user didn&#8217;t explicitly specify <code>-sS</code>, Nmap falls back to a normal TCP connect scan (<code>-sT</code>).</p>
<p>You can configure Nmap to use Linux <a href="http://linux.die.net/man/7/capabilities">capabilities</a> just like Wireshark. However in certain circumstances (such as specifying a source port less than 1024), Nmap also needs CAP_NET_BIND_SERVICE.</p>
<p></p><pre class="crayon-plain-tag">sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip /usr/bin/nmap</pre><p></p>
<p>Some NSE scripts may require additional capabilities, but these three should suffice.</p>
<p>You must explicitly tell Nmap that it has these capabilities:</p>
<p></p><pre class="crayon-plain-tag">nmap --privileged -sS 192.168.0.1</pre><p></p>
<p>You can save the extra typing by setting the NMAP_PRIVILEGED environmental variable.</p>
<p></p><pre class="crayon-plain-tag">export NMAP_PRIVILEGED=&quot;&quot;
nmap -sS 192.168.0.1</pre><p></p>
<p>There are many places to do this. Add the export line to one of the following:</p>
<ol>
<li><code>~/.bashrc</code>, for bash</li>
<li><code>~/.profile</code>, for most shells as well as bash</li>
<li><code>~/.xsessionrc</code>, for most graphical environments</li>
<li><code>~/.gnomerc</code>, for GNOME only</li>
</ol>
<p>I prefer <code>.xsessionrc</code>, since it will be inherited by any program I launch, including terminals and shells. However, some versions of LightDM, the login manager used by Ubuntu since 11.10, don&#8217;t source this file. An easy workaround for those users is to <del>upgrade to Linux Mint</del> use <code>.gnomerc</code> instead.</p>
<p>As with <a href="http://www.tolaris.com/2013/01/23/sniffing-with-wireshark-as-an-unprivileged-user/">other programs</a> using elevated capabilities, you should restrict Nmap to a certain group:</p>
<p></p><pre class="crayon-plain-tag">chgrp adm /usr/bin/nmap
chmod 750 /usr/bin/nmap</pre><p></p>
<p>Unfortunately Zenmap, Nmap&#8217;s GUI, ignores the NMAP_PRIVILEGED environment variable. On startup, it will complain that &#8220;You are trying to run Zenmap with a non-root user! Some Nmap options need root privileges to work.&#8221;</p>
<p><img src="http://www.tolaris.com/blog/wp-content/uploads/2013/01/zenmap_non_root_warning.png" alt="Zenmap warning non-root users on startup." width="399" height="178" class="aligncenter size-full wp-image-2064" /></p>
<p>If you used the .xsessionrc or .gnomerc methods above, Zenmap and the Nmap instances it calls will inherit NMAP_PRIVILEGED variable. So you can dismiss the annoying warning and use Zenmap as if you are the root user. I submitted a <a href="http://www.tolaris.com/blog/wp-content/uploads/2013/01/NMAP_PRIVILEGED.patch">patch</a> to nmap-dev, which was accepted and will be available in a release after Nmap 6.25. If your release doesn&#8217;t have this fixed yet, apply it with:</p>
<p></p><pre class="crayon-plain-tag">wget -q http://www.tolaris.com/blog/wp-content/uploads/2013/01/NMAP_PRIVILEGED.patch -O- \
| sudo patch /usr/share/pyshared/zenmapGUI/App.py</pre><p></p>
<p>You can now run Nmap and Zenmap as an unprivileged user without warnings.</p>
<p><em>Update 2013-01-29:</em> At Fyodor&#8217;s request, I&#8217;ve rewritten this guide for <a href="https://secwiki.org/w/Running_nmap_as_an_unprivileged_user">Secwiki.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/01/24/running-nmap-as-an-unprivileged-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sniffing with Wireshark as an unprivileged user</title>
		<link>http://www.tolaris.com/2013/01/23/sniffing-with-wireshark-as-an-unprivileged-user/</link>
		<comments>http://www.tolaris.com/2013/01/23/sniffing-with-wireshark-as-an-unprivileged-user/#comments</comments>
		<pubDate>Wed, 23 Jan 2013 20:20:35 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=2061</guid>
		<description><![CDATA[The Wireshark team has long warned us not to run Wireshark as root. However, since Wireshark 1.4 (between Ubuntu 10.04 and 12.04), they&#8217;ve raised the stakes. Wireshark no longer loads all its plugins and protocol dissectors when run by root, and it displays warning messages on the CLI and the GUI: [crayon-51a06ee237220/] Although I&#8217;ve long [...]]]></description>
				<content:encoded><![CDATA[<p>The Wireshark team has long <a href="http://wiki.wireshark.org/Security">warned us</a> not to run Wireshark as root. However, since Wireshark 1.4 (between Ubuntu 10.04 and 12.04), they&#8217;ve <a href="https://bugs.launchpad.net/ubuntu/+source/wireshark/+bug/780543">raised the stakes</a>. Wireshark no longer loads all its plugins and protocol dissectors when run by root, and it displays warning messages on the CLI and the GUI:</p>
<p></p><pre class="crayon-plain-tag">root@laptop:~# tshark 
tshark: Lua: Error during loading:
 [string &quot;/usr/share/wireshark/init.lua&quot;]:45: dofile has been disabled
Running as user &quot;root&quot; and group &quot;root&quot;. This could be dangerous.</pre><p></p>
<p><span id="more-2061"></span>Although I&#8217;ve long been aware of the dangers of running Wireshark as root, the convenience has outweighed the danger until now. The annoyance of this new output finally prompted me to act. The solution is to use Linux <a href="http://packetlife.net/blog/2010/mar/19/sniffing-wireshark-non-root-user/">capabilities</a> to <a href="http://wiki.wireshark.org/CaptureSetup/CapturePrivileges">allow Wireshark to sniff</a> without using any of root&#8217;s other permissions.</p>
<p>There are plenty of instructions out there telling people how to do this. Ubuntu users (since 10.04) have a very <a href="http://askubuntu.com/questions/74059/how-do-i-run-wireshark-with-root-privileges">easy method</a>. All solutions involve granting the CAP_NET_RAW and CAP_NET_ADMIN capabilities to any binary you want to allow to sniff:</p>
<p></p><pre class="crayon-plain-tag">sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/dumpcap</pre><p></p>
<p>However, this allows all local users to sniff. On a normal workstation, that&#8217;s probably fine. But if you want to be more secure, you can restrict access to <code>/usr/bin/dumpcap</code> to certain groups. &#8220;adm&#8221; is a good choice for most distributions, as console users are generally members. Alternately, consider the group &#8220;sudo&#8221; (Ubuntu 12.04 or later), &#8220;admin&#8221; (Ubuntu before 12.04), or &#8220;wheel&#8221; (Red Hat systems).</p>
<p></p><pre class="crayon-plain-tag">sudo chgrp adm /usr/bin/dumpcap
sudo chmod 750 /usr/bin/dumpcap</pre><p></p>
<p>In addition to wireshark, there are a number of other programs that I like to run as an unprivileged user. For my notes and yours:</p>
<p></p><pre class="crayon-plain-tag">for i in `which dumpcap iftop ngrep tcpdump tcptraceroute traceroute.db` ; do
sudo setcap cap_net_raw,cap_net_admin+eip $i
done</pre><p></p>
<p><a href="http://nmap.org/">nmap</a> is a special case. More on that <del datetime="2013-04-08T13:58:11+00:00">later</del> <a href="http://www.tolaris.com/2013/01/24/running-nmap-as-an-unprivileged-user/">now</a>.</p>
<p>The only problem I&#8217;ve found with this method is that unprivileged users still cannot sniff USB packets. For now only root can do that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2013/01/23/sniffing-with-wireshark-as-an-unprivileged-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
