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?

Steve Robbins
  • 1,904
  • 5
  • 23
  • 26

3 Answers3

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.

kasperd
  • 29,894
  • 16
  • 72
  • 122
0

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

ergohack
  • 101
  • 1
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.

BillThor
  • 27,354
  • 3
  • 35
  • 69