On 07/09/2010 12:40 PM, Antoine Martin wrote:
> On 07/09/2010 06:18 AM, DRC wrote:
>> I would prefer it if the semantics were the same as the legacy vncpasswd
>> from TightVNC, whereby passing an argument of -f makes vncpasswd read
>> the plain text password from stdin and output the encrypted password to
>> stdout. I think that is ultimately more useful, since one could then
>> use vncpasswd in any command chain.
> I wasn't aware of the "-f"
>>
>> I will modify your patch to do this if it sounds reasonable.
> Please do.
OK, I needed to test it, so here it is. What do you think?
Cheers
Antoine
>
> Antoine
>
>
>>
>> On 7/8/10 1:22 PM, Antoine Martin wrote:
>>> [snip]
>>>>>> $ vncpasswd ARDpasswd
>>>>>> Password: <type "mypasswd">
>>>>>> Verify: <type "mypasswd">
>>>>> The reason why I didn't want to use vncpasswd is that it is interactive,
>>>>> are there any pure command line alternatives that I can use?
>>>>
>>>> I'm affraid it is currently impossible. However you might temporarily
>>>> use the "passwdInput" patch from Fedora and pass password directly to
>>>> vncviewer via pipe.
>>> There is now (see patch attached).
>>>
>>> Allows us to specify the password on the vncpasswd command line. ie:
>>> vncpasswd --password=MYPASSWORD ./password-file
>>>
>>> Tested against Apple's ARD and Xvnc, works for me.
>>>
>>> The patch is pretty ugly, done to minimize the number of line changed
>>> rather than doing anything efficient.
>>> What do you think?
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> Tigervnc-devel mailing list
>> Tigervnc-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tigervnc-devel
>
Index: vncpasswd.man
===================================================================
--- vncpasswd.man (revision 4084)
+++ vncpasswd.man (working copy)
@@ -3,12 +3,14 @@
vncpasswd \- change a VNC password
.SH SYNOPSIS
.B vncpasswd
-.RI [ passwd-file ]
+.RI [ passwd-file | \-f ]
.SH DESCRIPTION
.B vncpasswd
allows you to set the password used to access VNC desktops. It stores an
obfuscated version of the password in the given file (default
-$HOME/.vnc/passwd). The \fBvncserver\fP script runs \fBvncpasswd\fP the first
+$HOME/.vnc/passwd). With the \fB\-f\fP option, the password will be read
+from stdin and then encrypted password is written to stdout.
+The \fBvncserver\fP script runs \fBvncpasswd\fP the first
time you start a VNC desktop, and invokes \fBXvnc\fP with the appropriate
\fB\-rfbauth\fP option. \fBvncviewer\fP can also be given a password file to
use via the \fB\-passwd\fP option.
@@ -21,6 +23,17 @@
challenge-response mechanism is used over the wire making it hard for anyone to
crack the password simply by snooping on the network.
+.SH OPTIONS
+
+.TP
+.B passwd-file
+Use the given file rather than the default ($HOME/.vnc/passwd).
+
+.TP
+.B \-f
+Read password from stdin and write encrypted password to stdout.
+
+
.SH FILES
.TP
$HOME/.vnc/passwd
Index: vncpasswd.cxx
===================================================================
--- vncpasswd.cxx (revision 4084)
+++ vncpasswd.cxx (working copy)
@@ -33,7 +33,7 @@
static void usage()
{
- fprintf(stderr,"usage: %s [file]\n",prog);
+ fprintf(stderr,"usage: %s [-f|file]\n",prog);
exit(1);
}
@@ -63,6 +63,22 @@
return 0;
}
+// Reads password from stdin and prints encrypted password to stdout.
+static int encrypt_pipe() {
+ PlainPasswd buf(256);
+ fgets(buf.buf, 256, stdin);
+ if (strlen(buf.buf) < 6) {
+ fprintf(stderr,"Password must be at least 6 characters\n");
+ return 1;
+ }
+ ObfuscatedPasswd obfuscated(buf);
+ //fputs(prompt, stdout);
+ if (fwrite(obfuscated.buf, obfuscated.length, 1, stdout) != 1) {
+ fprintf(stderr,"Writing to stdout failed\n");
+ return 1;
+ }
+ return 0;
+}
int main(int argc, char** argv)
{
@@ -72,6 +88,8 @@
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-q") == 0) { // allowed for backwards compatibility
+ } else if (strncmp(argv[i], "-f", 2) == 0) {
+ return encrypt_pipe();
} else if (argv[i][0] == '-') {
usage();
} else if (!fname) {
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel