Skip to content

Commit 1ebc7eb

Browse files
authored
Merge pull request #9 from codewhitesec/develop
Prepare v1.2.1 Release
2 parents f72b7b7 + 3bf84d0 commit 1ebc7eb

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## v1.2.1 - Jan 25, 2024
10+
11+
### Changed
12+
13+
* Fix bug when target qube is the vault qube itself
14+
15+
916
## v1.2.0 - Nov 17, 2023
1017

1118
### Changed

qubes-keepass-dom0.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
VAULT='vault'
5-
VERSION='qubes-keepass v1.2.0'
5+
VERSION='qubes-keepass v1.2.1'
66

77

88
function get_id() {

qubes-keepass.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import re
66
import time
7-
import time
7+
import socket
88
import hashlib
99
import argparse
1010
import subprocess
@@ -644,19 +644,17 @@ def copy_to_qube(self, attribute: int, qube: str, trust_level: int) -> None:
644644
return
645645

646646
print(f'[+] Copying password of credential {self.title} to {qube}.')
647-
value = self.get_secret().encode()
647+
value = self.get_secret()
648648

649649
elif attribute == 11:
650650
print(f'[+] Copying username of credential {self.title} to {qube}.')
651-
value = self.username.encode()
651+
value = self.username
652652

653653
elif attribute == 12:
654654
print(f'[+] Copying url of credential {self.title} to {qube}.')
655-
value = self.url.encode()
655+
value = self.url
656656

657-
process = subprocess.Popen(['qrexec-client-vm', qube, 'custom.QubesKeepass'], stdin=subprocess.PIPE)
658-
process.stdin.write(value)
659-
process.stdin.close()
657+
perform_copy(qube, value)
660658

661659
qube_hash = hashlib.md5(qube.encode()).hexdigest()
662660
lockfile = Path.home() / f'.qubes-keepass-{qube_hash}.lock'
@@ -675,14 +673,35 @@ def copy_to_qube(self, attribute: int, qube: str, trust_level: int) -> None:
675673

676674
else:
677675
lockfile.unlink()
678-
679-
process = subprocess.Popen(['qrexec-client-vm', qube, 'custom.QubesKeepass'], stdin=subprocess.PIPE)
680-
process.stdin.write(''.encode())
681-
process.stdin.close()
676+
perform_copy(qube, '')
682677

683678
print(f'[+] Clipboard of {qube} cleared.')
684679

685680

681+
def perform_copy(qube: str, data: str) -> None:
682+
'''
683+
Performs the actual copy operation. Before the data is copied, the function checks
684+
whether the qube to copy the data to is the vault qube. In this case, the copy operation
685+
isn't performed via qrexec-client-vm, as it does not work for invoking commands within
686+
the same qube.
687+
688+
Parameters:
689+
qube qube to copy the data to
690+
data the data to copy
691+
692+
Returns:
693+
None
694+
'''
695+
if socket.gethostname() != qube:
696+
process = subprocess.Popen(['qrexec-client-vm', qube, 'custom.QubesKeepass'], stdin=subprocess.PIPE)
697+
698+
else:
699+
process = subprocess.Popen(['/etc/qubes-rpc/custom.QubesKeepass'], stdin=subprocess.PIPE)
700+
701+
process.stdin.write(data.encode())
702+
process.stdin.close()
703+
704+
686705
class CredentialCollection:
687706
'''
688707
Represents a collection of Credential objects.
@@ -838,7 +857,7 @@ def load(service: Secret.Service) -> CredentialCollection:
838857
return CredentialCollection(credentials)
839858

840859

841-
parser = argparse.ArgumentParser(description='''qubes-keepass v1.2.0 - A rofi based KeePassXC frontend for Qubes''')
860+
parser = argparse.ArgumentParser(description='''qubes-keepass v1.2.1 - A rofi based KeePassXC frontend for Qubes''')
842861
parser.add_argument('qube', help='qube to copy the credential to')
843862
parser.add_argument('--trust-level', type=int, help='numerical trust level of the qube')
844863
parser.add_argument('--config', help='path to the configuration file')

0 commit comments

Comments
 (0)