mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
Password: Pass password to pipe, to hide password in command line
This commit is contained in:
parent
dc7199e47d
commit
09cf4cb72f
2 changed files with 18 additions and 12 deletions
6
main.qml
6
main.qml
|
@ -60,7 +60,7 @@ Item {
|
||||||
source: "mainWindow.qml"
|
source: "mainWindow.qml"
|
||||||
|
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
console.log("Status changed", status);
|
console.log("Loader Status Changed.", status);
|
||||||
if (status == Loader.Null) {
|
if (status == Loader.Null) {
|
||||||
gc();
|
gc();
|
||||||
// This cause memory leak at this moment.
|
// This cause memory leak at this moment.
|
||||||
|
@ -71,8 +71,7 @@ Item {
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
window.onVisibleChanged.connect(function(visible) {
|
window.onVisibleChanged.connect(function(visible) {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
console.log('hiding');
|
console.log("Unloading ApplicationWindow...");
|
||||||
console.log("unloading...");
|
|
||||||
mainLoader.active = false;
|
mainLoader.active = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -119,7 +118,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivated: function(reason) {
|
onActivated: function(reason) {
|
||||||
console.log(reason);
|
|
||||||
if (reason == SystemTrayIcon.Context) {
|
if (reason == SystemTrayIcon.Context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,12 @@ class SubprocessWrapper:
|
||||||
with open(os.devnull, "w") as f:
|
with open(os.devnull, "w") as f:
|
||||||
subprocess.check_call(arg.split(), stdout=f, stderr=f)
|
subprocess.check_call(arg.split(), stdout=f, stderr=f)
|
||||||
|
|
||||||
def run(self, arg: str) -> str:
|
def run(self, arg: str, input: str = None) -> str:
|
||||||
return subprocess.run(arg.split(), stdout=subprocess.PIPE).stdout.decode('utf-8')
|
if input:
|
||||||
|
input = input.encode('utf-8')
|
||||||
|
with open(os.devnull, "w") as f:
|
||||||
|
return subprocess.run(arg.split(), input=input, stdout=subprocess.PIPE,
|
||||||
|
stderr=f).stdout.decode('utf-8')
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Twisted class
|
# Twisted class
|
||||||
|
@ -157,7 +161,6 @@ class Display(object):
|
||||||
ret += f" not active {self.width}x{self.height}"
|
ret += f" not active {self.width}x{self.height}"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class DisplayProperty(QObject):
|
class DisplayProperty(QObject):
|
||||||
_display: Display
|
_display: Display
|
||||||
|
|
||||||
|
@ -538,11 +541,12 @@ class Backend(QObject):
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def createVNCPassword(self, password):
|
def createVNCPassword(self, password):
|
||||||
if password:
|
if password:
|
||||||
|
password += '\n' + password + '\n\n' # verify + confirm
|
||||||
p = SubprocessWrapper()
|
p = SubprocessWrapper()
|
||||||
try:
|
try:
|
||||||
p.run(f"x11vnc -storepasswd {password} {X11VNC_PASSWORD_PATH}")
|
p.run(f"x11vnc -storepasswd {X11VNC_PASSWORD_PATH}", input=password)
|
||||||
except:
|
except Exception as e:
|
||||||
print("Failed creating password")
|
print("Failed creating password", e)
|
||||||
return
|
return
|
||||||
self.vncUsePassword = True
|
self.vncUsePassword = True
|
||||||
else:
|
else:
|
||||||
|
@ -566,16 +570,20 @@ class Backend(QObject):
|
||||||
print("VNC Server is already running.")
|
print("VNC Server is already running.")
|
||||||
return
|
return
|
||||||
# regex used in callbacks
|
# regex used in callbacks
|
||||||
re_connection = re.compile(r"^.*Got connection from client.*$", re.M)
|
patter_connected = re.compile(r"^.*Got connection from client.*$", re.M)
|
||||||
|
patter_disconnected = re.compile(r"^.*client_count: 0*$", re.M)
|
||||||
# define callbacks
|
# define callbacks
|
||||||
def _onConnected():
|
def _onConnected():
|
||||||
print("VNC started.")
|
print("VNC started.")
|
||||||
self.vncState = self.VNCState.WAITING
|
self.vncState = self.VNCState.WAITING
|
||||||
def _onReceived(data):
|
def _onReceived(data):
|
||||||
data = data.decode("utf-8")
|
data = data.decode("utf-8")
|
||||||
if (self._vncState is not self.VNCState.CONNECTED) and re_connection.search(data):
|
if (self._vncState is not self.VNCState.CONNECTED) and patter_connected.search(data):
|
||||||
print("VNC connected.")
|
print("VNC connected.")
|
||||||
self.vncState = self.VNCState.CONNECTED
|
self.vncState = self.VNCState.CONNECTED
|
||||||
|
if (self._vncState is self.VNCState.CONNECTED) and patter_disconnected.search(data):
|
||||||
|
print("VNC disconnected.")
|
||||||
|
self.vncState = self.VNCState.WAITING
|
||||||
def _onEnded(exitCode):
|
def _onEnded(exitCode):
|
||||||
print("VNC Exited.")
|
print("VNC Exited.")
|
||||||
self.vncState = self.VNCState.OFF
|
self.vncState = self.VNCState.OFF
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue