Skip to content

Security: mktemp, file permissions, removing temp file after. And a basic feature I needed. #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ done

AW_PATH=$HOME/.vim-anywhere
TMPFILE_DIR=/tmp/vim-anywhere
TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S")
mkdir -p $TMPFILE_DIR
TMPFILE=`mktemp -p $TMPFILE_DIR`
VIM_OPTS=--nofork

# Use ~/.gvimrc.min or ~/.vimrc.min if one exists
Expand All @@ -50,12 +51,11 @@ for vimrc_path in "${VIMRC_PATH[@]}"; do
fi
done

mkdir -p $TMPFILE_DIR
touch $TMPFILE
xclip -selection clipboard -o > $TMPFILE

# Linux
if [[ $OSTYPE == "linux-gnu" ]]; then
chmod o-r $TMPFILE # Make file only readable by you
chmod 600 $TMPFILE # Make file only readable by you

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be one of chmod 0600 or chmod go-rwx?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your question.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your original command removed permission only from other. My suggestion was to ensure that only your user be allowed, i.e. to remove permission from others in the group.

gvim $VIM_OPTS $TMPFILE
cat $TMPFILE | xclip -selection clipboard

Expand All @@ -82,3 +82,5 @@ elif [[ $OSTYPE == "darwin"* ]]; then
LANG=en_US.UTF-8 pbcopy < $TMPFILE
osascript -e "activate application \"$app\""
fi

rm $TMPFILE