Can't do Mix_OpenAudio as root?

I have a problem with the SDL_mixer lib.
I can successfully opened the audiodevice when im running my application
from a normal user. But if i do sudo myapp the Mix_OpenAudio returns -1
and Mix_GetError tells me something like: Can’t open the requested file.

Do you have any idea what might cause this? Seems very strange that i
wouldn’t be able to run my application as root when i can run it as normal
user. There are some other restrictions in my application so it needs to
be run i sudo-mode.

I’ve tried this on slackware 10.2 and ubuntu 6.06, same error.

Any suggestions on what might cause this strange error?

Thanks
/Johan

johan at deepcore.se wrote:

I have a problem with the SDL_mixer lib.
I can successfully opened the audiodevice when im running my application
from a normal user. But if i do sudo myapp the Mix_OpenAudio returns -1
and Mix_GetError tells me something like: Can’t open the requested file.

Try strace.

Do you have any idea what might cause this? Seems very strange that i
wouldn’t be able to run my application as root when i can run it as normal
user. There are some other restrictions in my application so it needs to
be run i sudo-mode.

No matter what you app does, I highly doubt it. See Socker[1], for
example, which gives you access to privileged sockets. You can do
the equivalent for any kind of privileged system call or access to
a privileged filesystem object, if changing the group of that isn’
the right way to go. Socker can be used as setuid-root executable
or you can wrap it with sudo, whatever you prefer.

[1] http://ghostwhitecrab.com/socker/--
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060526/a44d9a62/attachment.pgp