3

I created some tmux session a while a ago, since then I've been added to some unix groups. As the tmux server has started before I was added into the groups, all shell I create in tmux won't be part of thoses groups.

I know there is this two thead who are related. 1 2

In the first one they use newgrp which open a new shell with a new group (if we have the right). It's not what I want for multiples reasons:

  • I'll have to do it for each groups (potentially a lot)
  • I'll have to do it for each new window/pane I'll create (potentially a lot)
  • I won't have access to the commands line history on the shells already open (potentially a lot)

In the second one, they simply kill the tmux server. I don't want to do that because I will lose all the shells history, and then I'll have to resetup all my env.

Is there a way to update the groups of the tmux server, and pass them to the open shells (potentially with a magic linux command)?

Phantom
  • 133
  • 6

1 Answers1

5

No. The credentials of a process cannot be changed externally, only by itself – and if the process no longer has the privileges to arbitrarily change its credentials (basically at the point where you log in and the login handler process drops its privileges from 'root' to your own UID), then it has no way of acquiring any additional groups.

Tools like newgrp or su or sg or sudo only work because they're external programs with the setuid bit (they start as root and initialize your credentials basically from scratch).

Use one of the other methods in the linked article (e.g. su to yourself) to get all groups at once, then use the scriptable tmux CLI to loop over all panes, sending them the shell commands to write history to some unique file, invoke su/sg, reload history from that file.

grawity
  • 501,077