Screen session running as root? (it shouldn’t be) node.js

gnu-screeniptablespermissions

cd /serv  
screen -R node  
{in the screen}  
node test.js  
C^a d  

initially,

ls -l /dev/pts  
total 0  
crw--w---- 1 tick-tock tty 136, 0 2011-04-19 16:41 0  
crw--w---- 1 tick-tock tty 136, 1 2011-04-19 16:41 1 

but after just a few seconds

ls -l /dev/pts  
total 0  
crw--w---- 1 tick-tock tty 136, 0 2011-04-19 16:47 0  
crw--w---- 1 root      tty 136, 1 2011-02-21 20:00 1  

How is the screen's terminal getting switched to root? Does this mean the node server is actually running with root permissions? It shouldn't be. The only other factor that might be an issue is that iptables forwards port 80 to port 8000 where the node server listens, so it doesn't have to run as root. I apologize if this is the wrong place to ask this, perhaps I should ask in a node.js community?

I have not su root or done any sudo commands beforehand, either.

Best Answer

Your system, once screen detaches, destroys the pts, and for some reason recreates it, if I understand correctly how udev is handling things on your system.

udev is the subsystem that controls the creation and destruction of devices in /dev, which is a dynamically generated filesystem. pts creation/destruction is handled by ptmx, which is used to create pseudo-terminal master/slave pairs. pts/* is the slave of the respective PTM, or pseudo-terminal master. As such, any permissions modifications that you see are a direct result of the destruction and creation of said device nodes, rather than modification. As for the date of the file, since the device nodes are clones, it's likely that the original used to create these nodes had a creation date of the time that you see in your ls output.

  • man ptmx -- Describes how ptmx creates new pts pseudo terminal device nodes.

What I don't understand is why there is a difference between how your system behaves versus how mine behaves with regard to /dev/pts/*. I do not experience perceived perms changes to devices; They either disappear entirely which is as it should be, or the perms do not change regardless of my actions (e.g., detaching screen, the device stays, and does not get destroyed/recreated.). Not only that, but the dates associated with my newly created pts/* devices are the current date.

One possibility is that the VPS you're using has something to do with this behavior. For example, I can't perform a dist-upgrade on my VPS, since the system they utilize only allows for one kernel version, the one they've hacked and put in place. The kind of restrictions that prevent you from updating your own kernel could also impact the functionality of other sub-systems. That's just speculation though, but it would make sense.

It could also just be a difference in how udev is configured.

Revision 3, with a lot of help from Gilles. ;)

Related Question