mirror of
https://github.com/He4eT/fuzzy-bitwarden-clipboard.git
synced 2026-05-04 14:57:22 +00:00
Save session in tmp
This commit is contained in:
parent
a002febdc7
commit
9a0b47e923
1 changed files with 21 additions and 5 deletions
26
bwc
26
bwc
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
set -ef
|
||||
|
||||
local sessionfile='/tmp/bw_session'
|
||||
|
||||
copy_data () {
|
||||
local id=$1
|
||||
local login=$2
|
||||
|
|
@ -28,17 +30,31 @@ copy_data () {
|
|||
fi
|
||||
}
|
||||
|
||||
function get_saved_sessionkey () {
|
||||
sudo touch $sessionfile
|
||||
echo $(sudo cat $sessionfile)
|
||||
}
|
||||
|
||||
function save_sessionkey () {
|
||||
local sessionkey=$1
|
||||
sudo sh -c "echo $sessionkey > $sessionfile"
|
||||
sudo chmod 600 $sessionfile
|
||||
}
|
||||
|
||||
main() {
|
||||
local searchterm=$1
|
||||
local sessionkey logins login id
|
||||
# Use an existing BW_SESSION or obtain a new session key
|
||||
if [[ -z $BW_SESSION ]] ; then
|
||||
echo "Creating new sessionkey..."
|
||||
|
||||
sessionkey=$(get_saved_sessionkey)
|
||||
|
||||
if [[ -z $sessionkey ]] ; then
|
||||
sessionkey=$(bw unlock --raw)
|
||||
save_sessionkey $sessionkey
|
||||
else
|
||||
echo "Using existing sessionkey..."
|
||||
sessionkey=$BW_SESSION
|
||||
echo "Using the existing session key from $sessionfile"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Search for passwords using the search term
|
||||
if [[ -z $searchterm ]] ; then
|
||||
echo "Searchterm can't be empty"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue