summaryrefslogtreecommitdiff
path: root/command.c (follow)
Commit message (Collapse)AuthorAge
* Merge topic branch t/socket-cookie into masterAndre Noll2026-05-30
|\ | | | | | | | | | | | | | | | | | | | | | | AFS socket cookie replacement ----------------------------- A small but rather intrusive patch set which touches the guts of the afs callback mechanism. * t/socket-cookie: afs: Avoid the void * argument of send_lls_callback_request(). Kill afs socket cookie and afs_client_list. afs: Improve error handling of afs_signal_post_monitor().
| * Kill afs socket cookie and afs_client_list.Andre Noll2026-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now create a per-command socket pair in the command handler and use the permanent server-afs socket to pass one end of the pair from the command handler to the afs process. With this approach only the command handlers can possibly talk to the afs process, so we don't need to worry about malicious or bogus connections arriving at the local socket. Consequently, we may remove the socket cookie and employ blocking I/O for the shared memory identifiers that are transferred through the per-command socket. Connections are now dispatched in one go, obviating the need to keep track of connected clients. So remove struct afs_client and the client list.
* | command.c: Move and improve comment for current_time.Andre Noll2026-05-26
| | | | | | | | | | | | Move it next to the definition of the variable it purports to document, and reword the comment to clarify why nobody updates the now pointer in command handler context.
* | command.c: Remove unnecessary casts.Andre Noll2026-05-24
| | | | | | | | | | | | The comment from commit f90e920b4 in 2017 no longer applies to more recent clang versions. In particular clang version 19.1.7 of FreeBSD 13.5 does not complain without the casts. so..
* | server: Move alarm(2) call into handle_connect() of command.c.Andre Noll2026-05-08
| | | | | | | | | | Since the alarm clock is cancelled in handle_connect(), let's also set it there. Remove the pointless ALARM_TIMEOUT macro while at it.
* | Prefer paraslash_version() over PACKAGE_VERSION.Andre Noll2026-05-03
|/ | | | | | | Currently we use at several places the package version, i.e. the version that was checked out when the package was configured. The paraslash version is recomputed every time the package is build, so this is more up-to-date. So use paraslash_version() everywhere and remove PACKAGE_VERSION.
* Switch to SPDX identifiers.Andre Noll2026-03-17
| | | | | | | | Generated with sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h followed by manually tweaking the result a bit. No license change intended.
* Move user_list.[ch] into server.[ch].Andre Noll2026-03-01
| | | | | | This works because only the server links with user_list.o. Since struct user contains a list head, list.h must now be included *before* server.h, which requires some trivial header shuffling in the .c files that include server.h.
* aft.c: Boolify send_afs_status().Andre Noll2026-03-01
| | | | | | The "parser_friendly" parameter is used as a boolean, so don't declare it as int. The function passes a reference to the bool via the callback method, so the callback, afs_stat_callback(), needs to be adjusted as well.
* Merge topic branch t/rm_dccp into masterAndre Noll2026-02-18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove dccp support The first patch of this series removes the dccp sender and receiver. Both are deprecated as of paraslash-0.7.6, released in 2025-11. The short depreciation period should not be a problem because dccp was never adopted widely, and the linux kernel no longer supports the protocol. The removal paves the way for quite some subsequent cleanups. In particular, the acl and chunk queue APIs, which used to be shared between the http and the dccp sender, no longer need to be public, so subsequent patches of the series move acl.c and chunk_queue.c into http_send.c. * refs/heads/t/rm_dccp: http_send.c: Simplify format_url(). Move format_url() from net.c to http_send.c. Merge acl.c into http_send.c. Merge chunk_queue.c into http_send.c. http_send.c: Move header_sent to struct private_http_sender_data. http_send.c: Move chunk queue into struct private_http_sender_data. struct sender: Remove unused sched pointer argument of ->post_monitor(). struct sender: Remove unused chunks_sent parameter of ->send(). http_send.c: Kill http_send_ok_msg() and http_send_err_msg(). http_send.c: Remove trivial shutdown wrapper. http_send.c: Merge free_sender_status() into http_shutdown(). http_send.c: Merge init_sender_status() into http_send_init(). http_send.c: Rename or remove generic_foo(). http_send.c: Remove sender_status pointer arguments. Move struct sender_status into http_send.c. Move send_common.c into http_send.c. Remove dccp.
| * Remove dccp.Andre Noll2026-01-26
| | | | | | | | | | | | | | | | | | | | | | This removes all traces of dccp, specifically dccp_recv.c and dccp_send.c. The flowops related functions of net.c can go away as well, as flowops were only needed for the dccp transport. A few other functions are simplified by dropping the flowops or protocol parameter. Further cleanups are possible, but are deferred to subsequent commits. In particular, some functions of send_common.c are only called by the http transport now. These can be moved to http_send.c and then be made static.
* | handshake: No longer announce/request the sha256 feature.Andre Noll2026-01-29
|/ | | | | | | | | | | Since 0.7.x the server no longer checks the client request but uses sha256 unconditionally. At the same time para_client started to no longer check whether the sha256 feature is announced by para_server but uses sha256 unconditionally. This commit is the next step towards the removal of the feature. We need to wait until 0.9.0 before the server starts to reject clients requesting the feature.
* server: Implement play -n.Andre Noll2025-12-12
| | | | This is quite useful, and easy to implement.
* Improve server documentation.Andre Noll2025-10-08
| | | | | | This touches just server.c and command.c since the sender, afs and virtual streaming system documentation has already been cleaned up in earlier commits of this series.
* Merge topic branch t/rm_sha1 into masterAndre Noll2025-09-22
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The series first drops the para_upgrade_db executable because it is no longer needed. This removes the penultimate user of the sha1 infrastructure. The remaining commits deal with the last user: the handshake between para_client and para_server. Since paraslash-0.7.0, client and server employ sha256 by default, but fall back to sha1 in order to stay compatible to old 0.6.x versions. After this series, server and client always employ sha256 as the hash algorithm, breaking compatibility with 0.6.x clients. As a result, the sha1 hash algorithm is no longer used anywhere, so the corresponding infrastructure is no longer needed. This gets rid of a fair amount of code. * refs/heads/t/rm_sha1: Rename hash2 -> hash. Remove sha1. Remove para_upgrade_db. aft: Compare the full hash, not just the first 20 bytes.
| * Rename hash2 -> hash.Andre Noll2025-05-22
| | | | | | | | | | Now that sha1 is no longer supported, the hash2 naming has become meaningless. Rename it back to "hash".
| * Remove sha1.Andre Noll2025-05-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Server and client prefer sha256 in the authentication protocol since paraslash-0.7.0, while 0.6.x clients and servers only know about sha1. This patch drops the compatibility code which enabled old clients to connect to new servers and vice versa. Now the client code no longer checks whether the sha256 feature is supported, but requests and uses the feature unconditionally. The server still announces the sha256 feature and accepts the corresponding feature request, but uses sha256 unconditionally. With this approach older 0.7.x clients are still compatible to current server versions and current clients can still talk to servers running older 0.7.x versions.
* | Deprecate the DCCP sender and receiver.Andre Noll2025-09-15
|/ | | | | | | | DCCP was marked deprecated in Linux since version 6.4 (released in 2023-06), and 6.16 (released in 2025-07) dropped the protocol. This patch adds some warnings which trigger when the dccp sender or receiver are in use. We also mark all DCCP related options as deprecated. However, the paraslash dccp sender and receiver will stay until at least v0.8.0.
* Merge topic branch t/build into masterAndre Noll2025-05-20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A medium sized series for the build system which improves the way the git version string is stored in the executables and man pages. Subsequent patches of the series remove some warts from the makefile: we no longer use order-only dependencies and the .PRECIOUS target. The merge results in a conflict against the "remove regex include" commit 67388cd4fae0. This is trivial to resolve, though. * refs/heads/t/build: Doxify version functions. Doxify OV_EXCLUDE_STATIC_CALLBACKS #define. Makefile: Fix braino in tarball target. build: Remove superfluous dependency in Makefile.real. build: Remove the .PRECIOUS target. build: Improve clean targets. build: Get rid of directory order-only dependencies. build: Compile with -Wunused -Wall also on BSD. build: Revamp git versioning. build: Merge version.{c,h} into string.{c,h}.
| * build: Merge version.{c,h} into string.{c,h}.Andre Noll2025-03-25
| | | | | | | | | | | | | | | | | | This is a preparatory patch for the upcoming revamp of the git version script. The revamped script generates version.c, a file which is currently tracked by git. We can easily get rid of it (and of version.h) since all paraslash executables link in both string.o and version.o. So let's move the three small functions of version.c to string.c and their declarations from version.h to string.h.
* | Include regex.h from para.h.Andre Noll2025-05-19
| | | | | | | | Every .c file includes it anyway.
* | Check return value of lsu_com_help().Andre Noll2025-05-03
|/ | | | | | | | | | | | | This function fails if an invalid command name is passed as the argument, yet all callers ignore the error. Modify the callers to print the strerror text as appropriate and no longer do that in lsu_lopsub_error(). Rename this function and introduce the error type argument to print more meaningful error messages. One visible consequence is that para_client help does-not-exist used to succeed while it now exits with status 1.
* apc_pub_encrypt: Let the callee allocate the buffer.Andre Noll2024-05-17
| | | | | | | | | | Change the encryption routine of the apc API to allocate a suitably sized buffer itself. Currently, the caller has to guess the size of the buffer to pass to the function and we reuse our 4k handshake buffer for that. While 4k is is plenty at the moment, that may change, and it's always better to use the exact size if it is readily available. This is the case here because the required buffer size is just the number of bits of the modulus of the key.
* Prevent doxygen from generating invalid html.Andre Noll2024-05-13
| | | | | Doxygen is too stupid to grok the preprocessor tricks we are playing here, so don't generate documentation for these parts.
* server: No longer accept "sideband" and "aes_ctr128" features.Andre Noll2023-12-24
| | | | | | | | | Both features are used unconditionally since commit d44413588dd7 (v0.6.3-27) from three years ago when the client stopped to request the feature. We don't need to support clients older than that any more, so fail the request if these features are still requested. Clarify the comment about the sha256 feature while at it.
* Merge topic branch t/ff-compat into masterAndre Noll2023-01-17
|\ | | | | | | | | | | | | | | | | A single commit which removes support for the old syntax of the ff command where negative values could be specified with a postfix such as "ff 30-". This syntax has long been deprecated. * refs/heads/t/ff-compat: server: Remove compatibility code of com_ff().
| * server: Remove compatibility code of com_ff().Andre Noll2022-10-18
| | | | | | | | | | | | | | The old syntax "ff 30-" is undocumented and deprecated since four years thanks to commit 9d232e63. According to the comment, the removal of the feature was scheduled for 0.7.0 but as of 0.7.1 the syntax is still accepted. So remove the extra code now.
* | Merge branch 'maint'Andre Noll2022-11-25
|\ \ | |/ |/| | | | | | | | | | | | | This fixes two old bugs related to signal handling which bite only rarely. But if they do, it hurts plenty. * maint: server: Fix race condition in com_stat(). server: Avoid deadlock in daemon_log().
| * server: Fix race condition in com_stat().Andre Noll2022-11-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to block not only SIGTERM but also SIGUSR1 in the command handler of the stat server command because otherwise the signal is lost if it arrives within a small race window. If this happens, the next status update will be up to 50 seconds late. The race condition is even explained in the comment nearby... The bug was observed in a situation where the last admissible file of the current mood became inadmissible, causing the server to stop streaming. This is reflected by the status flags transition from P (playing) to N (stopped) via the intermediate state PN (trying to load next file). After either transition the server process sends SIGUSR1 to the command handler. If the second signal arrives just after the PN state was sampled but before the command handler goes to sleep by calling pselect(2), the signal handler runs and sets subcmd_should_die, but this won't be acted upon until after we sleep for up to 50 seconds in pselect(2). As a result, para_audiod, hence para_gui, keep reporting the stale PN state during this period. This bug was present in the code base since day one of the git repo in 2006.
| * server: Avoid deadlock in daemon_log().Andre Noll2022-11-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently both the generic signal handler in signal.c and the signal handler for the stat command handler in command.c call daemon_log() via PARA_EMERG_LOG(). This is problematic because daemon_log() takes the log mutex and the signal might arrive while daemon_log() is executing. If this race condition is hit, the process deadlocks because daemon_log() tries to acquire a mutex which it already holds. All three types of server processes (main, afs and command handler) are susceptible to this bug, but regardless of which process happens to hit the race window, the server process hangs waiting on the mutex, and no longer accepts connections. Fix this by removing the problematic log call in the generic case and by printing it out of interrupt context in the command handler case. This bug was introduced together with the log mutex five years ago. Fixes: ced0c17d1a3ee0336dc7b35e69faff131dabecac
* | com_term(): Ignore SIGTERM.Andre Noll2022-10-03
| | | | | | | | | | Just to shut up valgrind when the server terminates due to the term command.
* | Merge topic branch t/overflow into masterAndre Noll2022-10-03
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This series implements a new memory allocation API which checks for overflows. The first part of the series just renames the main allocation functions. Later patches in the series implement allocators which take two size_t arguments (like calloc(3)) and check whether the multiplication overflows by employing the __builtin_mul_overflow() primitive supported by gcc and clang. This requires us to bump the lowest supported gcc and clang version. * refs/heads/t/overflow: build: Compile with -ftrapv. string: Introduce arr_zalloc(). string: Introduce arr_alloc(). string: Introduce arr_realloc() and check for integer overflow. string: Rename para_calloc() -> zalloc(). string: Rename para_malloc() -> alloc(). string: Overhaul para_strdup().
| * | string: Introduce arr_alloc().Andre Noll2022-07-29
| | | | | | | | | | | | | | | | | | | | | | | | Change all callers of alloc() which pass a product of two integers as the allocation size to call the new function instead. This function aborts if the multiplication overflows. With arr_alloc() in place, alloc() reduces to a trivial wrapper which calls new arr_alloc() with the first argument equal to one.
| * | string: Rename para_malloc() -> alloc().Andre Noll2022-07-29
| | | | | | | | | | | | | | | | | | | | | Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
* | | Merge branch 'refs/heads/t/ll'Andre Noll2022-09-18
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two little cleanups related to the logging facility and two commits which add the ll command to para_server and para_audiod. The merge resulted in a conflict in afs.c due to the earlier merge of the poll topic branch which replaced all calls to select() by calls to poll(). The implementation of the ll server command introduced a new caller of select(), afs_select(), which needs to be replaced by afs_poll() to resolve the conflict. * refs/heads/t/ll: New server command: ll to change the log level at runtime. New audiod command: ll to change the log level at runtime. daemon: Kill get_loglevel_by_name(). server/audiod: Don't parse loglevel argument unnecessarily.
| * | | New server command: ll to change the log level at runtime.Andre Noll2022-07-12
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes use of the infrastructure introduced in the previous patch. However, the implementation of the ll command for para_server is more involved than its audiod counterpart because in the server case we have to tell two different processes (server and afs) to change their log level while the calling process, the command handler, does not need to set the loglevel because it is about to exit anyway. For the inter-process communication we introduce a new field in the mmd shared memory area so that command handlers can read the current value or set a new value. The log level propagates from there via daemon_set_loglevel() to the server and afs processes during each iteration of the scheduler loop where para_log() will pick it up to set the log level threshold for subsequent log events. The si command handler currently refers to the argument of the --loglevel server option to include the log level in its output. With dynamic log levels this no longer works because it always prints the value from the command line or the config file rather than the run time log level. Since the new ll command also prints the loglevel when it is executed with no arguments, we simply remove this line from the si output and hope that nobody cares. The si command handler was the last user of the ENUM_STRING_VAL macro in command.c. Removing the macro also allows us to make CMD_PTR local to server.c and to remove the lopsub definitions of the server suite from command.c. However, we still include the lopsub definitions of the server *command* suite (server_cmd.lsg.h) of course. We let any authenticated user run the command with no arguments to report the current loglevel but require full privileges to change the loglevel. Thus, the check for sufficient privileges needs to be performed in the command handler.
* / / send: Avoid select-specific arguments in {pre,post}_select().Andre Noll2022-08-25
|/ / | | | | | | | | | | | | | | | | | | Just pass a pointer to struct sched instead of the fd sets. Since two of the prototypes declared in send.h now refer to this structure, sched.h must be included before send.h. The udp sender implements neither ->pre_select() nor ->post_select(), so we only need to fix the order in which send.h and sched.h are included.
* | Remove E_PERM.Andre Noll2022-05-18
| | | | | | | | There is only one user which may as well use the standard error code.
* | Merge branch 'refs/heads/t/sha256'Andre Noll2022-02-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of changes which start to eliminate the use of sha1 in favor of sha256. This series is only the first step, though, as we need to keep sha1 for the time being to provide backward compatibility. Cooking for four months. * refs/heads/t/sha256: manual: Avoid sha1. upgrade_db: Add copyright and purpose to upgrade_db.c. web: Add link to the para_upgrade_db(1) man page. afs: Switch to sha256 and change default database path. Add para_upgrade_db. Use sha256 for the challenge response. Introduce hash2 (sha256). Assume sideband and aes_ctr128 are always supported/requested.
| * | Use sha256 for the challenge response.Andre Noll2021-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sha1 is broken and should no longer be used. This commit introduces the new server feature "sha256". It is announced during the handshake with the client. The client code is patched to detect whether the server supports the feature and uses sha256 if it does. This change is backwards compatible. That is, old clients can still connect to a new server (using sha1). Also new clients can connect to an old server (and also use sha1 in this case).
| * | Assume sideband and aes_ctr128 are always supported/requested.Andre Noll2021-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sideband connections and the AES-based stream cipher have become mandatory in paraslash-0.6. The server no longer needs to annouce the feature as 0.6.x clients request it, regardless of whether it was announced or not. It needs to still accept the option, though. On the client side, we don't need to request the features any more as the server just ignores the request.
* | | Merge branch 'refs/heads/t/rm_task_subcmd'Andre Noll2022-01-03
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A single commit containing an incompatible change for 0.7.0. Cooking for almost a year. * refs/heads/t/rm_task_subcmd: Remove obsolete server subcommand "task".
| * | | Remove obsolete server subcommand "task".Andre Noll2021-02-27
| | | | | | | | | | | | | | | | It was deprecated long ago. Since v0.6.2 it does nothing anyway.
* | | | command.c: Remove unused includes.Andre Noll2021-11-20
| |_|/ |/| | | | | | | | None of these are needed. Tested on Linux, FreeBSD and NetBSD.
* | | command.c: Make aux_info_cb() static.Andre Noll2021-11-01
| |/ |/| | | | | It is only used in command.c.
* | com_jmp(): Handle negative values gracefully.Andre Noll2021-08-30
|/ | | | | | | | | Currently these get silently converted to a (large) unsigned number, which causes para_server to skip to the next audio file. This patch modifies the command handler to check whether the given value is within range and fails the command if it is out of range. Remove an uninteresting log message while at it.
* command.c: Improve documentation of handle_connect().Andre Noll2020-03-17
| | | | This text was not very precise, and it had some language issues.
* command.c: Also invalidate play time if no audio file is open.Andre Noll2019-11-23
| | | | | | | Without this, the time string of the previous audio file is continued to be shown in the top window of para_gui when stopped. It gets wiped out eventually, but this can take a few seconds. With the patch applied, the time string disappears immediately.
* Merge branch 'refs/heads/t/ff'Andre Noll2019-07-14
|\ | | | | | | | | | | | | | | | | | | | | | | A short series which overhauls the ff server command. Cooking for almost a year (for no good reason). * refs/heads/t/ff: com_ff(): Fix bad grammar in help text. com_ff(): Depreciate "n-" syntax. com_ff(): Simplify code for jumping backwards. com_ff(): Avoid "unsigned i".
| * com_ff(): Depreciate "n-" syntax.Andre Noll2018-07-31
| | | | | | | | | | | | | | | | | | | | | | | | This syntax was introduced long ago (pre git era) for no good reason. This patch adjusts the documentation to not mention it any more. The command handler is modified to use para_atoi32() instead of sscanf(), with fallback code for the old syntax which also prints a deprecation warning. Clarify the documentation by explaining what happens in case the argument is out of bounds.