UK Resident

One of my (many) pet peeves are shell scripts that fail to delete any temporary files they use. Included in this pet peeve are shell scripts that create more temporary files than they absolutely need, in most cases the number is 0 but there are a few cases where you really do need a temporary file but if it is temproary make sure you always delete the file.

The trick here is to use the EXIT trap handler to delete the file. That way if your script is killed (unless it is kill with SIGKILL) it will still clean up. Since you will be using mktemp(1) to create your temporary file and you want to minimize any race condition where the file could be left around you need to do (korn shell):

trap '${TMPFILE:+rm ${TMPFILE}}' EXIT

TMPFILE=$(mktemp /tmp/$0.temp.XXXXXX)

if further down the script you delete or rename the file all you have to do is unset TMPFILE eg:

mv $TMPFILE /etc/foo && unset TMPFILE
As noted here, I have been reading two books for a couple of months and not made much progress in recent times. My progress through books under consideration tend to be directly proportional to the amount of time spent traveling on trains or plains and I have not been doing that much of either for the last few month, hence the slow progress. A bit more focus and a train trip means I finished one of them last week.

Beautiful Security is a collection of 16 chapters written by 16 different people(s) with 16 different perspectives on 16 different aspects of security. This means there is no common thread other than it is about computer security. In my view this is no bad thing.

I think my favorite chapter was "The evolution of PGP's web of trust" by Phil Zimmermann and Jon Callas. The history and insight into the design decisions was really interesting. I also enjoyed the 1st chapter by Peiter Zatko on "Psychological Security Traps".

My interest in Computer Security got triggered about 6 months ago when I got cornered into helping 2 farmers run their PC and laptop. The virus and malware problems were just stunning. Work also had a few triggers (if you work for Sun ask me about the "find" incident) and this book has been very good at giving a informed view on 16 different areas of computer security.

After a couple of months off races, I am really looking forward to the Cardington Cracker in a couple of weeks.

Gregynog is a Country house near Newtown which was left to the University of Wales. For the last 13 years it has hosted a weekend of interview skills for 2nd Year Computer Science students from Aberystwyth University, of which I have managed to miss 2.

This year Paul Humphreys and myself ran objective setting sessions. A bit like life coaching, but without the 100 quid an hour overhead.

So good luck to those who's objectives included

  • Propose to his girl friends (maybe I should have pointed him to the Kepner Tregoe process for decision analysis)
  • Eat a baby dolphin
  • Stop smoking (not sure what, best not to ask)
  • Get an industrial year which involves Android
  • Finish their assignment by an appropriate date
  • Write code to do xxxxx in C,C++, Haskal, Perl, Python, etc and put to on their blog.

it takes all sorts to make a world. Many of the outcomes could have been tighter and better clarified, but it was an exercise in "How"

Both Paul and I also set out our list of 10 each, so I am off to finish my 2 books I have been reading since March and Paul will have dug manure into his allotment if it ever stops raining.

I spoke this morning at the South Tyrol Free Software Conference in Bolzano, Italy. My subject was the idea of a "software freedom scorecard", a list of indicators for the strength of software freedom in an open source project or product, about which I wrote recently. The slides are available for download.

I also refer to reptiles, and that's a reference to another blog post.

If you share a file system using the CIFS server (not SAMBA) and create a file in that file system using Windows XP the file ends up with these strange permissions and an ACL like this:

: pearson FSS 12 $; ls -vd Bad
d---------+  2 cjg      staff          2 Nov 13 17:11 Bad
     0:user:cjg:list_directory/read_data/add_file/write_data/add_subdirectory
         /append_data/read_xattr/write_xattr/execute/delete_child
         /read_attributes/write_attributes/delete/read_acl/write_acl
         /write_owner/synchronize:allow
     1:group:2147483648:list_directory/read_data/add_file/write_data

         /add_subdirectory/append_data/read_xattr/write_xattr/execute

         /delete_child/read_attributes/write_attributes/delete/read_acl

         /write_acl/write_owner/synchronize:allow

: pearson FSS 13 $; 


The first thing that riles UNIX some users is the lack of any file permissions, although things seem to work fine. The strange group ACL is for the local WINDOWS SYSTEM group. However the odd thing is for me it renders iTunes on the Windows system unable to see the files that it has created.

The solution is to add a default ACL to the root of the file system (well to every object in the file system if the file system is not new) that looks like this:

A+owner@:full_set:fd:allow,everyone@:read_set/execute:fd:allow

So this has the rather pleasant side effect of setting the UNIX permissions to something more recognisable:

: pearson FSS 20 $; ls -vd Good
drwxr-xr-x+  2 cjg      staff          2 Nov 13 18:16 Good
     0:owner@:list_directory/read_data/add_file/write_data/add_subdirectory
         /append_data/read_xattr/write_xattr/execute/delete_child
         /read_attributes/write_attributes/delete/read_acl/write_acl
         /write_owner/synchronize:file_inherit/dir_inherit/inherited:allow
     1:everyone@:list_directory/read_data/read_xattr/execute/read_attributes
         /read_acl:file_inherit/dir_inherit/inherited:allow
: pearson FSS 21 $; 

and the even more pleasant side effect of making iTunes works again!

I just posted this week's free music downloads list over on my personal blog.

I've said many times that dtrace is not just a wonderful tool for developers and performance gurus. The Kings of Computing, which are of course System Admins, also find it really useful.

There is an ancient version of make called Parallel make that occasionally suffers from a bug (1223984) where it gets into a loop like this:

waitid(P_ALL, 0, 0x08047270, WEXITED|WTRAPPED)	Err#10 ECHILD
alarm(0)					= 30
alarm(30)					= 0
waitid(P_ALL, 0, 0x08047270, WEXITED|WTRAPPED)	Err#10 ECHILD
alarm(0)					= 30
alarm(30)					= 0
waitid(P_ALL, 0, 0x08047270, WEXITED|WTRAPPED)	Err#10 ECHILD

This will then consume a CPU and the users CPU shares. The application is never going to be fixed so the normal advice is not to use it. However since it can be NFS mounted from anywhere I can't reliably delete all copies of it so occasionally we will see run away processes on our build server.

It turns out this is a snip to fix with dtrace. Simply look for cases where the wait system call returns an error and errno is set to ECHILD (10) and if that happens 10 times in a row for the same process and that process does not call fork then stop the process.

The script is simple enough for me to just do it on the command line:


# dtrace -wn 'syscall::waitsys:return / arg1 <= 0 && 
execname == "make.bin" && errno == 10  && waitcount[pid]++ > 20 / {

	stop();

	printf("uid %d pid %d", uid, pid) }

syscall::forksys:return / arg1 > 0 / { waitcount[pid] = 0 }'
dtrace: description 'syscall::waitsys:return ' matched 2 probes
dtrace: allowing destructive actions
CPU     ID                    FUNCTION:NAME
  2  20588                   waitsys:return uid 36580 pid 29252
  3  20588                   waitsys:return uid 36580 pid 2522
  5  20588                   waitsys:return uid 36580 pid 28663
  7  20588                   waitsys:return uid 36580 pid 29884
 10  20588                   waitsys:return uid 36580 pid 941
 15  20588                   waitsys:return uid 36580 pid 1098

This was way easier then messing around with prstat, truss and pstop!

At the request of the users the access hours for Sun Ray users in the house have been relaxed so that on Friday and Saturday nights the Sun Ray's in bedrooms can be used later.

This required that the access hour script be updated to understand the day of the week and hence the access_hour file also is updated in an incompatible way. There is now an extra column representing the days of the week when the rule is applied as the first column after the name of the user. The day of the week field will take a wild card '*' or ranges (1-5) for Monday to Friday, or lists (1,3,5). Sunday is day 0 as any self respecting geek would have it.

The new access_file I have looks something like this:

    user0:0-4:0001:2300:P8.00144f7dc383
    
    user2:0-4:0630:2300
    
    user3:0-4:0630:2230
    
    user4:0-4:0630:2100
    
    user4:5-6:0630:2200
    

The script is still here: http://blogs.sun.com/chrisg/resource/check_access_hours

It may just be that you need some free music to soothe away the bad taste from a bad week. There are a bunch of pointers on my personal blog.

I spent the last 2 days at a customer site in the south east of England. On my way home last night I decided to explore a route up a mountain called The Blorenge. I did not take any pictures, though I am sure the view would have been great if it was light. Being Novemeber the 5th, I felt the youff of Abergaveny let me down somewhat with few fireworks going off.

The Blorenge from the north is just over 500 meters of ascent, some of which is up a old mine works incline and some on open hill side. Nearly all of it is steep, so until the top plateau there was little I was able to run. Still a great hill training venue which is quite reasonable to do at night. Indeed, I was quite surprised to see an other set of lights out running who clearly knew an easier/better way down than straight back down the north face. I really missed my Mudclaws for the 1st 100m of descent.

Many thanks to Martin Beal and his blog for the idea. I have passed 100's of time to my shame, but never though of using it as a training ground and an excuse to break the drive home up. So if Martin at the top of end of the sport can do the ascent in 21.5 minutes, those of us at the other end might find 30 minutes a good target. Last night the ascent took about 45 minutes to the plateau, but some of that was spent reading the route description and looking for the track in the dark.

  • It may be an advertising stunt, but the videos are great and it embodies the idea central to open source that people contribute readily to thinks they get a kick out of.
  • "But to suggest that taking ecstasy is less dangerous than horse-riding, or that cannabis is safer than alcohol and tobacco - however true that may be - is to say the unsayable in the political drugs debate" -- The UK has a government that would rather appear OK to the Daily Mail reader than actually do what's right according to the experts advising them. It's true in the case of drugs, and it's true in the case of the internet and downloads. Watching Labour erode its core of support as it desperately tries to win over the Conservatives' heartland.
  • Good list, although I disagree with a few of thee choices which seem to prioritise simplicity over safety (for example, there's no way I will use Empathy for IM without OTR).
  • Carlo Piana (Europe's answer to Eben Moglen) once again delivers a clear analysis, this time showing how Amazon's announcement of hosted MySQL in the cloud punches a hole in Stallman's argument against the Oracle acquisition. Looking forward to hearing from Stallman both why Carlo is wrong and why dual-license is good for software freedom.
  • Finally Flickr has a serious competitior.
    (tags: Cat)
Smiling Crocodile

Several years ago, we had the chance to visit a crocodile farm in Queensland, Australia. There were several highlights, not least the chance for the children to hold a crocodile - a very small one, of course, with its jaws taped shut. Even with one that small, the frisson of terror remained and the children all laughed nervously for the camera.

[☝ Continued on Webmink Personal...]