]> git.tuebingen.mpg.de Git - paraslash.git/log
paraslash.git
6 weeks agoparaslash 0.7.3 master v0.7.3
Andre Noll [Tue, 12 Mar 2024 18:02:39 +0000 (19:02 +0100)]
paraslash 0.7.3

6 weeks agoUpdate copyright year.
Andre Noll [Sun, 7 Jan 2024 20:45:52 +0000 (21:45 +0100)]
Update copyright year.

6 weeks agogui: Fix off-by-one in colorful blackness theme.
Andre Noll [Sun, 16 Jul 2023 15:48:22 +0000 (17:48 +0200)]
gui: Fix off-by-one in colorful blackness theme.

Without this, on a 80 character window and the three-digit amp value,
the value gets truncated unnecessarily.

4 months agoaudiod: Improve stat_client_add().
Andre Noll [Tue, 20 Jun 2023 18:49:06 +0000 (20:49 +0200)]
audiod: Improve stat_client_add().

Let it receive a bool rather than an int and dedox its documentation
because it's a static function.

4 months agostring.c: Don't fall back to /tmp in para_homedir().
Andre Noll [Mon, 19 Jun 2023 19:24:29 +0000 (21:24 +0200)]
string.c: Don't fall back to /tmp in para_homedir().

This can only lead to trouble. If we can't get the path to the home
directory, something is deeply wrong and we really should abort.

4 months agocreate_argv_offset(): Use arr_zalloc().
Andre Noll [Mon, 19 Jun 2023 17:56:26 +0000 (19:56 +0200)]
create_argv_offset(): Use arr_zalloc().

There is no point in initializing the allocated array manually,
and it does not hurt to initialize also the last element.

4 months agoCompile with -Wsuggest-attribute=malloc.
Andre Noll [Tue, 30 May 2023 22:11:14 +0000 (00:11 +0200)]
Compile with -Wsuggest-attribute=malloc.

We already employ this attribute extensively to help the compiler
improve optimization. However, a few malloc-like functions were not
yet marked with __malloc. Fix that and enable the warning to make
sure that new malloc-like functions get marked.

Since not all supported compilers know about this warning option, we
need to check at compile time whether the option is supported. Thanks
to the existing cc-option make(1) function, this is a simple one-liner
for Makefile.real.

4 months agoserver: No longer accept "sideband" and "aes_ctr128" features.
Andre Noll [Tue, 9 May 2023 18:02:09 +0000 (20:02 +0200)]
server: No longer accept "sideband" and "aes_ctr128" features.

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.

4 months agogui: Clear status bar after pressing <End>.
Andre Noll [Fri, 7 Jul 2023 20:23:45 +0000 (22:23 +0200)]
gui: Clear status bar after pressing <End>.

Without this a stale message such as

"scrolled view: 1-36/42"

remains although the window has been updated to show the bottom of
the ringbuffer.

4 months agoMerge topic branch t/crypt-cleanups into master
Andre Noll [Sun, 24 Dec 2023 15:43:04 +0000 (16:43 +0100)]
Merge topic branch t/crypt-cleanups into master

This bunch of mostry trivial changes can be merged early, before the
openssl code is converted to use the EVP API. The topic was cooking
in next for six months.

* refs/heads/t/crypt-cleanups:
  openssl: Assign bignums in canonical order.
  openssl: Unify naming of public key structures.
  openssl: Rename read_private_rsa_params() -> read_openssh_private_key().
  openssl: Rename read_rsa_bignums() -> read_public_key().
  openssl: Dedox crypt_init().
  server: Improve "loading pubkey" log message.
  gcrypt: Remove pointless state variable.
  client: Reduce line length.

5 months agoMerge topic branch t/ls-L into master
Andre Noll [Sat, 28 Oct 2023 17:20:14 +0000 (19:20 +0200)]
Merge topic branch t/ls-L into master

A single patch which implements the new --limit option for the ls
server command. The confict in aft.c was trivial to fix.

* refs/heads/t/ls-L:
  server: Implement ls --limit.

6 months agoMerge topic branch t/afs-select into master
Andre Noll [Sat, 21 Oct 2023 16:56:48 +0000 (18:56 +0200)]
Merge topic branch t/afs-select into master

A single patch which silences the select command. The merge conflicted
in afs.c, but that was trivial to resolve.

* refs/heads/t/afs-select:
  server: Implement select -verbose.

6 months agoMerge topic branch t/afs-ls-a into master
Andre Noll [Sun, 15 Oct 2023 15:54:41 +0000 (17:54 +0200)]
Merge topic branch t/afs-ls-a into master

A new feature for the ls command. Unfortunately, several bugs were
found after the topic graduated to next, so the series contains a few
fixup commits on top of the single patch which implements the feature.

* refs/heads/t/afs-ls-a:
  afs: Really fix memory leak in mood_load().
  afs: Fix memory leak in mood_load().
  playlist: Fix error handling of playlist_load().
  server: Fix NULL pointer dereference in com_ls().
  Implement ls --admissible=m/foo.

8 months agoMerge topic branch t/fd into master
Andre Noll [Sun, 6 Aug 2023 16:38:05 +0000 (18:38 +0200)]
Merge topic branch t/fd into master

A rash of patches which clean up a good part of fd.c. Nothing major
here, mostly simplifications and documentation improvements.

* refs/heads/t/fd:
  fd: Simplify and move for_each_file_in_dir().
  fd.c: Improve error checking of para_mkdir().
  fd: Revamp para_mkdir().
  fd: Improve read_pattern(), rename it to read_and_compare().
  fd: Remove log message from para_munmap().
  fd: Open-code para_chdir().
  fd: Remove file_exists().
  fd: Improve documentation of xwritev().
  fd: Improve documentation of write_all().
  fd: Improve documentation of write_va_buffer().

9 months agoserver: Fix memory leak at exit.
Andre Noll [Tue, 20 Jun 2023 20:52:07 +0000 (22:52 +0200)]
server: Fix memory leak at exit.

If a playlist is open on exit, we miss to free it. Not a real leak,
but still..

10 months agoafs: Really fix memory leak in mood_load().
Andre Noll [Tue, 20 Jun 2023 21:05:10 +0000 (23:05 +0200)]
afs: Really fix memory leak in mood_load().

The previous fix was insufficient as we also have to destroy the
score table in the success case, so move the freeing to destroy_mood().

Fixes: bb0aec0963b1b2da617aebda26deca576684436c
10 months agoMerge branch 'maint'
Andre Noll [Sun, 18 Jun 2023 13:31:28 +0000 (15:31 +0200)]
Merge branch 'maint'

A single patch which adds a missing error check.

* maint:
  audiod: Fix error checking in init_default_filters().

10 months agoafs: Fix memory leak in mood_load().
Andre Noll [Mon, 12 Jun 2023 23:42:39 +0000 (01:42 +0200)]
afs: Fix memory leak in mood_load().

In the result != NULL case we open a fresh score table but miss to
close it if add_to_score_table() fails. This should never happen,
but still..

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoplaylist: Fix error handling of playlist_load().
Andre Noll [Mon, 12 Jun 2023 23:14:07 +0000 (01:14 +0200)]
playlist: Fix error handling of playlist_load().

We open a fresh score table if the result pointer is not NULL,
indicating that we are called from com_ls() (with -a=p/foo) rather
than from com_select(). However, if an error occurs afterwards, we
call score_close() unconditionally. This is wrong in the result ==
NULL case (com_select()) because it closes the global score table
which is expected to stay open.

The result is a UAF, which is diagnosed by valgrind as follows:

==4767== Invalid read of size 4
==4767==    at 0x408C51E: osl_add_and_get_row (osl.c:1216)
==4767==    by 0x408CA99: osl_add_row (osl.c:1348)
==4767==    by 0x8060648: score_add (score.c:116)
==4767==    by 0x805F08C: add_to_score_table (mood.c:451)
==4767==    by 0x805FA3E: mood_load (mood.c:650)
==4767==    by 0x8057ECF: activate_mood_or_playlist (afs.c:447)
==4767==    by 0x8059637: com_select_callback (afs.c:1005)

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoserver: Fix NULL pointer dereference in com_ls().
Andre Noll [Mon, 12 Jun 2023 16:06:10 +0000 (18:06 +0200)]
server: Fix NULL pointer dereference in com_ls().

The previous commit which extended the -a option of the ls command
to accept an optional argument introduced the following flaw: If the
argument of -a corresponds to the name of a mood for which no files
are admissible, the server crashes due to a NULL pointer dereference
because mood_load() leaves the mood instance pointer uninitialized
although it returns zero, indicating success.

This behaviour of mood_load() contradicts the promises made in
its documentation. Fix mood_load() by not special-casing the "zero
admissible files" case, which even simplifies the code a bit. If all
goes well but no files turn out to be admissible, we now open the
score table anyway and set the mood pointer to the allocated mood as
usual. Since get_statistics() may now be called with zero admissible
files, we have to add a check there before dividing by the number of
admissible files,

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoaudiod_command: Remove dump_stat_client_list().
Andre Noll [Tue, 30 May 2023 20:48:56 +0000 (22:48 +0200)]
audiod_command: Remove dump_stat_client_list().

It is not very useful and can spam the log.

10 months agotest-lib: Write error output to stderr.
Andre Noll [Sun, 7 May 2023 14:16:10 +0000 (16:16 +0200)]
test-lib: Write error output to stderr.

This way one can run

make test > /dev/null

to suppress normal output but still see test failures, if any.

10 months agoserver: Add missing newline in select -v error output.
Andre Noll [Tue, 13 Jun 2023 17:59:56 +0000 (19:59 +0200)]
server: Add missing newline in select -v error output.

The error message that lacks the newline can be triggered by runing
"select -v X".

10 months agoaudiod: Fix error checking in init_default_filters(). maint
Andre Noll [Wed, 17 May 2023 20:13:55 +0000 (22:13 +0200)]
audiod: Fix error checking in init_default_filters().

We ignore the return value of add_filter() instead of assigning it to
ret as usual, then test ret anyway. That's clearly bogus, even more
so since with the old code ret can never be negative at this point, so
the subsequent condition for the subsequent jump to out: is never true.

This bug was introduced 13 years ago.

Fixes: 081ea8699e6a309c44446884b8c3752529d96a25
11 months agoserver: Implement ls --limit.
Andre Noll [Wed, 19 Oct 2022 19:56:51 +0000 (21:56 +0200)]
server: Implement ls --limit.

The new option is quite easy to implement. The patch actually removes
more lines from aft.c than it adds, but this is just because the code
which loops over all matching files was duplicated across the two
branches of the clause which checks whether --reverse was given. The
branches can easily be combined.

11 months agoserver: Implement select -verbose.
Andre Noll [Sat, 22 Oct 2022 19:54:29 +0000 (21:54 +0200)]
server: Implement select -verbose.

Just set ->pbout to NULL if the new option is not given. This supresses
normal output while error messages still make it to the client because
those are sent with afs_error().

11 months agoopenssl: Assign bignums in canonical order.
Andre Noll [Sun, 7 May 2023 15:16:52 +0000 (17:16 +0200)]
openssl: Assign bignums in canonical order.

The order of the bignums stored in the private key is n, e, d, iqmp, p,
q. We read the bignums in this order, so assign the members of the RSA
structure in the same order. This does not really matter, but still..

11 months agoDeprecate openssl-1.0.
Andre Noll [Thu, 4 May 2023 17:09:26 +0000 (19:09 +0200)]
Deprecate openssl-1.0.

These days everybody should have openssl-1.1 (released in 2016)
or later. So warn if configure detects openssl-1.0 or earlier.

11 months agoopenssl: Unify naming of public key structures.
Andre Noll [Tue, 2 May 2023 20:28:56 +0000 (22:28 +0200)]
openssl: Unify naming of public key structures.

The pointers to private key structures are all called "priv", but for
their public counterparts we often use "key" rather than "pub". Fix
that to improve readability.

11 months agoopenssl: Rename read_private_rsa_params() -> read_openssh_private_key().
Andre Noll [Mon, 15 May 2023 16:35:03 +0000 (18:35 +0200)]
openssl: Rename read_private_rsa_params() -> read_openssh_private_key().

The new name encodes the format of the key in the function name just
like the counterpart read_pem_private_key() does.

11 months agoopenssl: Rename read_rsa_bignums() -> read_public_key().
Andre Noll [Sun, 7 May 2023 15:35:50 +0000 (17:35 +0200)]
openssl: Rename read_rsa_bignums() -> read_public_key().

This makes clear that the function is only used for public encryption.

11 months agoopenssl: Dedox crypt_init().
Andre Noll [Wed, 3 May 2023 18:03:18 +0000 (20:03 +0200)]
openssl: Dedox crypt_init().

The API of this function is documented in crypt.h while the comment
in openssl.c describes openssl specific implementation details which
do not need doxygen annotations.

11 months agoserver: Improve "loading pubkey" log message.
Andre Noll [Sun, 30 Apr 2023 14:05:13 +0000 (16:05 +0200)]
server: Improve "loading pubkey" log message.

Include the path to the key file in the output and make the message
more visible by increasing its severity level.

11 months agogcrypt: Remove pointless state variable.
Andre Noll [Tue, 2 May 2023 21:10:49 +0000 (23:10 +0200)]
gcrypt: Remove pointless state variable.

The variable is set but then only used for an unimportant log message.
So let's drop the message and the variable.

11 months agoclient: Reduce line length.
Andre Noll [Sun, 7 May 2023 14:48:58 +0000 (16:48 +0200)]
client: Reduce line length.

Trivial patch, nothing to see here.

11 months agocrypt: Deprecate PEM keys.
Andre Noll [Sat, 29 Apr 2023 21:23:32 +0000 (23:23 +0200)]
crypt: Deprecate PEM keys.

Users have been advised since 2018 to create RFC4716 keys (see
commit 9e2b093bed5d), and this has been the default key format for
ssh-keygen(1) for a long time as well. Upgrade the severity of the
existing log message from info to warning to encourage users at
runtime to replace their old keys.

11 months agoclient: Fix has_feature().
Andre Noll [Tue, 9 May 2023 17:42:21 +0000 (19:42 +0200)]
client: Fix has_feature().

The function returns bool, so a return value of zero is regarded as
false. Consequently, server feature #0 (sha256) is not detected even
if it is announced by the server, and therefore the client does not
request it. Hence both sides fall back to sha1.

This bug was introduced in paraslash-0.7.2.

Fixes: a0707daa23f8706326aa837f969c20d3e4ee02aa
11 months agoafs: Fix memory leak in mood_load().
Andre Noll [Sun, 7 May 2023 18:04:19 +0000 (20:04 +0200)]
afs: Fix memory leak in mood_load().

If mood_load() manages to load the mood but does not find any
admissible files, it does not deallocate the mood instance and does
not set up the global current_mood variable either. Plug the resulting
memory leak by destroying the mood also if there are no admissible
files (ret == 0).

11 months agoImplement ls --admissible=m/foo.
Andre Noll [Wed, 23 Mar 2022 22:19:55 +0000 (23:19 +0100)]
Implement ls --admissible=m/foo.

Currently there can be only one score table at a time because the
functions of score.c refer to the global score_table variable.
To implement the new feature, we need to overcome this restriction
so that the callback of the ls command can populate an independent
score table to print its output without interfering with the score
table that is currently active.

This commit changes most functions of score.c to receive an additional
table pointer argument. All current users of the score table pass a
NULL pointer to instruct the functions to operate on the global score
table as before.

However, if the ls command is invoked with an optional mood argument
to -a. the callback calls mood_load(), followed by mood_loop() and
mood_unload(). The former returns an opaque handle which is then
passed to the other two functions to instruct them to operate on the
temporary score table instead of the global one.

To make the feature work for playlists as well, analogous functionality
is implemented in playlist.c. The new mop_loop() of aft.c performs
the disambiguation in a similar way as the activate_mood_or_playlist()
does. It is a bit simpler though, since the ls command does not have
to deal with NULL arguments and does not need to fall back to the
dummy mood.

11 months agoMerge branch 'maint'
Andre Noll [Thu, 11 May 2023 17:50:22 +0000 (19:50 +0200)]
Merge branch 'maint'

Two fixes for gcc-12 warnings, and another fix for a benign but
embarrassing braino in gcrypt.c.

* maint:
  gcrypt: Fix return value of apc_get_pubkey().
  error.h: Be more careful with error code masking.
  mp3_afh: Drop unused fields from struct mp3header.

11 months agogcrypt: Fix return value of apc_get_pubkey().
Andre Noll [Mon, 8 May 2023 19:25:30 +0000 (21:25 +0200)]
gcrypt: Fix return value of apc_get_pubkey().

The function is supposed to return the key size in bytes, but it
returns the number of *bits*. A consequence of this bug is that
RSA keys which are too short to encrypt our 128 byte buffer are not
rejected as they should be. This is not too serious because we'll fail
later during the encryption step. Fix the bug anyway and clarify the
documentation of apc_get_pubkey().

11 months agoafs: Improve error message in init_admissible_files().
Andre Noll [Sat, 29 Apr 2023 18:08:38 +0000 (20:08 +0200)]
afs: Improve error message in init_admissible_files().

arg may well be NULL here, so print "dummy" in this case.

11 months agotest-lib: Fix typo in comment.
Andre Noll [Sun, 7 May 2023 14:15:12 +0000 (16:15 +0200)]
test-lib: Fix typo in comment.

11 months agoerror.h: Be more careful with error code masking.
Andre Noll [Sat, 6 May 2023 14:49:56 +0000 (16:49 +0200)]
error.h: Be more careful with error code masking.

It should never happen that two or more of the three special high bits
(osl, lopsub, system) are set in an integer that stores a paraslash
error value, but gcc-12 can't prove this and complains as follows:

error.h:304:28: warning: array subscript 268435456 is above array bounds of 'const char * const[220]' [-Warray-bounds]
  304 |         return para_errlist[num];
      |                ~~~~~~~~~~~~^~~~~

Avoid this warning by always clearing all three special bits.

11 months agomp3_afh: Drop unused fields from struct mp3header.
Andre Noll [Sat, 6 May 2023 14:47:21 +0000 (16:47 +0200)]
mp3_afh: Drop unused fields from struct mp3header.

These are never initialized, but still checked in compare_headers(), so
gcc-12 is right when it complains about uninitialized use. Fix this by
simply removing the uninitialized fields and the comparisons. Fix also
a whitespace issue in the definition of compare_headers() while at it.

11 months agofd: Simplify and move for_each_file_in_dir().
Andre Noll [Sun, 25 Sep 2022 19:17:38 +0000 (21:17 +0200)]
fd: Simplify and move for_each_file_in_dir().

With only one user it can be static in aft.c. Modify the function
so that it no longer changes the current working directory, remove
para_opendir() because it is unused now, dedox the documentation and
streamline it a bit.

11 months agofd.c: Improve error checking of para_mkdir().
Andre Noll [Tue, 1 Nov 2022 20:55:33 +0000 (21:55 +0100)]
fd.c: Improve error checking of para_mkdir().

The old code returned success in case the pathname existed but was
no directory, so try to improve on this a bit. However, don't be
over-zealous as any pathname based approach won't be bullet-proof
because the file identified by the pathname may change at any time.

11 months agofd: Revamp para_mkdir().
Andre Noll [Sun, 25 Sep 2022 20:35:16 +0000 (22:35 +0200)]
fd: Revamp para_mkdir().

It has two callers which both pass the mode value 0777 and contain
extra code to regard the EEXIST error case as a success. Move the
common bits into the wrapper and improve the documentation.

11 months agofd: Improve read_pattern(), rename it to read_and_compare().
Andre Noll [Sun, 25 Sep 2022 20:01:25 +0000 (22:01 +0200)]
fd: Improve read_pattern(), rename it to read_and_compare().

The old name was a poor choice because the pattern argument actually
is neither a regular expression nor a filename pattern.

More importantly, the function receives a buffer size and tries
to read this many bytes but then compares only the first part of
the received buffer to the expected string. This is a rather weird
calling convention.

The only two callers are the http sender and receiver which both
call the function during the initial handshake where no other data is
available. Thus we can change the function to read only the minimal
amount of data (length of the expected string), and drop the bufsize
parameter.

Remove the unnecessary log message in the error case and streamline
the documentation while at it.

11 months agofd: Remove log message from para_munmap().
Andre Noll [Sun, 25 Sep 2022 20:58:21 +0000 (22:58 +0200)]
fd: Remove log message from para_munmap().

Low-level functions like this should leave it to the caller to log
the error. Extend the documentation a bit while at it to document
the fact that passing NULL is OK.

11 months agofd: Open-code para_chdir().
Andre Noll [Sun, 25 Sep 2022 18:57:16 +0000 (20:57 +0200)]
fd: Open-code para_chdir().

Another public trivial wrapper that can go away because it has only
a single caller. POSIX says

Upon successful completion, 0 shall be returned. Otherwise, âˆ’1 shall
be returned, the current working directory shall remain unchanged,
and errno shall be set to indicate the error.

So the new check against zero is equivalent to the old code which
checked whether the return value is non-negative.

13 months agofd: Remove file_exists().
Andre Noll [Sun, 25 Sep 2022 18:45:40 +0000 (20:45 +0200)]
fd: Remove file_exists().

Open-coding this function actually improves code readability. The
function name was a misnomer anyway because any error from the stat()
call (such as EACCES) was reported as "file does not exist".

13 months agofd: Improve documentation of xwritev().
Andre Noll [Sun, 25 Sep 2022 15:57:29 +0000 (17:57 +0200)]
fd: Improve documentation of xwritev().

This is another essential helper which was poorly documented. In
particular the EINTR and short write cases were not covered, and it
was left open what a return value of zero means.

Omit the DCCP-specific part and the sentence which explains what
EAGAIN means.

13 months agofd: Improve documentation of write_all().
Andre Noll [Thu, 22 Sep 2022 20:34:14 +0000 (22:34 +0200)]
fd: Improve documentation of write_all().

The name of this public function is a bit of a misnomer, so be at
least clear in the one-line description what the function does in
the EAGAIN case or if a short write occurs.

13 months agofd: Improve documentation of write_va_buffer().
Andre Noll [Thu, 22 Sep 2022 20:14:09 +0000 (22:14 +0200)]
fd: Improve documentation of write_va_buffer().

This public function was a bit underdocumented, so explain in more
detail what the function does, and how it differs from fprintf(3).

13 months agoConsolidate EOF error codes.
Andre Noll [Fri, 30 Dec 2022 14:08:59 +0000 (15:08 +0100)]
Consolidate EOF error codes.

Currently we have ~15 error codes which indicate an EOF condition. One
should suffice, so drop all codes except the generic E_EOF and use
that everywhere.

13 months agosched: Improve error diagnostics.
Andre Noll [Fri, 30 Dec 2022 13:47:46 +0000 (14:47 +0100)]
sched: Improve error diagnostics.

Currently the error code of the negative return value
from ->post_monitor() is not logged anywhere under normal
conditions. Instead we log "[dead]" in unlink_and_free_task(). Replace
this by a more meaningful message in task_reap().

13 months agoserver: Improve error diagnostics of com_select().
Andre Noll [Tue, 13 Dec 2022 18:02:15 +0000 (19:02 +0100)]
server: Improve error diagnostics of com_select().

The attempt to select a non-existing mood or playlist currently
results in

remote: key not found in rbtree

This is a bit cryptic, so be a bit more user-friendy and provide a
paraslash error code for this case.

13 months agogui: Improve loglevel message.
Andre Noll [Sun, 4 Dec 2022 19:21:55 +0000 (20:21 +0100)]
gui: Improve loglevel message.

When changing the log level, show the new severity string rather than
its numerical representation.

13 months agobuild: Activate warnings and LTO on *BSD.
Andre Noll [Sun, 13 Nov 2022 00:33:17 +0000 (01:33 +0100)]
build: Activate warnings and LTO on *BSD.

Newer versions of BSD ship compilers/packages which no longer
throw warnings, so activate the warnings on all platforms. Also LTO
(link-time optimization) seems to work on the test machines now,
so activate this as well.

Tested on FreeBSD-13.1 with clang-13.0.0 and on NetBSD-9.3 with
gcc-7.5.0.

13 months agoAdd two new tests for para_server.
Andre Noll [Thu, 29 Sep 2022 15:52:45 +0000 (17:52 +0200)]
Add two new tests for para_server.

In a (non-public) development branch the add subcommand was broken
although t0004-server exercises this subcommand and reported no
error. The bug went unnoticed because it would only bite when the
subcommand was given a directory to add, but the test specifies a
pathname which refers to a regular file.

To detect such breakage early, add a test which tries to add a
directory and another which exercises the rm command.

13 months agoparaslash 0.7.2 v0.7.2
Andre Noll [Wed, 8 Mar 2023 19:04:14 +0000 (20:04 +0100)]
paraslash 0.7.2

14 months agoManually tweak Doxyfile to squash warnings.
Andre Noll [Sun, 25 Sep 2022 22:01:48 +0000 (00:01 +0200)]
Manually tweak Doxyfile to squash warnings.

The Doxyfile introduced by the previous commit (created by running doxygen -u)
causes doxygen to complain:

warning: Tag 'TCL_SUBST' at line 260 of file '-' has become obsolete.
 To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"
warning: argument 'a4wide' for option PAPER_TYPE is not a valid enum value
Using the default: a4!

This patch should get rid of the warnings.

14 months agoUpdate DOXYFILE.
Andre Noll [Sun, 25 Sep 2022 21:27:17 +0000 (23:27 +0200)]
Update DOXYFILE.

The patched file was created with doxygen -u with no manual editing. We
picked doxygen-1.8.17 although that's already a bit old because this
version ships with Ubuntu-20.04. However, this version generates a file
list (shown on the Documentation page) which lacks the description
column, so we use a self-compiled doxygen executable for the time
being.

14 months agoaft: Always copy and compare full hash value.
Andre Noll [Mon, 30 Jan 2023 14:10:32 +0000 (15:10 +0100)]
aft: Always copy and compare full hash value.

Although we switched to 32 byte hash function in paraslash-0.7.0,
we kept comparing only the first 20 bytes to verify that the file
has not changed. Also the ls output and the status items contained
only the first 20 bytes of the hash value.

14 months agoserver: Don't save bogus chunk table for aac files.
Andre Noll [Tue, 24 Jan 2023 22:13:55 +0000 (23:13 +0100)]
server: Don't save bogus chunk table for aac files.

The audio file selector stores the chunk table of each audio file
as an osl disk object. Since the aac audio format handler employs
dynamic chunks, these on-disk chunk tables of aac files will never
be consulted for streaming. They exist only for consistency with the
other audio formats and should be empty.

Due to a mis-computation of the chunk table size in the callback of
the add command we happen to store the serialized lopsub parse result
as the chunk table.

This is a benign bug since it only affects the ls command, and only
if -l=c is given to print the chunk table.

14 months agoFix memory leak in para_play().
Andre Noll [Thu, 6 Oct 2022 15:12:13 +0000 (17:12 +0200)]
Fix memory leak in para_play().

We leak one filter parse result per audio file played. Valgrind reports:

==24559== 24 (12 direct, 12 indirect) bytes in 1 blocks are definitely lost in loss record 34 of 104
==24559==    at 0x4044B0B: calloc (vg_replace_malloc.c:1328)
==24559==    by 0x453A997: lls_parse (lopsub.c:768)
==24559==    by 0x8057612: filter_setup (filter_common.c:98)
==24559==    by 0x80500A4: load_file (play.c:377)
==24559==    by 0x80500A4: load_next_file (play.c:454)
==24559==    by 0x80500A4: play_post_monitor (play.c:1154)
==24559==    by 0x8051110: call_post_monitor (sched.c:80)
==24559==    by 0x8051110: sched_post_monitor (sched.c:106)
==24559==    by 0x8051110: schedule (sched.c:148)
==24559==    by 0x804EB80: main (play.c:1217)

14 months agoPara_play: Improve doxygen global description.
Andre Noll [Wed, 5 Oct 2022 19:31:03 +0000 (21:31 +0200)]
Para_play: Improve doxygen global description.

Expand and reword this text a bit, and move it into the documentation
of main() so that it appears in the generated html.

14 months agoMerge branch 'maint'
Andre Noll [Sun, 12 Feb 2023 16:17:24 +0000 (17:17 +0100)]
Merge branch 'maint'

Two fixes for the chunk table output of the ls command.

* maint:
  server: ls -l=c: Don't print chunk table in case of dynamic chunks.
  server: Fix ls -l=c.

14 months agoserver: ls -l=c: Don't print chunk table in case of dynamic chunks.
Andre Noll [Tue, 24 Jan 2023 18:57:33 +0000 (19:57 +0100)]
server: ls -l=c: Don't print chunk table in case of dynamic chunks.

The chunk table stored in the osl disk object of the paraslash
database is useless for audio formats which support dynamic chunks
(aac only). Omit this part of the ls output.

15 months agoserver: Fix ls -l=c.
Andre Noll [Tue, 24 Jan 2023 18:16:50 +0000 (19:16 +0100)]
server: Fix ls -l=c.

This classic copy+paste bug caused ls -l=c to work as if -l=m had
been given. Introduced seven years ago in commit 7af252cbfe13 (server:
Convert com_ls() to lopsub).

15 months agoMerge topic branch t/ff-compat into master
Andre Noll [Tue, 17 Jan 2023 15:29:16 +0000 (16:29 +0100)]
Merge topic branch t/ff-compat into master

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().

15 months agoaudiod_command.c: Dedox stat_item_valid().
Andre Noll [Mon, 21 Nov 2022 12:59:09 +0000 (13:59 +0100)]
audiod_command.c: Dedox stat_item_valid().

Another static function which does not need to be documented with
doxygen.

15 months agoBump copyright year to 2023.
Andre Noll [Sun, 1 Jan 2023 14:37:58 +0000 (15:37 +0100)]
Bump copyright year to 2023.

Happy new year.

16 months agoMerge topic branch t/openssl-3 into master
Andre Noll [Thu, 1 Dec 2022 17:08:44 +0000 (18:08 +0100)]
Merge topic branch t/openssl-3 into master

Two patches. The first suppresses warnings when compiling against
openssl-3, the second switches the two hash functions over to the
EVP API. More work is needed but it does not hurt to merge this first
step now.

* refs/heads/t/openssl-3:
  openssl: Switch to evp API for sha1 and sha256.
  openssl: Deactivate openssl-3 warnings for now.

16 months agoMerge branch 'maint'
Andre Noll [Fri, 25 Nov 2022 12:27:13 +0000 (13:27 +0100)]
Merge branch 'maint'

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().

16 months agoserver: Fix race condition in com_stat().
Andre Noll [Wed, 9 Nov 2022 19:46:48 +0000 (20:46 +0100)]
server: Fix race condition in com_stat().

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.

17 months agoserver: Avoid deadlock in daemon_log().
Andre Noll [Wed, 9 Nov 2022 19:20:26 +0000 (20:20 +0100)]
server: Avoid deadlock in daemon_log().

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
17 months agoafs.h: Improve documentation of typedefs.
Andre Noll [Mon, 21 Nov 2022 12:57:17 +0000 (13:57 +0100)]
afs.h: Improve documentation of typedefs.

Doxygen expects the comments to consist of a one-line summary and an
optional long description.

17 months agoMerge topic branch t/afs-cleanups into master
Andre Noll [Sun, 20 Nov 2022 18:21:35 +0000 (19:21 +0100)]
Merge topic branch t/afs-cleanups into master

A fair number of patches which clean up all parts of the audio file
selector. The most visible change is probably that error messages from
afs callbacks are sent with a proper sideband designator so that they
are written to stderr on the client side.

* refs/heads/t/afs-cleanups: (30 commits)
  Introduce afs_error().
  afs.c: Move com_select() and its callback down.
  Rename mood_switch(), mood_close(), playlist_{open/close}.
  Assume that score_open() and score_clear() always succeed.
  playlist.c: Rename playlist_info -> playlist_instance.
  mood.c: Rename struct mood to mood_instance.
  afs.c: Rename ->handler of struct callback_query to ->cb.
  Simplify and improve activate_mood_or_playlist().
  afs: Replace ->init of afs tables by table operations.
  Merge load_playlist() into playlist_open() and simplify.
  Simplify row_belongs_to_score_table().
  Remove mood.h.
  Clean up and rename change_current_mood().
  mood.c: Simplify and rename load_mood().
  mood.c: Move struct statistics into struct mood.
  afs.c: Improve activate_mood_or_playlist().
  Improve playlist_open().
  blob.c: Don't initialize table pointer in table->init().
  blob: Constify name argument of blob_get_def_by_name().
  Rename admissible_file_loop() -> score_loop().
  ...

17 months agovss: Streamline and dedox documentation of vss_send().
Andre Noll [Wed, 9 Nov 2022 19:54:56 +0000 (20:54 +0100)]
vss: Streamline and dedox documentation of vss_send().

The new text says the same and is only half as long.

17 months agoMerge topic branch t/mixer into master
Andre Noll [Wed, 16 Nov 2022 17:12:04 +0000 (18:12 +0100)]
Merge topic branch t/mixer into master

A few patches for the sleep subcommand of para_mixer, in particular
the two new options to set the initial mood.

This code has been cooking in next for exactly one month.

* refs/heads/t/mixer:
  mixer: sleep: Fade out before stopping the stream.
  mixer: sleep: Cycle audiod on stop.
  mixer: sleep: Add --initial-mood and --initial-delay.
  mixer: sleep: Always set initial volume and channel.
  mixer: sleep: Improve description of sleep subcommand.

17 months agoMerge branch 'maint'
Andre Noll [Mon, 14 Nov 2022 21:18:04 +0000 (22:18 +0100)]
Merge branch 'maint'

To bring in the 0.5.9 tag.

* maint:
  paraslash 0.5.9

17 months agoMerge tags 'v0.5.9' and 'v0.6.4' into maint
Andre Noll [Mon, 14 Nov 2022 21:16:22 +0000 (22:16 +0100)]
Merge tags 'v0.5.9' and 'v0.6.4' into maint

For some reason, the release commits for 0.5.9 and 0.6.4 releases
(which updated only the NEWS file) did not make it into the maint
branch. This octopus commit merges both tags to correct this omission.

17 months agoDoxyfile: Remove GNUC definitions.
Andre Noll [Sun, 2 Oct 2022 18:10:47 +0000 (20:10 +0200)]
Doxyfile: Remove GNUC definitions.

These defines have been present since day one of the git repo in 2006.
The log message of the cvs commit which introduced them back then
just states "activate the source browser", so it will have to remain
a mystery why __GNUC__ and __GNUC_MINOR__ needed to be predefined.

17 months agoExclude status items and error list from doxygen.
Andre Noll [Sun, 2 Oct 2022 22:33:59 +0000 (00:33 +0200)]
Exclude status items and error list from doxygen.

These lists are rather long and make the doxygen source code
documentation harder to read without providing a real benefit.

17 months agoMerge topic branch t/net into master
Andre Noll [Mon, 7 Nov 2022 16:34:31 +0000 (17:34 +0100)]
Merge topic branch t/net into master

A moderately sized series which contains a bunch of simple cleanups
for net.c and net.h.

* refs/heads/t/net:
  net: De-doxify static functions.
  net: Refer to correct man page in stringify_port().
  net: Pass true/false instead of 0/1 to makesock().
  net: Demote log level of error message in makesock().
  net: Rename para_connect_simple() -> para_connect().
  net: Make is_valid_ipv{4,6}_address() local to net.c.
  net: Remove IPPROTO_DCCP define.
  net: Make single-use macros local.
  net: Combine documentation of struct flowopts.
  net: Drop extern keyword of function declarations.

17 months agoopenssl: Switch to evp API for sha1 and sha256.
Andre Noll [Fri, 10 Sep 2021 18:37:37 +0000 (20:37 +0200)]
openssl: Switch to evp API for sha1 and sha256.

This is easy to do and gets rid of some warnings about depreciated APIs
(which got deactivated in the previous commit, but still).

17 months agoopenssl: Deactivate openssl-3 warnings for now.
Andre Noll [Mon, 22 Nov 2021 18:41:20 +0000 (19:41 +0100)]
openssl: Deactivate openssl-3 warnings for now.

openssl-3 depreciated a bunch of functions we are using in openssl.c,
but the suggested alternatives are not available in older versions
of the openssl library. This makes a smooth transition harder than
necessary. Suppress the warnings for now.

18 months agogui: Allow for 4-digit image IDs on 80-character terminals.
Andre Noll [Tue, 27 Sep 2022 10:05:01 +0000 (12:05 +0200)]
gui: Allow for 4-digit image IDs on 80-character terminals.

Currently, the first digit of a 4-digit image ID get truncated to
three characters if the width of the terminal window is at its minimal
size of 80 characters. We can squeeze out two more characters from
the previous field, so this is easy to fix.

This only affects the colorful blackness theme.

18 months agomood: Fix compute_score().
Andre Noll [Sat, 22 Oct 2022 17:59:52 +0000 (19:59 +0200)]
mood: Fix compute_score().

This fixes a bug which was introduced 10 months ago in merge
commit 88bf6848d1c (Merge branch 'refs/heads/t/rm_v1_moods'). This
merge conflicted in mood.c, and the conflicting hunks that touched
compute_score() were resolved incorrectly. Put simply, we kept the
old code and disregarded the correction factors that were introduced
by the other side of the merge. As a result, at mood load time the
correction factors were initialized correctly but not taken into
account for computing the score of the admissible files.

The fact that the bug went unnoticed for so long can only mean that
the correction factors don't make much of a difference in practice.
However, the bug was found because one particular mood behaved
unexpectedly, likely because its admissible files consisted of a
bunch of very new files among many very old ones.

18 months agoserver: Remove compatibility code of com_ff().
Andre Noll [Mon, 16 May 2022 19:08:05 +0000 (21:08 +0200)]
server: Remove compatibility code of com_ff().

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.

18 months agoIntroduce afs_error().
Andre Noll [Tue, 30 Aug 2022 11:55:54 +0000 (13:55 +0200)]
Introduce afs_error().

The callbacks of some afs commands employ the normal ->pbpout para
buffer to send an error message to the client on failure. These
messages are therefore tagged with the OUTPUT sideband designator
just as regular command output.

The receiving client writes such messages to stdout, so applications
which call para_client have no other way than parsing the output to
guess whether it is normal command output or an error message.

This commit improves on this by providing a public helper in afs.c
to format and send an error message that is tagged with the ERROR
sideband designator and thus gets written to stderr on the client
side. All afs callbacks which currently use ->pbout for error messages
are converted to call the new helper.

18 months agoafs.c: Move com_select() and its callback down.
Andre Noll [Tue, 30 Aug 2022 11:55:48 +0000 (13:55 +0200)]
afs.c: Move com_select() and its callback down.

Preparation for the upcoming introduction of afs_error(), which will
be called by the select callback and should therefore be located
above the callback. No code changes, nothing to see here.

18 months agoRename mood_switch(), mood_close(), playlist_{open/close}.
Andre Noll [Wed, 23 Mar 2022 17:42:08 +0000 (18:42 +0100)]
Rename mood_switch(), mood_close(), playlist_{open/close}.

This naming is unfortunate because we also have the static
{mood,pl}_{open,close}() in blob.c which operate on the osl table. In
contrast, the functions renamed in this commit operate on blob objects
and change the current mood or playlist. Let's call these operations
load/unload to avoid confusion.

18 months agoAssume that score_open() and score_clear() always succeed.
Andre Noll [Tue, 22 Mar 2022 18:33:52 +0000 (19:33 +0100)]
Assume that score_open() and score_clear() always succeed.

Since the score table has only volatile columns, the only possible
error is memory exhaustion, in which case we can only abort
anyway. This patch changes score_open() to abort if osl_open()
fails. This allows us to let score_clear() return void. We can't get
rid of the return value of score_open(), however, since a pointer to
this function is stored the afs table operations structure.

18 months agoplaylist.c: Rename playlist_info -> playlist_instance.
Andre Noll [Mon, 21 Mar 2022 18:24:00 +0000 (19:24 +0100)]
playlist.c: Rename playlist_info -> playlist_instance.

The new name is more descriptive and matches the its mood counterpart,
mood_instance.

18 months agomood.c: Rename struct mood to mood_instance.
Andre Noll [Sun, 20 Mar 2022 20:53:44 +0000 (21:53 +0100)]
mood.c: Rename struct mood to mood_instance.

A mood is an blob object stored in the mood table. This structure
describes something different, so name it accordingly.

18 months agoafs.c: Rename ->handler of struct callback_query to ->cb.
Andre Noll [Thu, 17 Mar 2022 21:59:44 +0000 (22:59 +0100)]
afs.c: Rename ->handler of struct callback_query to ->cb.

The term "handler" is already overloaded. Besides command and signal
handlers we have callback result handlers, table event handlers and
max size handlers for para buffers. The simple "cb" is a shorter and
clearer name for the callback function pointer.

18 months agoSimplify and improve activate_mood_or_playlist().
Andre Noll [Sun, 13 Mar 2022 22:28:21 +0000 (23:28 +0100)]
Simplify and improve activate_mood_or_playlist().

The logic of this function can be simplified to match the four
possible cases for the argument. Each of the four conditional blocks
now initializes ret, mode and the message pointer.

The message is then printed into the para buffer, which is now
passed to the function instead of a char ** because this simplifies
the select callback a bit. The other callers (for init and SIGHUP
handling) pass NULL and don't need to be adjusted.

To make this work we have to make sure that the message pointer is
properly initialized in all cases, not only in the error case as
before. Thus, playlist_open() and mood_switch() are changed to return
a suitable message also on success.

For playlists, the message only contains the number of files in the
playlist. For moods we also include the afs statistics of the mood
and no longer write this information to the server log. We omit the
correction factors and the normalization divisor, however, as these
are not very interesting.

The only purpose of the num_admissible parameter of
activate_mood_or_playlist() was to let the caller log this
information. This task is now performed by playlist_open() and
mood_switch(), so the parameter can be dropped.