extern struct audio_file_selector selectors[];
extern struct sender senders[];
extern char *user_list;
-struct sockaddr_in *in_addr;
static void dummy(__a_unused int s)
{}
return get_cmd_ptr(buf, NULL);
}
-long int para_rand(long unsigned max)
+static long int para_rand(long unsigned max)
{
return (long int) ((max + 0.0) * (random() / (RAND_MAX + 1.0)));
}
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;
signal(SIGHUP, SIG_DFL);
signal(SIGUSR1, SIG_IGN);
- in_addr = addr;
challenge_nr = random();
/* send Welcome message */
ret = send_va_buffer(fd, "This is para_server, version "