Sunday, September 25, 2005

Samba

Today I set up samba properly. Previously it only worked one way (viewing windows shares on the linux box) and involved typing the tedious command "sudo mount -t smbfs //192.168.0.1/share /mnt/share" and entering two passwords (one for sudo, and one for the mounting).

Firstly I set up a line in /etc/fstab to make this much quicker.

//192.168.0.1/share /mnt/network smbfs _netdev,noauto,users,password="",fmask=777,umask=777 0 0

Now I can just type "mount /mnt/network" to mount the share. No password is necessary (in actual fact, you could just put a blank password when mounting it manually) since it's in the fstab command (password=""). I also changed sudoers to allow this command to be run without a password, so overall it's much quicker to mount.

The fmask=777 and umask=777 are important as they give regular users permission to write on the shared drive (since windows doesn't have permissions).

The other stage of setting up samba was getting the windows computer to see me, and be able to access my files. This was achieved by setting up a smb.conf file like this:

[global]
workgroup = MSHOME
netbios name = Tux
security = user
password level = 8
deadtime = 3
guest account = nobody

[homes]
browseable = no
writable = yes

[mp3]
path = /home/ian/Music
browseable = yes
guest ok = yes
writable = no

It's quite straightforward since there's not printers or anything complicated to set up. I have two shares set up, for home directories (which require correct username/password to view) and for my mp3s (read only, can be viewed by the guest account, nobody). You have to set up the accounts for any users logging on like this using smbpasswd (just "smbpasswd -a username" as root, there must already be a local account with that name).

Sunday, August 07, 2005

More sudo

I've set up the sudoers file a little more sensibly now.

%wheel ALL=(ALL) ALL
%wheel ALL = NOPASSWD: /sbin/poweroff, /sbin/reboot, /bin/mount /mnt/cdrom, /bin
/umount
%wheel ALL=(ALL) !/bin/su

The first line says that anyone in the wheel group (i.e. me) can run any command as root, but needs to enter his password first.

The second line says that I can do some mundane tasks like mount the cdrom drive, or poweroff without needing a password at all. This line has to be after the previous line - if it's before, you still need a password as the other line overrules it or something.

The third line says that you can't sudo to su. I originally put this in a security thing, then realised that if someone unauthorised got access to a wheel group user, they could just sudo everything and wouldn't need the su to root at all. So in reality, its function is more to make sure I don't forget the root password, and slow me up from running lots of commands as root, where I might make silly mistakes (such as "rm -Rf /").

In fact, the whole file doesn't really increase security at all (although it'd be just as hard to get access to my account as root's). It just serves to save me typing passwords on mundane things, and make me type passwords on anything that could actually damage the computer. It's just a way of stopping and saying "wait a minute, are you sure you want to do this?" before I blow up the computer.

Sunday, July 31, 2005

xscreensaver

I'm not a big fan of screensavers since they tend to either look rubbish or use up lots of processing power, but I figured I needed something to lock the screen whilst I'm away. After a little experimenting with xlockmore, I figured it probably wasn't worth going against the norm and installed xscreensaver.

My biggest gripe with xscreensaver is that ugly screen you get when you go to unlock it. It is truly unpleasant. However I found out that you can change that by editing /etc/X11/app-defaults/XScreenSaver. I'm not sure if you can do it on a user level by editing ~/.xscreensaver.

Here's the relevant section. Basically I just changed all of the colours to black and white and removed the "XScreensaver vX.Y. This display is locked" text. It looks much better than before, although I couldn't figure out how to get rid of the xscreensaver logo.

! Resources for the password and splash-screen dialog boxes of
! the "xscreensaver" daemon.
!
!*Dialog.headingFont: *-times-bold-r-*-*-*-180-*-*-*-iso8859-1
*Dialog.headingFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
*Dialog.bodyFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
*Dialog.labelFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
*Dialog.buttonFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
*Dialog.dateFont: *-courier-medium-r-*-*-*-80-*-*-*-iso8859-1
*Dialog.foreground: #FFFFFF
*Dialog.background: #000000
*Dialog.Button.foreground: #000000
*Dialog.Button.background: #000000
!*Dialog.Button.background: #D6D6D6
!*Dialog.Button.pointBackground: #EAEAEA
!*Dialog.Button.clickBackground: #C3C3C3
*Dialog.text.foreground: #FFFFFF
*Dialog.text.background: #000000
*passwd.thermometer.foreground: #FF0000
*passwd.thermometer.background: #000000
*Dialog.topShadowColor: #000000
*Dialog.bottomShadowColor: #000000
*Dialog.logo.width: 210
*Dialog.logo.height: 210
*Dialog.internalBorderWidth: 0
*Dialog.borderWidth: 0
*Dialog.shadowThickness: 0

!*passwd.heading.label: XScreenSaver %s
*passwd.heading.label:
!*passwd.body.label: This display is locked.
*passwd.body.label:
*passwd.user.label: User:
*passwd.passwd.label: Password:
*passwd.passwdFont: *-courier-medium-r-*-*-*-140-*-*-*-iso8859-1
*passwd.thermometer.width: 8

Friday, July 29, 2005

.bashrc

For some reason, .bashrc is not running when I log in. This is a pain, since aliases such as poweroff="sudo /sbin/poweroff". Ok, it takes seconds to type the extra characters, but it bugs me nonetheless. And I may want to put other stuff in there at some point.

I added the following to /etc/profile:

if [ -x ~/.bashrc ]; then
. ~/.bashrc
fi

Problem solved.

[EDIT]
I did a little more searching and found out that slackware doesn't use .bashrc, but does have .bash_profile. Anyway, I removed the lines from /etc/profile, and put all my user stuff in .bash_profile. It works fine, no point adding extra files for no reason, it'll only complicate things.

Wednesday, July 27, 2005

Email

My email setup consists of fetchmail, procmail, mutt, nbsmtp and msmtpqueue.

Setting up fetchmail and procmail is not really a problem, there are umpteen guides on the net.

Sending mail is a little harder. I don't use sendmail/qmail etc. since they're far too advanced for my needs, and I have no idea how to set them up. Instead I go for small smtp programs such as msmtp, esmtp or nbsmtp.

msmtp and esmtp wouldn't work. I have no idea what was wrong, instead I just gave up and installed nbsmtp, which works fine. I set up mutt with "sendmail = 'nbsmtp -h smtp.gmail.com -p 465 -U username@gmail.com ...'" and it sent mails through gmail just great.

The next thing to do was set up so that I could switch at will between gmail accounts when I compose and email. This is a case of constructing a macro in mutt which changes the sendmail option to pass different option to nbsmtp (i.e. a different username and password), and also change the from address in the headers.

I came up with a line which looked a little like this:

macro compose \e1 "\ef^uJoe Bloggs \n
set sendmail='/usr/local/bin/nbsmtp -f joebloggs1@gmail.com -h smtp.g
mail.com -p 465 -s -U joebloggs1@gmail.com -P joespassword'" 'choose
Joe Bloggs smtp profile'

I'll dissect it bit by bit:

macro - this is a macro...
compose - it works if you're on the compose screen (the one after typing your mail but before sending it)
\e1 - it's activated when you type escape, then 1
"\ef^uJoe Bloggs \n - this changes the from header to "Joe Bloggs ". (escape f means change the from line, control u clears it, then Joe... \n is equivalent to typing it in followed by enter.)

set sendmail='/usr/local/bin/nbsmtp -f joebloggs1@gmail.com -h smtp.g
mail.com -p 465 -s -U joebloggs1@gmail.com -P joespassword' - this simply changes the sendmail option to nbsmtp...

'choose Joe Bloggs smtp profile' - the text to display in the help screen

I have a line like this for each email address I will be sending mail from.


The final part of the email setup is set up msmtpqueue scripts so that it doesn't matter if I'm online when I send email in mutt.

The scripts are set up for use with msmtp, but it works with nbsmtp if you simply change the relevant line. I also changed the names of the files, folders, variables etc. from *msmtp* to *nbsmtp* to avoid confusing myself.

Now mutt sends mail to the msmtpqueue script ("sendmail=/usr/local/bin/nbsmtp-queue -h smtp.gmail.com etc."), with the same options as before (they are passed onto nbsmtp). If the internet connection is up (tested by pinging google, probably not the best way) it runs the sendmail script straight away. If not, the sendmail script runs every 5 minutes as a cronjob, so the mail just sits in the queue until the net is up and then gets sent.

Tuesday, July 26, 2005

More Lilo

Finally got around to setting up lilo properly today. Here's my lilo.conf:

boot = /dev/hda
install=text
vga = 773
delay=0
password=""
default=Linux

# Override dangerous defaults that rewrite the partition table:
change-rules
reset

image = /boot/vmlinuz
root = /dev/hda1
label = Linux
read-only
restricted

other = /dev/fd0
label = Floppy
mandatory
unsafe

other = /boot/cdboot.b
label = CD
mandatory


Key things to note:

install=text - I hate the crappy ascii menu.
delay=0 - boot straight away, no waiting.
password="" - when you run lilo it asks for the password to use and stores it somewhere safe, not in lilo.conf.
restricted/mandatory - you need the password to boot from floppy or CD, or to pass options to the kernel (you also need to put scroll lock on otherwise you won't get the chance as delay=0).
unsafe - you need this to get the floppy bit to work. It tells it not to check what's in the drive when you run lilo (although I think putting a bootable disk in would work too)

And finally:

other = /boot/cdboot.b
This is a little hack I found here to allow me to boot from CD "through lilo". It's explained better on that page, but I'll give it a go in case that site goes down or something.

Basically, lilo can't boot up a CD (or it can, but I couldn't figure out how to make it work). Instead, it tells the BIOS that it failed to boot from the hard drive, so the BIOS then passes control to whatever is next on your boot order, which conveniently is the CD drive.

cdboot.b is the program which tells the BIOS that the hard drive failed. It consists of 512 bytes and goes: CD 18 00 00 00 ... 00 00 55 AA. So that's CD, then 18, then 508 lots of 00, then 55, then AA.

Monday, July 25, 2005

mp3cddb

mp3cddb is a mp3 tagging/renaming perl script. After a couple of days of searching for a suitable program to do my tagging, I found this, and it suits my needs quite well. No real problems installing, just had to make sure all the dependencies were installed (and they were easily found once I found a working website for the project, since the link on freshmeat is wrong).

It's very simple - you take a directory of mp3s, it finds the track information from freedb.org and presents you with the most likely match. You can then edit the tags if necessary, and then it writes the tags to the files and renames them for you. Everything you could want in an mp3 tagger.

The only minor inconvenience is that to find the correct information the tracks need to be named in the right order (e.g. "01 catch the pigeon.mp3"). This is fine since most of my ripping will be using cdparanoia and give me tracks imaginatively titled "track01.cdda.wav.mp3". But since I have a few albums which need to be tagged which were ripped on windows and given names in the format "title.mp3", they're in the wrong order.