[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] allow unauth control connections for now



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	control.c 
Log Message:
allow unauth control connections for now
let control connections recognize eof


Index: control.c
===================================================================
RCS file: /home/or/cvsroot/src/or/control.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- control.c	7 Nov 2004 01:33:06 -0000	1.8
+++ control.c	7 Nov 2004 11:33:04 -0000	1.9
@@ -248,7 +248,8 @@
       authentication_cookie_is_set &&
       !memcmp(authentication_cookie, body, len)) {
     goto ok;
-  } else if (options->HashedControlPassword) {
+  }
+  if (options->HashedControlPassword) {
     char expected[S2K_SPECIFIER_LEN+DIGEST_LEN];
     char received[DIGEST_LEN];
     if (base64_decode(expected,sizeof(expected),
@@ -262,6 +263,9 @@
     if (!memcmp(expected+S2K_SPECIFIER_LEN, received, DIGEST_LEN))
       goto ok;
   }
+  if (len == 0) { /* accept it for now */
+    goto ok;
+  }
 
  err:
   send_control_error(conn, ERR_FAILED_AUTHENTICATION,"Authentication failed");
@@ -271,7 +275,6 @@
   send_control_done(conn);
   conn->state = CONTROL_CONN_STATE_OPEN;
   return 0;
-
 }
 
 int connection_control_finished_flushing(connection_t *conn) {
@@ -289,6 +292,12 @@
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_CONTROL);
 
+  if(conn->inbuf_reached_eof) {
+    log_fn(LOG_INFO,"Control connection reached EOF. Closing.");
+    connection_mark_for_close(conn);
+    return 0;
+  }
+
  again:
   switch(fetch_from_buf_control(conn->inbuf, &body_len, &command_type, &body))
     {