7

For some reason I'm not able to write to other users on my system.

[root@hostname ~]# write
write: you have write permission turned off.
[root@hostname ~]# mesg y
[root@hostname ~]# mesg
is y
[root@hostname ~]# write
write: you have write permission turned off.

What else needs to be enabled/corrected for this to work?

5
  • Open a second session, and using w to get the tty of your first user, use write user yourtty and see what that does.
    – Nathan C
    Oct 1, 2013 at 16:45
  • This gives the same result. Oct 1, 2013 at 16:58
  • 1
    Check /var/log/audit/audit.log for SELinux denials. Oct 1, 2013 at 17:27
  • @MichaelHampton There's a whole lot going on in here, but I don't see anything that looks like an error. Oct 1, 2013 at 22:45
  • What is the result of the command "ls -l /dev/tty" Jun 1, 2016 at 14:34

3 Answers 3

1

Testing strace write and strace mesg reveals a slight difference in how they identify your tty.

write will first do readlink("/proc/self/fd/0", ...) to find the name of the tty and then do a stat call on the resulting path.

mesg on the other hand will call fstat(1, ...) which skips the step of using readlink and doesn't rely on the /proc file system.

Notice that they also look at different file descriptors 0 vs 1. Normally an interactive shell will have file descriptors 0, 1, and 2 all referencing the same tty. If you have somehow gotten your shell running with 0 and 1 referencing something different for example if you had redirected one of them, that could explain the discrepancy between the output from mesg and write.

If the file descriptors are both referencing the same tty, another possible reason for the discrepancy could be that your /proc mount is not behaving as expected or the character device inode for your tty has been replaced.

0

When running as root with mesg disabled (returning n), I get the same error you have. Running the command mesg y enables me to run write. Running as root I can write to users that have mesg disabled, which I can't do as non-root.

There are multiple utilities that provide the write functionality. All of them will need to be able to write to terminals. However, as you are running as root permissions should not be an issue.

0

I had to edit /etc/login.defs and change TTYPERM 0600 to TTYPERM 0620.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .