sys-admin
KiBi’s blog
http://mraw.org/blog/tags/sys-admin/
KiBi’s blog
ikiwiki
2014-08-11T18:25:13Z
How to serve Perl source files
http://mraw.org/blog/2014/08/11/How_to_serve_Perl_source_files/
2014-08-11T18:25:13Z
2014-08-11T17:45:00Z
<p>I noticed a while ago a Perl script file included on my blog wasn’t
served properly, since the charset wasn’t announced and web browsers
didn’t display it properly. The received file was still valid UTF-8
(hello, little <code>©</code> character), at least!</p>
<h2>First, wrong intuition</h2>
<p>Reading Apache’s <code>/etc/apache2/conf.d/charset</code> it looks like the
following directive might help:</p>
<pre><code>AddDefaultCharset UTF-8
</code></pre>
<p>but comments there suggest reading the documentation! And indeed that alone
isn’t sufficient since this would only affect <code>text/plain</code> and
<code>text/html</code>. The above directive would have to be combined with
something like this in <code>/etc/apache2/mods-enabled/mime.conf</code>:</p>
<pre><code>AddType text/plain .pl
</code></pre>
<h2>Real solution</h2>
<p>To avoid any side effects on other file types, the easiest way forward
seems to <strong>avoid</strong> setting <code>AddDefaultCharset</code> and to associate the
<code>UTF-8</code> charset with <code>.pl</code> files instead, keeping the <code>text/x-perl</code>
MIME type, with this single directive (again in
<code>/etc/apache2/mods-enabled/mime.conf</code>):</p>
<pre><code>AddCharset UTF-8 .pl
</code></pre>
<p>Looking at response headers (<code>wget -d</code>) we’re moving from:</p>
<pre><code>Content-Type: text/x-perl
</code></pre>
<p>to:</p>
<pre><code>Content-Type: text/x-perl; charset=utf-8
</code></pre>
<h2>Conclusion</h2>
<p>Nothing really interesting, or new. Just a small reminder that tweaking
options too hastily is sometimes a bad idea. In other news, another Perl
script is coming up soon. <code>:)</code></p>
SysRq trick
http://mraw.org/blog/2008/07/11/SysRq_trick/
2013-12-17T02:11:28Z
2008-07-10T22:00:00Z
<p>While building and testing LiveCDs, <a href="http://bellard.org/qemu/">QEMU</a> and
<a href="http://www.virtualbox.org/">VirtualBox</a> can speed up development cycles…
until a bug is encountered: <code>apt-get update</code> hanging on a <code>rename</code>
operation. Maybe <a href="http://aufs.sourceforge.net/">aufs</a> is at fault? Its
author then asks for some data, including what happens when some SysRq keys are
pressed. What they are is already quite extensively explained in
<a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/sysrq.txt">Documentation/sysrq.txt</a>
(Linux sources), but I’d like to point to a nice trick for people using
emulation and virtualization tools (ever tried to send <code>Ctrl+Alt+Delete</code> to
a virtual machine?):</p>
<pre><code># echo $letter > /proc/sysrq-trigger
</code></pre>
<p>where <code>$letter</code> is any of the supported SysRq keys. As an example:</p>
<pre><code># echo d > /proc/sysrq-trigger
# dmesg | tail -1
[558193.423427] SysRq : HELP : loglevel0-8 reBoot Crashdump tErm Full kIll
saK showMem Nice powerOff showPc show-all-timers(Q) unRaw Sync showTasks
Unmount shoW-blocked-tasks
</code></pre>
Keyboard-aware VirtualBox
http://mraw.org/blog/2007/09/21/Keyboard-aware_VirtualBox/
2013-12-17T02:11:28Z
2007-09-20T22:00:00Z
<p><a href="http://www.virtualbox.org/">VirtualBox</a> (available in Debian as
<code>virtualbox-ose</code> with a <code>m-a</code>-buildable kernel driver:
<code>virtualbox-ose-source</code>), is quite interesting, and works great on
both <code>sid</code> and <code>lenny</code>. [Why <code>OSE</code>? Open Source Edition.]</p>
<p>Example: X freezes sometimes when <code>gtk-2.11</code> is installed, maybe due
to bugs like <a href="http://packages.debian.org/xfwm4">xfwm4</a>'s <a href="http://bugs.debian.org/442053">Debian bug #442053</a>, which is quite
annoying since epiphany's trunk needs it. Then develop in a virtual
machine and restart it when needed, leaving the host system
unaffected. It is also quite easy to duplicate, pause, resume, etc.
the virtual machines.</p>
<p>Note: Virtual machines are stored in <code>.vdi</code> files (Virtual Disc
Images). Copying them isn't the way to clone images, since a UID is
stored inside them. Use <code>vboxmanage clone original.vdi clone.vdi</code>
instead.</p>
<p>An annoying bug in VirtualBox is <a href="http://bugs.debian.org/443500">Debian bug #443500</a>: the <code>AltGr</code> key
isn't passed to the virtual machines. Fortunately, upstream's
<a href="http://www.virtualbox.org/changeset/3938">changeset 3939</a> fixes that.</p>
<p>Now <code>{</code>, <code>}</code>, <code>[</code>, <code>]</code>, <code>@</code>, <code>|</code>, <code>#</code> are available! \o/</p>
IP forwarding
http://mraw.org/blog/2007/07/29/IP_forwarding/
2013-12-17T02:11:28Z
2007-07-29T00:00:00Z
<p>A while ago, IP forwarding was being set through <code>/etc/network/options</code>, which
has been deprecated.</p>
<p>It is possible to play a bit with <code>/etc/sysctl.conf</code>:</p>
<pre><code>net.ipv4.conf.default.forwarding=1 # Or 0...
</code></pre>
<p>This sets the default forwarding state of network devices without explicit
configuration. It only affects the devices that will be registered in the
future.</p>
<p>A similar setting is the following:</p>
<pre><code>net.ipv4.conf.all.forwarding=1 # Or 0...
</code></pre>
<p>This applies to all the network devices (even those not in the <code>UP</code> state), but
doesn't apply to the devices that will be registered in the future.</p>
<p>Another setting is the following, which acts as an alias of the previous one:</p>
<pre><code>net.ipv4.ip_forward=1
</code></pre>
<p>Then just run <code>sysctl -p</code> to take this parameter into account.</p>
<p>These settings can also be specified replacing the dots by slashes, and are
available under <code>/proc/sys</code>.</p>