[Bug 2872] wall command shows error when logged in through non-root user.

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Fri Jun 1 21:57:23 AEST 2018


https://bugzilla.mindrot.org/show_bug.cgi?id=2872

--- Comment #4 from Mayank Sharma <mayasha9 at in.ibm.com> ---
Hi Darren,

Let me clarify this further :

On my AIX machine, currently we have 3 terminals opened as seen below :
# who
root        pts/0       Jun 01 05:05     
root        pts/1       Jun 01 02:19     
root        pts/2       Jun 01 06:11     


Now when we try to open a new terminal then pts/3 should get allocated
and ssh will change the terminal permissions accordingly.


So before opening the terminal we have the below permissions :
: /dev/pts
# ls -l 3
crw-rw-rw-    1 root     system       19,  3 Jun 01 06:28 3

After SSH session is opened and terminal 3 is assigned then the
terminal permissions changes as shown below:
: /dev/pts
# ls -l 3
crw-------    1 mayank   staff        19,  3 Jun 01 06:30 3
# who
root        pts/0       Jun 01 05:05     
root        pts/1       Jun 01 02:19     
root        pts/2       Jun 01 06:11     
mayank      pts/3       Jun 01 06:30  <---- terminal 3 assigned to
non-root user


Here, what we see is that modes of terminal 3 has been changed to 600
(since we dont have tty group) as per the below code:

File: sshpty.c

void
pty_setowner(struct passwd *pw, const char *tty)
{
.
.
.
        /* Determine the group to make the owner of the tty. */
        grp = getgrnam("tty");
        gid = (grp != NULL) ? grp->gr_gid : pw->pw_gid;
        mode = (grp != NULL) ? 0620 : 0600;

        /*
         * Change owner and mode of the tty as required.
.
.
.

In this scenario, if we try to run wall command then it fails with the
error message as I mentioned in comment 1.


Now we tried to change the modes in pty_setowner function and replace
it with permissions as per openssh release before 6.8 version.
So, as per the commit
https://github.com/openssh/openssh-portable/commit/a5883d4eccb94b16c355987f58f86a7dee17a0c2#diff-49e4e431bffb87ccf87cea3ce20c82f3

We see in the case of 'else' part, the modes has been changed from
mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
to
mode = (grp != NULL) ? 0622 : 0600;
The S_IWGRP and S_IWOTH permission is missing in the 'else' part.
Hence, we modified the code as :
void
pty_setowner(struct passwd *pw, const char *tty)
{
.
.
.
        /* Determine the group to make the owner of the tty. */
        grp = getgrnam("tty");
        gid = (grp != NULL) ? grp->gr_gid : pw->pw_gid;
/*      mode = (grp != NULL) ? 0620 : 0600; */
        mode = (grp != NULL) ? 0620 : 0620; 

        /*
         * Change owner and mode of the tty as required.
.
.
.
With this modification, we didnot see the issue with wall command. Can
you please let us know if our changes are valid ?

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list