mirror of
https://github.com/He4eT/fuzzy-bitwarden-clipboard.git
synced 2026-05-04 23:07: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
|
set -ef
|
||||||
|
|
||||||
|
local sessionfile='/tmp/bw_session'
|
||||||
|
|
||||||
copy_data () {
|
copy_data () {
|
||||||
local id=$1
|
local id=$1
|
||||||
local login=$2
|
local login=$2
|
||||||
|
|
@ -28,17 +30,31 @@ copy_data () {
|
||||||
fi
|
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() {
|
main() {
|
||||||
local searchterm=$1
|
local searchterm=$1
|
||||||
local sessionkey logins login id
|
local sessionkey logins login id
|
||||||
# Use an existing BW_SESSION or obtain a new session key
|
|
||||||
if [[ -z $BW_SESSION ]] ; then
|
sessionkey=$(get_saved_sessionkey)
|
||||||
echo "Creating new sessionkey..."
|
|
||||||
|
if [[ -z $sessionkey ]] ; then
|
||||||
sessionkey=$(bw unlock --raw)
|
sessionkey=$(bw unlock --raw)
|
||||||
|
save_sessionkey $sessionkey
|
||||||
else
|
else
|
||||||
echo "Using existing sessionkey..."
|
echo "Using the existing session key from $sessionfile"
|
||||||
sessionkey=$BW_SESSION
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Search for passwords using the search term
|
# Search for passwords using the search term
|
||||||
if [[ -z $searchterm ]] ; then
|
if [[ -z $searchterm ]] ; then
|
||||||
echo "Searchterm can't be empty"
|
echo "Searchterm can't be empty"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue