summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-05-07 16:03:45 +0200
committerPierre Ossman <ossman@cendio.se>2018-05-07 16:06:53 +0200
commite58fcb99b0b545767de51b57ef3f1bb4293b79f9 (patch)
tree271b32888674e6662cfa56de9069ead3d48032fe /unix
parent67814b638783f3dde6dd8df12346bbdf81c70efc (diff)
downloadtigervnc-e58fcb99b0b545767de51b57ef3f1bb4293b79f9.tar.gz
tigervnc-e58fcb99b0b545767de51b57ef3f1bb4293b79f9.zip
Handle view only password in vncpasswd filter mode
Diffstat (limited to 'unix')
-rw-r--r--unix/vncpasswd/vncpasswd.cxx20
-rw-r--r--unix/vncpasswd/vncpasswd.man3
2 files changed, 18 insertions, 5 deletions
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 16c925ee..8bd4e48e 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -67,18 +67,28 @@ static char* getpassword(const char* prompt) {
return 0;
}
-// Reads password from stdin and prints encrypted password to stdout.
+// Reads passwords from stdin and prints encrypted passwords to stdout.
static int encrypt_pipe() {
- char *result = getpassword(NULL);
- if (result) {
+ int i;
+
+ // We support a maximum of two passwords right now
+ for (i = 0;i < 2;i++) {
+ char *result = getpassword(NULL);
+ if (!result)
+ break;
+
ObfuscatedPasswd obfuscated(result);
if (fwrite(obfuscated.buf, obfuscated.length, 1, stdout) != 1) {
fprintf(stderr,"Writing to stdout failed\n");
return 1;
}
- return 0;
}
- else return 1;
+
+ // Did we fail to produce even one password?
+ if (i == 0)
+ return 1;
+
+ return 0;
}
static ObfuscatedPasswd* readpassword() {
diff --git a/unix/vncpasswd/vncpasswd.man b/unix/vncpasswd/vncpasswd.man
index e9250fdf..a62c0edd 100644
--- a/unix/vncpasswd/vncpasswd.man
+++ b/unix/vncpasswd/vncpasswd.man
@@ -32,6 +32,9 @@ Filter mode. Read a plain-text password from stdin and write an encrypted
version to stdout. Note that in filter mode, short or even empty passwords
will be silently accepted.
+A view-only password must be separated from the normal password by a newline
+character.
+
.SH FILES
.TP