<?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>Gerrit&#039;s work in progress &#187; linux</title>
	<atom:link href="http://blog.wessendorf.org/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.wessendorf.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 09 Jun 2011 01:57:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Mounting NAS with Read-Write Permissions</title>
		<link>http://blog.wessendorf.org/2009/06/mounting-nas-with-read-write-permissions/</link>
		<comments>http://blog.wessendorf.org/2009/06/mounting-nas-with-read-write-permissions/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 03:01:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=871</guid>
		<description><![CDATA[When I browsed my shared folders on the Lacie Ethernet Disk I noticed that I didn&#8217;t have any write access in Ubuntu, even though I explicitly gave read/write access to the NAS users. As I was never asked for a password I was quickly able to conclude that I had to provide username and password [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop w">W</span>hen I browsed my shared folders on the Lacie Ethernet Disk I noticed that I didn&#8217;t have any write access in Ubuntu, even though I explicitly gave read/write access to the NAS users. As I was never asked for a password I was quickly able to conclude that I had to provide username and password in order to gain full access to my shared folders.</p>
<p>So I entered a url like <tt>smb://username:password@ip-address/path/</tt> which worked in other situations before, but Nautilus the file browser showed me a new dialog to enter a domain (Windows) and password. No matter what I entered there, it didn&#8217;t appear to work. And I&#8217;m not sure how to remove this dialog box.</p>
<p>One way to work around this behavior is to mount the Samba/CIFS share on the command line. (CIFS is the <em>Common Internet File System</em> and replaces <tt>sambafs</tt>.) First I had to make sure that a non-root user has the permissions to mount a file system. I created a new group &#8216;samba&#8217; and added myself to it.</p>
<pre class="brush:bash;light:true;">
sudo groupadd samba
sudo adduser gerrit samba
sudo visudo
</pre>
<p>And added a new line in the &#8220;group&#8221; section:</p>
<pre class="brush:bash;">
## Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%samba   ALL=(ALL) /bin/mount,/bin/umount,/sbin/mount.cifs,/sbin/umount.cifs
</pre>
<p>All set, now I could create a folder for my Samba share <code>mkdir ~/mnt</code> and mount:</p>
<pre class="brush:bash;light:true;">
sudo mount -t cifs //ip-address/path ~/mnt -o username=gerrit,password=xxxxxx,noexec
</pre>
<p>More details can be found in the Ubuntu help on <a href="https://help.ubuntu.com/community/SettingUpSamba">Setting up Samba</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2009/06/mounting-nas-with-read-write-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music Networking with XMMS2, Icecast2 and Last.fm</title>
		<link>http://blog.wessendorf.org/2009/06/music-networking-with-xmms2-icecast2-and-lastfm/</link>
		<comments>http://blog.wessendorf.org/2009/06/music-networking-with-xmms2-icecast2-and-lastfm/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 05:37:54 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[icecast2]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[lifestream]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xmms2]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=825</guid>
		<description><![CDATA[In the last few months I haven&#8217;t found much time to listen to music, but I decided this needs to change and I should finally dust off my old music library. About two years ago I signed up for last.fm, the social music network that makes it easy to discover new music and connect with [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop i">I</span>n the last few months I haven&#8217;t found much time to listen to music, but I decided this needs to change and I should finally dust off my old music library. About two years ago I signed up for <a href="http://www.last.fm/user/celeph"><strong>last.fm</strong></a>, the social music network that makes it easy to discover new music and connect with other music fans. I used their software on my Windows box, but I rarely work with this system anymore. After adding several other computers and laptops to the household I didn&#8217;t bother with shared music folders and last-fm anymore. This was then.</p>
<p>Today I&#8217;m trying to setup a server that makes my music available to any of my computers and operating systems in the LAN, and possibly even outside the local network. At the same time I would like to add last.fm again, however, not linked to each individual player, but only once, to the music server.</p>
<p><img src="http://blog.wessendorf.org/wp-content/uploads/2009/06/musicnetwork.png" alt="musicnetwork" title="musicnetwork" width="425" height="445" class="aligncenter size-full wp-image-846" /></p>
<p>I stored my music files on an external <a href="http://www.lacie.com/products/product.htm?pid=10994"><strong>network drive</strong></a>. This music folder is a <a href="http://wiki.samba.org/index.php/Main_Page">Samba</a> share and accessible from other computers on the network.</p>
<p>VLC is known for its network streaming features and I wrote a little about it back in <a href="http://blog.wessendorf.org/software/videolan/">May</a>. While I use it occasionally to stream videos from one computer to another I was looking for a solution that could work better as a permanent configuration, well-suited as a music library. That&#8217;s how I stumbled upon the <em>X-platform Music Multiplexing System 2</em>, <a href="http://wiki.xmms2.xmms.se/wiki/Main_Page"><strong>XMMS2</strong></a>.<span id="more-825"></span></p>
<h3>XMMS2</h3>
<p>XMMS2 is a client-server music platform which can be controlled via command line but also through a variety of other interfaces available on Linux, Windows as well as Mac. It allows you to play and manage your music collection on a local server or across the network. It is free, open-source and extensible with a growing number of plugins. </p>
<p>On my Ubuntu system, it was just a matter of seconds to install XMMS2. Ubuntu&#8217;s repositories already include everything you might need. I browsed the Synaptic package manager for&#8230; </p>
<ul>
<li><tt>xmms2</tt>, the core application with server and command line client interface.</li>
<li><tt>xmms2-plugin-smb</tt>, a Samba transport extension I needed to get access to my music share.</li>
<li><tt>xmms2-scrobbler</tt>, used to submit data to Last.fm</li>
<li><tt>esperanza</tt>, a simple player, xmms2-client and graphical user interface</li>
<li><tt>xmms2-plugin-flac</tt>, to support the flac-format</li>
<li><tt>xmms2-plugin-mp4</tt>, to support the mp4-format</li>
</ul>
<p>XMMS2&#8242;s command line interface is very easy to use thanks to its legible commands and parameters, just to mention a few:</p>
<ul>
<li>To start the server: <code>xmms2-launcher</code></li>
<li>To quit the server: <code>xmms2 quit</code></li>
<li>To add some music: <code>xmms2 add /home/gerrit/Music/track.mp3</code></li>
<li>To add a folder recursively: <code>xmms2 radd /home/gerrit/Music/electronic/</code></li>
<li>To add some music from my samba-share: <code>xmms2 add smb://username:password@edmini/music/electronic/track.mp3</code></li>
<li>To list the contents of the current playlist: <code>xmms2 list</code></li>
<li>To play: <code>xmms2 play</code></li>
<li>To stop playback: <code>xmms2 stop</code></li>
</ul>
<p>If the server is already running and you install new plugins, you may have to restart it before you can use the plugin. You can stop the server with <code>xmms2 quit</code>, or if that doesn&#8217;t work for some reason:</p>
<ol>
<li>find the process-id with  <code>ps aux | grep xmms2d</code> and</li>
<li>kill the process with <code>sudo kill processid</code>.</li>
</ol>
<p>XMMS2 makes it easy to organize music in playlists:</p>
<ul>
<li><code>xmms2 playlist list</code> lists all available playlists</li>
<li><code>xmms2 playlist create myplaylistname</code> creates a new playlist</li>
<li><code>xmms2 playlist load myplaylistname</code> loads an existing playlist</li>
<li><code>xmms2 playlist active</code> shows which playlist is currently active</li>
</ul>
<p>With a separate set of <em>media library</em> commands you can also keep track of your artists, track and album titles, cover images, etc. To display a list of related commands: <code>xmms2 mlib</code>. To search for an artist: <code>xmms2 mlib search artist:"Boards*"</code>. Standard wildcard characters like &#8216;*&#8217; and &#8216;?&#8217; are supported, too. It&#8217;s probably easier to use these mlib functions from an XMMS2 client software other than the command line. With a player like <em>Esperanza</em> you will find an easy-to-use graphical user interface for command line parameters.</p>
<p>To make the XMMS2 daemon reachable from other computers I added a tcp-socket to the configuration <code>nano ~/.config/xmms2/xmms2.conf</code></p>
<pre class="brush:bash;light:true;">
<property name="ipcsocket">unix:///tmp/xmms-ipc-gerrit;tcp://
</property>
</pre>
<p>More details on remote machines can be found in the <a href="http://wiki.xmms2.xmms.se/wiki/FAQ#How_do_I_use_clients_on_remote_machines.3F">FAQ</a>. The default port is 9667. After restarting the xmms2d daemon I was ready to test my configuration from the other computer, a Windows system.</p>
<p>I installed the Windows built of XMMS2 and Esperanza which I found <a href="http://wiki.xmms2.xmms.se/wiki/Windows">here</a>, <a href="http://xmms2.xmms.se/~puzzles/win32/">puzzle&#8217;s win32 folder</a>. I had to make sure to use the version that matches the version of my server, in this example it was <em>XMMS2-DrLecter</em>. </p>
<p>I defined the following environment variable <tt>XMMS_PATH = tcp://192.168.1.43:9667</tt> to let XMMS2 know where to find my music server.</p>
<p>The command-line version of XMMS2 works great on Windows, but I was still experiencing some problems with Esperanza (downloaded Esperanza-0.3.exe) which exited with a runtime error. Whenever I tried to launch Esperanza on Windows, the server responded with <em>&#8220;Client &#8216;Esperanza&#8217; with bad protocol version (1, not 11) connected&#8221;</em>.</p>
<p>This looked like a similar conflict I experienced with the wrong XMMS2 version before, so I looked for another version. I found the DrLecter built Esperanza4-DrL.7z <a href="http://www.schrijnen.nl/auke/">here</a>. This version works great.</p>
<p><img src="http://blog.wessendorf.org/wp-content/uploads/2009/06/esperanzawin.png" alt="Esperanza" title="Esperanza" width="448" height="286" class="aligncenter size-full wp-image-857" /></p>
<p>Now I was ready to play, stop, and control my XMMS2 daemon from my remote computers, may it run Windows or Ubuntu. However, this configuration didn&#8217;t actually stream music from my server to the remote machine. It only served as a channel to remote control the server&#8217;s playlist. The music was still played nowhere but on the server system. </p>
<h3>Icecast2</h3>
<p>Icecast2 is a streaming server, a package that will allow you to setup a simple Internet radio station. It, too, is readily available in Ubuntu&#8217;s repository and can be installed via Synaptic. After installation I updated two configuration files: <code>sudo nano /etc/icecast2/icecast.xml</code></p>
<p>There I defined some passwords where the default was marked with &#8216;<em>hackme</em>&#8216;. I also changed the ports to 9600/9601. No particular reason, other than having the Icecast2 ports relatively close to the XMMS2 default port. You can choose any port there. More details in the <a href="http://www.icecast.org/docs/icecast-2.3.1/icecast2_basicsetup.html">basic setup help</a>. I left all the other settings alone and edited <code>sudo nano /etc/default/icecast2</code> to set <tt>ENABLE=true</tt>. After that I could start Icecast2 with <code>/etc/init.d/icecast2 start</code>.</p>
<p>The Icecast admin-page should now show up with the url <tt>http://localhost:9600</tt>. But there still is no music to stream. In the next step I linked XMMS2 to Icecast, using the&#8230; </p>
<h3>xmms2-plugin-ices</h3>
<p>As part of the Ubuntu repository it was installed in a matter of a few seconds. It needed to be configured in the <em>ices</em> section of <code>nano ~/.config/xmms2/xmms2.conf</code>.</p>
<p>Make sure you stop the daemon before you make any changes, otherwise they might not be visible next time you restart. If you can&#8217;t find an <em>ices</em> section after a fresh installation, you can let XMMS2 and the plugin set a default section up for you. Try restarting the daemon. In the <em>ices</em> section I just set the password and portnumber (9600) to match what I defined for Icecast2 earlier. See also the <a href="http://wiki.xmms2.xmms.se/wiki/Using_ICES_Output">XMMS2 wiki</a>.</p>
<p>This didn&#8217;t want to work in the beginning. I received error messages about insufficient permissions. I think this was caused by the fact that XMMS2 and the plugin both ran as <em>gerrit</em>, Icecast2, however, as <em>root</em>. To solve this problem I copied the Icecast configuration (icecast.xml and admin, web-folders) to my home-folder, and changed the owner of all these files.</p>
<pre class="brush:bash;light:true;">
chown -hR gerrit ~/.icecast
sudo nano /etc/default/icecast2
</pre>
<p>Now I had to point the daemon to the new folder:</p>
<pre class="brush:bash;">
CONFIGFILE="/home/gerrit/.icecast/icecast.xml"

# Name or ID of the user and group the daemon should run under
USERID=gerrit
GROUPID=gerrit
</pre>
<p>Almost done. There still was a warning about the error- and access logfiles in <tt>/var/log/icecast2/</tt>. To solve this I had to change the owner of the log-files <code>chown gerrit /var/log/icecast2/*</code> and restart Icecast2 <code>/etc/init.d/icecast2 start</code></p>
<p>Now I could set the output plugin to <em>ices</em> and start the playback with</p>
<pre class="brush:bash;light:true;">
xmms2 config output.plugin ices
xmms2 play
</pre>
<p>The radio stream is reachable with the following address for favorite media player: <tt>http://localhost:9600/stream.ogg.m3u</tt>, or <tt>http://192.168.1.43:9600/stream.ogg.m3u</tt></p>
<p><img src="http://blog.wessendorf.org/wp-content/uploads/2009/06/vlcwin.png" alt="VLC" title="VLC" width="447" height="146" class="alignnone size-full wp-image-860" /></p>
<p>Having turned the output to Icecast, you won&#8217;t be able to hear any music on the server, unless you open the stream. If you want to return to the standard sound output, use the following command:</p>
<pre class="brush:bash;light:true;">xmms2 config output.plugin alsa</pre>
<p>At this time, both output plugins can&#8217;t be activated together to hear music both on server and remote computer. You can only hear music if you connect to the Icecast server. The <a href="http://wiki.xmms2.xmms.se/wiki/FAQ#Why_can.27t_I_use_multiple_output_plugins_at_the_same_time.3F_I_want_to_listen_to_music_and_act_as_a_stream_source">XMMS2 FAQ</a> explains:</p>
<blockquote><p>The possibility of multiple outputs involves a nontrivial solution. The biggest problem is keeping all of the outputs in sync with each other. Each output must pull audio data from a buffer following the last decoder or effect plugin in the xform chain at a rate determined by the samplerate of the underlying device. For example, streaming audio will have an exact bitrate since no actual audio hardware is used for obtaining audio data, but a soundcard&#8217;s samplerate may vary by a few Hertz with temperature, components, and voltage. We end up with an ever growing buffer (if the buffer holds data longer for slower outputs) or dropped samples (if the data is destroyed after the faster output has read it). </p>
<p>    There are also smaller issues like that the xmms2 daemon takes into account the delays caused by the output plugin when showing the current playtime, but if there are multiple outputs these delays can vary. So one of them would have to be defined as a primary output to keep this feature in use. </p>
<p>    Current plan to resolve the aforementioned problem with concurrent output and stream sourcing is to make it possible for effect plugins to keep a constant input format and stay alive through song changes. That way they can draw the data from the stream itself and it won&#8217;t have synchronizing problems because the whole chain is still simple and one-dimensional.<span class="end"/></p></blockquote>
<p>The current configuration works great now. I have a server that provides a stream of music. This stream is accessible from all other computers, and I am able to control this Internet radio stream using XMMS2 and Esperanza if needed, from any other computer running Linux or Windows. </p>
<p>At this point I could probably stop and let it be, but I want to integrate some web-services and social media tools. While I&#8217;m mostly just experimenting with a new range of Internet applications, I&#8217;m also interested in sharing my music favorites and creating some personal charts of my highlights, the most frequently played tracks, the most important artists, etc. A great tool to link my local music adventures to the web 2.0 world is last.fm.</p>
<h3>Last.fm</h3>
<p><img src="http://blog.wessendorf.org/wp-content/uploads/2009/06/lastfm.png" alt="Last.fm" title="Last.fm" width="442" height="272" class="aligncenter size-full wp-image-862" /></p>
<p>To make my XMMS2/Icecast2 server talk with Last.fm I installed the <em>xmms2-scrobbler</em> plugin&#8230;as usual, from the standard Ubuntu repository. To configure this plugin I followed the instructions I found at <a href="http://sudosys.be/?q=xmms2-scrobbler">sudosys</a>.</p>
<p>The XMMS2 configuration is stored in <tt>~/.config/xmms2</tt>, but the plugin tries to read it in <tt>~/.xmms2</tt>. To work around this, I created a symlink <code>ln -s ~/.config/xmms2 ~/.xmms2</code></p>
<p>Next, I created a new directory for the plugin configuration and created a config file with my credentials:</p>
<pre class="brush:bash;light:true;">
mkdir -p ~/.config/xmms2/clients/xmms2-scrobbler
nano ~/.config/xmms2/clients/xmms2-scrobbler/config
</pre>
<p>added</p>
<pre class="brush:bash;light:true;">
user: MY_LASTFM_USER
password: MY_LASTFM_PASS
</pre>
<p>I created another symlink for the actual xmms2-scrobbler script, so it gets executed when I launch XMMS2.</p>
<pre class="brush:bash;light:true;">
ln -s /usr/bin/xmms2-scrobbler ~/.config/xmms2/startup.d/
</pre>
<p>After restarting XMMS2 your music will show up on your last.fm profile.</p>
<p><img src="http://blog.wessendorf.org/wp-content/uploads/2009/06/facebook.png" alt="Facebook" title="Facebook" width="207" height="263" class="alignright size-full wp-image-863" />Continuing from there you can expand your network by adding other services that access last.fm for your music statistics. On Facebook you can use a <a href="http://apps.new.facebook.com/listening/">last.fm application</a> to display your charts on your page or profile.</p>
<p>You can also integrate your last.fm data into your WordPress site with the <a href="http://www.ibegin.com/labs/wp-lifestream/">LiveStream</a> plugin. There is much more you can do, especially if you write your own applications, but this is how far my own configuration goes right now.</p>
<p>I hope you found any of these notes use- or helpful. As usual, please let me know if I forgot something or made a mistake somewhere. :]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2009/06/music-networking-with-xmms2-icecast2-and-lastfm/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Headphones with Ubuntu 9.04 and Gateway T-6345u</title>
		<link>http://blog.wessendorf.org/2009/05/headphones-with-ubuntu-904-and-gateway-t-6345u/</link>
		<comments>http://blog.wessendorf.org/2009/05/headphones-with-ubuntu-904-and-gateway-t-6345u/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:07:57 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=789</guid>
		<description><![CDATA[Ubuntu seemed to work perfectly on the Gateway T-6345u laptop model&#8230;until I plugged my headphones in and found that no sound was coming out of them. I tried a second pair and could make sure there was nothing wrong with the headphones. When I plugged them in while something was playing, I noticed that there [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop u">U</span>buntu seemed to work perfectly on the Gateway T-6345u laptop model&#8230;until I plugged my headphones in and found that no sound was coming out of them. I tried a second pair and could make sure there was nothing wrong with the headphones. When I plugged them in while something was playing, I noticed that there was some sound for a very brief split-second. I could reproduce this effect with both headphones and began to wonder if this could be a software issue.</p>
<p>So I looked around and quickly found discussions about the same or similar symptoms occurring on several releases of Ubuntu, from 8.x up to the 9.04 <em>Jaunty Jackalope</em> release I am using on this laptop. Some suggested to kill PulseAudio, but this didn&#8217;t help at all. It was most likely related to <a href="http://www.alsa-project.org/">ALSA</a>, the <em>Advanced Linux Sound Architecture</em> drivers.</p>
<p>I found <a href="http://ubuntuforums.org/showthread.php?t=806620&#038;highlight=sound+headphones">this thread</a> in the Ubuntu forums revolving around pretty much the same problem I experienced. The solution sounded pretty simple:<span id="more-789"></span></p>
<pre class="brush:bash;light:true;">
head -n 1 /proc/asound/card0/codec*
or
less /proc/asound/card0/codec#0
</pre>
<p>to find out what soundcard or chipset I&#8217;m using. For this Gateway model I got <tt>"Codec: SigmaTel STAC9205"</tt>.</p>
<pre class="brush:bash;light:true;">
zless /usr/share/doc/alsa-base/driver/ALSA-Configuration.txt.gz
</pre>
<p>and looked for the section for <tt>"Module snd-hda-intel"</tt>. In this section I was supposed to find <tt>STAC9205</tt>. I found the following models:</p>
<ul>
<li>ref           Reference board</li>
<li>dell-m42      Dell (unknown)</li>
<li>dell-m43      Dell Precision</li>
<li>dell-m44      Dell Inspiron</li>
</ul>
<pre class="brush:bash;light:true;">
sudo nano /ect/modprobe.d/alsa-base.conf
</pre>
<p>Next I had to configure alsa to use the right model. None of the entries I found fit, but I started with <em>&#8220;ref&#8221;</em>, and added the following line: </p>
<pre class="brush:bash;light:true;">
options snd-hda-intel model=ref
</pre>
<p>I restarted, but nothing changed for me. I tried dell-m42, m43, m44 and even other (Gateway related) models I found in other sections. Sometimes I would get a headphone slider and/or checkbox in the volume control dialog, sometimes not, sometimes I would get no sound at all, and I never managed to get a beep out of my headphones.</p>
<p>I tried to follow some other leads I found in the Ubuntu forums, installed tools, helpers, and libraries, but none of them made a difference. Ultimately, everything led back to alsa.</p>
<p>I downloaded and installed the latest alsa-driver:</p>
<pre class="brush:bash;light:true;">
sudo apt-get install alsaconf
sudo apt-get install alsa-base alsa-utils
sudo apt-get install build-essential linux-headers-$(uname -r)
wget ftp://ftp.alsa-project.org/pub/driver/alsa-driver-1.0.20.tar.bz2
tar -xjf alsa-driver-1.0.20.tar.bz2
cd alsa-driver-1.0.20
./configure
sudo make
sudo make install
</pre>
<p>This didn&#8217;t seem to make much of a difference, so I looked around and tried a <a href='http://blog.wessendorf.org/wp-content/uploads/2009/05/alsaupgrade-10x-rev-117.tar'>script</a> I found <a href="http://ubuntuforums.org/showthread.php?t=1046137">here</a> to download and install the latest snapshot. Again, this first didn&#8217;t seem to make much of a difference. Until I looked at the following list of models:</p>
<pre class="brush:bash;light:true;">
gedit /usr/src/Alsa-1.0.20/alsa-driver-1.0.20/alsa-kernel/Documentation/HD-Audio-Models.txt
</pre>
<p>This file reveals the following list of models for <tt>STAC9205/9254</tt>:</p>
<ul>
<li>ref		Reference board</li>
<li>dell-m42	Dell (unknown)</li>
<li>dell-m43	Dell Precision</li>
<li>dell-m44	Dell Inspiron</li>
<li>eapd		Keep EAPD on (e.g. Gateway T1616)</li>
<li>auto		BIOS setup (default)</li>
</ul>
<p>Compared to the previous version that shipped with Ubuntu, there are two new entries, <tt>eapd</tt> and <tt>auto</tt> now. The <tt>eapd</tt> (<em>external amplifier power down</em>) option looks quite promising, so back to&#8230;</p>
<pre class="brush:bash;light:true;">
sudo nano /etc/modprobe.d/alsa-base.conf
</pre>
<p>and added the following line:</p>
<pre class="brush:bash;light:true;">
options snd-hda-intel model=eapd probe_mask=1 position_fix=1
</pre>
<p>Restart and success! The headphones finally work properly. If you were having similar problems and found this blog in the attempt to find a solution, I hope these steps could help you a bit further in your quest. I can imagine that other headphone issues could perhaps be solved as well, with an alsa-upgrade and adjustments to <tt>alsa-base.conf</tt>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2009/05/headphones-with-ubuntu-904-and-gateway-t-6345u/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Accessing MySQL through SSH Tunnel</title>
		<link>http://blog.wessendorf.org/2008/06/accessing-mysql-through-ssh-tunnel/</link>
		<comments>http://blog.wessendorf.org/2008/06/accessing-mysql-through-ssh-tunnel/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 20:14:00 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=289</guid>
		<description><![CDATA[I&#8216;ve been experimenting with SSH the secure shell lately and wanted to write a little about it. When I needed to access a remote computer I used to use SSH as a simple replacement for telnet providing an encrypted channel and supporting public-key based authentication instead of plain clear-text passwords. For example: ssh gerrit@example.com ssh [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop i">I</span>&#8216;ve been experimenting with SSH the <a href="http://en.wikipedia.org/wiki/Secure_Shell">secure shell</a> lately and wanted to write a little about it. When I needed to access a remote computer I used to use SSH as a simple replacement for telnet providing an encrypted channel and supporting public-key based authentication instead of plain clear-text passwords. For example:</p>
<pre class="brush:bash;light:true;">
ssh gerrit@example.com
ssh example.com -l gerrit
</pre>
<p>I also used it to copy files through SSH with scp:</p>
<pre class="brush:bash;light:true;">
scp helloworld.txt gerrit@example.com:~/test/newhello.txt
scp gerrit@example.com:/test/newhello.txt .
</pre>
<p>Or to transfer files via sftp:</p>
<pre class="brush:bash;light:true;">
sftp gerrit@example.com
!ls
ls
mget test1.txt
mput test2.txt
</pre>
<p>But there is so much more you can do with SSH. You can also forward network traffic through SSH as a tunnel, and the possibilities really seem endless. The following command copies a directory tree through a gzipped SSH tunnel:<br />
<span id="more-289"></span></p>
<pre class="brush:bash;light:true;">
tar cf - test | ssh -C gerrit@example.com "cd ~ &amp;&amp; tar xpf -"
</pre>
<p>This command first creates a tar-file (“<tt>cf</tt>”) of test to stdout (“<tt>-</tt>”). Using SSH this stream is then gzipped (“<tt>-C</tt>”) and moved to example.com. And on the receiving end, the tar-file from stdin (“<tt>-</tt>”) is extracted with permissions to our home directory (“<tt>xpf</tt>”).</p>
<h3>Local Port Forwarding</h3>
<p>You can also forward traffic on single ports through an SSH tunnel. For example:</p>
<pre class="brush:bash;light:true;">
ssh -L 6080:example.com:80 gerrit@basement.lan
</pre>
<p class="center"><img class="frame1 alignnone size-full wp-image-135 aligncenter" title="local-forwarding1" src="http://blog.wessendorf.org/wp-content/uploads/2008/06/local-forwarding1.png" alt="Local Port Forwarding" width="424" height="107" /></p>
<p>The lan-domains are just for demonstration purposes&#8230;the hosts can be located anywhere and don’t really have to be in the LAN. With <code>netstat -ant</code> you will find that localhost or gerrit.lan is now listening on port 6080. If you load <tt>http://localhost:6080</tt> in your web-browser it will display example.com. Traffic will flow through localhost’s port 6080 through the secure tunnel (marked in red) to basement.lan. It is basement.lan who accesses  example.com on a regular, insecure channel and returns traffic back through the tunnel to localhost. This is not limited to port 80, it can also be used for IMAP, POP3, SMTP, VNC sessions or other protocols.</p>
<p>If ssh-daemon and example.com are on the same machine, you can build a tunnel as follows:</p>
<pre class="brush:bash;light:true;">
ssh -L 6080:localhost:80 example.com
</pre>
<p>In this example, localhost:80 refers to example.com&#8217;s localhost, not the localhost ssh has been launched from.</p>
<p>SSH and the client-application (lynx in the example above) don’t have to be on the same machine. SSH’s command line option <tt>-g</tt> can be used to give other computers access to gerrit.lan:6080.</p>
<pre class="brush:bash;light:true;">
ssh -g -L 6080:example.com:80 gerrit@basement.lan
</pre>
<p class="center"><img class="frame1 alignnone size-full wp-image-136 aligncenter" title="Local Port Forwarding" src="http://blog.wessendorf.org/wp-content/uploads/2008/06/local-forwarding2.png" alt="" width="424" height="201" /></p>
<p>Alice.lan will now be able to access example.com through gerrit.lan and basement.lan.</p>
<h3>Remote Port Forwarding</h3>
<pre class="brush:bash;light:true;">
ssh -R 6080:localhost:80 gerrit@basement.lan
</pre>
<p class="center"><img class="frame1 alignnone size-full wp-image-134 aligncenter" title="Remote Port Forwarding" src="http://blog.wessendorf.org/wp-content/uploads/2008/06/remote-forwarding.png" alt="" width="424" height="111" /></p>
<p>Remote port forwarding is similar to local port forwarding, but works in the opposite direction. Instead of securing the channel between web-client and ssh-daemon, you are securing the channel between web-server and ssh-daemon here. All traffic between web-server on gerrit.lan and the ssh-daemon on basement.lan is secure, the web-client accesses port 6080 on basement.lan, through the regular insecure channel. This can be used to connect a remote intranet-server with the local network. If you can&#8217;t connect, you might have to add <tt>GatewayPorts yes</tt> to /etc/ssh/sshd_config on basement.lan.</p>
<h3>MySQL</h3>
<p>All these tunneling and forwarding methods can be chained together and combined in a countless number of ways across a countless number of hosts that would really exceed the scope of this document.</p>
<p>Webhosting providers generally allow access to MySQL databases from localhost only. Your webpages are allowed to access them, and you can use tools like PHPMyAdmin to do maintenance, but for security reasons they can&#8217;t be accessed directly from external hosts. Sometimes you may need direct access to a database, for example if you want to run reports from another application, data-mining scripts, statistical analysis with SPSS, use the MySQL Query Browser or create backups with mysqldump.</p>
<p>That’s a really nice, practical real-world example for SSH tunnels. You can work around these provider limitations by building a tunnel between your local machine and the remote database host. The following solution is based on an interesting article in<em> </em>issue 06/2008 of the <em>iX</em> magazine. It uses ssh, netcat (nc) and xinetd to establish an ssh-channel automatically whenever the local client attempts to connect to the remote MySQL database. I made a few changes to the script because the database-host may not be on the same machine as the ssh-daemon [in my case it wasn’t].</p>
<pre class="brush:bash;light:true;">
ssh -l gerrit -N -L [bind_address:]12345:dbhost.lan:3306 basement.lan
mysql --port=12345 -h 127.0.0.1 --user=dbgerrit --password=dbpasswd mydatabase
</pre>
<ul>
<li style="text-align: left;"><tt>-l</tt> is the username on remoteServer</li>
<li style="text-align: left;"><tt>-N</tt> inhibits the login-shell</li>
<li style="text-align: left;"><tt>-L</tt> forwards the local port (see above). dbhost.lan:3306 is forwarded through basement.lan to localhost:12345. The local port can optionally be linked to an 	ip-address (bind_address).</li>
<li style="text-align: left;">you can now access the remote database via localhost:12345</li>
<li style="text-align: left;"><tt>-h 127.0.0.1</tt> forces a connection through the given port. Normally, MySQL would use a local socket and 	ignore the port parameter.</li>
</ul>
<h3>Using a keypair to simplify authentication</h3>
<p>First, create a keypair and merge them to a single keyring:</p>
<pre class="brush:bash;light:true;">
ssh-keygen -t rsa
ssh-keygen -t dsa
cd ~/.ssh
cat id_rsa.pub &gt; public_keys
cat id_dsa.pub &gt;&gt; public_keys
</pre>
<p>Transfer the keyring and append it to the list of authorized keys. Make sure the directory .ssh exists on the destination host and that you have permissions to access it.</p>
<pre class="brush:bash;light:true;">
scp public_keys gerrit@basement.lan:.ssh
ssh gerrit@basement.lan
cd ~/.ssh
cat public_keys &gt;&gt; authorized_keys
rm public_keys
</pre>
<p>Make sure the permissions are set properly [<a href="http://wiki.dreamhost.com/Ssh#Passwordless_Login">via</a>]:</p>
<pre class="brush:bash;light:true;">
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
exit
</pre>
<p>Now you should be able to log in without having to enter a password, try:</p>
<pre class="brush:bash;light:true;">
ssh gerrit@basement.lan
ssh -l gerrit basement.lan hostname
</pre>
<h3>Automatic tunnels with xinetd and netcat</h3>
<p>With xinetd and netcat you can automate the creation of the SSH-tunnel and simply provide a local port for tools like MySQL Query Browser or mysqldump. Netcat (nc), the tcp/ip swiss army knife, should already be available, if not you can install it using</p>
<pre class="brush:bash;light:true;">
apt-get install netcat xinetd
</pre>
<p>To test xinetd, you can use the echo service which reads incoming data and returns them without a change. To enable the echo service</p>
<pre class="brush:bash;light:true;">
nano /etc/xinet.d/echo
</pre>
<p>In the tcp section, set <code>disable = no</code>.</p>
<pre class="brush:bash;light:true;">
/etc/init.d/xinetd reload
cat /etc/services | grep echo
</pre>
<p>should reveal that echo is assigned to port 7.<br />
With <code>netstat -an | grep :7</code> you can make sure that xinetd provides the echo-service and that it’s actually listening on port 7. If that’s not the case, check the log files in /var/log.</p>
<p><code>nc basement.lan echo</code> allows you to check if the echo service returns what you provide through the standard input.</p>
<p class="center"><img class="alignnone size-full wp-image-137" title="MySQL through SSH Tunnel" src="http://blog.wessendorf.org/wp-content/uploads/2008/06/mysql-tunnel.png" alt="" width="424" height="248" /></p>
<p>With xinetd, netcat and ssh-tunnel we have everything we need to setup a proxy server. Each remote database will get a representative port on the proxy-server which is watched by xinetd. If a local database client tries to connect to this port, the daemon will start a shell script that opens the SSH-tunnel and starts netcat to copy data back &amp; forth between the database server and local client.</p>
<p>In /etc/xinetd.d create a service configuration for our proxy<br />
<code>nano <a href="http://blog.wessendorf.org/wp-content/uploads/2008/06/mysql-proxy-3310.txt">/etc/xinetd.d/mysql-proxy-3310</a></code></p>
<pre class="brush:bash;">
# default: on
service mysql-proxy-3310
{
port		= 3310
type		= UNLISTED
socket_type	= stream
wait		= no
user		= gerrit
server          = /opt/portproxy.sh
server_args     = dbhost.lan 3306 basement.lan gerrit
log_on_success += USERID PID HOST EXIT DURATION
log_on_failure += USERID HOST ATTEMPT
disable	= no
log_type        = FILE /tmp/portproxy.xinetd.log
}
</pre>
<p>For more details, see also <code>man xinetd.conf</code>.</p>
<p>Next, create the proxy script:<br />
<code>nano <a href="http://blog.wessendorf.org/wp-content/uploads/2008/06/portproxysh.txt">/opt/portproxy.sh</a></code></p>
<pre class="brush:bash;">
#!/bin/bash
# Usage: $0 dbServerHost dbServerPort remoteHost remoteUser

# prepare logging
LOGFILE=/tmp/`basename $0 .sh`.log

function log() {
	echo $$: $@ &gt;&gt;$LOGFILE
}

log start $0 at `date` with arguments -"$@"-

# find a free port, assign free port to $port
function getFreePort() {
	while true
	do
		port=$RANDOM
		[ $port -lt 1025 ] &amp;&amp; continue
		netstat -an | fgrep -q ':'$port || break
	done
}

# the function does the work (see comments inside), arguments:
#   $1 the remote database host
#   $2 the remote database port
#   $3 the remote host for tunnel
#   $4 the remote user for tunnel
function doWork() {
	# get free local port for the ssh tunnel
	getFreePort
	log free port is $port

	# build tunnel to remote host
	log start tunnel to $4@$3 and database $1:$2
	ssh -l $4 -C -L $port:$1:$2 -N $3 &gt;&gt; $LOGFILE 2&gt;&amp;1 &amp;

	# wait max up to 20 seconds for the tunnel to start
	s=1
	while ! netstat -an | grep -q ':'$port
	do
		log waiting for ssh tunnel -$s-
		sleep 1
		s=$(($s + 1))

		if [ $s -gt 20 ]
		then
			log unable to start ssh tunnel
			exit 1
		fi
	done
	log tunnel built

	# start I/O copying
	log start nc copy program for stdin/stdout and localhost:$port
	nc localhost $port 2&gt;&gt;$LOGFILE

	# kill background tunnel
	log killing ssh tunnel
	kill %1
}

# test arguments: $0 dbServerHost dbServerPort remoteHost remoteUser
if [ $# -ne 4 ]
then
	log `basename $0` was called with an illegal argument list: "$@"
	exit 1
fi

# do the work
doWork $1 $2 $3 $4

log end of $0 at `date`
exit 0
</pre>
<p>As mentioned before, this is based on the <em>iX</em> magazine,  issue 6/2008. I modified the script to introduce a new parameter <em>remoteHost</em>. The original script assumed that the database host was on localhost. As this may not always be the case, I build a tunnel to remoteUser@remoteHost, and then forward  dbServerHost:dbServerPort through the tunnel.</p>
<p>Make sure the script is executable: <code>chmod 755 /opt/portproxy.sh</code></p>
<p>Restart xinetd: <code>/etc/init.d/xinetd reload</code></p>
<p>Now, if you connect to the MySQL database on port 3310, it will automatically establish a connection to the remote server. Try</p>
<pre class="brush:bash;light:true;">
mysql --port=3310 -h 127.0.0.1 --user=dbgerrit --password=mydbpasswd mydatabase
mysqldump --port=3310 -h 127.0.0.1 --user=dbgerrit --password=mydbpasswd mydatabase &gt; mydatabase-backup.sql
</pre>
<p>I find this solution brilliant! With little adjustments this could be used for a lot of other applications as well.</p>
<p>I hope I got everything right. Please let me know if I made a mistake somewhere. Although I mostly wrote it down to support my memory, I hope any of this was useful, helpful or interesting to you, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2008/06/accessing-mysql-through-ssh-tunnel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DynDNS with ddclient</title>
		<link>http://blog.wessendorf.org/2008/05/dyndns-with-ddclient/</link>
		<comments>http://blog.wessendorf.org/2008/05/dyndns-with-ddclient/#comments</comments>
		<pubDate>Wed, 21 May 2008 16:47:53 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.wessendorf.org/?p=374</guid>
		<description><![CDATA[If your router doesn&#8217;t have a build-in feature to update dynamic DNS records you will have to use a software client that runs on one of your computers. The Linux tool ddclient already comes packaged in the Ubuntu repository and very easy to install. See also DynDNS&#8217; knowledge base artcicle. apt-get install ddclient nano /etc/ddclient.conf [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop i">I</span>f your router doesn&#8217;t have a build-in feature to update dynamic DNS records you will have to use a software client that runs on one of your computers. The Linux tool <em>ddclient</em> already comes packaged in the Ubuntu repository and very easy to install. See also DynDNS&#8217; <a href="http://www.dyndns.com/support/kb/using_ddclient_with_dyndns_services.html" target="_blank">knowledge base artcicle</a>.</p>
<div class="metamargin">
<pre class="brush:bash;light:true;">
apt-get install ddclient
nano /etc/ddclient.conf
</pre>
</div>
<p><a href="http://blog.wessendorf.org/wp-content/uploads/2008/05/ddclientconf.txt">/etc/ddclient.conf</a>:</p>
<pre class="brush:bash">
daemon=600                  # check every 600 seconds
syslog=yes                  # log update to syslog
mail=gerrit                 # mail all messages to gerrit
mail-failure=gerrit         # mail failed update messages to gerrit
pid=/var/run/ddclient.pid   # record PID in file
cache=/tmp/ddclient.cache   # cache file

# use DynDNS' checkip-service to determine IP
use=web, web=checkip.dyndns.com/, web-skip='IP Address'

protocol=dyndns2            # default protocol
server=members.dyndns.org   # default server
login=my-username           # DynDNS username
password='my-password'      # DynDNS password
my-dyndns-domain.dyndns.org
wildcard=YES
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.wessendorf.org/2008/05/dyndns-with-ddclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

