Skip to content

Instantly share code, notes, and snippets.

@markizano
Last active January 29, 2024 13:20
Show Gist options
  • Save markizano/ac56a701d355885616c1023ae1d8f1dd to your computer and use it in GitHub Desktop.
Save markizano/ac56a701d355885616c1023ae1d8f1dd to your computer and use it in GitHub Desktop.
Run teams as its own user in Linux!
#!/bin/bash
# Teams shell you can add to ~teams/bin/teams and use `update-alternatives` to point to this instead.
# Be sure to add this to `/etc/sudoers.d/teams`
# %apps ALL=(msteams:apps) NOPASSWD: /usr/bin/teams
#
# I create a `teams` user using this:
# sudo addgroup --gid=200 apps
# sudo adduser --home=/home/apps/teams --shell=/usr/bin/teams --gid=200 --system msteams
#
# Now, when I run teams, it's as its own unprivileged user.
# Might have to run `xhost +SI:localuser:msteams` if you get X11 permission denied errors.
# If you are having sound issues, have a look at `~msteams/.pulse/client.conf` and make sure
# it's pointing to your pulseaudio server if you are using pulse (not sure for Alsa/Jack as of yet).
RUNAS_USER=teams
RUNAS_GROUP=apps
test "$UID" -eq `id -u $RUNAS_USER` || {
exec sudo -H -u$RUNAS_USER -g$RUNAS_GROUP "$0" $@
}
export XAUTHORITY="$HOME/.Xauthority"
. /usr/local/bin/common.sh
exec > >(NO_STDERR=1 log Microsoft-Teams)
exec 2>&1
cd
TEAMS_PATH="/usr/share/teams/teams"
TEAMS_LOGS="$HOME/.config/Microsoft/Microsoft Teams/logs"
mkdir -p "$TEAMS_LOGS"
exec "$TEAMS_PATH" "$@" --disable-namespace-sandbox --disable-setuid-sandbox > "$TEAMS_LOGS/teams-startup.log" &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment