[MacPorts] #40872: attach in multiuser mode fails with "Attach attempt with bad pid" message

MacPorts noreply at macports.org
Wed Oct 23 14:06:58 PDT 2013


#40872: attach in multiuser mode fails with "Attach attempt with bad pid" message
---------------------+--------------------------------
 Reporter:  steve@…  |      Owner:  macports-tickets@…
     Type:  defect   |     Status:  new
 Priority:  Normal   |  Milestone:
Component:  ports    |    Version:  2.2.0
 Keywords:           |       Port:
---------------------+--------------------------------
 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. :)

-- 
Ticket URL: <https://trac.macports.org/ticket/40872>
MacPorts <http://www.macports.org/>
Ports system for OS X


More information about the macports-tickets mailing list