Merge branch 'dev' of feistymeow.org:feisty_meow into dev
authorChris Koeritz <fred@gruntose.com>
Fri, 29 May 2020 17:44:40 +0000 (17:44 +0000)
committerChris Koeritz <fred@gruntose.com>
Fri, 29 May 2020 17:44:40 +0000 (17:44 +0000)
infobase/feisty_inits/dot.bashrc-normal-user
infobase/feisty_inits/dot.bashrc-root
scripts/core/functions.sh
scripts/core/launch_feisty_meow.sh
scripts/core/variables.sh
scripts/security/get_x_auth.sh [deleted file]

index fde023212e7de61709a0d8c90674f7a99cb34296..9c15d01120ecaa85b661bb9186fa9bcd40c4a69c 100644 (file)
@@ -9,6 +9,9 @@ if [ -f /etc/bash.bashrc ]; then
   # drag in the default version of this file.  this may not be needed if your
   # .bashrc script already has substantial code or already does this.
   source /etc/bash.bashrc
+elif [ -f /etc/bashrc ]; then
+  # pull in the mac's version of this file.
+  source /etc/bashrc
 fi
 
 ##############
index b3ff3381074e72f7ee45695602bb5a23e5d572bf..944ed1ad3ae663238a0c33d44ca49ebd79089d3f 100644 (file)
@@ -9,6 +9,9 @@ if [ -f /etc/bash.bashrc ]; then
   # drag in the default version of this file.  this may not be needed if your
   # .bashrc script already has substantial code or already does this.
   source /etc/bash.bashrc
+elif [ -f /etc/bashrc ]; then
+  # pull in the mac's version of this file.
+  source /etc/bashrc
 fi
 
 ##############
index 6389b6684b4cc7215613a69c2b3ecb52aae1a6b1..7876fb90908617b9ee79e435f85edd8bd16bde0a 100644 (file)
@@ -199,7 +199,7 @@ if [ -z "$skip_all" ]; then
   # wraps secure shell with some parameters we like, most importantly to enable X forwarding.
   function ssh()
   {
-    local args=($*)
+    local args=($@)
     # we remember the old terminal title, then force the TERM variable to a more generic
     # version for the other side (just 'linux'); we don't want the remote side still
     # thinking it's running xterm.
@@ -211,7 +211,7 @@ if [ -z "$skip_all" ]; then
 #    local oldterm="$TERM"
 #    export TERM=linux
 
-    /usr/bin/ssh -X -C "${args[@]}"
+    /usr/bin/ssh -Y -C "${args[@]}"
 
 #    # restore the terminal variable also.
 #    TERM="$oldterm"
@@ -400,13 +400,13 @@ if [ -z "$skip_all" ]; then
     fi
   }
   
-  # switches from an X:/ form to a /cygdrive/X/path form.  this is only useful
-  # for the cygwin environment currently.
-  function dos_to_unix_path() {
-    # we always remove dos slashes in favor of forward slashes.
-#old:    echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/'
-         echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/'
-  }
+#  # switches from an X:/ form to a /cygdrive/X/path form.  this is only useful
+#  # for the cygwin environment currently.
+#  function dos_to_unix_path() {
+#    # we always remove dos slashes in favor of forward slashes.
+##old:    echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/'
+#         echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/'
+#  }
 
   # returns a successful value (0) if this system is debian or ubuntu.
   function debian_like() {
@@ -422,45 +422,65 @@ if [ -z "$skip_all" ]; then
     fi
   }
   
-  # su function: makes su perform a login.
-  # for some OSes, this transfers the X authority information to the new login.
-  function su() {
-    if debian_like; then
-      # debian currently requires the full version which imports X authority
-      # information for su.
-  
-      # get the x authority info for our current user.
-      source "$FEISTY_MEOW_SCRIPTS/security/get_x_auth.sh"
-  
-      if [ -z "$X_auth_info" ]; then
-        # if there's no authentication info to pass along, we just do a normal su.
-        /bin/su -l $*
-      else
-        # under X, we update the new login's authority info with the previous
-        # user's info.
-        (unset XAUTHORITY; /bin/su -l $* -c "$X_auth_info ; export DISPLAY=$DISPLAY ; bash")
-      fi
-    else
-      # non-debian supposedly doesn't need the extra overhead any more.
-      # or at least suse doesn't, which is the other one we've tested on.
-      /bin/su -l $*
-    fi
-  }
+#bork  # su function: makes su perform a login.
+#bork  # for some OSes, this transfers the X authority information to the new login.
+#bork  function su() {
+#bork    if debian_like; then
+#bork      # debian currently requires the full version which imports X authority
+#bork      # information for su.
+#bork  
+#bork      # get the x authority info for our current user.
+#bork      source "$FEISTY_MEOW_SCRIPTS/security/get_x_auth.sh"
+#bork  
+#bork      if [ -z "$X_auth_info" ]; then
+#bork        # if there's no authentication info to pass along, we just do a normal su.
+#bork        /bin/su -l $*
+#bork      else
+#bork        # under X, we update the new login's authority info with the previous
+#bork        # user's info.
+#bork        (unset XAUTHORITY; /bin/su -l $* -c "$X_auth_info ; export DISPLAY=$DISPLAY ; bash")
+#bork      fi
+#bork    else
+#bork      # non-debian supposedly doesn't need the extra overhead any more.
+#bork      # or at least suse doesn't, which is the other one we've tested on.
+#bork      /bin/su -l $*
+#bork    fi
+#bork  }
   
-  # sudo function wraps the normal sudo by ensuring we replace the terminal
-  # label if they're doing an su with the sudo.
+  # this function wraps the normal sudo by ensuring we replace the terminal
+  # label before we launch what they're passing to sudo.  we also ensure that
+  # the feisty meow environment is recreated; normal subshells don't need
+  # this, but when switching identity with sudo, it seems important.  yet,
+  # we also don't want to hose up their normal sudo actions, such as passing
+  # along the current environment, should the user choose.
   function sudo() {
     save_terminal_title
     # hoist our X authorization info in case environment is passed along;
     # this can allow root to use our display to show Xorg windows.
-    export IMPORTED_XAUTH="$(xauth list $DISPLAY)"
-    /usr/bin/sudo "$@"
+    if [ ! -z "$DISPLAY" ]; then
+      export IMPORTED_XAUTH="$(xauth list $DISPLAY | head -n 1 | awk '{print $3}')"
+    fi
+    # prep a simple command string here, rather than messing with arguments
+    # in the already complicated command below.  i was seeing some really
+    # screwy behavior trying to expand $@ when embedded for the bash -c flag,
+    # but making the variable ahead of time gets rid of that.
+    cmd="/usr/bin/sudo ""$@"
+
+    # omit any variables that are either wrong for a different user or used
+    # to shield the feisty meow scripts from reconfiguring.  when we do the
+    # sudo, we want a fresh start for feisty meow at least.
+    # our approach to launching sudo is further complicated by our sentinel
+    # alias, which normally is passed to any subshells (to prevent recreating
+    # aliases).  we turn off the expand_aliases shell option to avoid passing
+    # the sentinel, which ensures aliases do get recreated for the new user.
+    BUILD_VARS_LOADED= \
+    CORE_VARIABLES_LOADED= \
+    FEISTY_MEOW_SCRIPTS_LOADED= \
+    function_sentinel= \
+    MAIL= \
+    bash +O expand_aliases -c "$cmd"
     retval=$?
     restore_terminal_title
-#    if [ "$first_command" == "su" ]; then
-#      # yep, they were doing an su, but they're back now.
-#      label_terminal_with_info
-#    fi
     return $retval
   }
   
index 913f82b43b2ac6c53273ecb2caa368799d5d21cf..1e7e6c993f0657d813bfbd0066ad053ef7835244 100644 (file)
@@ -86,6 +86,13 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
   # some preconditions we want to establish before loading anything...
   
   # make sure that aliases can be used in non-interactive shells.
+  # this causes all aliases that are currently defined for this shell to
+  # be inherited by subshells that this shell starts.  this is unusual,
+  # but is preferred for my workflow in feisty meow scripts; it saves me
+  # time re-adding aliases if i can count on them already being there.
+  # this is a problem if you *don't* want the aliases there though.  we can
+  # solve that problem by running bash with the "-O expand_aliases" flags to
+  # stop the expansion for the next subshell.
   shopt -s expand_aliases
   
   # patch the user variable if we were launched by one of our cron jobs.
@@ -97,7 +104,7 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
   # this allows root or other su'd identities to create windows with same
   # display variable.
   if [ ! -z "$DISPLAY" -a ! -z "$IMPORTED_XAUTH" ]; then
-    xauth add $IMPORTED_XAUTH
+    xauth add $DISPLAY . $IMPORTED_XAUTH
   fi
   
   ##############
index d8b44bc845aeaa7b2451473caabcb822bc1e83bb..c843dba6d20c4544bcd4438e67a889622e8da031 100644 (file)
@@ -9,8 +9,6 @@
 
 ##############
 
-#hmmm: moved from functions.sh; does that hose everything up?
-
   # defines a variable within the feisty meow environment and remembers that
   # this is a new or modified definition.  if the feisty meow codebase is
   # unloaded, then so are all the variables that were defined.
 return 0
   }
 
+  # switches from an X:/ form to a /cygdrive/X/path form.  this is only useful
+  # for the cygwin environment currently.
+  # defined here rather than in functions.sh since we need it when setting variables
+  # and cannot count on load order during a fresh startup in some circumstances.
+  function dos_to_unix_path() {
+    # we always remove dos slashes in favor of forward slashes.
+#old:    echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/'
+         echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/cygdrive\/\1\/\2/'
+  }
+
+
 
 ##############
 
diff --git a/scripts/security/get_x_auth.sh b/scripts/security/get_x_auth.sh
deleted file mode 100644 (file)
index c9f2ea8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-# This script finds the X window system authorization info that's already
-# been established for this display.  The information can then be used to
-# set the authorization for a new su session, which keeps X secure as
-# well as allowing the user to run X programs on the original display.
-
-# make sure we have some information to return in the first place.
-if [ ! -z "$DISPLAY" ]; then 
-  disp_search=$(echo $DISPLAY | sed -e 's/.*:\([0-9]*\).*/:\1/')
-#echo disp search is $disp_search
-  temp_auth=$(xauth list | grep -i $HOSTNAME | grep $disp_search)
-#echo temp auth is $temp_auth
-  temp_auth2=$(echo $temp_auth | sed -e "s/$HOSTNAME/; xauth add $HOSTNAME/g" )
-#echo temp auth2 is $temp_auth2
-  export X_auth_info="echo setting X permissions $temp_auth2"
-#echo $X_auth_info
-
-fi
-