5
|
1 |
Index: ChangeLog
|
|
2 |
===================================================================
|
|
3 |
RCS file: ChangeLog,v
|
|
4 |
retrieving revision 1.1
|
|
5 |
retrieving revision 1.4
|
|
6 |
diff -u -r1.1 -r1.4
|
|
7 |
--- ChangeLog 25 Apr 2006 04:23:47 -0000 1.1
|
|
8 |
+++ ChangeLog 26 Apr 2006 11:14:24 -0000 1.4
|
|
9 |
@@ -0,0 +1,24 @@
|
|
10 |
+2006-04-26 Jimmy Yin <[email protected]>
|
|
11 |
+ add -logtostdout arg to unison
|
|
12 |
+ if this arg is added with unison, unison would output the log msg to stdout at the same with logfile.
|
|
13 |
+ * ubase/trace.ml
|
|
14 |
+ * ubase/trace.mli
|
|
15 |
+ * uitext/ml
|
|
16 |
+2006-04-26 Jimmy Yin <[email protected]>
|
|
17 |
+ SyncIt need the UnisonSyncLogMsg to detemine the sync status.
|
|
18 |
+ The patch makes unison output msg to stdout the same time as output msg to logfile.
|
|
19 |
+ Unison output the percentage of syncing for each file, but it do not flush the stdout.
|
|
20 |
+ The patch add "\n" to percentage message to flush the stdout. Then syncit could get percentage message.
|
|
21 |
+ * ubase/trace.ml
|
|
22 |
+ * uitext.ml
|
|
23 |
+2006-04-25 Jimmy Yin <[email protected]>
|
|
24 |
+ Solaris do not support openpty and forkpty functions
|
|
25 |
+ The same functionality could be implemented by solaris pty driver and pts drive.
|
|
26 |
+ * pty.c
|
|
27 |
+2006-04-25 Jimmy Yin <[email protected]>
|
|
28 |
+ add a new args to unison : sshpassword
|
|
29 |
+ it is used to give the ssh password to unison
|
|
30 |
+ when unison get the password, it do not ask user to input password during syncing
|
|
31 |
+ * terminal.ml
|
|
32 |
+ * terminal.mli
|
|
33 |
+ * remote.ml
|
|
34 |
Index: pty.c
|
|
35 |
===================================================================
|
|
36 |
RCS file: pty.c,v
|
|
37 |
retrieving revision 1.1
|
|
38 |
retrieving revision 1.2
|
|
39 |
diff -u -r1.1 -r1.2
|
|
40 |
--- pty.c 19 Apr 2006 15:42:06 -0000 1.1
|
|
41 |
+++ pty.c 24 Apr 2006 11:59:59 -0000 1.2
|
|
42 |
@@ -9,6 +9,8 @@
|
|
43 |
extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
|
|
44 |
extern void uerror (char * cmdname, value arg) Noreturn;
|
|
45 |
|
|
46 |
+#define SOLARIS 1 //for solaris only, if no solaris, remote it
|
|
47 |
+
|
|
48 |
// openpty
|
|
49 |
#if defined(__linux)
|
|
50 |
#include <pty.h>
|
|
51 |
@@ -25,6 +27,14 @@
|
|
52 |
#define HAS_OPENPTY 1
|
|
53 |
#endif
|
|
54 |
|
|
55 |
+#ifdef SOLARIS
|
|
56 |
+#include <fcntl.h>
|
|
57 |
+#include <sys/termios.h>
|
|
58 |
+#include <unistd.h>
|
|
59 |
+#include <stropts.h>
|
|
60 |
+#define HAS_OPENPTY 1
|
|
61 |
+#endif
|
|
62 |
+
|
|
63 |
#ifdef HAS_OPENPTY
|
|
64 |
|
|
65 |
#include <sys/ioctl.h>
|
|
66 |
@@ -32,16 +42,31 @@
|
|
67 |
|
|
68 |
CAMLprim value setControllingTerminal(value fdVal) {
|
|
69 |
int fd = Int_val(fdVal);
|
|
70 |
+#ifdef SOLARIS
|
|
71 |
+ ioctl(fd, I_PUSH, "ptem"); /* push ptem */
|
|
72 |
+ ioctl(fd, I_PUSH, "ldterm"); /* push ldterm*/
|
|
73 |
+#else
|
|
74 |
if (ioctl(fd, TIOCSCTTY, (char *) 0) < 0)
|
|
75 |
uerror("ioctl", (value) 0);
|
|
76 |
+#endif
|
|
77 |
return Val_unit;
|
|
78 |
}
|
|
79 |
|
|
80 |
/* c_openpty: unit -> (int * Unix.file_descr) */
|
|
81 |
CAMLprim value c_openpty() {
|
|
82 |
int master,slave;
|
|
83 |
+#ifdef SOLARIS
|
|
84 |
+ char * slavename;
|
|
85 |
+ extern char *ptsname();
|
|
86 |
+ master = open("/dev/ptmx", O_RDWR);
|
|
87 |
+ grantpt(master);
|
|
88 |
+ unlockpt(master);
|
|
89 |
+ slavename = ptsname(master);
|
|
90 |
+ slave = open(slavename, O_RDWR);
|
|
91 |
+#else
|
|
92 |
if (openpty(&master,&slave,NULL,NULL,NULL) < 0)
|
|
93 |
uerror("openpty", (value) 0);
|
|
94 |
+#endif
|
|
95 |
value pair = alloc_tuple(2);
|
|
96 |
Store_field(pair,0,Val_int(master));
|
|
97 |
Store_field(pair,1,Val_int(slave));
|
|
98 |
Index: remote.ml
|
|
99 |
===================================================================
|
|
100 |
RCS file: remote.ml,v
|
|
101 |
retrieving revision 1.1
|
|
102 |
retrieving revision 1.3
|
|
103 |
diff -u -r1.1 -r1.3
|
|
104 |
--- remote.ml 19 Apr 2006 15:39:42 -0000 1.1
|
|
105 |
+++ remote.ml 25 Apr 2006 13:10:37 -0000 1.3
|
|
106 |
@@ -422,6 +422,15 @@
|
|
107 |
^ "command used to invoke the remote server. "
|
|
108 |
)
|
|
109 |
|
|
110 |
+let sshpassword =
|
|
111 |
+ Prefs.createString "sshpassword" ""
|
|
112 |
+ "recommended ssh password for remote shell command"
|
|
113 |
+ ("The string value of this preference will be passed as additional "
|
|
114 |
+ ^ "arguments (besides the host name and the name of the Unison "
|
|
115 |
+ ^ "executable on the remote system) to the \\verb|ssh| "
|
|
116 |
+ ^ "command used to invoke the remote server. "
|
|
117 |
+ )
|
|
118 |
+
|
|
119 |
let serverCmd =
|
|
120 |
Prefs.createString "servercmd" ""
|
|
121 |
("name of " ^ Uutil.myName ^ " executable on remote server")
|
|
122 |
@@ -860,6 +869,9 @@
|
|
123 |
Prefs.read rshargs
|
|
124 |
else
|
|
125 |
"") in
|
|
126 |
+ let shellCmdPwd =
|
|
127 |
+ Prefs.read sshpassword
|
|
128 |
+ in
|
|
129 |
let preargs =
|
|
130 |
([shellCmd]@userArgs@portArgs@
|
|
131 |
[host]@
|
|
132 |
@@ -890,20 +902,30 @@
|
|
133 |
debug (fun ()-> Util.msg "Shell connection: %s (%s)\n"
|
|
134 |
shellCmd (String.concat ", " args));
|
|
135 |
let term =
|
|
136 |
- match termInteract with
|
|
137 |
- None ->
|
|
138 |
- ignore (Unix.create_process shellCmd argsarray i1 o2 Unix.stderr);
|
|
139 |
- None
|
|
140 |
- | Some callBack ->
|
|
141 |
- fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr)
|
|
142 |
- in
|
|
143 |
+ (if shellCmdPwd = "" then
|
|
144 |
+ match termInteract with
|
|
145 |
+ None ->
|
|
146 |
+ ignore (Unix.create_process shellCmd argsarray i1 o2 Unix.stderr);
|
|
147 |
+ None
|
|
148 |
+ | Some callBack ->
|
|
149 |
+ fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr)
|
|
150 |
+ else
|
|
151 |
+ fst (Terminal.create_session shellCmd argsarray i1 o2 Unix.stderr)
|
|
152 |
+ ) in
|
|
153 |
Unix.close i1; Unix.close o2;
|
|
154 |
- begin match term, termInteract with
|
|
155 |
- | Some fdTerm, Some callBack ->
|
|
156 |
+ (if shellCmdPwd = "" then begin match term, termInteract with
|
|
157 |
+ | Some fdTerm, Some callBack ->
|
|
158 |
Terminal.handlePasswordRequests fdTerm (callBack rootName)
|
|
159 |
- | _ ->
|
|
160 |
+ | _ ->
|
|
161 |
()
|
|
162 |
- end;
|
|
163 |
+ end
|
|
164 |
+ else begin match term with
|
|
165 |
+ | Some fdTerm ->
|
|
166 |
+ Terminal.handlePasswordRequestsWithPassword fdTerm shellCmdPwd
|
|
167 |
+ | _ ->
|
|
168 |
+ ()
|
|
169 |
+ end);
|
|
170 |
+
|
|
171 |
initConnection i2 o1
|
|
172 |
|
|
173 |
let canonizeOnServer =
|
|
174 |
Index: terminal.ml
|
|
175 |
===================================================================
|
|
176 |
RCS file: terminal.ml,v
|
|
177 |
retrieving revision 1.1
|
|
178 |
retrieving revision 1.3
|
|
179 |
diff -u -r1.1 -r1.3
|
|
180 |
--- terminal.ml 19 Apr 2006 15:39:42 -0000 1.1
|
|
181 |
+++ terminal.ml 25 Apr 2006 13:10:37 -0000 1.3
|
|
182 |
@@ -244,3 +244,32 @@
|
|
183 |
end)
|
|
184 |
in
|
|
185 |
ignore (loop ())
|
|
186 |
+
|
|
187 |
+(* Read messages from the terminal and input the password *)
|
|
188 |
+let handlePasswordRequestsWithPassword fdTerm sshpwd =
|
|
189 |
+ Unix.set_nonblock fdTerm;
|
|
190 |
+ let buf = String.create 10000 in
|
|
191 |
+ let rec loop () =
|
|
192 |
+ Lwt_unix.read fdTerm buf 0 10000 >>= (fun len ->
|
|
193 |
+ if len = 0 then
|
|
194 |
+ (* The remote end is dead *)
|
|
195 |
+ Lwt.return ()
|
|
196 |
+ else if len = 10 then (* "Password:\n"*)
|
|
197 |
+ begin
|
|
198 |
+ let response = sshpwd in
|
|
199 |
+ Lwt_unix.write fdTerm
|
|
200 |
+ (response ^ "\n") 0 (String.length response + 1)
|
|
201 |
+ >>= (fun _ ->
|
|
202 |
+ loop ())
|
|
203 |
+ end
|
|
204 |
+ else
|
|
205 |
+ begin
|
|
206 |
+ let response = "yes" in
|
|
207 |
+ Lwt_unix.write fdTerm
|
|
208 |
+ (response ^ "\n") 0 (String.length response + 1)
|
|
209 |
+ >>= (fun _ ->
|
|
210 |
+ loop ())
|
|
211 |
+ end )
|
|
212 |
+ in
|
|
213 |
+ ignore (loop ())
|
|
214 |
+
|
|
215 |
Index: terminal.mli
|
|
216 |
===================================================================
|
|
217 |
RCS file: terminal.mli,v
|
|
218 |
retrieving revision 1.1
|
|
219 |
retrieving revision 1.3
|
|
220 |
diff -u -r1.1 -r1.3
|
|
221 |
--- terminal.mli 19 Apr 2006 15:39:42 -0000 1.1
|
|
222 |
+++ terminal.mli 25 Apr 2006 13:10:37 -0000 1.3
|
|
223 |
@@ -17,6 +17,9 @@
|
|
224 |
val handlePasswordRequests :
|
|
225 |
Unix.file_descr -> (string -> string) -> unit
|
|
226 |
|
|
227 |
+val handlePasswordRequestsWithPassword :
|
|
228 |
+ Unix.file_descr -> string -> unit
|
|
229 |
+
|
|
230 |
(* For recognizing messages from OpenSSH *)
|
|
231 |
val password : string -> bool
|
|
232 |
val authenticity : string -> bool
|
|
233 |
Index: uitext.ml
|
|
234 |
===================================================================
|
|
235 |
RCS file: uitext.ml,v
|
|
236 |
retrieving revision 1.1
|
|
237 |
retrieving revision 1.3
|
|
238 |
diff -u -r1.1 -r1.3
|
|
239 |
--- uitext.ml 19 Apr 2006 15:39:42 -0000 1.1
|
|
240 |
+++ uitext.ml 26 Apr 2006 11:12:27 -0000 1.3
|
|
241 |
@@ -374,8 +374,12 @@
|
|
242 |
let t = truncate ((t1 -. t0) *. (100. -. v) /. v +. 0.5) in
|
|
243 |
Format.sprintf "%02d:%02d" (t / 60) (t mod 60)
|
|
244 |
in
|
|
245 |
+ let isetaflush =
|
|
246 |
+ if (Prefs.read Trace.logtostdout) then "\n"
|
|
247 |
+ else ""
|
|
248 |
+ in
|
|
249 |
Util.set_infos
|
|
250 |
- (Format.sprintf "%s %s ETA" (Util.percent2string v) remTime)
|
|
251 |
+ (Format.sprintf "%s %s ETA%s" (Util.percent2string v) remTime isetaflush)
|
|
252 |
in
|
|
253 |
if not (Prefs.read Trace.terse) && (Prefs.read Trace.debugmods = []) then
|
|
254 |
Uutil.setProgressPrinter showProgress;
|
|
255 |
Index: ubase/trace.ml
|
|
256 |
===================================================================
|
|
257 |
RCS file: ubase/trace.ml,v
|
|
258 |
retrieving revision 1.1
|
|
259 |
retrieving revision 1.3
|
|
260 |
diff -u -r1.1 -r1.3
|
|
261 |
--- ubase/trace.ml 19 Apr 2006 15:34:06 -0000 1.1
|
|
262 |
+++ ubase/trace.ml 26 Apr 2006 11:12:27 -0000 1.3
|
|
263 |
@@ -83,6 +83,11 @@
|
|
264 |
\\verb|unison.log| in your HOME directory. Set this preference if
|
|
265 |
you prefer another file."
|
|
266 |
|
|
267 |
+let logtostdout =
|
|
268 |
+ Prefs.createBool "logtostdout" false
|
|
269 |
+ "Log to stdout, for syncit parse only"
|
|
270 |
+ "if you are not using syncit, do not add this arg."
|
|
271 |
+
|
|
272 |
let logch = ref None
|
|
273 |
|
|
274 |
let rec getLogch() =
|
|
275 |
@@ -103,6 +108,9 @@
|
|
276 |
let sendLogMsgsToStderr = ref true
|
|
277 |
|
|
278 |
let writeLog s =
|
|
279 |
+ if Prefs.read logtostdout then begin
|
|
280 |
+ Printf.printf "%s\n" s
|
|
281 |
+ end;
|
|
282 |
if !sendLogMsgsToStderr then Util.msg "%s" s
|
|
283 |
else debug "" (fun() -> Util.msg "%s" s);
|
|
284 |
if Prefs.read logging then begin
|
|
285 |
Index: ubase/trace.mli
|
|
286 |
===================================================================
|
|
287 |
RCS file: ubase/trace.mli,v
|
|
288 |
retrieving revision 1.1
|
|
289 |
retrieving revision 1.2
|
|
290 |
diff -u -r1.1 -r1.2
|
|
291 |
--- ubase/trace.mli 19 Apr 2006 15:34:06 -0000 1.1
|
|
292 |
+++ ubase/trace.mli 26 Apr 2006 11:12:27 -0000 1.2
|
|
293 |
@@ -64,6 +64,8 @@
|
|
294 |
(* Suppress all message printing *)
|
|
295 |
val terse : bool Prefs.t
|
|
296 |
|
|
297 |
+val logtostdout : bool Prefs.t
|
|
298 |
+
|
|
299 |
(* Show a string to the user. *)
|
|
300 |
val message : string -> unit
|
|
301 |
|