# kernel >=2.6.9 writing as a normal user [SOLVED]

## pinnockio

Hello,

This post provides a possible workaround for the following error encountered when normal users want to burn on a system with a kernel >=2.6.9:

 *Quote:*   

> cdrecord: Cannot allocate memory. Cannot get SCSI I/O buffer

 .

Note that it could entail some security-issues as for burning root priviliges are no longer needed.   So it is a temporarily workaround  :Exclamation:  .  My cd/dvd-writer is an external usb one, and I'm not using udev but scsi cd-rom support for cd-roms on a kernel-2.6.10-rc3 to get this usb-block device to work   :Wink: .

We are going to build ourselves an ebuild (note that I'm not an 'e-builder', but simply copied an existing e-build and made some modifications).

step1: copy the ebuild

```
 cd /usr/portage/app-cdr/cdrtools

 cp cdrtools-2.01.01_alpha01.ebuild cdrtools-2.01_alpha38.ebuild

 vim cdrtools-2.01_alpha38.ebuild
```

step2: make modifications

replace the following lines:

 *Quote:*   

> SRC_URI="ftp://ftp.berlios.de/pub/cdrecord/alpha/${P/_alpha/a}.tar.bz2"
> 
> -> SRC_URI="ftp://ftp.berlios.de/pub/cdrecord/alpha/${P/_alpha/a}.tar.gz"
> 
> S=${WORKDIR}/${PN}-2.01.01
> ...

 

step3: make 'permission patch'

```

cd /usr/portage/app-cdr/cdrtools/files

touch cdrtools-2.01-permission.patch

vim cdrtools-2.01-permission.patch

```

and add exactly the following:

```

--- cdrtools-2.01/cdrecord/cdrecord.c.orig   2004-10-28 12:44:39.927882183 -0400

+++ cdrtools-2.01/cdrecord/cdrecord.c   2004-10-28 13:00:02.627948467 -0400

@@ -492,8 +492,11 @@

    /*

     * XXX Below this point we do not need root privilleges anymore.

     */

-   if (geteuid() != getuid()) {   /* AIX does not like to do this */

+   

+   // fixing issue with kernel >= 2.6.8.1

+   //if (geteuid() != getuid()) {   /* AIX does not like to do this */

                /* If we are not root      */

+   /*

 #ifdef   HAVE_SETREUID

       if (setreuid(-1, getuid()) < 0)

 #else

@@ -505,6 +508,8 @@

 #endif

          comerr("Panic cannot set back effective uid.\n");

    }

+    */

+

    /*

     * WARNING: We now are no more able to do any privilleged operation

     * unless we have been called by root.

@@ -1009,10 +1014,14 @@

        * even on OS that do not support getreuid() which is *BSD

        * and SUSv3 only.

        */

+

+      // fixing issue with kernel >= 2.6.8.1

+      /*

       if (oeuid != getuid()) {

          if (setreuid(-1, oeuid) < 0)

             errmsg("Could set back effective uid.\n");

       }

+       */

 #endif

       /*

        * fork() here to start the extra process needed for

@@ -1027,11 +1036,14 @@

       /*

        * XXX Below this point we never need root privilleges anymore.

        */

-      if (geteuid() != getuid()) {   /* AIX does not like to do this */

+      // fixing issue with kernel >= 2.6.8.1

+      //if (geteuid() != getuid()) {   /* AIX does not like to do this */

                   /* If we are not root      */

+      /*

          if (setreuid(-1, getuid()) < 0)

             comerr("Panic cannot set back effective uid.\n");

       }

+       */

 #endif

    }

    if ((*dp->cdr_set_speed_dummy)(scgp, dp, &speed) < 0) {

```

step 4: create auxilairy ebuild files

(note the digest at the end  :Wink:  )

```
ebuild /usr/portage/app-cdr/cdrtools/cdrtools-2.01_alpha38.ebuild digest
```

step 5: try it!

```
emerge /usr/portage/app-cdr/cdrtools/cdrtools-2.01_alpha38.ebuild 
```

Now I can burn as a normal user using my external USB-device using xcdroast (note that I'm not able to use it as a normal user under K3B.It seems like the normal user can't read alll the information for the writer (eg.: the writing modes supported) and can't use the writer   :Crying or Very sad:  ).

These were the references I used:

http://kerneltrap.org/node/view/4022

https://bugs.gentoo.org/show_bug.cgi?id=68825

Kind regards,

A belgian Gentoo user

----------

## Ishino

This patch is not really necessary, since one can just remove the SUID-bit from cdrecord and will be able to burn cds as a normal user.

----------

## pinnockio

Hello,

Could you then explain to me why

chmod u-s /usr/bin/cdrecord

did not do the trick on my system?  I've got a USB-dvd-writer on a kernel-2.6.10-rc10 not using udev but scsci-cdrom support and usb mass storage support.

Kind regards,

A belgian Gentoo user

----------

## pinnockio

Hello,

Just re-emerged the normal one, and checked wether the su-bit was set.  It is not, and I still couldn't burn.  I re-emerge the version with the patch applied as above and it works like a charm (with xcdroast at least   :Wink:  )

Kind regards,

A belgian gentoo user

----------

## Ishino

I didn't mean to argue about the patch.   :Razz: 

I tried to use cdrecord as a normal user a while ago using the gentoo-dev-sources-2.6.9-r4. It did not work. After reading the nice LKML thread (Schilling vs. all others) and finding out about the available patch (the one for cdrecord itself, that you presented in your post) I decided not to patch, neither the kernel (patch exists and afaik has been included in some later gentoo-dev-sources release)  nor the cdrecord sources. Mostly because I'm not using cdrecord too often. But since it was clear that the kernel changes only affected applications that run with SUID privileges, I just gave it a try and cleared the SUID-bit from cdrecord - which actually solved the problem. Others reported this to be working fine for them and it seemed to be the easiest workaround.

So much for the explanation...  :Smile: 

And again, I did not mean to argue...just tried to point out another way to solve the problem - which worked at least on one machine.  :Wink: .

----------

## pinnockio

Hello,

I haven't got the minest problem with the post you made earlier.After all, this is a forum for a linux-community   :Wink:  .  I'm glad somebody responded.  Now there are 2 solutions on one page  :Very Happy: .

Kind regards,

A belgian Gentoo user

----------

## Wim VDM

Make that 3 solutions  :Very Happy: 

I'm using kernel 2.6.9-gentoo-r4, and I always got this

"cdrecord: Cannot allocate memory. Cannot get SCSI I/O buffer."

error

I don't know why, but recomiling cdrecord without nptl solved the problem.

```
USE="-nptl" emerge cdrtools 
```

----------

## pinnockio

Hello,

It still didn't work for me   :Crying or Very sad: .  Are you using udev? Cause I'm not,... .

Kind regards,

a Belgian Gentoo user

----------

## pinnockio

Hello,

If you get an error the patch can't be applied during the emerge.Just download the patch directly from https://bugs.gentoo.org/attachment.cgi?id=42797.

Kind regards,

a Belgian Gentoo user

----------

## Wim VDM

I am using udev. I don't think you need it though.

Have you tried setting permissions with k3b? k3bsetup2 seems to be able to correct alot of permissions problems. In case it helps, I'm using cdrtools-2.01 and k3b-0.11.17.

----------

## pinnockio

Hello,

Jups jups! Exactly the same as you  :Wink: . Note that with the switch '-nldp' in '/etc/make.conf' and a re-emerge of the normal cdrtools, burning under x-cdroast doesn't work any-more as the cd-burner after a rescan of the available devices only shows up as a normal cd-device.

I think this has got something to do with the normal user who is unable to read the scsi-capabilities of the device.That's why I think it could have something to do with udev (and I must be honest I don't have a clue what the difference of udev with devfs).  So perhaps somebody could correct me on this latest statement,... .

Kind regards,

A belgian Gentoo user

ps.: I'll try a re-emerge of k3b with '-nldp' switch set in 'make.conf'

----------

## Wim VDM

I hope you tried: "nptl" (Native POSIX Threads Library) and not "nldp" (the typo in your last post).

On my PC everything (including k3b) except cdrecord is compiled with nptl.

----------

## pinnockio

Hello,

A typo, I meant nptl,... .  Lazy   :Embarassed: 

Kind regards,

A belgian Gentoo user

----------

## tabanus

[rant] Man this sucks...I mean it's almost 2005 and something that should be as simple as saving a file has to have root permissions. It's madness. [/rant]

To put you in the picture, I've just built a PC for my kids for xmas. No intel. No micro$oft.   :Smile:   It looks great, sounds great, it's fast, and burns CDs flawlessly, much better than my WinXP with Easy CD Creater5 Platinum POS that I had to buy for my work PC. But only as root. AAAGHHHH...

I'm using k3b, and for the kids, I don't want them going near a command line, and I didn't want them to even *know* there's such a thing as a root account (they're 8 & 10, and have a remarkable propensity to f*ck things up).

I've set it up with gentoo-dev-sources 2.6.9-r6 kernel. Is there no easy way to allow them to burn a CD without having to do it for them? (There's no way I'm telling them the root password).

Sorry to butt into this thread, but I've been looking all over for an easy solution, maybe changing file permissions and stuff, and this seemed the most suitable place to put it.

Cheers. (Oh, and happy xmas  :Wink:  )

----------

## Wim VDM

It should just work if you use k3bsetup2 to set permissions right. The  2.6.8-x kernels seem to mess up some things. It should work in 2.6.9-x, although it doesn't always work it seems. It works here, but I can't really say why (except that it started working after a recompile without nptl, which is strange).

If this helps, my cdrecord permissions are:

-rwxr-xr-x  1 root root 337972 Dec 12 12:22 /usr/bin/cdrecord

I've tried to get k3b to run cdrecord with sudo, but k3b refuses to be tricked in doing that. (I had replaced the original cdrecord by a script that called the real cdrecord through sudo, with identical arguments).

There are 2 other solutions I can think off to make it work:

- If you have no real need for 2.6, you could off course just use the latest 2.4 kernel. That will solve this problem guaranteed.

- You could run k3b with sudo. This will run k3b with root permissions, which is quite dangerous. You can mess things up pretty bad if you want, by deleting files from the filebrowser.

----------

## tabanus

Wim VDM consider yourself on my christmas card list   :Very Happy:  . Changing the permissions of cdrecord to what you suggested did the trick. K3b wanted to change them back when I ran it of course, warning something about not running as root wouldn't work LOL.

Many, many thanks

----------

