server: Constify return value of lookup_user(). Command handlers only need to read this structure.
server: Remove unused ->peer from struct command_context. It is initialized in handle_connect() but never used.
server: Remove ->argc, ->argv from struct command_context. Command handlers should not look at the argv[] vector directly but only use the lopsub library functions to access the parsed command line. In fact, the only function which accesses the argv vector is run_command(). Defining argc and argv as local variables in this function allows to drop the two members from the command context structure.
server: Convert non-afs commands to lopsub. Currently the server commands are divided into two group: those commands which are handled by the server process and those which communicate with the afs process. This commit converts the commands of the former group and the corresponding completers for para_client to the lopsub suite format while the afs commands will be converted in subsequent commits. After this change para_server needs to be linked with -llopsub. To this aim the options and help texts of of the server commands are transferred from server.cmd to the new server_cmd.suite.m4, enabling long-style options in the progress. Moreover, an introduction is added at the beginning of the list of server commands which describes how server commands are executed. Command permissions are now handled by making use of the aux_info feature of lopsub. To keep those commands working which do not have any permission bit set, we need to add a new identifier NO_PERMISSION_REQUIRED to enum server_command_permissions of user_list.h. The value of this identifier is zero of course. Naturally the bulk of the change takes place in command.c where all server commands are implemented. The command handlers are modified to take a pointer to a struct lls_parse result as an additional argument. A new helper, send_errctx(), is introduced to avoid code duplication. Since command.h now refers to a lopsub parse result, all files which include command.h, including those which implement only afs commands, need to include the system header lopsub.h. To keep afs commands working, some compatibility code in run_command() is added. This will go away after all commands have been converted. A couple of macros in command.h ease the handling of the long symbolic constants exposed by the generated lopsub header file. Although only the non-afs commands are converted, the change allows for a couple of cleanups: * The E_BAD_COMMAND error code is no longer needed and has been removed. * cmd_perms_itohuman() has become unused and is removed. * The server_cmds[] array is empty and can be removed, along with the loop in send_list_of_commands() which iterated over the array. The patch also adjusts tests t0004 and t0005 since the help output format changed slightly, breaking the expectations of these tests.
server: Remove command pointer from struct command_context. Command handlers should not know about this implementation detail. This commit also changes parse_sb_command() to not only parse the command line but to actually run the command in case the caller has sufficient permissions. The function is renamed to run_command() to reflect this change. We use the opportunity to clean up the allocation and freeing of the command buffer and the argument vector. Both are now freed in the same function they were allocated, which is considered good programming practice.
server: Reduce scope of struct server_command. This structure is only needed in command.c, so we can make it local to this file. As structures defined in .c files are not included in doxygen, the reference to struct server_command in server.h must be removed.
command: Make struct command_context->cmd_ptr const. The fields of struct server command never need to be modified so they can be const.
client: Remove sb-compatibility code. Now that non-client sideband connection attempts are rejected up-front, we may get rid of all the non-sideband code.
Introduce send_strerror(). There are many places in various command handlers where the error path contains code like sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); to send an error message to the client. This patch simplifies all these places by introducing the public function send_strerror() which takes a command context structure and an error code, and executes the above statement. All places where this was open-coded are changed to call the new function instead.
Add sideband implementation. This adds the new source files sideband.[ch] to the repository and links the corresponding object file into para_server, para_audiod and para_client. The sideband API enables the command handlers of para_server to send a multiplexed output stream. The client side (para_client or para_audiod) demultiplex the received stream afterwards. The design is as simple as it can be: Each data buffer is preceded by a 5-byte header containing the length and the band designator, a one-byte number which specifies the type of the data which follows. The server-side and the client-side implement their own variant of the send_sb() and recv_sb() functions for sending and receiving sideband packets. Two implementations are necessary because the underlying file descriptor is blocking on the server side (command handlers of para_server) while it is non-blocking on the client side (para_client and para_audiod). The sideband API allows to optionally filter all data (including the sideband header) through an arbitrary transformation. This patch adds a suitable transformation as a new public function performs RC4 to the crypto API. To keep the patch within reasonable size, this commit does not contain any users of the new sideband API yet. Subsequent commits will teach the authentication handshake code and the command handlers to send and receive data as sideband packets.
Implement client-server feature negotiation. The server announces a list of supported features and the client may request any subset of features. The only supported feature is "sideband". It has no effect at the moment but this will change in subsequent patches. TODO: Documentation, remove "foo" feature.
command: Introduce struct command_context. This exposes a couple of variables which were previously local to handle_connect() to the command handlers, allowing them to make use of the full command context. All newly exposed variables are stored in an instance of the new structure, and the command handlers now take a pointer to such a structure. The patch is large but also straight forward.
Rename struct rc4_context and stream cipher send/receive functions. This only changes the name structures and functions. Unfortunately, the patch is rather large since it requires to fixup all callers of the affected functions. However, each change is either a simple rename or a trivial documentation adjustment.
Make rc4 encryption/decryption more explicit. The old code used a rather fancy way to (de)activate encryption on a per fd basis: In net.c there was an array of rc4 keys, indexed by fd. This is rather wastful because the array size is determined by the highest fd for which encryption is activated. It's also hard to comprehend and it's easy to get strange results if one forgets to deactivate the encryption after the fd is closed. This patch introduces a new structure, rc4_context, which consists of an fd and the needed rc4 keys. Users explicitly call the new rc4 variants of the receving/sending functions which take a pointer to a struct rc4_context instead of a file descriptor but are otherwise identical. Keep crypt simple!