From: Chris Koeritz Date: Fri, 29 May 2020 17:44:40 +0000 (+0000) Subject: Merge branch 'dev' of feistymeow.org:feisty_meow into dev X-Git-Tag: 2.140.123^2~4^2~4 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=b70135c76bac81e4fe7182c9b85fa810f7d31303;hp=2e34b725fd2553955fdfd41e400d2bf12c76ca03;p=feisty_meow.git Merge branch 'dev' of feistymeow.org:feisty_meow into dev --- diff --git a/infobase/feisty_inits/dot.bashrc-normal-user b/infobase/feisty_inits/dot.bashrc-normal-user index fde02321..9c15d011 100644 --- a/infobase/feisty_inits/dot.bashrc-normal-user +++ b/infobase/feisty_inits/dot.bashrc-normal-user @@ -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 ############## diff --git a/infobase/feisty_inits/dot.bashrc-root b/infobase/feisty_inits/dot.bashrc-root index b3ff3381..944ed1ad 100644 --- a/infobase/feisty_inits/dot.bashrc-root +++ b/infobase/feisty_inits/dot.bashrc-root @@ -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 ############## diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 6389b668..7876fb90 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -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 } diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index 913f82b4..1e7e6c99 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -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 ############## diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index d8b44bc8..c843dba6 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -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. @@ -30,6 +28,17 @@ 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 index c9f2ea81..00000000 --- a/scripts/security/get_x_auth.sh +++ /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 -