Opened 11 years ago

Last modified 6 years ago

#40872 assigned defect

screen: attach in multiuser mode fails with "Attach attempt with bad pid" message

Reported by: steve@… Owned by: dgilman (David Gilman)
Priority: Normal Milestone:
Component: ports Version: 2.2.0
Keywords: Cc:
Port: screen

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Screen has a multiuser sharing capability which is ordinarily enabled by setting the screen executable to setuid root and executing the following commands for a screen:

multiuser on
acladd OTHER_USER_ID

When screen is working properly, one user can start a screen with screen -S SCREEN_NAME while OTHER_USER_ID joins the same screen with screen -x FIRST_USER_ID/SCREEN_NAME.

However, when attempting to do this on os-X Lion (and probably previously all the way back to Snow Leopard), the second user's attachment fails (hangs) while the first user sees the message "Attach attempt with bad pid" at the bottom of their screen for a few seconds.

The source of the problem is a line that looks like this in socket.c:

UserReturn(kill(pid, 0))

Apparently, the kill runs in the context of the real user id instead of the effective user id and thus the attachee process does not have permission to kill 0 the attaching process (the processes are owned by different users) even though screen is setuid root.

For some reason, this is not a problem on many other operating systems such as previous versions of OS-X or any version of Linux I've ever seen.

One workaround that may or may not introduce other problems is to simply presume the attaching process is indeed running and return success instead of returning the result of the kill call.

i.e.:

perl -p -i -e  's/UserReturn\(kill\(pid, 0\)\)/return 0/' socket.c

I have tested the patch and it solves the problem although I am not sure what other problems it might create. :)

Change History (4)

comment:1 Changed 11 years ago by steve@…

I'd like to edit the title of this ticket but cannot figure out how to.

Please let me know or edit the title to include reference to the fact that this is a problem with gnu screen.

comment:2 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Port: screen added
Summary: attach in multiuser mode fails with "Attach attempt with bad pid" messagescreen: attach in multiuser mode fails with "Attach attempt with bad pid" message

comment:3 Changed 11 years ago by neverpanic (Clemens Lang)

Does this still happen with 4.2.1 committed in r119587?

comment:4 Changed 6 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to dgilman
Status: newassigned
Note: See TracTickets for help on using tickets.