Andre Noll [Tue, 20 Aug 2019 07:10:53 +0000 (09:10 +0200)]
Avoid warning about sys/sysctl.h on glibc-2.30.
From glibc-2.30 NEWS:
The Linux-specific <sys/sysctl.h> header and the sysctl function have
been deprecated and will be removed from a future version of glibc.
Compilation against the glibc-2.30 headers results in the following warning:
In file included from ipc.c:10:
/usr/include/sys/sysctl.h:21:2: warning: #warning "The <sys/sysctl.h> header is deprecated and will be removed." [-Wcpp]
On NetBSD and FreeBSD, however, we still need to include the header
to get the declaration of sysctlbyname(3).
This patch changes ipc.c to include sys/sysctl.h only if __FreeBSD__ or
__NetBSD__ is defined. Also remove the pointless check for __APPLE__.
Andre Noll [Sun, 1 Sep 2019 11:18:41 +0000 (13:18 +0200)]
Merge branch 'refs/heads/t/afh'
A couple of patches which remove ->init of struct audio_format_handler
and struct receiver.
Cooking for 9 months.
* refs/heads/t/afh:
Remove ->init() of struct receiver.
afh: Constify definition of audio format handlers.
afh: Introduce audio_format_names[].
afh: Get rid of dummy entry at the end of afl[].
afh: Minor simplification for afh_get_chunk().
afh: Move audio_format_name() up.
Andre Noll [Sat, 24 Aug 2019 11:38:29 +0000 (13:38 +0200)]
Merge branch 'refs/heads/t/compress'
A short series which overhauls the algorithm behind the compress
filter and its documentation.
Cooking for almost a year.
* refs/heads/t/compress:
compress: Overhaul the meaning of --aggressiveness.
compress: Apply damping later.
compress: Warn when samples are clipped.
compress: Document and sanity-check command line options.
compress: Fix off by one in help of --target-level.
Andre Noll [Sun, 27 Jan 2019 23:00:40 +0000 (00:00 +0100)]
aft: Avoid invalid read.
This happens with dynamic chunks. In this case we don't reserve any
space for the chunk table, yet the code copies one entry.
==6827== Invalid read of size 4
==6827== at 0x805A7C6: write_u32 (portable_io.h:95)
==6827== by 0x805A7C6: save_chunk_table (aft.c:402)
==6827== by 0x805E035: save_afd (aft.c:616)
==6827== by 0x805E035: open_and_update_audio_file (aft.c:1097)
==6827== by 0x80589B5: open_next_audio_file (afs.c:425)
==6827== by 0x80589B5: execute_server_command (afs.c:867)
==6827== by 0x80589B5: command_post_select.part.3 (afs.c:921)
==6827== by 0x80632CE: call_post_select (sched.c:80)
==6827== by 0x80632CE: sched_post_select (sched.c:106)
==6827== by 0x80632CE: schedule (sched.c:159)
==6827== by 0x8059555: afs_init (afs.c:1006)
==6827== by 0x804D53A: init_afs (server.c:528)
==6827== by 0x804D53A: server_init (server.c:600)
==6827== by 0x804D53A: main (server.c:689)
==6827== Address 0x58c4a20 is 0 bytes after a block of size 40 alloc'd
==6827== at 0x40345EE: malloc (vg_replace_malloc.c:299)
==6827== by 0x80539C5: para_malloc (string.c:63)
==6827== by 0x805B38A: load_chunk_table (aft.c:415)
==6827== by 0x805DFC4: open_and_update_audio_file (aft.c:1087)
==6827== by 0x80589B5: open_next_audio_file (afs.c:425)
==6827== by 0x80589B5: execute_server_command (afs.c:867)
==6827== by 0x80589B5: command_post_select.part.3 (afs.c:921)
==6827== by 0x80632CE: call_post_select (sched.c:80)
==6827== by 0x80632CE: sched_post_select (sched.c:106)
==6827== by 0x80632CE: schedule (sched.c:159)
==6827== by 0x8059555: afs_init (afs.c:1006)
==6827== by 0x804D53A: init_afs (server.c:528)
==6827== by 0x804D53A: server_init (server.c:600)
==6827== by 0x804D53A: main (server.c:689)
Andre Noll [Fri, 21 Dec 2018 17:11:40 +0000 (18:11 +0100)]
build: Check also for CRYPTO_cleanup_all_ex_data.
FreeBSD 12 does not seem to have it. This is not fatal since omitting
the call to CRYPTO_cleanup_all_ex_data() just results in a harmless
memory leak at exit.
Andre Noll [Fri, 21 Dec 2018 15:43:54 +0000 (16:43 +0100)]
build: Detect openssl library/header mismatch.
This catches the case where openssl-1.0 headers are used for compiling
but openssl-1.1 libraries for linking. Without the check that is added
by this commit the compilation succeeds in this case but the executable
segfaults on the attempt to modify the RSA structure directly. With
the new check, configure fails gracefully.
This happened on a FreeBSD system where the openssl-1.0 headers were
installed in /usr/local and openssl-1.1 headers in /usr.
Andre Noll [Sun, 30 Sep 2018 21:39:58 +0000 (23:39 +0200)]
mp3_afh: Move mode_text[] into header_mode().
The array is only used in header_mode(), so it should be local to
the function. Also, it's confusing to let the last element play the
role of the invalid header mode, and it's clearer to use ARRAY_SIZE()
instead of spelling out the index of the last element. Next, it's
unnecessary to write to the mp3header structure, so avoid this and
mark the pointer argument const. Finally, the patch makes the array
constant, not only the mode strings.
Andre Noll [Sat, 22 Dec 2018 13:54:24 +0000 (14:54 +0100)]
build: Remove hard-coded include path.
Compilers generally have /usr/local/include in their default search
path. And if they don't, that has to be considered a local policy
which should not be ignored. The user can always override it by
setting CPPFLAGS.
Andre Noll [Sat, 22 Dec 2018 13:00:14 +0000 (14:00 +0100)]
build: Fix CPPFLAGS for openssl.
The effect of the wrong file name was that --with-openssl-headers
was effectively ignored.
This bug was introduced one year ago in commit a4c2c4f9c7cd (crypt:
Rename RSA functions) which renamed the crypt.c file to openssl.c but
missed to adjust the Makefile accordingly.
Andre Noll [Sun, 30 Sep 2018 20:58:25 +0000 (22:58 +0200)]
vss: Add documentation of MAP_POPULATE.
It should be clear why the vss should ask the kernel to prefault the
page tables for the mapping, but it's less clear why we might need
to define the preprocessor symbol.
Andre Noll [Sat, 8 Sep 2018 18:31:38 +0000 (20:31 +0200)]
Improve description of para_play.
For one, there is no stop command. Furthermore, make it clear that
the path and the playback position are shown *instead of* the prompt
and the command line.
Andre Noll [Sat, 5 Aug 2017 22:55:50 +0000 (00:55 +0200)]
build: Use .ONESHELL.
This instructs "make" to pass all the lines in the recipe to a
single invocation of the shell. This has no disadvantage and improves
performance slightly. Best out of five "make -j 4" runs:
Before: 0m3.510s
After: 0m3.280s
Speedup: 6.55%
With .ONESHELL given, only the first line of each recipe will be
checked for the special '@' prefix character. This made it necessary
to modify the "Q" macro slightly. Rename it to "SAY" while at it.
The second issue with .ONESHELL is that a failure of any but the
final recipe line will not be noticed by make. To work around this,
we set .SHELLFLAGS to '-ec'. The '-e' flag instructs the shell to
exit at any failure anywhere in the command line.
Andre Noll [Tue, 25 Sep 2018 21:25:42 +0000 (23:25 +0200)]
Remove ->init() of struct receiver.
The previous patch removed the ->init() method of the afh receiver.
Since the afh receiver was the only receiver that defined an init
method, the method can now be removed from struct receiver.
As a consequence, recv_init(), which calls each receiver's init method
has become a no-op and can also be removed.
Andre Noll [Tue, 25 Sep 2018 19:41:20 +0000 (21:41 +0200)]
afh: Constify definition of audio format handlers.
The audio_format_handler structure contains only pointers, and the
->init method of each instance initializes these pointers to constant
values. The ->init() method is thus useless at best, and it prevents
the structures from being declared constant.
This patch removes ->init() of struct audio_format_handler and the
public afh_init() which iterates over all audio formats to call each
->init() method. The audio format handlers are modified to define an
instance of the structure rather than an init function which fills the
fields of the given structure. The structure can be declared constant,
but not static because afh_common.c needs a way to refer to it.
We rely on weak symbols to deal with audio format handlers which are
not compiled in. The codec-independent code in afh_common.c defines
a weak instance of the audio_format_handler structure for each audio
format. The command handlers which are compiled in override the weak
symbol with their own definition.
The afh receiver used to define afh_init() as its (receiver!) init
function, which no longer exists. Since receiver init functions are
optional, we don't need to supply a replacement. However, play.c
calls ->init() of the afh_receiver unconditionally. This call needs
to be removed to avoid a null pointer dereference.
Andre Noll [Fri, 21 Sep 2018 07:29:18 +0000 (09:29 +0200)]
afh: Introduce audio_format_names[].
This removes .name of struct audio_format in favor of an array of
strings. This will allow us to make afl[] a constant array of pointers,
some of which may be NULL to indicate that the audio format was not
compiled in.
This temporarily duplicates the list of audio formats. The second
list will be removed in a subsequent commit.
Andre Noll [Fri, 21 Sep 2018 07:25:46 +0000 (09:25 +0200)]
afh: Get rid of dummy entry at the end of afl[].
The number of audio formats is a compile-time constant. It used to be
the array size of afl[] minus one due to the dummy entry. Without
it, it becomes simply the array size. This patch introduces
NUM_AUDIO_FORMATS as a shortcut for ARRAY_SIZE(afl) and adjusts
next_audio_format() to avoid the access of memory past the end of
the array. With these preparations in place, the dummy entry can
be removed.
Andre Noll [Wed, 5 Sep 2018 10:13:35 +0000 (12:13 +0200)]
blob: Avoid direct access to blob IDs.
Some places of blob.c use read_u32() to get the blob ID from the
osl object while others directly access the mapped memory through
a uint32_t pointer. Besides alignment issues, this causes trouble
on big endian machines. Make sure we always use the primitives from
portable_io.h.
Andre Noll [Wed, 19 Sep 2018 19:08:14 +0000 (21:08 +0200)]
spxdec: Use read_u16() from portable_io.h.
It's about 1% slower on my little endian system, but this is not
reason enough to keep the le_short() macro of spxdec.c. If anything,
the primitives in portable_io.h should be improved.
Andre Noll [Wed, 19 Sep 2018 18:50:01 +0000 (20:50 +0200)]
server: Remove declarations of sender init functions.
The init functions of the three senders have been made static long ago.
Since then vss_init() calls these functions indirectly through the
function pointer of the sender struct. Hence the declarations in
vss.c are no longer needed.
Andre Noll [Wed, 1 Aug 2018 16:29:05 +0000 (18:29 +0200)]
oss: Bail out on unsupported audio formats.
This is better than assuming signed 16 bit little endian. The patch
also improves the error message in oss.c that gets printed when the
audio format could not be set.
Andre Noll [Sat, 8 Sep 2018 13:29:44 +0000 (15:29 +0200)]
aft: Consolidate comments for sorting/listing enums.
This saves a couple of lines and improves readability.
The patch also changes the format of the doxygen comments from -sX
to -s=X and similar for -l, as this has become the required syntax
for -s, and is preferred (albeit not required) also for -l.
Andre Noll [Tue, 4 Sep 2018 11:21:06 +0000 (13:21 +0200)]
ao: Improve help text.
It was not clear how to obtain the list of available drivers and
their keys. This commit adds this information to the help text and
the man page of the ao writer.
Andre Noll [Tue, 4 Sep 2018 10:48:46 +0000 (12:48 +0200)]
write: Remove osx writer from write_cmd suite.
The osx writer seems to be kind of a zombie: osx_write.c came back
through a mistake in a merge commit, see commit 7d9e3454 (remove
osx_write.c, this time for real) from last year. But we also missed
to remove the osx subcommand from the write_cmd lopsub suite.
Andre Noll [Sat, 1 Sep 2018 19:07:54 +0000 (21:07 +0200)]
compress: Overhaul the meaning of --aggressiveness.
Large values for the argument to --aggressiveless are next to useless
because they correspond to gain factors which are much too large. The
default value of four is already too large as it allows for a 16-fold
volume amplification.
This patch changes the meaning of the argument to be a multiplication
rather than a shift. Admissible values are restricted to the range
0..10, which allows for fine-grained control over the maximal gain
factor.
The maximal gain factor is four, so the inertia argument must not
exceed 14 to guarantee that no integer overflow can happen.
Andre Noll [Mon, 23 Jul 2018 08:52:14 +0000 (10:52 +0200)]
compress: Apply damping later.
This changes the algorithm of the compress filter to apply the right
shift defined by the --damp argument *after* the peak value of the
current block has been computed. This makes damping orthogonal to
the dynamic volume adjustments.
However, we increase the downshift so that the initial value of the
gain multiplier results in a right shift by one. Hence the expected
peak value is 16384, so make this the default target gain.
Andre Noll [Sun, 15 Jul 2018 20:52:46 +0000 (22:52 +0200)]
compress: Document and sanity-check command line options.
The arguments of most of the options to the compress filter are used
as shifts and therefore have rather tight requirements on the range of
admissible/useful values. Let's document these values and make sure
to print a meaningful error message if an argument is out of range.
Andre Noll [Sat, 11 Aug 2018 19:52:05 +0000 (21:52 +0200)]
net.c: Remove compat macros for AI_V4MAPPED et al.
These were added 11 years ago during NetBSD-3.1 days because this
version of NetBSD lacked the three macros. At least on NetBSD-7.1
(released 2017), the compat macros are no longer necessary while
FreeBSD and Linux never needed them. So let's get rid of them.
Andre Noll [Mon, 27 Aug 2018 12:34:46 +0000 (14:34 +0200)]
doc: Advise the user to generate PEM keys.
With openssh-7.8 the default has been changed to write OpenSSH format
private keys instead of OpenSSL's PEM format. paraslash can only read
the latter, so make sure everyone stays at PEM for now.
Andre Noll [Tue, 28 Aug 2018 09:08:00 +0000 (11:08 +0200)]
gcrypt: Fix gcrypt error log message in read_bignum().
The message says the error occured while scanning for the public
modulus n, which is not true because the function is called for each
of the five bignums stored in an RSA private key file.
Andre Noll [Mon, 27 Aug 2018 14:56:26 +0000 (16:56 +0200)]
t0004: Always create PEM keys.
New versions of ssh-keygen create RFC4716 keys by default, which
breakes the test suite. Fortunately, the fix is easy and works also
for old versions of openssh/ssh-keygen.
Andre Noll [Sat, 11 Aug 2018 14:01:51 +0000 (16:01 +0200)]
mixer: sleep: Change to next file at fade-in time.
If a sleep mood is given, we currently start fading in with the current
file of the sleep mood still playing. It might therefore take a long
time until the first file of the fade-in mood is started. This patch
avoids this problem by running "para client next" at fade-in time
right after the mood has been changed to the fade-in mood.
Andre Noll [Mon, 30 Apr 2018 18:31:05 +0000 (20:31 +0200)]
Check for abstract sockets only once.
In net.c there is a static variable which is supposed to cache whether
the abstract local socket namespace is supported. This variable is
pointless because it is only ever set by command handlers, which exit
after the command completed. Hence the command handler process of
each subsequent afs command checks again. To make the caching work as
intended we must initialize the variable in the *parent* process. The
parent process, however, does not create any local sockets.
This patch changes init_unix_addr() to initialize the variable
without creating a socket when NULL is passed as the name parameter.
The server process passes NULL to initialize the static variable
while command handlers pass non NULL.
Andre Noll [Sat, 7 Jul 2018 10:44:47 +0000 (12:44 +0200)]
mixer: sleep: Change to fade-in mood later.
When a sleep mood is given, we currently switch to the fade-in mood
too early, so that the fade-in mood rather than the sleep mood is
active during sleep time.
Andre Noll [Tue, 1 May 2018 14:52:30 +0000 (16:52 +0200)]
com_ff(): Depreciate "n-" syntax.
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.
Andre Noll [Mon, 25 Jun 2018 18:12:27 +0000 (20:12 +0200)]
Merge branch 'refs/heads/t/aft_fixes'
Two fixes related to the audio file table.
Cooking for three weeks.
* refs/heads/t/aft_fixes:
aft: Remember current audio file after SIGHUP.
aft: Honor AUDIO_FILE_REMOVE events.
server: Update status items on file renames.
Andre Noll [Sun, 10 Jun 2018 16:59:36 +0000 (18:59 +0200)]
Merge branch 'refs/heads/t/long-help'
This series introduces lsu.c and lsu.h which contain helpers related to
the lopsub library. These helpers are designed to be shared between
the executables. The series starts by implementing a generic help
command for lopsub suites and converts para_server. Subsequent patches
convert audiod and para_play.
The second part of the series adds another lopsub related helper which
merges command line options and config file options. Each executable
is modified to make use of the new helper, getting rid of quite some
code duplication.
The conflict resolution for server.c has been tested for a while.
Cooking for five weeks.
* refs/heads/t/long-help:
play: Use lsu_merge_config_file_options().
mixer: Use lsu_merge_config_file_options().
gui: Use lsu_merge_config_file_options().
filter: Use lsu_merge_config_file_options().
audioc: Use lsu_merge_config_file_options().
audiod: Use lsu_merge_config_file_options().
client: Use lsu_merge_config_file_options().
lsu: Add helper to merge config file options, convert server.
Trivial: Rename completion_result variables.
play: Implement help --long.
audiod: Implement help --long.
Introduce lsu.{c,h}, implement help --long for para_server.
Andre Noll [Sun, 20 May 2018 09:26:26 +0000 (11:26 +0200)]
Merge branch 'refs/heads/t/clean_server_exit'
This series removes many memory leaks of para_server by refactoring
the shutdown and signal handling code. Most of the leaks happen only
at shutdown and are hence harmless. But it is still good to plug
the leaks because this puts more focus on real memory leaks in the
valgrind output.
The merge conflicted rather badly due to the changes introduced with
the crypt branch that was merged last week. The resolution has been
thoroughly tested, though.
* refs/heads/t/clean_server_exit: (32 commits)
command.c: Document return value of handle_connect().
user_list: Make list head static.
afs: Allow database switching on sighup.
afs: Free current mood or playlist on exit.
afs: Free status items on exit.
afs: Shutdown signals on exit.
server: Free parse result also in afs.
afs: Deplete user list at startup.
server: Free audio file header on exit.
sender: Deplete ACLs on exit.
Remove some unused includes from {dccp,http}_send.c.
server: Make argument of user_list_init() constant.
server: Deplete user list on exit.
server: Combine user_list_init() and populate().
server: Move para_fgets() to user_list.c.
server: Initialize user list at compile time.
server: Rename functions related to user lists.
server: Constify return value of lookup_user().
server: Let stat command handler perform cleanup on signals.
server: Have afs process close the current mood on exit().
...
Andre Noll [Sun, 13 May 2018 12:03:20 +0000 (14:03 +0200)]
Merge branch 'refs/heads/t/crypt'
A couple of simple patches which clean up the openssl and gcrypt crypto
backends. The non-trivial parts are the get_public_key() unification,
the memory leak fixes for openssl and the activation of the secmem
pool for gcrypt.
* refs/heads/t/crypt:
gcrypt: Allocate a secmem pool at startup.
crypt: Introduce crypt_shutdown().
crypt: Rename init_random_seed_or_die() -> crypt_init().
gcrypt: Use ROUND_DOWN() macro.
crypt: Rename RSA functions.
crypt: Deduplicate get_public_key().
crypt.h: Remove two unused constants.
Rename crypt.c -> openssl.c.
Andre Noll [Mon, 16 Apr 2018 18:41:39 +0000 (20:41 +0200)]
aft: Remember current audio file after SIGHUP.
The current_aft_row pointer becomes stale when the osl tables are
re-opened because SIGHUP has been received. If the current audio file
is renamed, or its metadate (afs info or afh info) are modified,
the table event dispatcher of the audio file table compares the
stale row pointer against the (non-stale) row pointer of the audio
file that has been obtained by path lookup. The two pointers never
compare equal under normal circumstances due to ASLR, so the file
modification does not trigger an update of the status items.
This patch fixes this inconvenience by remembering the hash of the
current audio file at table close time. On SIGHUP, after the table
has been re-opened, we lookup the stored hash to replace the stale
row pointer.
Andre Noll [Mon, 9 Apr 2018 19:05:56 +0000 (21:05 +0200)]
server: Update status items on file renames.
The audio file table currently ignores rename events. This has the
effect that the status items, hence the display of para_gui, is not
updated when the current file has been renamed. Fix this oversight.
Andre Noll [Mon, 30 Apr 2018 19:18:01 +0000 (21:18 +0200)]
server: Fix return value of com_ff().
We set the VSS_NEXT flag if the amount of seconds to jump forward
would exceed the end of the current audio file. However, in this case
we fail the command by returning -E_NO_AUDIO_FILE, which is incorrect.
This bug was present since day one of the git repo (2006).
Andre Noll [Thu, 15 Mar 2018 01:31:10 +0000 (02:31 +0100)]
play: Use lsu_merge_config_file_options().
Besides parsing the command line options and the config file,
parse_config_or_die() also checks the key map arguments
syntactically. This check needs to be kept of course.
play.c already includes lsu.h because it calls lsu_com_help().
Andre Noll [Thu, 15 Mar 2018 01:14:37 +0000 (02:14 +0100)]
mixer: Use lsu_merge_config_file_options().
para_mixer is special in the way the config file is handled because
it is the only executable which allows options for subcommands
to be stored in the config file. Therefore the mixer specific
parse_and_merge_config_file() is called twice. First to merge the
global (supercommand) options, then to merge the subcommand options.
This does not cause any problems regarding the conversion, though.
Andre Noll [Thu, 15 Mar 2018 00:36:19 +0000 (01:36 +0100)]
gui: Use lsu_merge_config_file_options().
para_gui supports config file reloading, so parse_config_file_or_die()
needs to set MCF_DONT_FREE to keep a reference to the command line
parse result and MCF_OVERRIDE in the reload case. Also, the code to
check the key maps and to initialize the theme needs to be kept.
Andre Noll [Wed, 14 Mar 2018 23:04:06 +0000 (00:04 +0100)]
audiod: Use lsu_merge_config_file_options().
Besides reading and merging the config file, parse_config_or_die()
also creates the uid whitelist. This part has to be retained, but we
can reduce the indentation level by returning early if --user-allow
was not given.
Andre Noll [Wed, 14 Mar 2018 19:42:57 +0000 (20:42 +0100)]
lsu: Add helper to merge config file options, convert server.
After the command line options have been parsed, most paraslash
executables read options from a config file. The two lopsub parse
result structures are then merged in a way that command line options
take preference over config file options. This logic is duplicated
in all executables.
This patch introduces a generic helper to eliminate the duplication.
The new lsu_merge_config_file_options() will eventually be employed
by all executables which need to parse the config file. This patch,
however, only converts para_server.
Andre Noll [Tue, 13 Mar 2018 23:10:42 +0000 (00:10 +0100)]
play: Implement help --long.
Also para_play benefits from the conversion to the generic
lsu_com_help(). After this patch, the three help commands of server,
audiod and play have the same syntax and their output is formatted
in the same way.