[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?

Thanks
Antoine
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 [--password=PASSWORD] [file]\n",prog);
   exit(1);
 }
 
@@ -49,8 +49,12 @@
   tcsetattr(fileno(stdin), TCSAFLUSH, &attrs);
 }
 
-static char* getpassword(const char* prompt) {
+static char* getpassword(const char* prompt, char* arg_pass) {
   PlainPasswd buf(256);
+  if (arg_pass!=0) {
+    strncpy(buf.buf, arg_pass, 256);
+    return buf.takeBuf();
+  }
   fputs(prompt, stdout);
   enableEcho(false);
   char* result = fgets(buf.buf, 256, stdin);
@@ -69,9 +73,12 @@
   prog = argv[0];
 
   char* fname = 0;
+  char* arg_pass = 0;
 
   for (int i = 1; i < argc; i++) {
     if (strcmp(argv[i], "-q") == 0) { // allowed for backwards compatibility
+    } else if (strncmp(argv[i], "--password=", 11) == 0) {
+      arg_pass = argv[i]+11;
     } else if (argv[i][0] == '-') {
       usage();
     } else if (!fname) {
@@ -92,8 +99,8 @@
     sprintf(fname, "%s/.vnc/passwd", getenv("HOME"));
   }
 
-  while (true) {
-    PlainPasswd passwd(getpassword("Password:"));
+  do {
+    PlainPasswd passwd(getpassword("Password:", arg_pass));
     if (!passwd.buf) {
       perror("getpassword error");
       exit(1);
@@ -107,7 +114,7 @@
       continue;
     }
 
-    PlainPasswd passwd2(getpassword("Verify:"));
+    PlainPasswd passwd2(getpassword("Verify:", arg_pass));
     if (!passwd2.buf) {
       perror("getpass error");
       exit(1);
@@ -135,4 +142,5 @@
 
     return 0;
   }
+  while (arg_pass==0);
 }
------------------------------------------------------------------------------
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

Reply via email to