]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
command.c: add documentation of handle_connect()
authorAndre <maan@meins.(none)>
Sun, 28 Jan 2007 22:26:10 +0000 (23:26 +0100)
committerAndre <maan@meins.(none)>
Sun, 28 Jan 2007 22:26:10 +0000 (23:26 +0100)
command.c

index 7bde617e1a5406108c17a5f6e821dff5dbfb1c24..bf3371f0c315b413623d333bcac9ffab70b76c0e 100644 (file)
--- a/command.c
+++ b/command.c
@@ -757,6 +757,37 @@ static void rc4_send(unsigned long len, const unsigned char *indata,
        RC4(&rc4_send_key, len, indata, outdata);
 }
 
+/**
+ * perform user authentication and execute a command
+ *
+ * \param fd the file descriptor to send output to
+ * \param addr socket address info of peer
+ *
+ * \return EXIT_SUCCESS or EXIT_FAILURE
+ *
+ * Whenever para_server accepts an incoming tcp connection on
+ * the port it listens on, it forks and the resulting child
+ * calls this function.
+ *
+ * An RSA-based challenge/response is used to authenticate
+ * the peer. It that authentication succeeds, a random RC4
+ * session key is generated and sent back to the peer,
+ * encrypted with its RSA public key.  From this point on,
+ * all transfers are crypted with this session key.
+ *
+ * Next it is checked if the peer supplied  a valid server
+ * command or a command for the audio file selector currently
+ * in use.  If yes, and if the user has sufficient
+ * permissions to execute that command, the function calls
+ * the corresponding command handler which does argument
+ * checking and further processing.
+ *
+ * In order to cope with a DOS attacks, a timeout is set up
+ * which terminates the function if the connection was not
+ * authenticated when the timeout expires.
+ *
+ * \sa alarm(2), rc4(3), crypt.c, crypt.h
+ */
 int handle_connect(int fd, struct sockaddr_in *addr)
 {
        int numbytes, ret, argc, use_rc4 = 0;