Permission denied

I'm using a SUN server and while using

echo "Yoh" > /dev/pts/x (x is a number)

I can send the message to myself, or when I'm root, I can send mesg to user but user cannot send message to each other, error message is "permission denied", what can I do with this ?
ahTriAsked:
Who is Participating?
 
festiveConnect With a Mentor Commented:
As stated already by jlevie this is not something that you would normally do,
however if you must do it you need to setup a shell script or program as "setuid" root.
you could then redirect the output to the target pty, ie something like the following:

#!/bin/sh -p
PROGRAM=$0
ARG1="$1" # pty number
ARG2="$2" message in quotes
cat $ARG2 > $ARG1

This is not recommended, and perhaps a compromise may be to put setuid on one of the mentioned utilities.

0
 
jlevieCommented:
Well you're not supposed to be able to do that as an ordinary user. If you could write to just any user's terminal a lot of malicious things would be possible and there wouldn't be any way for the user to control it. Don't do it that way.

There are facilities within Unix specifically for this purpose. Look at the man pages for wall(1M), write(1), mesg(1), and talk(1). Probably the one you want is write(1).
0
 
ahTriAuthor Commented:
it gotta be something relate to tty because currently every user have mesg on, can talk, can write ...
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
markparrCommented:
Have you checked the permissions on the /dev/pts/#?  I just checked my nonsecure development machine (IBM RS/6000) and the permissions are set to rw--w--w- so everyone has write access to my tty so a "echo message > /dev/pts/#" would work.
0
 
ahTriAuthor Commented:
I did try but onn SUN /dev/pts/# is just a link to ../devices/pseudo/..... so cannot change access right
0
 
jlevieCommented:
I don't think you need suid on write(1) and I know that you don't on talk(1).
0
 
ahTriAuthor Commented:
festive, is that a script to run on root ?

#!/bin/sh -p

this line doesn't run, maybe I don't have sh
0
 
festiveCommented:
this script to run needs to be setuid root, and the top line means that it is a bourne shell script.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.