Search A-Z index Help
University of Cambridge Home Physics Dept Home Mike Roses' Home Page TCM Group Home

Making cdrecord work with Suse 9.3 in a multi-user environment

So you want people to be able to remotely login to a Suse Linux PC and be able to burn CDRs?

With Suse 9.3 this has become a little easier. If the CD writer is an ide one then:

boot parameter: hdc=ide-cd
group X owns /dev/hdc and has rw permissions
cdrecord is setgid X

Making cdrecord work with Suse 9.1 and the ide-scsi thang

Broken - we had to use ATAPI in the end - click on this link for the final answer

You get this problem with cdrecord -scanbus:
> cdrecord.bin -scanbus
Cdrecord-Clone 2.01a35 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
cdrecord.bin: No such file or directory. Cannot open '/dev/pg*'. Cannot open SCSI driver.
cdrecord.bin: For possible targets try 'cdrecord -scanbus'.
cdrecord.bin: For possible transport specifiers try 'cdrecord dev=help'.

You go and google around for a while and find lots of different answers out there:

Kernel SCSI emulation for CD burning - the truth
CD-Writing-HOWTO

You then read the rant against Suse (and Redhat), and wonder if you should be using the SCSI method:

cdrecord home page

I do not have an opinion either way on the SCSI/ATAPI debate (although I do find myself wondering what is going on when the cdrecord web page slates ATAPI so much, but some distros are using it), but what I do want is a cdrecord that our non-root users can actually use! Yes you can burn a CD as root on a standard suse install, but that is it.

You then spend a substantial amount of time mucking around with devices permissions, cdrecord, kernel modules and finally come up with something that actually works:

Add a little bit to kernel boot parameters:

hdc=ide-scsi

if cdrom is ide device hdc

Muck around with permissions so cdrecord is setguid, then you find out that you need to choose the SCSI bus number as this is not always going to be the same because of this:

Linux Kernel: RE: OOPS - ide-scsi bug - SCSI BUS number increasing

we figured we could get the bus number reliably from: ls -l /sys/bus/scsi/drivers/sr
, but to get that bit of data you need the sr_mod kernel module to be loaded which means writing a wee bit of C to call "modprobe sr_mod" as root . Put all of that together and you get this hack:

rpm -e cdrecord
rpm -Uvh cdrecord-2.01a35-0.pm.2.i686.rpm
(rpm is from: http://packman.links2linux.org/?action=316)

# cdrecord hacking to get it to work with SCSI commands and not ATAPI
cd /root
wget http://XXX/cdrecord
mv /usr/bin/cdrecord /usr/bin/cdrecord.bin
mv /root/cdrecord /usr/bin/cdrecord
chmod u-s /usr/bin/cdrecord.bin
chgrp floppy /usr/bin/cdrecord.bin
chmod g+s /usr/bin/cdrecord.bin
chgrp floppy /dev/sr0
chgrp floppy /dev/sg0
chmod g+w /dev/sg0
chgrp floppy /usr/bin/cdrecord
chmod g+s /usr/bin/cdrecord
mv /root/install_sr_mod /usr/local/bin/install_sr_mod
chmod u+s /usr/local/bin/install_sr_mod
chmod +x /usr/local/bin/install_sr_mod

List of files used:

kernel
menu.lst
modules.conf
cdrecord
install_sr_mod.c

KNACKERED!

We were happy, then we found that on some of our PCs if you tried to read a file from a mounted cdrom the computer would lock up and when you rebooted it the network card would no longer work! Power the computer off for a few minutes then boot it and all would be fine again until a cdrom was read. You could mount the cdrom and list contents, but any read operation stopped everything.

We want a cdrecord that can be run as a non-root user, that also works!

So we went back to the ATAPI idea and used the hacked cdrecord rpm - this works for us, now....

rpm -Uvh cdrecord-2.01a35-0.pm.2.i686.rpm

cdrecord -scanbus dev=ATAPI

cdrecord -v speed=4 dev=ATAPI:0,0,0 /scratch/myimage.iso

Now broken by latest kernel upgrade. We've found that this command works, though, in a multi-user environment:

cdrecord -v /scratch/myimage.iso

With /etc/default/cdrecord as

CDR_SPEED=4
CDR_DEVICE=/dev/cdrom
default=0,0,0 4 -1 burnfree

The burnfree option was the critical bit that enabled the setuid behaviour we want.

More info on our working setup:

$ ls -l /dev/cdrom 
lrwxrwxrwx  1 root root 8 Oct  1 21:09 /dev/cdrom -> /dev/hdc
$ ls -l /dev/hdc
brw-rw----  1 root floppy 22, 0 Apr  6  2004 /dev/hdc
$ cat /proc/cmdline 
root=/dev/hda1 splash=silent acpi=off desktop resume=/dev/hda2 showopts hdc=ide-cd
$ ls -l `which cdrecord`
-r-sr-xr-x  1 root root 373171 Aug  6 21:55 /usr/bin/cdrecord