Friday, February 22, 2008

Asus EEE Arrives and Samba Goes

I've finally got hold of an Asus EEE PC 4G. Initial impressions are very good, it feels robust and of good quality. There has been some mention of poorly aligned keyboards in recent models, but this one is fine. Despite being a little cramped the keys have a decent feel and I was touch-typing on it without too many errors by the end of an evening.

Before allowing it onto the InterTube I first disabled Samba. Samba allows the EEE to interoperate with Windows File and Print services, but unfortunately the version installed has a security flaw. There are various options for fixing this, including removal of Samba altogether or updating to the latest version. However I decided to just stop it running automatically at boot-up. This takes a little command line tweaking but is pretty easy. Here's what I did:

Hit Ctrl-Alt-T to pop up a command line prompt and type:

ps -e | grep smbd

The ps -e command lists all the processes running on the machine; about 60-odd on the EEE at rest, making the Samba processes hard to spot. The pipe symbol ( Fn-Shift-Z on the UK keyboard) 'pipes' the output of one command into another, in this case grep smbd. The grep command is an incredibly powerful search facility, but in this incantation it just returns any line containing 'smbd', the name of the Samba process. Running that command line gives something like:

1840 ?   00:00:00 smbd
1841 ?   00:00:00 smbd

confirming that a couple of Samba processes are running. Incidentally man followed by the name of a command displays the 'manual' for that Xandros command.

Now at boot-up the EEE runs a script called /usr/sbin/services.sh which starts various services including Samba. Near the end of the file the following lines start up Samba:

mkdir -p /tmp/.samba
/usr/sbin/invoke-rc.d samba start

We can comment them out by placing a hash ("#") at the start of each line. The EEE has various editors available from the command line, but I used Vi - it is something of an acquired taste and can be intimidating to new users because of its initially steep learning curve, but it has the advantage that it is available anywhere, under virtually any OS. There are also circumstances when Vi is likely to be the only editor that will work on a partially booted Xandros.

Vi is a modal editor and most keystrokes you type will be interpreted as commands rather than being inserted into the text. You have to switch into Insert mode to enter text. It is essential to spend some time practicing on scratch files and going through the tutorials on the Vi Home Page before going near anything essential with Vi. The most important Vi command to know is [Esc] to get out of Insert mode and then :q!. Colon opens the command line and 'q!' forces a quit without saving.

Editing the script with:

vi /usr/sbin/services.sh

works fine until you try and save the file, when Xandros will complain:

E45: 'readonly' option is set (add ! to override)

Trying :w! as suggested will also fail with:

"sbin/services.sh" E212: Can't open file for writing

This is because you are logged into Xandros as a user who doesn't have the authority to change this system file. You need to be logged in as the super-user 'root' instead. Fortunately you can use the sudo command to give yourself limited, audited, access to super-user permissions. So typing:

sudo vi /usr/sbin/services.sh

gives full editing access to the file. It can then be changed with the following commands:

  • G - moves the cursor to the bottom of the file

  • Cursor up - to the start of the first line that needs commenting out

  • i - Go into insert mode, then type '#' and then [Esc]. Don't try and cursor down in Insert mode - it will end in tears

  • Cursor down - to start of second line that needs commenting out

  • i - Go into insert mode, then type '#' and then [Esc]

  • ZZ - Save and Exit


The relevant part of the file should now read:

# Store samba run state in /tmp, as it gets written to frequently
# mkdir -p /tmp/.samba
# /usr/sbin/invoke-rc.d samba start

Restart the EEE and run ps -e | grep smbd again. This time no lines should be listed showing that Samba is no longer running.

Details of this fix, along with discussion of alternative solutions are given in the this thread on EeeUser.com.

No comments: