Created
January 11, 2022 03:28
-
-
Save boltronics/5cf521b53d37112fe7eb8ed7e15c0b44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Add supplementary group permissions and update the shell prompt. | |
| # Requires adding the following to .bashrc after PS1 has been set: | |
| # if [ -n "${PS1_PREFIX}" ] | |
| # then | |
| # export PS1="${PS1_PREFIX}${PS1}" | |
| # unset PS1_PREFIX | |
| # fi | |
| declare newsubgrp="${1}" | |
| if [ -z "${newsubgrp}" ] | |
| then | |
| echo "Usage: $(basename ${0}) GROUP" 1>&2 | |
| exit 1 | |
| fi | |
| if ! groups | cut -d ' ' -f 2- | grep -q "${newsubgrp}" | |
| then | |
| export NEWSUBGRP_OLDPS1="${PS1}" PS1_PREFIX="[${newsubgrp}] " | |
| sg "${newsubgrp}" "newgrp "$(id -gn)"" | |
| PS1="${NEWSUBGRP_OLDPS1}" | |
| unset PS1_PREFIX NEWSUBGRP_OLDPS1 newsubgrp | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Starting from Debian 13, Debian has replaced the login package from shadow with the utilities from util-linux (Debian bug report #833256).
In the case of either implementation, the output of the
idcommand after callingsg <somegroup>will list the group in both thegid=value, as well as in the supplementarygroups=list. However only shadow'ssgimplementation will seemingly tell the truth about what it's told the kernel.Debian 12:
Debian 13:
In Debian 12, the supplementary group
Groups:line of/proc/self/statusshows the ID of the group that was added. yet it does not appear there in Debian 13. As you might surmise, this prevents newsubgrp from working.Fortunately, Arch continues to use shadow at the time of writing, and that's what I use these days. It's why it took me this long to notice the issue.