<?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>jkroon</title>
	<atom:link href="http://jkroon.blogs.uls.co.za/feed" rel="self" type="application/rss+xml" />
	<link>http://jkroon.blogs.uls.co.za</link>
	<description>Ultimate Linux Solutions</description>
	<lastBuildDate>Tue, 13 Jul 2010 19:42:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ticketing Systems and email</title>
		<link>http://jkroon.blogs.uls.co.za/general/ticketing-systems-and-email</link>
		<comments>http://jkroon.blogs.uls.co.za/general/ticketing-systems-and-email#comments</comments>
		<pubDate>Wed, 07 Jul 2010 22:26:02 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=305</guid>
		<description><![CDATA[So after some experience with working with these on both sides of the fence I&#8217;ve formed some rather strong-willed opinions on these things.  Both good and bad, a lot of common mis-use from users, mis-perceptions from developers and support staff, as well as some other frustrations.

I think all of us have been frustrated by [...]]]></description>
			<content:encoded><![CDATA[<p>So after some experience with working with these on both sides of the fence I&#8217;ve formed some rather strong-willed opinions on these things.  Both good and bad, a lot of common mis-use from users, mis-perceptions from developers and support staff, as well as some other frustrations.<br />
<span id="more-305"></span><br />
I think all of us have been frustrated by having to wait in call queues.  I also think most of us has been frustrated by sending emails to support systems, and waiting days for responses.  Trust me when I tell you the frustration goes both ways.  I&#8217;m on both sides of the fence.</p>
<p>Firstly, I think people need to understand how many emails comes in which are duplicates of existing issues (often logged by the same person).  This can be caused by many things, the best thing to note here is that most ticketing systems use a &#8220;subject tag&#8221; to identify the ticket it&#8217;s using.  RT for example puts a [uls.co.za #???] string in our tickets.  Now consider the following scenarios:</p>
<ul>
<li><b>Subject Cleanup</b>:  The act of cleansing the subject.  Most users guilty of this don&#8217;t realize that email can be processed by automated systems, and that those automated systems may be relying on the subject to remain in tact for some reason.
<li><b>New Emails with subject referencing the other ticket</b>:  Often I&#8217;ll see subjects like &#8220;re ticket 1234&#8243;, this isn&#8217;t good enough for RT to link the tickets automatically, causing a new ticket to be logged.
<li><b>New emails with no reference</b>:  Often we&#8217;ll get emails that are obvious replies, but doesn&#8217;t contain message context.  For example, one we&#8217;ve recently recently was an email with subject &#8220;problem&#8221; and body &#8220;yes&#8221; and I also recall some tickets where the subject is simply &#8220;thanks&#8221; with an empty body.
<li><b>Replying to an existing email for a new issue</b>:  This also has the potential for causing great chaos.  Often one reads emails in the light of the context, and keeping the subject in the back of your head &#8230;
<li><b>Useless subjects</b>: For examples &#8220;phones&#8221; or &#8220;email&#8221; or something.  This is NOT a descriptive subject.  When under load support staff tends to scan subjects of logged tickets for important things that needs to be dealt with first.  Subjects such as &#8220;phones&#8221; or something equally cryptic is NOT likely to get your issue on the top of that list.
</ul>
<p>These things are actually general email etiquette, and comes from writing proper letters.  I know I used to be hammered on how to write a proper letter, both in Afrikaans and English.  I also recall thinking how useless that was at the time seeing that everything is moving towards email.  The art of writing letters however teaches you how to think structured.  In other words:  How do you pick a subject, how to structure paragraphs and how to convey information in a concise manner (an art I suck at &#8211; I tend to write essays and then have to trim them back down).</p>
<p>It&#8217;s difficult to give advice on how to best approach an issue.  However, I can say this, often just phoning isn&#8217;t going to get your problem sorted out.  The problem here is that unless the technician has the savvy to open a new ticket with your email address as requestor, and actually entering all the information you&#8217;re giving him/her over the phone chances are another call is going to come in as soon as you put down the phone totally obliterating the technicians thought process, and if you&#8217;re lucky he might context-switch back to your issue.  More likely than not (especially for the scatter-brained like myself) your issue is completely forgotten by now.  Thus I personally believe that if at all possible, take the time to write an email with the information you deem required and email that.  If the technician requires more info he&#8217;ll contact you.  The other risk is providing too much information, requiring the technician to first sift through relevant and irrelevant information.  Not always an easy task.</p>
<p>I think the most crucial thing when logging a ticket is picking a good subject.  For example, instead of just saying &#8220;phones&#8221; one could say &#8220;switchboard phone @ company xyz is down&#8221; or &#8220;switchboard phone @ company xyz is unable to transfer&#8221;.  This is concise and I can almost promise you you don&#8217;t even need to write something in the body.  This appears immediately in the list of tickets, it&#8217;s easy for technicians to pick out their tickets and they can almost commence work on your issue without even having to open your email.</p>
<p>Picking subjects like &#8220;urgent&#8221; is absolutely useless, it doesn&#8217;t tell us what the issue is about, and we&#8217;ve learned from experience that all issues are urgent.  However, if you email me a subject with &#8220;urgent&#8221; stating that you&#8217;re unable to receive incoming email you&#8217;re very likely to be ignored the next time round you do have an urgent query.  Yes, your email may be urgent, but let&#8217;s say you&#8217;re the technician and next to that you have a ticket that states:  &#8220;PABX system down, unable to make/receive calls&#8221;, or &#8220;web server down&#8221; or &#8220;database corruption on server xyz database abc&#8221; &#8211; which do you think is more urgent?  Your email problem (which is most likely caused by a temporary delay anyway) or the fact that a database that goes corrupt tends to cascade down the corruptness ladder once it gets going?</p>
<p>Other than subjects my other pet peeves are not using the reply and forward buttons correctly.  There are two extremes for the reply here &#8211; on the one hand there are people that will NEVER use the reply button &#8211; they always create a new email, usually with a subject somewhat similar to the email they&#8217;re replying on, without copying any of the context they&#8217;re replying on.  On the other hand you get folks that will always go and dig out an old email and hit reply, and updating the subject line is optional.  At this point I&#8217;m going to curse at Microsoft.  Outlook doesn&#8217;t do any kind of half-decent threading display last I checked.  Almost every other mail client do.  Guess what the usual suspects tends to use.  The importance of the reply button is critical, almost all mail clients honor the Message-Id and In-Reply-To email headers (not visible by most mail clients, but used in order to figure out threading).  If you don&#8217;t reply when you should our threaded displays will start a new thread (which it&#8217;s not).  If you reply instead of creating a new email your email goes into an existing thread, again incorrectly so.</p>
<p>The rule is really very simple:  Always use the reply-all button and not just reply (there is a reason people was added as a Cc on a mail in the first place &#8211; they should probably also receive the reply).  Use reply if you&#8217;re answering or responding to an existing email.  Do NOT use reply if you&#8217;re starting a new &#8220;discussion&#8221;.  It&#8217;s not difficult.  Common sense should be more than sufficient to grok this.</p>
<p>Now, recently I&#8217;ve started seeing a new trend (or possibly accidental usage).  And that is to click forward instead of reply, and then manually re-entering all the email addresses.  Not overly serious, just annoying.  This mostly just messes with the subject line.</p>
<p>When forwarding messages, please do bother checking the subject.  A prime example here is if you receive a bounce and simply forward it &#8211; the subject itself is most likely useless, in fact, I&#8217;m likely to treat it as a bounce myself and it&#8217;s likely going to end up somewhere trashy.  In the case of a bounce, it&#8217;s all good and well, but please do think a bit, a subject of &#8220;mail undeliverable&#8221; compared to &#8220;unable to send email to abc@def.co.za&#8221; is likely to be better received, and in the body you can simply state &#8220;when trying to send email to abc@def.co.za I receive the following bounce back: &#8230;&#8221;.  The same goes if you forward something you&#8217;ve received from another person.</p>
<p>Keep enough context, but do clean it up.  This is related to the whole top-posting vs bottom-posting vs inline posting.  I tend to use a combination.  I usually have a greeting at the top, then I respond inline in the email, sometimes add a new conclusion paragraph and then my salutation and signature at the bottom.  The reason I do this is so that someone that sees my email (without having received the original) can read the newly formed &#8220;document&#8221; top to bottom like a sane human being.  It&#8217;s extremely important to clean up the email though.  Outlook users tend to spam us with email footers that is approximately ten times longer than the actual content of their email (this goes to the cut buffer never to be returned).</p>
<p>On the topic of footers &#8211; yes, they can look nice, but more often than not they only serve to irritate the recipient, especially if you top-post (as most outlook users do).  When logging issues with issue trackers &#8211; strip them out.  They waste space, and seeing that issue loggers often prefer reading the plaintext version it looks like garbage when compared to the html variant.  The reason why these footers are irritating when top-posting is because it makes it difficult for the recipient to locate the original email.  Why is that important?  Well, you may only send one or two emails a day and can remember exactly what you said in each of them &#8211; there are some of us that send anywhere upwards of 30 to 50 emails a day.  Personally I don&#8217;t remember what I said in an email I wrote a minute back, thus when I receive an email I first scan what I wrote in order to joggle the memory before I read your reply.  If three quarters or even more of the email is headers and not actual content this becomes difficult.</p>
<p>Now, when everyone follows these extremely basic rules it saves technicians a LOT of time.  To give you an idea &#8211; I personally spend probably around 45 to 60 minutes a day just sorting through the above few things.  This wastes time that could have been spent way better towards actually solving real problems.  In normal day-to-day email it&#8217;s not as painful because I just tend to read my email top-to-bottom usually but even here it&#8217;s preferred to follow the rules.  Especially the aesthetics such as maintaining good subjects, cleaning up emails etc.  For ticketing systems especially it&#8217;s crucial to follow the rules regarding when to reply and when no to reply.  Never clean out the subject.  Ever.  There is most likely a reference tag in the reply you received and removing this will annoy the technicians trying to help you.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/general/ticketing-systems-and-email" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/general/ticketing-systems-and-email" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/general/ticketing-systems-and-email/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cell C following in the footsteps of Vodacom?</title>
		<link>http://jkroon.blogs.uls.co.za/it/security/cell-c-following-in-the-footsteps-of-vodacom</link>
		<comments>http://jkroon.blogs.uls.co.za/it/security/cell-c-following-in-the-footsteps-of-vodacom#comments</comments>
		<pubDate>Sun, 04 Jul 2010 18:52:48 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=296</guid>
		<description><![CDATA[Most people that know me well will know that I really don&#8217;t like the way Vodacom runs their firewalls for their 3G consumers.  In fact, they&#8217;ve managed to make it onto my blog no less than 3 times now &#8211; and not once for anything they&#8217;ve done right.  And now Cell C have [...]]]></description>
			<content:encoded><![CDATA[<p>Most people that know me well will know that I really don&#8217;t like the way Vodacom runs their firewalls for their 3G consumers.  In fact, they&#8217;ve managed to make it onto my blog no less than 3 times now &#8211; and not once for anything they&#8217;ve done right.  And now Cell C have decided to join the crowd of braindead arseholes who can&#8217;t run firewalls.  I present to you the man-in-the-middle TCP connection reset.  As it stands right now I can&#8217;t ssh.  I can&#8217;t connect to my jabber server.  I can&#8217;t even browse.  At least, not using my Cell C internet connection.<br />
<span id="more-296"></span><br />
<b>UPDATE</b>:  Please note that Cell C has already contacted me regarding this.  See comment #1 below for more details.</p>
<p>Unfortunately it&#8217;s insanely hard to prove conclusively where the TCP resets are coming from, again the only evidence I&#8217;ve got that it has to be Cell C is the fact that it works flawlessly from everywhere else (SAIX ADSL, Mweb ADSL and Vodacom 3G).  So the first things I started noticing yesterday was ssh connections going something down these lines (serenity is my local machine, linux.delter.co.za a relatively big mail server from one of my clients):</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">jkroon@serenity ~ $ ssh root@linux.delter.co.za 
ssh_exchange_identification: read: Connection reset by peer</pre></div></div>

<p>Now my employees knows, if I can&#8217;t ssh and it&#8217;s your fault, you&#8217;re going to get it.  Firstly I will hunt you down, then I will do things which cannot be considered polite, and if you&#8217;re name is bigger than mine and my client believes that because your name is bigger than mine that implies you&#8217;re right and I&#8217;m wrong I will ensure that I prove them wrong and make very sure that they understand that I don&#8217;t take these things lightly.  Well, not when it affects my work anyway, but I do understand if things breaks periodically, but at the moment I can&#8217;t even browse and in excess of 95 % of the connections I&#8217;m pushing out over my Cell C SIM is outright being reset.</p>
<p>So after seeing the above for for approximately 3 out of 5 connections this morning whilst sitting in a data center in johannesburg I just ran a tcpdump in a different shell on serenity to see what happens:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">08:53:56.835503 IP 196.35.70.139.ssh &gt; 10.213.51.133.47019:
    Flags [R.], seq 2902460094, ack 3806794395, win 199,
    options [nop,nop,TS val 26312228 ecr 4876698], length 0</pre></div></div>

<p>Now I KNOW the way I set up my servers.  And if my server is in fact generating that RST then there is something severely broken.  But I&#8217;m getting this from different servers.  So, having had one of the craziest weekends for a while going on I decided to push this to the back of my mind and concentrate on more urgent matters.  It&#8217;s only about 30 minutes back that I wanted to quickly check mail, browse a bit and just unwind a little that I couldn&#8217;t actually browse, ssh to my servers for a quick checkup after the weekend&#8217;s events and write an official complaint to a certain hosting company that I decided enough is enough.  Got a jump box and ssh&#8217;ed via another route to linux.delter.co.za (and no surprises) it worked flawlessly.  Fire up pppd and add a route for linux.delter.co.za over that, fire up tcpdump on both ends and I get this, first on serenity (sorry for the horizontal scrolling, and also note that the time on my laptop is out by ~30 minutes due to ntp failing and the CMOS on this Lenovo being of the ultra crappy kind):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">18:46:14.706636 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [S], seq 8197450, win 5840, options [mss 1460,sackOK,TS val 187563 ecr 0,nop,wscale 7], length 0
18:46:15.326350 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [S.], seq 1497501202, ack 8197451, win 5792, options [mss 1460,sackOK,TS val 2837150 ecr 187563,nop,wscale 6], length 0
18:46:15.326445 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [.], ack 1, win 46, options [nop,nop,TS val 187626 ecr 2837150], length 0
18:46:15.659155 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [P.], seq 1:21, ack 1, win 91, options [nop,nop,TS val 2837190 ecr 187626], length 20
18:46:15.659267 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [.], ack 21, win 46, options [nop,nop,TS val 187659 ecr 2837190], length 0
18:46:15.659458 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [P.], seq 1:22, ack 21, win 46, options [nop,nop,TS val 187659 ecr 2837190], length 21
18:46:15.969153 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [.], ack 22, win 91, options [nop,nop,TS val 2837221 ecr 187659], length 0
18:46:15.969221 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [P.], seq 22:814, ack 21, win 46, options [nop,nop,TS val 187690 ecr 2837221], length 792
18:46:16.349157 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [P.], seq 21:805, ack 22, win 91, options [nop,nop,TS val 2837221 ecr 187659], length 784
18:46:16.386434 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [.], ack 805, win 58, options [nop,nop,TS val 187732 ecr 2837221], length 0
18:46:16.599149 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [.], ack 814, win 116, options [nop,nop,TS val 2837284 ecr 187690], length 0
18:46:16.599227 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [P.], seq 814:838, ack 805, win 58, options [nop,nop,TS val 187753 ecr 2837284], length 24
18:46:16.926374 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [.], ack 838, win 116, options [nop,nop,TS val 2837315 ecr 187753], length 0
18:46:16.986396 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [P.], seq 805:957, ack 838, win 116, options [nop,nop,TS val 2837315 ecr 187753], length 152
18:46:16.986458 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [.], ack 957, win 71, options [nop,nop,TS val 187792 ecr 2837315], length 0
18:46:16.988362 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [P.], seq 838:982, ack 957, win 71, options [nop,nop,TS val 187792 ecr 2837315], length 144
18:46:17.477898 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [.], ack 982, win 140, options [nop,nop,TS val 2837372 ecr 187792], length 0
18:46:17.798919 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [P.], seq 957:1677, ack 982, win 140, options [nop,nop,TS val 2837372 ecr 187792], length 720
18:46:17.801802 IP 10.212.100.200.46247 &gt; 196.35.70.139.ssh: Flags [P.], seq 982:998, ack 1677, win 83, options [nop,nop,TS val 187873 ecr 2837372], length 16
18:46:18.048892 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [R.], seq 1677, ack 982, win 0, length 0
18:46:18.088924 IP 196.35.70.139.ssh &gt; 10.212.100.200.46247: Flags [R.], seq 1677, ack 998, win 0, length 0</pre></td></tr></table></div>

<p>And on linux.delter.co.za:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">20:17:52.448213 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: S 8197450:8197450(0) win 5840 &lt;mss 1460,sackOK,timestamp 187563[|tcp]&gt;
20:17:52.448247 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: S 1497501202:1497501202(0) ack 8197451 win 5792 &lt;mss 1460,sackOK,timestamp 2837150[|tcp]&gt;
20:17:52.840000 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: . ack 1 win 46 &lt;nop,nop,timestamp 187626 2837150&gt;
20:17:52.846789 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: P 1:21(20) ack 1 win 91 &lt;nop,nop,timestamp 2837190 187626&gt;
20:17:53.079622 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: . ack 21 win 46 &lt;nop,nop,timestamp 187659 2837190&gt;
20:17:53.161323 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: P 1:22(21) ack 21 win 46 &lt;nop,nop,timestamp 187659 2837190&gt;
20:17:53.161345 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: . ack 22 win 91 &lt;nop,nop,timestamp 2837221 187659&gt;
20:17:53.162056 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: P 21:805(784) ack 22 win 91 &lt;nop,nop,timestamp 2837221 187659&gt;
20:17:53.750503 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: P 22:814(792) ack 21 win 46 &lt;nop,nop,timestamp 187690 2837221&gt;
20:17:53.784763 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: . ack 814 win 116 &lt;nop,nop,timestamp 2837284 187690&gt;
20:17:53.839959 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: . ack 805 win 58 &lt;nop,nop,timestamp 187732 2837221&gt;
20:17:54.100058 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: P 814:838(24) ack 805 win 58 &lt;nop,nop,timestamp 187753 2837284&gt;
20:17:54.100072 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: . ack 838 win 116 &lt;nop,nop,timestamp 2837315 187753&gt;
20:17:54.102989 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: P 805:957(152) ack 838 win 116 &lt;nop,nop,timestamp 2837315 187753&gt;
20:17:54.479858 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: . ack 957 win 71 &lt;nop,nop,timestamp 187792 2837315&gt;
20:17:54.630280 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: P 838:982(144) ack 957 win 71 &lt;nop,nop,timestamp 187792 2837315&gt;
20:17:54.664784 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: . ack 982 win 140 &lt;nop,nop,timestamp 2837372 187792&gt;
20:17:54.673005 IP linux.delter.co.za.ssh &gt; 41.157.80.24.57790: P 957:1677(720) ack 982 win 140 &lt;nop,nop,timestamp 2837372 187792&gt;
20:17:55.236939 IP 41.157.80.24.57790 &gt; linux.delter.co.za.ssh: R 982:982(0) ack 1677 win 0</pre></td></tr></table></div>

<p>Upon initial inspection I have to say, I don&#8217;t see the tell-tale signs of tcp splicing as I did with Vodacom.  There doesn&#8217;t appear to be any sequence number adjustments.  There is some NAT going on which isn&#8217;t desirable (and Vodacom moved away from using NAT once they&#8217;re user base started getting beyond a certain point because &#8220;it didn&#8217;t scale&#8221; according to one of their lead technicians).</p>
<p>When I say I can&#8217;t find signs of tampering I really mean it.  Looking at the above you&#8217;ll see there is 19 packets on linux.delter.co.za and 21 on serenity.  The first 18 of both these traces ARE IDENTICAL (other than the NAT&#8217;ed IP).  After this 18th packet the server side receives an RST packet directly after it sent the data for 957:1677, along with a correct ACK for 1677.  The client side receives this data, and no surprisingly doesn&#8217;t actually respond with an RST but instead with an ACK.  Directly after sending this ACK it receives two identical RST packets, which again, has not been sent by the server.</p>
<p>So I ask this &#8211; who is generating these RST packets?  Who can I have beaten with a blunt object?  I want to unwind &#8211; it&#8217;s been a bad weekend with this little cherry on top.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/security/cell-c-following-in-the-footsteps-of-vodacom" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/security/cell-c-following-in-the-footsteps-of-vodacom" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/security/cell-c-following-in-the-footsteps-of-vodacom/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Capped, Uncapped and Unmetered</title>
		<link>http://jkroon.blogs.uls.co.za/it/networking/capped-uncapped-and-unmetered</link>
		<comments>http://jkroon.blogs.uls.co.za/it/networking/capped-uncapped-and-unmetered#comments</comments>
		<pubDate>Sun, 04 Jul 2010 10:13:27 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=292</guid>
		<description><![CDATA[Recently we&#8217;ve seen an explosion of uncapped accounts entering the market.  We&#8217;ve also seen that they are typically horribly slow in comparison to capped accounts &#8211; and if one goes and reads most of the acceptable use policies it becomes clear that they are in fact not uncapped, but rather, severely shaped capped accounts.

Shaping [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we&#8217;ve seen an explosion of uncapped accounts entering the market.  We&#8217;ve also seen that they are typically horribly slow in comparison to capped accounts &#8211; and if one goes and reads most of the acceptable use policies it becomes clear that they are in fact not uncapped, but rather, severely shaped capped accounts.<br />
<span id="more-292"></span><br />
Shaping implies that certain traffic classes will get priority over others, so for example http traffic and smtp to their local services will be OK&#8217;ish and mostly everything else will be rather bad.  This, dear providers, is NOT broadband.  This is abuse of the word uncapped and you should clearly mark your products for what they are.  If you have a &#8220;soft cap&#8221; of 30GB &#8211; that is still a cap.  If you have a (like IS&#8217;s newly released business class uncapped accounts) floating CAP &#8211; state it (thanks IS, at least you don&#8217;t try to mislead here, 20 GB over 10-days floating CAP with the top 20 % of users throttled sounds reasonable).</p>
<p>Now, the price tag on the IS uncapped account mentioned above is slightly in excess of R2000 ex VAT.  For my office I&#8217;ll need two of those accounts (we run through approximately 100GB worth of traffic each month and I&#8217;m NOT willing to sacrifice on quality of the service).  For those doing the math already, R4400 vs R5000 &#8230; yea.  If those were the complete facts I might consider switching and doing some careful load balancing over the two accounts to try and stay out of the top 20 % as well as to remain under the floating cap.  However, the price difference isn&#8217;t severe enough for me to honestly consider it, and I&#8217;ve got another trick up my sleave:  split routing.</p>
<p>I&#8217;ve approximately three years ago figured out how to separate local and international bandwidth at the client premises into two separate accounts.   This allows me to utilize cheap local-only ADSL accounts for local bandwidth, and normal blended ADSL accounts for my international traffic.  Seeing that our split is about 60 % local 40 % international this means that my cost ends up being around R2500 to R3000 per month, ex VAT for my bandwidth every month.  And I get this at the same quality that you&#8217;ve come to expect from SAIX&#8217;s ADSL accounts.  No frills, no fuss, good international latencies (usually at around 250 to 300 ms) and excellent local latencies of as low as 10ms (compared to around 25 to 30 on IS accounts).</p>
<p>Even three years ago this was beneficial, and I thought that this concept was going to be killed when the uncapped accounts started entering the market &#8230; yet the opposite has become true &#8211; I&#8217;ve now got even more inquiries asking WHY uncapped is so bad, and what alternatives are there.  And this is only from a &#8220;consumer dsl&#8221; perspective (ie, sme and home market).<br />
When one starts looking at data centres the costs associated with bandwidth starts looking even worse.  No more el-cheapo ADSL (yes, trust me when I tell you ADSL bandwidth is EXTREMELY cheap).  Now you have to start getting things like metro-ethernet.  You need to start buying transit.  If you&#8217;re hosting you&#8217;re most likely paying per GB over a certain thresshold (eg, first 3GB for your server is included with monthly and after that you&#8217;re paying per GB).  If you&#8217;re the hosting environment you&#8217;re most likely buying bandwidth in per mega-bit chunks.<br />
No matter in which of these arenas you&#8217;re playing there is NO SUCH THING as uncapped bandwidth.  Either you&#8217;re being limited by an artificial cap such as you can use 3GB at any rate you please (which is also a lie as the upstream BW has a limit in terms of bits per second) or you&#8217;re being limited by the bits per second.</p>
<p>What uncapped really means is unmetered.  In other words:  We will allow you to consume bandwidth at an average of X bits per second, and we won&#8217;t actually (for billing purposes) measure how many bytes you push over the link.  This means immediately that you pay for capacity instead of per byte.  It&#8217;s also possibly to buy such unmetered solutions in an oversubscribed manner, for example, you can buy &#8220;gold&#8221; or &#8220;silver&#8221; transit from SAIX, &#8220;gold&#8221; means that you will have a contention ratio of 1:1 (meaning you will always be able to use your full capacity), or with silver you can get a contention ratio of 3:1 &#8211; which means that permitting that the other people aren&#8217;t consuming bandwidth you can burst up to your pipe size, but you&#8217;re only guaranteed of a third of it.  Either way &#8211; 4Mbps of this is likely to make you understand why uncapped ADSL is a bad idea.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/networking/capped-uncapped-and-unmetered" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/networking/capped-uncapped-and-unmetered" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/networking/capped-uncapped-and-unmetered/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Quasar &#8211; using git to manage your reports</title>
		<link>http://jkroon.blogs.uls.co.za/it/quasar/quasar-using-git-to-manage-your-reports</link>
		<comments>http://jkroon.blogs.uls.co.za/it/quasar/quasar-using-git-to-manage-your-reports#comments</comments>
		<pubDate>Tue, 29 Jun 2010 14:55:38 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Quasar]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=285</guid>
		<description><![CDATA[So after a recent minor bug I got mailed a new report.xml file &#8230; and now have to sift through the changes manually, or do I?
I realized that had I had an &#8220;upstream&#8221; git repository from which the changes came, I would simply have been able to &#8220;merge&#8221; this into my existing reports.  And [...]]]></description>
			<content:encoded><![CDATA[<p>So after a recent minor bug I got mailed a new report.xml file &#8230; and now have to sift through the changes manually, or do I?</p>
<p>I realized that had I had an &#8220;upstream&#8221; git repository from which the changes came, I would simply have been able to &#8220;merge&#8221; this into my existing reports.  And then came the idea &#8230; and then the simplification<br />
<span id="more-285"></span><br />
The list of companies on the Quasar server is stored in /opt/quasar/data/companies, for each company there exists a .xml file.  An extract of this file looks as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE QuasarCompany&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;QuasarCompany<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Ultimate Linux Solutions CC<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uuid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...removed...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/uuid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2008-06-01<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dbtype<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>PostgreSQL<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dbtype<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;database<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...removed...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/database<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dataDir<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/dataDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;status<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valid<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/status<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/QuasarCompany<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Piet Ackermann pointed out the dataDir tag for me.  This allows us to have a separate datadir for each company (well, I would probably create a separate datadir for each company and just symlink most of the folders straight back into the original data folder.  With one exception, and that&#8217;s the reports folder.  Now, for the above example, let&#8217;s assume we want to change the dataDir to /opt/quasar/ULS instead of the default /opt/quasar/data, so off we go:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> ULS
<span style="color: #7a0874; font-weight: bold;">cd</span> ULS
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> ..<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/*</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$i</span> .; <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> reports</pre></div></div>

<p>Note that I rm the reports symlink again.  So now to get our &#8220;clean&#8221; copies into git (this assumes you haven&#8217;t already made modifications to reports, if you have, make backup copies and restore the clean, unmodified reports):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>reports
git init
git add <span style="color: #000000; font-weight: bold;">*</span>.xml
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;prestine reports from 2.1.5&quot;</span></pre></div></div>

<p>Note that 2.1.5 is an example, it can be any older version, also, this is a log message, it can be anything.  Once these are in git, we can proceed to clone them for modification purposes (can be done for as many companies as you desire):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>ULS
git clone ..<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>reports reports</pre></div></div>

<p>This will create a reports folder inside /opt/quasar/ULS and copy everything from the &#8220;upstream&#8221; (/opt/quasar/data/reports) into it, along with some meta information stored in a hidden .git folder.</p>
<p>You can now edit your reports here.  (or in the case of old reports, copy them in here).  There are a few very basic operations now.</p>
<p>When updating reports, you should add them into the &#8220;slave&#8221; or &#8220;downstream&#8221; repository, and commit them.  For example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> quote_print.xml
git add quote_print.xml
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Added my logo&quot;</span></pre></div></div>

<p>This has the advantage of keeping a history.  You can view the history using &#8220;git log&#8221;, it&#8217;s quite detailed.</p>
<p>After upgrading quasar new reports will overwrite those in /opt/quasar/data/reports, this isn&#8217;t a problem, in fact, it&#8217;s what we want, we now want to pull this into our little git system:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>reports
git add .
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Upgrade to version 2.1.6&quot;</span></pre></div></div>

<p>That&#8217;s it on the upstream side, and now to update the ULS reports:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>ULS<span style="color: #000000; font-weight: bold;">/</span>reports
git pull</pre></div></div>

<p>This will (usually) perform a clean import of the changes Linux Canada has made to the upstream reports into yours.  If it doesn&#8217;t, git will inform you that a conflict has occurred.  So let&#8217;s say for example we changed the same line that Linux Canada changed, then git will complain that it can&#8217;t auto-merge quote_print.xml.  This is known as a conflict.  Simply open the conflicting file in a text editor, look for the >>>>>> ====== <<<<<< conflict markers, edit as you see fit (you need to leave the file without any markers, as you would have wanted it to look after the merge).  Now you need to "git add" the conflicting file, eg "git add quote_print.xml" and then you can commit the merge with "git commit".</p>
<p>A controved example follows, let's say in the original version Linux Canada had a file (called file) with one line it "this file has one line in it".  Now this was committed in the repository at /opt/quasar/data/reports, at this point we cloned it, and changed the line to "customize".  We also did a "git add file" and "git commit -m 'customization'".  Now Linux Canada releases a new version of quasar, you go through the process above, and when you execute the "git pull" git spits this at you:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/jkroon/tmp/a
   b6e12ff..457d983  master     -&gt; origin/master
Auto-merging file
CONFLICT (content): Merge conflict in file
Automatic merge failed; fix conflicts and then commit the result.</pre></div></div>

<p>As you can see, it says big and loud CONFLICT.  It also says Merge config in file (which shows I&#8217;ve chosen my filename really badly).  Opening the file in a text editor shows this:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
customize
=======
this file only has one line in it
&gt;&gt;&gt;&gt;&gt;&gt;&gt; 457d983d0405dac4617a6ca5f42299e491ce8a4c</pre></div></div>

<p>We decide we want to keep our version, so we delete the <<<< marker, as well as ==== through to the >>>> lines.  Now we can either use the git shorthand for &#8220;git add .&#8221; and &#8220;git commit&#8221; and simply do &#8220;git commit -a&#8221;.  This will bring up a text editor with Merge branch &#8216;master&#8217; of /opt/quasar/data/reports, indicating the Conflicts.  You should probably add some text indicating what the cause of the conflicts was and how it was resolved.  When you save and quit git will do what&#8217;s required.</p>
<p>It&#8217;s also possible to do this whole thing using branches, and it&#8217;s a shorter process, but there are more pitfalls.  So I&#8217;ll run over it very quickly.</p>
<p>Do not bother making copies.  What I&#8217;ve done just now is this.  I&#8217;ve copied everything in /opt/quasar/data/reports to ~/quasar/reports/ in order to ensure that I&#8217;ve got backup copies.  I then re-installed the same version of quasar to get fresh copies of the Linux Canada reports.  Now comes the tricky part:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>reports
git init
git add .
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;reports from 2.1.4&quot;</span></pre></div></div>

<p>So far so good.  Now we &#8220;branch&#8221; this and re-import the backed up reports:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout <span style="color: #660033;">-b</span> uls
<span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>quasar<span style="color: #000000; font-weight: bold;">/</span>reports<span style="color: #000000; font-weight: bold;">/*</span> .
git add .
git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;existing customizations&quot;</span></pre></div></div>

<p>All done.  Now comes the careful bit though (and there are ways around this, so if you forget, know that git is ultra powerful and can save you).  Before you update you should switch back to the master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout master</pre></div></div>

<p>Once you&#8217;re done updating quasar, you can go back to your own branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git checkout uls</pre></div></div>

<p>And now you can merge the updated reports:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git merge master</pre></div></div>

<p>Resolve conflicts as per above.</p>
<p>Whichever way you choose, it is a good idea to familiarize yourself with git.  I can highly recommend the book at <a href="http://progit.org/book/">progit.org</a>, it&#8217;s very informative, but deals with git from a programmers perspective.  The main points from my side:</p>
<p>* Always make sure you don&#8217;t leave uncommitted changes around, especially not before an update (git status).<br />
* Use sensible changelog entries.  Trust me.</p>
<p>Other advantages of this for me is that I get a revision history of what I changed and when (and depending on the details of your changelog, why).  I can imagine that consultants like Piet will find this extremely useful for managing reports for multiple &#8220;hosted&#8221; clients.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/quasar/quasar-using-git-to-manage-your-reports" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/quasar/quasar-using-git-to-manage-your-reports" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/quasar/quasar-using-git-to-manage-your-reports/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Soccer Fever and those (horrid) Vuvuzelas</title>
		<link>http://jkroon.blogs.uls.co.za/uncategorized/soccer-fewer-and-those-horrid-vuvuzelas</link>
		<comments>http://jkroon.blogs.uls.co.za/uncategorized/soccer-fewer-and-those-horrid-vuvuzelas#comments</comments>
		<pubDate>Fri, 18 Jun 2010 12:35:35 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=280</guid>
		<description><![CDATA[So I got stuck on some mathematical calculations to get some multi-level paging system done.  And getting the breakdowns right.  And someone discovered http://www.vuvuzela-time.co.uk/ &#8230; well, some may recall the blue-bulls hack we pulled on google a whilst back.  Well, by now I reckon you can add the two together.

This time was [...]]]></description>
			<content:encoded><![CDATA[<p>So I got stuck on some mathematical calculations to get some multi-level paging system done.  And getting the breakdowns right.  And someone discovered http://www.vuvuzela-time.co.uk/ &#8230; well, some may recall the blue-bulls hack we pulled on google a whilst back.  Well, by now I reckon you can add the two together.<br />
<span id="more-280"></span><br />
This time was a tad more tricky.  vuvuzela-time.co.uk just loads the url passed as an iframe, so just doing an outright rewrite is a tad more tricky.  The redirect program from last time required a few adjustments, and ended up looking like this:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #0000ff;">$|</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$_</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/http:\/\/www\.google\.([^\/]*)\/? /i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;http://www.vuvuzela-time.co.uk/www.google.$1/webhp<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">#   elsif ($_ =~ /http:\/\/www\.google\.[^\/]+\/intl\/en_com\/images\/logo_plain.png/i) {</span>
<span style="color: #666666; font-style: italic;">#       print &quot;http://tauri.local.uls.co.za/bb.png\n&quot;;</span>
<span style="color: #666666; font-style: italic;">#   }</span>
<span style="color: #666666; font-style: italic;">#   elsif ($_ =~ /http:\/\/www\.google\.[^\/]+\/images\/nav_logo7.png/i) {</span>
<span style="color: #666666; font-style: italic;">#       print &quot;http://tauri.local.uls.co.za/nav_logo7.png\n&quot;;</span>
<span style="color: #666666; font-style: italic;">#   }</span>
    <span style="color: #b1b100;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then just add the redirect stuff in /etc/squid/squid.conf back:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">url_rewrite_program /etc/squid/redirect
url_rewrite_children 10</pre></div></div>

<p>And now you can hear whenever anybody is in need of assistance from google :p.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/uncategorized/soccer-fewer-and-those-horrid-vuvuzelas" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/uncategorized/soccer-fewer-and-those-horrid-vuvuzelas" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/uncategorized/soccer-fewer-and-those-horrid-vuvuzelas/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash file descriptors, pipes and &#8230; lockf.</title>
		<link>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-file-descriptors-pipes-and-lockf</link>
		<comments>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-file-descriptors-pipes-and-lockf#comments</comments>
		<pubDate>Mon, 14 Jun 2010 16:01:46 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Scripting/Programming]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=266</guid>
		<description><![CDATA[Bash and long-standing file descriptors is a pain, to put it politely.  For example, I&#8217;d like to spawn a sub-process into which I can &#8220;write&#8221; stuff at arbitrary points in time by doing echo fneh >&#038;4 &#8230; sounds simple enough right?  But how to spawn that sub process?

In particular, after getting stuck on [...]]]></description>
			<content:encoded><![CDATA[<p>Bash and long-standing file descriptors is a pain, to put it politely.  For example, I&#8217;d like to spawn a sub-process into which I can &#8220;write&#8221; stuff at arbitrary points in time by doing echo fneh >&#038;4 &#8230; sounds simple enough right?  But how to spawn that sub process?<br />
<span id="more-266"></span><br />
In particular, after getting stuck on the lockf situation last night I think I may have found a solution.  What I plan to do is write a simple (probably around 20 lines or so of C code) program that&#8217;ll perform an lockf on it&#8217;s stdout (fd=2), and then go to background using fork() (steps may need to be reversed, or something done in order to block executing of the invoking process until the lock has been obtained, this little note in lockf(3) concerns:  A child process does not inherit these locks.), and then keep on reading from stdin until it receives end-of-file, at which point it will simply terminate.  This should then allow one to create a fifo (mkfifo) somewhere on disk, open that fifo for writing from bash (exec 3>/path/to/fifo) and to then execute the lockf utility using something like &#8220;lockf </path/to/fifo >/path/to/lockfile&#8221; &#8230; at which point the idea would be that it blocks until the lock has been obtained, and then keep running in the background until it&#8217;s stdin closes (if the bash script terminates the fifo will be closed).</p>
<p>This begged a few questions (to which some of the answers is already present above).  So a few bash notes (mostly obtained from the advanced bash scripting guide), firstly the objective, then two lines, firstly the semantics, then an example line:</p>
<p>Open a file for reading:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> fd<span style="color: #000000; font-weight: bold;">&lt;/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&lt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>infile.txt</pre></div></div>

<p>Open a file for writing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> fd<span style="color: #000000; font-weight: bold;">&gt;/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>outfile.txt</pre></div></div>

<p>Closing a file descriptor:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> fd<span style="color: #000000; font-weight: bold;">&lt;&amp;</span>-
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span>-  <span style="color: #666666; font-style: italic;"># will close stdin</span></pre></div></div>

<p>Writing to a file descriptor:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span>fd
<span style="color: #7a0874; font-weight: bold;">echo</span> fneh <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">3</span></pre></div></div>

<p>Reading from a file descriptor:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">&lt;&amp;</span>fd
<span style="color: #c20cb9; font-weight: bold;">read</span> VARNAME <span style="color: #000000; font-weight: bold;">&lt;&amp;</span><span style="color: #000000;">4</span></pre></div></div>

<p>Renumbering file descriptors (ala dup2(2)), depends on whether it&#8217;s for reading/writing, but basically you just open the new fd, and instead of specifying a filename you give it an existing file descriptor.  So to &#8220;copy&#8221; stdin from fd=0 (standard) to fd=6 for whatever reason, and fd=2 (stderr) to fd=7 you can do this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span><span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span></pre></div></div>

<p>You can perform multiple exec actions in a single line, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&lt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>infile.txt <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>outfile <span style="color: #000000;">6</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span><span style="color: #000000;">0</span> <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span></pre></div></div>

<p>This is interpreted left to right.  And yes, order does matter when for example doing this (saving stderr to fd 7, and redirecting the scripts stderr to /tmp/errout.txt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>errout.txt</pre></div></div>

<p>What I can&#8217;t seem to find is a bash way of doing pipe2(2) without using mkfifo (which has name prediction attacks on it).  mktemp can&#8217;t create pipes for us, so we&#8217;re stuck with generating a random name, attempting to create it (remember &#8211;mode=0600).  This still suffers from problems similar to mktemp in that the content can be high-jacked by users with read/write permissions to the pipe.</p>
<p>I&#8217;m still working on a sane way to enforce the lock though, and it&#8217;s looking more and more like I will need to create two fifo&#8217;s, and pass the filename of the lockfile as a parameter to the program, so something like (ignoring path name collisions and other failures on the fifo&#8217;s for the moment):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>lockf-<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000; font-weight: bold;">in</span>,out<span style="color: #7a0874; font-weight: bold;">&#125;</span>.<span style="color: #007800;">$$</span>.fifo
<span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;rm /tmp/lockf-{in,out}.$$.fifo&quot;</span> EXIT
<span style="color: #666666; font-style: italic;"># Note that exec will block waiting for the bash process</span>
<span style="color: #666666; font-style: italic;"># preparing the lockf command to open the fifo's first.</span>
<span style="color: #666666; font-style: italic;"># Order of redirects is crucial to prevent deadlocks.</span>
lockf <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>lockfile.lock <span style="color: #000000; font-weight: bold;">&lt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>lockf-in.<span style="color: #007800;">$$</span>.fifo \
    <span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>lockf-out.<span style="color: #007800;">$$</span>.fifo <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>lockf-in.<span style="color: #007800;">$$</span>.fifo <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&lt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>lockf-out.<span style="color: #007800;">$$</span>.fifo
<span style="color: #c20cb9; font-weight: bold;">read</span> LOCKED<span style="color: #000000; font-weight: bold;">&lt;&amp;</span><span style="color: #000000;">3</span>
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span>-
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LOCKED</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Error obtaining lock&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
... rest of code here ...
... to explicitly unlock:
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&lt;&amp;</span>-</pre></td></tr></table></div>

<p>This assumes the semantics from lockf is as follows:</p>
<p>* Takes a single argument, filename of the lockfile.<br />
* Will open this file for writing (creating it if required).<br />
* Issue lockf() on the file (entire file &#8230; probably empty anyway).<br />
* Write a single line to stdout before closing stdout.<br />
* If unable to obtain a lock, simply close stdout (probably by terminating).<br />
* Block on a read from stdin, when stdin is closed (receives EOF) terminate (letting go of the lock).</p>
<p>The code for lockf below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;sys/types.h&gt;</span>
<span style="color: #339933;">#include &lt;sys/stat.h&gt;</span>
<span style="color: #339933;">#include &lt;fcntl.h&gt;</span>
<span style="color: #339933;">#include &lt;unistd.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> fd<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> bfr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">128</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;USAGE: %s filename<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* parent process should correctly set umask
       (0066 is a good one) */</span>
    fd <span style="color: #339933;">=</span> open<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> O_WRONLY <span style="color: #339933;">|</span> O_CREAT<span style="color: #339933;">,</span> <span style="color: #208080;">0660</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>fd <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        perror<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>lockf<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> F_LOCK<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        perror<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    fprintf<span style="color: #009900;">&#40;</span>stdout<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;locked<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fclose<span style="color: #009900;">&#40;</span>stdout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>fgets<span style="color: #009900;">&#40;</span>bfr<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>bfr<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> stdin<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Initial (rudementary) testing shows that this does actually work.  Surprise surprise.</p>
<p>I initially had two unlink(2)s in the code, which I realized introduces other races.  If not in the invoking process then potentially in other processes.  These locations was if we opened the file and then failed to obtain the lock (note that I don&#8217;t set alarms but I don&#8217;t block signals either, so there are other reasons the system call may get interrupted).  The other was just before the final exit, with the lock still held.  This opens race conditions as follows, for the failure case (line structure is P:action, where P is process indicator, a number, 1 is us, 2 + 3 is others, and action is a logical action):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">1:create lockfile
2:open lockfile
2:lock lockfile
1:lock fails
1:unlink lockfile
3:create new lockfile
3:lock new lockfile</pre></div></div>

<p>In this case both processes two and three will think it has the lockfile.  In the success case:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">1:create lockfile
1:lock succeeds
2:opens lockfile
2:blocks waiting for lock
1:unlinks lockfile
1:closes lockfile
2:lock succeeds on already open fd
3:creates new lockfile
3:lock succeeds</pre></div></div>

<p>In this case again we have both 2 and 3 with the &#8220;same&#8221; lock.</p>
<p>In the case of portage this probably doesn&#8217;t matter too much seeing that &#8220;1&#8243; should complete in downloading the file, and the lock file is mostly for in-process stuff, for it&#8217;s background fetching.  There is (to the best of my knowledge) no concurrent compiling locks implemented, albeit, there probably should be.</p>
<p>As it stands, strictly speaking this is a bug in portage.  The moral of the story is that a lock file should never, ever, ever, be removed.  Ever.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-file-descriptors-pipes-and-lockf" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-file-descriptors-pipes-and-lockf" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-file-descriptors-pipes-and-lockf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash, lockf and flock</title>
		<link>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-lockf-and-flock</link>
		<comments>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-lockf-and-flock#comments</comments>
		<pubDate>Sun, 13 Jun 2010 18:00:20 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Scripting/Programming]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=261</guid>
		<description><![CDATA[So after having had enough I decided it&#8217;s time to make torpage integrate better into the portage locking.  The current state isn&#8217;t bad, it&#8217;s just not complete.  The fact of the matter is that it is possible should torpage initiate the fetch that portage will (permitting it attempts to fetch the same file) [...]]]></description>
			<content:encoded><![CDATA[<p>So after having had enough I decided it&#8217;s time to make torpage integrate better into the portage locking.  The current state isn&#8217;t bad, it&#8217;s just not complete.  The fact of the matter is that it is possible should torpage initiate the fetch that portage will (permitting it attempts to fetch the same file) ignore the fact that torpage is busy downloading the file and kick off a dual download.  What&#8217;s happening is that torpage (currently) treats the mere existence of the file as a lock, whereas portage takes out a fcntl (lockf) based lock on the file.  Using the existince/lack of existence of files as the basis for a lock is a bad idea anyway, so I decided it&#8217;s time I took what I learned in the last six years and fix it.<span id="more-261"></span></p>
<p>So off I go, opening the portage code I looked at six years ago to just refresh my memory on how portage does the lock.  It basically creates the file by opening it for read/write, then issuing the lockf function in the fcntl module.  Essentially it&#8217;s a fresh open so the file position is 0, and the len isn&#8217;t passed (probably defaults to zero, indicating infinity, ie, the whole file).  It attempts to take an exclusive lock, albeit an advisory (ie, the kernel will keep the data for us but it won&#8217;t actually enforce it, that&#8217;s what mandatory locks are for).</p>
<p>In the kernel there are two locking functions, fcntl (with operation F_SETLK) and flock.  The man pages presents some cryptic information ((2)flock, (2)fcntl, (3)lockf).  So I go off and read the Documentations/filesystems/locks.txt and mandatory-locks.txt files in the kernel sources.  This reveals that flock was once upon a time (kernels older than 1.3.x from the looks of it) implemented flock on top of fcntl.  In 1.3.x the flock emulation code was swapped out for proper flock implementation (compatible with BSD).  The problem now is that the two ignore each other, completely.  But that, from the looks of it, seems to be the intended behaviour.</p>
<p>Now, looking at (1)flock you will note that bash gives us flock semantics (util-linux-ng @ sftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/ trictly speaking).  Which means a snippet like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&gt;/</span>usr<span style="color: #000000; font-weight: bold;">/</span>portage<span style="color: #000000; font-weight: bold;">/</span>distfiles<span style="color: #000000; font-weight: bold;">/</span>.fneh.tar.gz.portage_lockfile
<span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;rm '/usr/portage/distfiles/.fneh.tar.gz.portage_lockfile'&quot;</span> EXIT
flock <span style="color: #660033;">-x</span> <span style="color: #000000;">4</span></pre></div></div>

<p>Will not cause portage to block until we terminate.  Quite the contrary, portage will still just proceed to grab the lockf version and continue on it&#8217;s merry.</p>
<p>Some (ok, not just some, a lot actually) googling finds us http://rpm.pbone.net/index.php3/stat/4/idpl/5182919/dir//com/bash-builtin-lockf-0.2-alt1.i586.rpm.html &#8211; which based on the name looks really, really promising.  Until you download the source RPM and after examination it reveals this actualy looks like the current bash built-in flock version 0.1-beta1.  Except the packages is all wrong from the looks of it.  This essentially turns flock into a bash builtin.</p>
<p>This leaves me with some possible solutions:</p>
<p>1.  Learn some more python, hook into the portage package and use their code to base torpage on top of.<br />
2.  Take the referenced code above as a basis for writing a lockf variant (shouldn&#8217;t be too hard).<br />
3.  Take whatever partition houses /usr/portage/distfiles/ and enable mandatory locking.<br />
4.  Alter flock(1) to add an option for using lockf instead of flock.</p>
<p>Option three looks like the simplest solution at first glance, however, it also won&#8217;t work any better than what I currently have.  Basically once mandatory locking is enabled I thought of just trying to write one byte to the file &#8211; this will in the portage-has-the-lock case cause torpage to block, however, I still won&#8217;t be able to cause portage to block.  Option 1 is probably the right thing to do but also the least attractive imho (almost complete rewrite of torpage).  Or possibly invoke emerge/ebuild to fetch the files for the package.  This however re-introduces a very old bug I had in portage.  The files that needs to be fetched varies based on architecture and USE flags.  This is problematic.  In other words, I&#8217;m not even sure whether option 1 is viable.</p>
<p>In essence it seems option 2 and/or 4 is the most feasible in short time.  The question between 2 and 4 is whether or not a single option to the existing flock is better, or whether one should rather write a separate utility.  One should note that fcntl G_SETLK doesn&#8217;t differentiate between exclusive (write) and shared (read) locks.  For this reason a separate utility may be better, on the other hand, a flag -f (for fcntl) may well be a simpler solution, and may well be something that could possibly be accepted upstream (given some motivation, which I don&#8217;t think will be too difficult considering the context of this discussion).  On the other hand, cloning the utility and modifying allows me to package it straight into torpage (until upstream merges and releases) as an immediate solution.  The advantage of a simple patch is that all the other functionality (-o, -c etc &#8230;) comes for free even though I personally only really care about the file-descriptor based case.</p>
<p>Based on the code it looks like flock() on an fd applies to the group of processes sharing the file description.  To be exact (ignoring errors):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">flock<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> LOCK_EX<span style="color: #009900;">&#41;</span></pre></div></div>

<p>is equivalent to:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">pid_t p <span style="color: #339933;">=</span> fork<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>p <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     flock<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> LOCK_EX<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
waitpid<span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Albeit crap slowly.</p>
<p>This needs to be confirmed by testing, and then it needs to be confirmed that the fcntl based version has the same semantics.  This is simpler than one would initially imagine.  One can use bash to perform the initial testing against flock.  Basically when bash executes a command it implicitly does the fork for us, so what we need is a command that has similar semantics to flock.  In this case a program taking a single parameter, blocking for the lock, returning 0 if, and only if the lock was successfully obtained:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;sys/file.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> fd<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>eon<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;USAGE: %s fd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    fd <span style="color: #339933;">=</span> strtol<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>eon<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>eon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;USAGE: %s fd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>flock<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> LOCK_EX<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This just needs to be compiled using something like &#8220;gcc -o takelock takelock.c&#8221; (assuming the content is stored in takelock.c) and placed on a partition mounted with exec perms.  Now, open up two terminals and in both execute the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">&gt;/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">lockfile</span></pre></div></div>

<p>This will open /tmp/lockfile for writing in both terminals, attached to file descriptor number 4.  In the one terminal now execute &#8220;flock -x 4&#8243;, which should terminate with exit code 0 (can be confirmed with echo $?).  In the other you now need to execute our takelock executable (./takelock 4) which should block until you type &#8220;flock -u 4&#8243; in the other terminal.  To release the lock in the takelock terminal you can also use flock -u 4.</p>
<p>Updating the the code above to use lockf leaves us with this snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;unistd.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">long</span> <span style="color: #993333;">int</span> fd<span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>eon<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;USAGE: %s fd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    fd <span style="color: #339933;">=</span> strtol<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>eon<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>eon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;USAGE: %s fd<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>lockf<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> F_LOCK<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Running this first in the one terminal and then in the other reveals that the semantics differ and doesn&#8217;t work.  We&#8217;ll be able to enforce the -c semantics from the flock command, but not the fd semantics.  Which is a shame really, but there is probably good reasons for it behaving this way.  Again, this can be confirmed by adding a sleep(10); to the lockf if statement.  Something like:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>lockf<span style="color: #009900;">&#40;</span>fd<span style="color: #339933;">,</span> F_LOCK<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Got lock!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        sleep<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>And to then run both, about 5 seconds apart.  If this still doesn&#8217;t convince you, not much will.</p>
<p>This still allows us to implement it as a bash builtin, or to rewrite portage to take the lock and have a sub-shell actually doing the download.  Either way, that&#8217;s more work than what I&#8217;m willing to do tonight.</p>
<p>Option 4 is thus eliminated (for the most part) seeing that lockf&#8217;s semantics isn&#8217;t similar enough.  Option 2 may still be viable, but hard to motivate.  The altlinux code suggests that one can modularly add bash built-ins &#8211; perhaps this is still an option, except that adding a global built-in is not a clean solution, so I&#8217;m in two minds as to whether or not to attempt it.  A quick grep of the bash-4.0 source code however also suggests that altlinux hacked bash to add the required capabilities to load builtins as modules.</p>
<p>*cheers*.  Here&#8217;s to hoping that this helps someone else looking to understand the difference and nuances of these two rather confusing locking mechanisms.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-lockf-and-flock" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-lockf-and-flock" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/scriptingprogramming/bash-lockf-and-flock/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Great Wall of Vodacom &#8211; FAIL</title>
		<link>http://jkroon.blogs.uls.co.za/it/security/the-great-wall-of-vodacom-fail</link>
		<comments>http://jkroon.blogs.uls.co.za/it/security/the-great-wall-of-vodacom-fail#comments</comments>
		<pubDate>Tue, 25 May 2010 09:35:05 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=254</guid>
		<description><![CDATA[Right, so Kevin (one of my staff) had the savvy to take a few tcpdump traces on both the client and the server side of a failed PPtP VPN connection over the weekend.  The result?  It seems the great firewall of Vodacom has yet again taken another victem.
I&#8217;m not sure whether this is [...]]]></description>
			<content:encoded><![CDATA[<p>Right, so Kevin (one of my staff) had the savvy to take a few tcpdump traces on both the client and the server side of a failed PPtP VPN connection over the weekend.  The result?  It seems the great firewall of Vodacom has yet again taken another victem.<span id="more-254"></span></p>
<p>I&#8217;m not sure whether this is a result of too little testing, total ignorance or just incompetence.  Either way, it would seem it&#8217;s a bit of a race condition, and hits something similar to what we in the office refer to as the &#8220;connection tracking bit bucket&#8221;.  Basically it seem most connection tracking implementations (when combined with a state full firewall such as that used by Vodacom &#8211; as per their own admission in their <a href="/it/security/vodacom-responds">last letter</a> to me) results in certain flows being prematurely marked as &#8220;invalid&#8221;.  In particular in the example that Kevin has captured for me the server ends up being the first entity to send a GRE packet, this then gets (or got, seeing that it&#8217;s fixed again) intercepted by the firewall, perceived as an inbound connection to the client and the uni-directional flow gets marked as invalid.  When the client now sends GRE traffic to the server this gets allowed, but the return traffic still bites the &#8220;invalid&#8221; mark.  I can only speculate as to the exact state (seeing that Vodacom doesn&#8217;t reveal exactly what software they are using &#8211; probably proprietary anyway) of things, making it difficult.  This I will attempt to speculate as objectively as possible (not always easy).</p>
<p>Seeing that there are two entities involved in this dump, and I want to do a side-by side comparison, some ASCII art is in order.  Essentially three columns being used, the sending agent will indicate what is being sent, and if it was received by the destination I&#8217;ll mark that column with an ACK.  I&#8217;ll also add (R) to retransmits on the sending side.  The ISN mods still applies to the TCP connections, however, the data itself isn&#8217;t being tampered with in this case.  Note that in the GRE traffic case there are still ACK packets being sent by the server, these ACK packets however goes lost (as indicated in the packet sequence).</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Client                Direction  Server
SYN                        -&gt;    ACK
ACK                        &lt;-    SYN
PPTP (Start Req)           -&gt;    ACK
ACK                        &lt;-    PPTP (Start Resp)
                           &lt;-    GRE (PPP-LCP Conf Req)
GRE (PPP-LCP Conf Req) (R) -&gt;    ACK (goes lost)
GRE (PPP-LCP Conf Req) (R) -&gt;    ACK (goes lost)
... a few more of these ...
GRE (PPP-LCP Conf Req) (R) -&gt;    ACK (goes lost)
PPTP (Call Clear Req)      -&gt;    ACK</pre></div></div>

<p>Once the Call Clear Req is received TCP/IP teardowns happens, surprisingly without the flurry of injected RST packets I&#8217;ve growned accustomed to, just a single out-of-order delivery between one ACK and FIN/ACK packet.</p>
<p>What I would want (not sure what resolution they picked) is for them to either perform a routine inspection of the PPTP control traffic (specifically the Start Request and Start Reply packets) to determine the GRE traffic parameters (based on what I can see, just mark the fact that GRE is to be expected between the two given end points) and allow that traffic, or, stop this firewalling nonsense.  It&#8217;s only the Cellular &#8220;ISPs&#8221; performing actions such as these.  The arguments for providing this protection is sound.  But then it needs to be done sanely.  For the most part I&#8217;ll have to admit that the firewall works and doesn&#8217;t cause too many problems.</p>
<p>Seeing that the problem has been resolved by Vodacom, I&#8217;ll let it rest, for now.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/security/the-great-wall-of-vodacom-fail" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/it/security/the-great-wall-of-vodacom-fail" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/it/security/the-great-wall-of-vodacom-fail/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vodacom &#8211; still messing with TCP/IP?</title>
		<link>http://jkroon.blogs.uls.co.za/uncategorized/vodacom-still-messing-with-tcpip</link>
		<comments>http://jkroon.blogs.uls.co.za/uncategorized/vodacom-still-messing-with-tcpip#comments</comments>
		<pubDate>Mon, 24 May 2010 08:17:16 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=251</guid>
		<description><![CDATA[Some of you may recall that a whilst back I wrote a blog entry (two actually) regarding Vodacom messing with (and breaking) TCP/IP.  Specifically they adjust (present tense seeing that it&#8217;s still happening) the ISN from the TCP connection initiator (client) to the server, and they hold up RFC 1948 (here) to substantiate why [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may recall that a whilst back I wrote a blog entry (two actually) regarding Vodacom messing with (and breaking) TCP/IP.  Specifically they adjust (present tense seeing that it&#8217;s still happening) the ISN from the TCP connection initiator (client) to the server, and they hold up RFC 1948 (<a href="http://tools.ietf.org/html/rfc1948">here</a>) to substantiate why they do this.  As explained in my <a href="/it/security/vodacom-responds">previous entry</a> regarding this issue their reason is bogus and invalid.  I additionally proceeded to explain why their inherent disregard for the TCP/IP standards by which the rest of the world abides in fact creates additional exposure for exploiting such vulnerabilities.  Whilst my response at the time was quite harshly phrased it remains valid.<span id="more-251"></span></p>
<p>This entry is written out of some slight frustration &#8211; yet again with Vodacom.  We run a PPTP VPN firewall for a (large) number of clients.  As of approximately a week ago these clients are having severe issues connecting to the VPN specifically when connecting from the Vodacom 3G network.  Also the reason why I went back and re-checked these ISN adjustments that were being made at the time.  It seems, however, that they are still making these (justified or not) adjustments.  They have now gotten the &#8220;systems provider&#8221; to fix up the sequence number adjustments inside of selective ACK options inside TCP segments fortunately.</p>
<p>My frustration also grows from the fact that the solutions the Vodacom call center are now giving me are in direct contradiction to what I was being told about a year and a half ago.  At the time they said I need to get off the InternetVPN APN and onto the normal Internet APN because it no longer uses private IP addresses and contains full support for VPNs etc etc &#8230; &#8230; and now I&#8217;m being told to revert back to the InternetVPN APN.  You try and explain how to do this to 100+ different clients, how and why it&#8217;s required and more importantly you consistently get some snotty comment down the lines of &#8220;yea yea, you&#8217;re just using this as an excuse for breaking this and that&#8221;, so explaining to them that it&#8217;s Vodacom that changed something (whilst accurate) isn&#8217;t really an option as it&#8217;s just perceived as instigation against a &#8220;company bigger than yourself&#8221;.  The end result?  Vodacom yet again gets away with breaking stuff, and the small guys takes the fall.</p>
<p>The other solution that I&#8217;ve been offered is to put the server on the unrestricted APN.  Didn&#8217;t you listen the first time round?  The server ISN&#8217;T on 3G for, amongst others, the fact that you&#8217;re messing with TCP/IP options, it&#8217;s damn expensive at the traffic volumes we&#8217;re requiring, not to mention slow in comparison with wired connections such as ADSL (yes I know 7.2Mbps is more than 4Mbps, I don&#8217;t care, it&#8217;s NOT comparable, be it due to latency, high packet loss or jitter, I&#8217;d rather have a 512Kbps ADSL than any kind of 3G connection @ 7.2Mbps).</p>
<p>Anyhow, now I return to figuring out what is causing breakage this time.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/uncategorized/vodacom-still-messing-with-tcpip" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/uncategorized/vodacom-still-messing-with-tcpip" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/uncategorized/vodacom-still-messing-with-tcpip/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>We should be glad Darth Vader isn&#8217;t a spammer</title>
		<link>http://jkroon.blogs.uls.co.za/general/we-should-be-glad-darth-vader-isnt-a-spammer</link>
		<comments>http://jkroon.blogs.uls.co.za/general/we-should-be-glad-darth-vader-isnt-a-spammer#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:57:14 +0000</pubDate>
		<dc:creator>Jaco Kroon</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[SPAM]]></category>

		<guid isPermaLink="false">http://jkroon.blogs.uls.co.za/?p=246</guid>
		<description><![CDATA[Right, so we&#8217;re busy doing some top secret email stuff in the office relating to client support and generally being more efficient when it comes to queries and stuff.  And part of this testing involves the transmission of emails that needs to comply with RFC specifications, and generally having the correct headers and content [...]]]></description>
			<content:encoded><![CDATA[<p>Right, so we&#8217;re busy doing some top secret email stuff in the office relating to client support and generally being more efficient when it comes to queries and stuff.  And part of this testing involves the transmission of emails that needs to comply with RFC specifications, and generally having the correct headers and content in it, blah blah blah.  All good fun.  And then this gem landed in my inbox (tracing the Received headers reveals it was Stephen &#8211; perfectly spoofed in every other way from Darth.Vader.This.is.legit@gmail.com, quite a mean feat seeing that I haven&#8217;t yet received spam from professional fraudsters that managed this):<br />
<span id="more-246"></span><br />
DEAR SIR,</p>
<p>MY NAME IS DARTH VADER, THE APPRENTICE TO THE SITH MASTER</p>
<p>SITH MASTER, FORMER EMPOROR OF THE GALAXY, FORMERLY SENATOR PALPATINE, WAS RECENTLY KILLED BY OUTLAW HAN SOLO. I HAVE JUST RECENTLY BEEN INFORMED BY MY LATE MASTERS&#8217;S BANKING OFFICER THAT THE OLD MAN OPERATED A SECRET ACCOUNT WITH THE BANK INTO WHICH A TOTAL SUM OF SEVEN BILLION EIGHT HUNDRED MILLION THREE HUNDRED AND TWENTY ONE THOUSAND GALACTIC CREDITS (7,800,321,000) WAS TRANSFERED AND CREDITED IN HIS FAVOUR. I HAVE NOW BEEN ADVICED BY THE BANKING OFFICER TO SEEK IN CONFIDENCE A FOREIGN ACCOUNT INTO WHICH THIS FUND COULD BE TRANSFERED FOR SAFE KEEPING TO AVOID A LEAK TO THE ACCURSED JEDI.</p>
<p>IT HAS BEEN RESOLVED THAT 25% WILL BE YOUR SHARE FOR NOMINATING AN ACCOUNT FOR THIS PURPOSE AND ANY OTHER ASSISTANCE YOU GIVE IN THAT REGARD, 5% HAS BEEN SLATED FOR REIMBURSEMENT OF ALL LOCAL AND INTERNATIONL EXPENSES WHICH MAY BE INCURED IN THE TRANSFER PROCESS, AND 5% HAS BEEN CONCEDED TO THE LOCAL BANKING OFFICER HERE ASSISTING AND FACILITATING THE TRANSFER. FINALLY 65% WILL COME TO MYSELF AND FAMILY AND A GOOD PART OF THIS SHALL BE DIRECTED TOWARDS EXECUTING HIS WILL, WHICH IS TO BUY SHARES AND STOCK IN FOREIGN COUNTRIES AND TO SECURE HIS CHILDREN&#8217;S FUTURE. TO FACILITATE THE CONCLUSION OF THIS TRANSACTION, IF ACCEPTED, DO SEND TO ME PROMPTLY BY E-MAILLING THE FOLLOWING:</p>
<p>1.NAME AND ADDRESS OF YOUR BANK. 2. TELEPHONE AND FAX NUMBERS THROUGH WHICH YOU WILL BE CONTACTED PROMPTLY BY ME FOR THE COMPLETION OF THIS TRANSACTION.</p>
<p>PLEASE PROMISE ME YOU WILL ASSIST ME, AND REMEMBER TO KEEP THIS TRANSACTION VERY CONFIDENTIAL,NOTE THERE IS NO RISK INVOLVED. OR I WILL FORCE CHOKE YOU.</p>
<p>I LOOK FORWARD TO HEAR FROM YOU.</p>
<p>THANK YOU AND GOD BLESS.</p>
<p>DARTH VADER</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/general/we-should-be-glad-darth-vader-isnt-a-spammer" target="_blank"><img src="http://jkroon.blogs.uls.co.za/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://jkroon.blogs.uls.co.za/general/we-should-be-glad-darth-vader-isnt-a-spammer" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://jkroon.blogs.uls.co.za/general/we-should-be-glad-darth-vader-isnt-a-spammer/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
