From 41bba1a13e04c472115c71242a2d0ee1549e519b Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 15 Sep 2009 13:59:34 +0100 Subject: [PATCH] Don't use SCREENDIR under sudo. If SCREENDIR is set and we sudo the directory will probably be unusable. Unset it if SUDO_USER is defined. --- .profile.d/screen.bashrc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.profile.d/screen.bashrc b/.profile.d/screen.bashrc index ca08f6e..02026cd 100644 --- a/.profile.d/screen.bashrc +++ b/.profile.d/screen.bashrc @@ -1,9 +1,13 @@ # Fixup screen and define ``session'' if available. screen=$(find_working screen 2>/dev/null) if [ $? = 0 ]; then - # Override SCREENDIR iff screen is not setuid. + # Override SCREENDIR iff screen is not setuid (but not under sudo). if ! ls -l "$screen" | cut -d ' ' -f 1 | grep s >/dev/null; then - export SCREENDIR="$HOME/.screen/$HOSTNAME" + if [ -n "$SUDO_USER" ]; then + unset SCREENDIR + else + export SCREENDIR="$HOME/.screen/$HOSTNAME" + fi fi krenew=$(find_working krenew 2/dev/null) -- 2.20.1