Solved

/dev/audio

Posted on 1998-06-19
6
1,302 Views
Last Modified: 2013-12-16
Hi
Need some help with audio device in Solaris 2.4 running on sparc-10.
Using audioplay command in shell scripts to play warning sound under certain conditions.

# audioplay /usr/demo/SOUND/sounds/doorbell.au

Unless the script is run by root or the user who is currently logged in on the console then permission is denied for the audio device "/dev/audio". The audio device only has rw permission and is owned by the user who is logged onto the console.

# ls -l /dev/audio
lrwxrwxrwx   1 root     root          12 Feb  2  1997 /dev/audio -> /dev/sound/0
# ls -l /dev/sound/0
lrwxrwxrwx   1 root     root          42 Feb  2  1997 /dev/sound/0 -> ../../devices/audio@1,f7201000:sound,audio
# ls -l /devices/audio@1,f7201000:sound,audio
crw-------   1 <loginName>   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio

The scripts are run by cron and cannot be run as root or as the user who is logged onto console.
The console login is always the same so to get round this for now I have added the following to the console login users .profile:
chmod g+w /devices/audio@1,f7201000:sound,audio.

However this will fail if the sparc is rebooted at any time without a login taking place on the console (a remote re-boot for example), as permission will be denied.

This is the question:
Is there any way to set the permissions of the audio device regardless of who logs into the console.
0
Comment
Question by:gormenghast
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:rickyr
ID: 1812150
Hi....
have you tried...
#chmod ugw+rw  /devices/audio@1,f7201000:sound,audio
I noticed that the character special is only read/write for root.
regards
0
 
LVL 3

Expert Comment

by:rickyr
ID: 1812151
Sorry...
Imeant ugo (user group other)................
0
 
LVL 2

Author Comment

by:gormenghast
ID: 1812152
Hi rickyr

The permissions and ownership for "/devices/audio@1,f7201000:sound,audio" is dependent on who logged onto the console, and any change of permissions or ownership will only be valid while that person is logged on.
For example:
boot up sparc and login in locally

login: fredf
password: •••••••
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-------   1 fredf   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio
# chmod 666 /devices/audio@1,f7201000:sound,audio
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-rw-rw-   1 fredf   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio

logout

login: barneyr
password: •••••••
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-------   1 barneyr   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 2

Expert Comment

by:seedy
ID: 1812153
>Is there any way to set the permissions of the audio device regardless of who logs into the console.

No.  Let me explain.  The audio device is a "speaker" housed in the main CPU box of the Sun machine.  And is considered part of the console - just like the keyboard, mouse and the display unit of the console.  That is the reason it is set to be owned by the user who is currently logged on to the console.

Imagine you telnet to the host via a network - miles away from the machine/console.  And if you play anything to the audio device, you can't hear anything, can you?

If your requirement is to play something to the audio device from a script run from crontab, you must be a root to change the permissions of the device and to 'write' to it.
0
 
LVL 2

Accepted Solution

by:
seedy earned 100 total points
ID: 1812154
Palying back to the console audio device from a cron job is not something I would like.  But then it may be is possible by some indirect way.

You can create another device node with the same major and minor device number as that of '/dev/audio' and use that device to play your audio files.

Find out device type and the major & minor device number of the audio device.
Do an "ls -l" to get this info.

From what you have posted, I see that your audio device is a charater special device with major number 28 and minor number 0(zero).
Now, create a new device with this info.
# mknod /devices/myaudio c 28 0
Set permissions to this device
# chmod 666 /device/myaudio

Use this device to play back your audio files in your scripts by
    audioplay -d /devices/myaudio <file>

0
 
LVL 3

Expert Comment

by:rickyr
ID: 1812155
Hello...
Run your script as root, then su to the user that will run the script,
Then su to the user that will ding the bell.
then su to the user that runs the script, to carry on with the script.
regards
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now