Bug 11127

Summary: mesg does not work after su --login
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Patrick Ohly <patrick.ohly>
Component: coreAssignee: Patrick Ohly <patrick.ohly>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: meta.mr.watcher, meta.watcher
Version: unspecified   
Target Milestone: 2.4 M2   
Hardware: x86   
OS: Multiple   
Whiteboard: Backport to 2.3.1
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Patrick Ohly 2017-03-06 13:22:26 UTC
To reproduce, build current core-image-minimal for Poky with default config. Boot into qemu, then:

root@qemux86:~# adduser test
Changing password for test
New password: 
Retype password: 
Password for test changed by root
root@qemux86:~# su - test
qemux86:~$ mesg n
qemux86:~$ mesg y
mesg: error: tty device is not owned by group `tty'

qemux86:~$ cat ~/.profile 
# ~/.profile: executed by Bourne-compatible login shells.

if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# path set by /etc/profile
# export PATH

mesg n

Note that "mesg n" is run by default and just happens to work accidentally (?).

qemux86:~$ ls -l /proc/self/fd/2 
lrwx------    1 test     test            64 Mar  6 13:07 /proc/self/fd/2 -> /dev/ttyS0
qemux86:~$ ls -l /dev/ttyS0
crw-------    1 root     root        4,  64 Mar  6 13:07 /dev/ttyS0
qemux86:~$ ls -l /usr/bin/mesg
/usr/bin/mesg -> /usr/bin/mesg.sysvinit

It fails slightly differently with systemd + pam (not tested without pam):

DISTRO_FEATURES_append = " pam systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"

qemux86 login: root
root@qemux86:~# adduser test
New password: 
Retype new password: 
passwd: password updated successfully
root@qemux86:~# su - test
mesg: Operation not permitted
qemux86:~$ mesg n
mesg: Operation not permitted
qemux86:~$ mesg y
mesg: Operation not permitted
root@qemux86:~# ls -l /usr/bin/mesg 
lrwxrwxrwx    1 root     root            19 Mar  6 13:11 /usr/bin/mesg -> /bin/busybox.nosuid

Here "mesg" always fails and prints the error message.

That the /dev/tty* permissions prevent using mesg after "su --login" is probably unavoidable. It does not happen when logging into the console as the user directly.

However, the error message is annoying. Perhaps the default .profile should use "mesg n 2>/dev/null" ?
Comment 1 Ross Burton 2017-06-06 11:27:08 UTC
Patrick, would you be able to handle this?  Your resolution seems sensible to me.
Comment 2 Patrick Ohly 2017-08-01 09:38:54 UTC
Fixed in "base-files: ignore "mesg n" error messages".