paraslash.git
4 years agomixer: sleep/snooze: Close mixer during sleep.
Andre Noll [Sat, 23 Mar 2019 15:51:56 +0000 (16:51 +0100)]
mixer: sleep/snooze: Close mixer during sleep.

This makes these subcommands work in case the audio device goes away
temporarily during the sleep interval. This does not work at the moment
because we connect to the mixer only once at startup. The mixer handle
becomes invalid when the audio device goes away, so fade-in fails.

Another drawback of this "connect only once" design is that the
mixer device is opened even for the help subcommand, which is not
only silly but also has the effect that the help subcommand fails if
the mixer device can not be opened.

To improve on this, we have the individual subcommand handlers open and
close the mixer device. Consequently, the command handlers no longer
take a struct mixer_handle * argument. To obtain a mixer handle,
command handlers must now call the new open_mixer_and_set_channel()
at startup, and m->close() on return to free the handle.

5 years agoaft: Avoid invalid read.
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)

5 years agoMerge branch 'refs/heads/t/mixer-fix'
Andre Noll [Sat, 23 Mar 2019 16:42:12 +0000 (17:42 +0100)]
Merge branch 'refs/heads/t/mixer-fix'

Two bug fixes for the sleep mode of para_mixer.  Started on 2018-07-07,
cooking since 2018-08-19.

* refs/heads/t/mixer-fix:
  mixer: sleep: Change to next file at fade-in time.
  mixer: sleep: Change to fade-in mood later.

5 years agoFix i9e completion.
Andre Noll [Sat, 22 Dec 2018 21:28:37 +0000 (22:28 +0100)]
Fix i9e completion.

i9e_print_completions() does not work as intended when the cursor is
positioned right after a word. This patch should fix it.

5 years agomp3_afh: Move mode_text[] into header_mode().
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.

5 years agoAdd homepage link.
Andre Noll [Sat, 19 Jan 2019 23:13:17 +0000 (00:13 +0100)]
Add homepage link.

People who like this project might be interested in the other projects
of the author too..

5 years agoChange copyright year to 2019.
Andre Noll [Sun, 20 Jan 2019 10:50:12 +0000 (11:50 +0100)]
Change copyright year to 2019.

5 years agobuild: Remove hard-coded include path.
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.

5 years agobuild: Fix CPPFLAGS for openssl.
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.

5 years agostring.c: Fix typos in comment.
Andre Noll [Sun, 23 Dec 2018 21:37:31 +0000 (22:37 +0100)]
string.c: Fix typos in comment.

5 years agomixer: Trivial whitespace fix.
Andre Noll [Fri, 23 Nov 2018 19:28:45 +0000 (20:28 +0100)]
mixer: Trivial whitespace fix.

5 years agocom_select(): Improve message.
Andre Noll [Wed, 10 Oct 2018 18:12:28 +0000 (20:12 +0200)]
com_select(): Improve message.

Let's be gramatically correct and omit the plural "s" if there is
only one admissible file.

5 years agoerror.h: Clarify difference between para_errlist[] and DEFINE_PARA_ERRLIST.
Andre Noll [Sun, 30 Sep 2018 21:25:36 +0000 (23:25 +0200)]
error.h: Clarify difference between para_errlist[] and DEFINE_PARA_ERRLIST.

5 years agomixer.c: Fix doxygen \file description.
Andre Noll [Sun, 30 Sep 2018 21:15:39 +0000 (23:15 +0200)]
mixer.c: Fix doxygen \file description.

para_mixer supports the OSS and the ALSA mixer API.

5 years agovss: Add documentation of MAP_POPULATE.
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.

5 years agodoc: Silence doxygen warnings.
Andre Noll [Sun, 30 Sep 2018 20:51:23 +0000 (22:51 +0200)]
doc: Silence doxygen warnings.

This gets rid of many warnings of the form

warning: Member lyr_get_def_by_id(uint32_t id, struct osl_object *def) (function) of file afs.h is not documented.

which show up if EXTRACT_ALL is set to "no".

5 years agodaemon: Add documentation of daemon_set_hooks().
Andre Noll [Wed, 26 Sep 2018 22:46:08 +0000 (00:46 +0200)]
daemon: Add documentation of daemon_set_hooks().

The function was introduced already one year ago in commit ced0c17d1a3e
(daemon: Introduce log mutex), but no documentation was provided
back then.

5 years agoImprove description of para_play.
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.

5 years agomanual: Fix command to create keys.
Andre Noll [Fri, 21 Dec 2018 14:26:09 +0000 (15:26 +0100)]
manual: Fix command to create keys.

$key is neither defined nor required here.

5 years agoMerge branch 'refs/heads/t/blob'
Andre Noll [Fri, 21 Dec 2018 14:50:47 +0000 (15:50 +0100)]
Merge branch 'refs/heads/t/blob'

A single endian fix to blob.c.  Started on 2018-09-04, cooking since
2018-10-13, merged on 2018-12-21.

* refs/heads/t/blob:
  blob: Avoid direct access to blob IDs.

5 years agoblob: Avoid direct access to blob IDs.
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.

5 years agospxdec: Use read_u16() 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.

5 years agoserver: Remove declarations of sender init functions.
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.

5 years agoao: Get rid of E_AO_BAD_SAMPLE_FORMAT.
Andre Noll [Sat, 8 Sep 2018 12:43:58 +0000 (14:43 +0200)]
ao: Get rid of E_AO_BAD_SAMPLE_FORMAT.

This error code is pointless as the generic E_BAD_SAMPLE_FORMAT is
just fine here.

5 years agocheck_wav: Remove pointless cast.
Andre Noll [Sat, 8 Sep 2018 11:14:37 +0000 (13:14 +0200)]
check_wav: Remove pointless cast.

cwc->channels is already unsigned.

5 years agocheck_wav: Use read_u32() and read_u16().
Andre Noll [Sat, 8 Sep 2018 11:13:32 +0000 (13:13 +0200)]
check_wav: Use read_u32() and read_u16().

This is equivalent and improves readability.

5 years agooss: Bail out on unsupported audio formats.
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.

5 years agoaft: Consolidate comments for sorting/listing enums.
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.

5 years agoaft: Change return type of make_status_items() to void.
Andre Noll [Fri, 7 Sep 2018 10:44:08 +0000 (12:44 +0200)]
aft: Change return type of make_status_items() to void.

All callers ignore the return value anyway. However, let's print a
warning in the failure case.

5 years agoaft: Add documentation of free_status_items().
Andre Noll [Fri, 7 Sep 2018 10:41:11 +0000 (12:41 +0200)]
aft: Add documentation of free_status_items().

It's a public function and thus should get doxygen comments.

5 years agoblob.c: Fix stale comment of stdin_command().
Andre Noll [Tue, 4 Sep 2018 23:14:02 +0000 (01:14 +0200)]
blob.c: Fix stale comment of stdin_command().

The arg_obj variable was removed last year in commit 02623a7cbff3
(server: Convert blob commands to lopsub).

5 years agoao: Improve help text.
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.

5 years agoao: Fix formatting of aow_show_drivers().
Andre Noll [Tue, 4 Sep 2018 11:11:25 +0000 (13:11 +0200)]
ao: Fix formatting of aow_show_drivers().

This got messed up in the lopsup conversion commit 870fcd0379ab
from more than one year ago.

5 years agoblob.c: Trivial whitespace fixes.
Andre Noll [Wed, 5 Sep 2018 15:32:58 +0000 (17:32 +0200)]
blob.c: Trivial whitespace fixes.

5 years agowrite: Remove osx writer from write_cmd suite.
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.

5 years agocommand.c: Fix braino in help text of recv_sb().
Andre Noll [Tue, 4 Sep 2018 18:35:43 +0000 (20:35 +0200)]
command.c: Fix braino in help text of recv_sb().

5 years agonet.c: Remove compat macros for AI_V4MAPPED et al.
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.

5 years agodoc: Advise the user to generate PEM keys.
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.

5 years agogcrypt: Fix gcrypt error log message in read_bignum().
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.

5 years agoopenssl: Fix memory leak in read_rsa_bignums().
Andre Noll [Wed, 29 Aug 2018 10:14:38 +0000 (12:14 +0200)]
openssl: Fix memory leak in read_rsa_bignums().

If an error occurs while reading the second bignum we leak the memory
allocated for the first bignum.

5 years agot0004: Always create PEM keys.
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.

5 years agomixer: sleep: Change to next file at fade-in time.
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.

5 years agoCheck for abstract sockets only once.
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.

5 years agoao_write: Silence sparse warning.
Andre Noll [Sun, 15 Jul 2018 09:16:18 +0000 (11:16 +0200)]
ao_write: Silence sparse warning.

ao_write.c:336:58: warning: incorrect type in argument 3 (different modifiers)
ao_write.c:336:58:    expected void *( *__start_routine )( ... )
ao_write.c:336:58:    got void [noreturn] *( *<noident> )( ... )

gcc versions 5, 6 and 7 all seem to be happy without the __noreturn
as well, so let's lose it.

5 years agomixer: sleep: Change to fade-in mood later.
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.

5 years agocompress: Use unsigned constant for definition of mask.
Andre Noll [Sun, 15 Jul 2018 20:15:42 +0000 (22:15 +0200)]
compress: Use unsigned constant for definition of mask.

Without this, the integer constant is of signed type, which may cause
problems when blocksize is 31.

5 years agoparaslash 0.6.2 v0.6.2
Andre Noll [Sat, 30 Jun 2018 08:54:34 +0000 (10:54 +0200)]
paraslash 0.6.2

5 years agoMerge branch 'refs/heads/t/aft_fixes'
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.

5 years agoMerge branch 'refs/heads/t/long-help'
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.

5 years agoMerge branch 'refs/heads/t/listen-address'
Andre Noll [Mon, 28 May 2018 16:29:06 +0000 (18:29 +0200)]
Merge branch 'refs/heads/t/listen-address'

A short series which adds options for para_server that allow the user
to specify the listening addresses of the passive sockets.

The resolution of the conflicts in server.c and send_common.c have
been well tested and were cooking for a couple of weeks.

* refs/heads/t/listen-address:
  server: Add --http-listen-address and --dccp-listen-address.
  server: Implement --listen-address for control service.

5 years agoMerge branch 'refs/heads/t/clean_server_exit'
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().
  ...

5 years agoMerge branch 'refs/heads/t/crypt'
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.

5 years agoMerge branch 'refs/heads/t/doc'
Andre Noll [Sun, 6 May 2018 08:54:47 +0000 (10:54 +0200)]
Merge branch 'refs/heads/t/doc'

Some minor documentation improvements. Cooking for four months.

* refs/heads/t/doc:
  Fix bad grammar "allows <infinitive>".
  doc: Move filter examples to man page.
  doc: Move sender examples to manual page.

5 years agoaft: Remember current audio file after SIGHUP.
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.

5 years agoaft: Honor AUDIO_FILE_REMOVE events.
Andre Noll [Tue, 17 Apr 2018 08:05:07 +0000 (10:05 +0200)]
aft: Honor AUDIO_FILE_REMOVE events.

If the current audio file has been removed, we should invalidate the
current_aft_row pointer.

5 years agoserver: Update status items on file renames.
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.

5 years agoserver: Remove incorrect __a_unused in com_ff() and com_jmp().
Andre Noll [Mon, 30 Apr 2018 18:38:18 +0000 (20:38 +0200)]
server: Remove incorrect __a_unused in com_ff() and com_jmp().

These subcommands do use the command context pointer.

5 years agoMerge branch 'maint'
Andre Noll [Sun, 6 May 2018 08:37:42 +0000 (10:37 +0200)]
Merge branch 'maint'

This fix for an ancient bug should also be in master.

* maint:
  server: Fix return value of com_ff().

5 years agoMerge branch 'refs/heads/t/gui-sigwinch'
Andre Noll [Tue, 1 May 2018 16:17:32 +0000 (18:17 +0200)]
Merge branch 'refs/heads/t/gui-sigwinch'

A single patch which removes a long standing issue of para_gui.

Cooking for half a year.

* refs/heads/t/gui-sigwinch:
  gui: Catch SIGWINCH.

5 years agoserver: Fix return value of com_ff().
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).

5 years agoserver: Fix brown paper bag bug in generic_com_on().
Andre Noll [Mon, 30 Apr 2018 18:59:59 +0000 (20:59 +0200)]
server: Fix brown paper bag bug in generic_com_on().

Due to this bug an the wrong integer is stored in ->listen_fd,
resulting in errors of the form

Apr 30 20:56:15 (4) (31884) accept_sender_client: Socket operation on non-socket

Fixes: ac9f8fc0b4a20 (send_common: Combine generic_com_on() and
open_sender()) from one month ago.

5 years agoplay: Use lsu_merge_config_file_options().
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().

5 years agomixer: Use lsu_merge_config_file_options().
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.

5 years agogui: Use lsu_merge_config_file_options().
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.

5 years agofilter: Use lsu_merge_config_file_options().
Andre Noll [Thu, 15 Mar 2018 00:18:12 +0000 (01:18 +0100)]
filter: Use lsu_merge_config_file_options().

Straight forward conversion. We now set the loglevel only once,
after the config file options have been merged.

5 years agoaudioc: Use lsu_merge_config_file_options().
Andre Noll [Wed, 14 Mar 2018 23:59:56 +0000 (00:59 +0100)]
audioc: Use lsu_merge_config_file_options().

This gets rid of the pointless configfile_exists() and the equally
pointless cmd variable.

5 years agoaudiod: Use lsu_merge_config_file_options().
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.

5 years agoclient: Use lsu_merge_config_file_options().
Andre Noll [Thu, 15 Mar 2018 01:45:59 +0000 (02:45 +0100)]
client: Use lsu_merge_config_file_options().

The helper is a drop-in replacement for the old code. We only have
to include the lsu header and link with the object.

5 years agolsu: Add helper to merge config file options, convert server.
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.

5 years agoTrivial: Rename completion_result variables.
Andre Noll [Wed, 14 Mar 2018 01:14:58 +0000 (02:14 +0100)]
Trivial: Rename completion_result variables.

Most completers call the completion result pointer "cr", but some use
"result" instead. Let's be consistent and rename those to cr.

5 years agoplay: Implement help --long.
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.

5 years agoaudiod: Implement help --long.
Andre Noll [Tue, 13 Mar 2018 22:47:11 +0000 (23:47 +0100)]
audiod: Implement help --long.

This converts the help command of para_audiod to the generic
lsu_com_help(), adding --long and removing quite a few lines of
duplicated code.  This patch also touches audioc.c since para_audioc
needs to learn to complete the new --long option. Moreover the help
text of the help command is made a bit more useful.

5 years agoIntroduce lsu.{c,h}, implement help --long for para_server.
Andre Noll [Tue, 13 Mar 2018 21:37:39 +0000 (22:37 +0100)]
Introduce lsu.{c,h}, implement help --long for para_server.

This adds the --long option to the server help subcommand. The former
help output becomes the long help while the short help text is shown
if --long is not given.

Although only the help command of para_server is converted in this
patch, the new functionality is implemented in a generic way so
that the help commands of para_audiod and para_play can use the same
implementation. Those will be converted in subsequent patches.

t0004 parses the help output and thus needs to be changed to include
--long.

5 years agoaft: Reorder global static variables of aft.c.
Andre Noll [Mon, 16 Apr 2018 17:43:09 +0000 (19:43 +0200)]
aft: Reorder global static variables of aft.c.

These variables constitute the state of the audio file table. The
overall logic is easier to understand if they are combined at one
spot at the top of the file.

The definition of struct ls_data needs to be moved up because of
this. Pure code movement, no semantic changes.

5 years agoafs: Don't log table open error twice.
Andre Noll [Fri, 13 Apr 2018 07:16:16 +0000 (09:16 +0200)]
afs: Don't log table open error twice.

If ->open() fails, open_afs_tables() returns a negative error code,
so there is no need to log the error string.

5 years agoaft.c: Trivial whitespace fix.
Andre Noll [Wed, 18 Apr 2018 18:33:32 +0000 (20:33 +0200)]
aft.c: Trivial whitespace fix.

6 years agoserver: Add --http-listen-address and --dccp-listen-address.
Andre Noll [Sat, 17 Mar 2018 01:11:01 +0000 (02:11 +0100)]
server: Add --http-listen-address and --dccp-listen-address.

Currently the http and the dccp sender accept connections on all IP
addresses. This commit makes it possible to configure the senders to
listen only on the specified subset of addresses.

To make this work, the sender_status structure has to be extended to
store an array of file descriptors rather than just a single one.
Several places need to iterate over all listening sockets of the
sender. The new FOR_EACH_LISTEN_FD macro helps to avoid duplicating
the corresponding loop.

The status part of the sender command now prints the listening
addresses instead of just on/off. This is why we also maintain the
ascii representation of the listening addresses in the sender_status
structure and introduce the format_url() helper to format host/port
pairs.

6 years agoMove MAX_HOSTLEN from server.h to net.h.
Andre Noll [Wed, 7 Mar 2018 18:45:09 +0000 (19:45 +0100)]
Move MAX_HOSTLEN from server.h to net.h.

This generic networking-related constant does not belong to
server.h. However, since server.h uses the constant, we have to make
sure that net.h is included before server.h.

6 years agoserver: Implement --listen-address for control service.
Andre Noll [Wed, 7 Mar 2018 11:32:15 +0000 (12:32 +0100)]
server: Implement --listen-address for control service.

For hosts with multiple IP addresses one might want to configure the
listening sockets so that connections can only arrive on a subset of
the host's addresses. This patch implements this feature.

Unlike para_listen_simple() the new para_listen() receives an optional
argument to let the caller specify the listening address in addition
to the port number. para_listen_simple() is now a simple wrapper
that passes a NULL pointer as the new argument which indicates that
the socket should listen on all local addresses, just like prior to
this change.

The set of listening addresses for the control service of para_server
can be specified via the new --listen-address option. This option
can be given multiple times, once for each listening address.

Due to this change the server needs to maintain more than a single
file descriptor to dispatch incoming connections. Hence the integer
->listen_fd of struct server_command_task has to be replaced by an
array of file descriptors and the {pre,post}_select methods of the
command task have iterate over all descriptors in the array.

The meaning of the --port option has changed due to the new option:
since the argument to --listen-address can also contain a port number,
the argument to --port is only used for addresses with no port number,
or if --listen-address is not given at all.

Although the http and dccp senders also open a listening socket, this
commit affects only the control service of para_server (listening on
TCP 2990 by default). Senders will be covered in the next commit.

6 years agonet: Combine para_listen() and para_listen_simple().
Andre Noll [Wed, 7 Mar 2018 11:00:58 +0000 (12:00 +0100)]
net: Combine para_listen() and para_listen_simple().

The only caller of para_listen() is para_listen_simple(), since
flowops are only used for active sockets.

6 years agonet: Improve error diagnostics of makesock_addrinfo().
Andre Noll [Thu, 22 Mar 2018 01:09:43 +0000 (02:09 +0100)]
net: Improve error diagnostics of makesock_addrinfo().

Since the function iterates over all addresses in the passed
addressinfo structure, errors can be non-fatal and may even be
expected. Therefore the function does not log any errors from
socket(2), setsockopt(2), connect(2) or bind(2), but only returns
a generic -E_MAKESOCK error code if none of the addressinfo members
worked. Unfortunately, this means it's impossible to tell from the
log message which of these system calls has failed.

This patch changes the function to also log the errors from the above
system calls, but only with loglevel notice. This way the non-fatal
errors are not shown by default (since the default loglevel is
"warning"), but one can easily activate them by specifying a lower
loglevel.

6 years agosend_common: Improve error diagnostics of generic_com_on().
Andre Noll [Sat, 17 Mar 2018 01:10:55 +0000 (02:10 +0100)]
send_common: Improve error diagnostics of generic_com_on().

Currently the function returns an error code but does not log a message
on errors. The callers, http_send_init() and dccp_send_init(), print
the strerror text with no indication that it is was generic_com_on()
which caused the error.

This commit moves the log messages from the callers to generic_com_on()
and changes the return type of generic_com_on() to void because both
callers now ignore the return value. The new log messages include a
text which tells the user what went wrong.

6 years agosend_common: Combine generic_com_on() and open_sender().
Andre Noll [Sat, 17 Mar 2018 00:57:43 +0000 (01:57 +0100)]
send_common: Combine generic_com_on() and open_sender().

The latter function is only called by the former, and both are short.

6 years agofd: Let readv_nonblock() recover from EINTR.
Andre Noll [Mon, 26 Mar 2018 22:39:48 +0000 (00:39 +0200)]
fd: Let readv_nonblock() recover from EINTR.

No need to fail the operation if the read was interrupted by a signal.

The patch also fixes some minor issues in the documentation:
a typo ("The" was incorrectly capitalized) and a missing \ref
for xwrite().  We use the opportunity to get rid of the \a and \p
font annotations. This improves the readability of the source code,
which is more imporatant than nice looking web pages. However, we
only touch those parts of the documentation which are modified anyway.

6 years agomixer: Improve sleep subcommand.
Andre Noll [Fri, 5 Jan 2018 15:11:36 +0000 (16:11 +0100)]
mixer: Improve sleep subcommand.

This avoids a pointless exec of "para_client stop" in case no fade-out
mood is given, and another pointless "para_client play" exec which
was executed when already playing.

Other than that behaviour should be identical.

6 years agohttp_recv: Improve error diagnostics.
Andre Noll [Wed, 21 Mar 2018 12:56:04 +0000 (13:56 +0100)]
http_recv: Improve error diagnostics.

If the http receiver is started when the stream is stopped or paused,
para_recv exits silently with no error message. Let's tell the user
what is going on.

6 years agoafh_recv: Improve error diagnostics.
Andre Noll [Tue, 9 Jan 2018 23:19:13 +0000 (00:19 +0100)]
afh_recv: Improve error diagnostics.

There are many reasons for afh_recv_open() to fail. For example, the
afh receiver could be unable to open its input file, or the given
begin chunk was larger than the end chunk. At the moment the error
reporting is a bit scarce since only the string of the error code is
printed. This commit makes afh_recv_open() print also the reason for
the error and the name of the file that caused the error.

6 years agoafs: Document ->lpr of struct afs_callback_arg.
Andre Noll [Mon, 26 Mar 2018 23:23:07 +0000 (01:23 +0200)]
afs: Document ->lpr of struct afs_callback_arg.

This should have been documented when the ->lpr member was introduced
two years ago in commit ba0a963f (server: Convert com_add() to lopsub).

6 years agobase64.h: Add Copyright and Doxygen header.
Andre Noll [Tue, 20 Mar 2018 02:58:09 +0000 (03:58 +0100)]
base64.h: Add Copyright and Doxygen header.

6 years agodoxygen: Exclude config.h.
Andre Noll [Tue, 20 Mar 2018 03:00:14 +0000 (04:00 +0100)]
doxygen: Exclude config.h.

This file is generated by autoconf and contains no doxygen
comments. Therefore it should not be part of the web documentation.

6 years agorecv: Mention default for --receiver.
Andre Noll [Wed, 21 Mar 2018 12:40:23 +0000 (13:40 +0100)]
recv: Mention default for --receiver.

It's not obvious that http is the default receiver, so let's mention this.

6 years agorecv: Add description of para_recv.
Andre Noll [Mon, 12 Mar 2018 17:32:52 +0000 (18:32 +0100)]
recv: Add description of para_recv.

para_recv is the only executable whose man page has no short
description at the beginning.

6 years agoclient: Remove unused ->config_file member.
Andre Noll [Wed, 14 Mar 2018 19:39:28 +0000 (20:39 +0100)]
client: Remove unused ->config_file member.

Currently we store a copy of the config file path in the client task
structure for no reason at all. Remove it.

6 years agoclient: Remove duplicate error message.
Andre Noll [Wed, 14 Mar 2018 19:33:58 +0000 (20:33 +0100)]
client: Remove duplicate error message.

client_parse_config() returns an error code, so the caller is responsible
for printing a suitable error message.

6 years agoclient: Fix loglevel setting.
Andre Noll [Sat, 17 Mar 2018 22:29:12 +0000 (23:29 +0100)]
client: Fix loglevel setting.

If --loglevel is given in the config file but not at the command line,
the value from the config file should be used. However, currently we
use the default value in this case. Moreover, client_parse_config()
sets the loglevel *after* it already printed some log messages.

This commit changes client_parse_config() to initialize the loglevel
pointer right after the command line and config file options have
been merged.

6 years agocommand.c: Document return value of handle_connect().
Andre Noll [Mon, 26 Mar 2018 23:09:35 +0000 (01:09 +0200)]
command.c: Document return value of handle_connect().

Kind of pointless, but gets rid of the following Doxygen warning:

/home/maan/scm/paraslash/server.h:112: warning: return type of member handle_connect is not documented

6 years agoFix help text of the dccp receiver.
Andre Noll [Mon, 12 Mar 2018 19:18:07 +0000 (20:18 +0100)]
Fix help text of the dccp receiver.

CCIDs are no longer reported in the server info output for more than
three years, see commit 435ad905 (Add sender subcommand "status").

6 years agosend_common: Remove outdated comment.
Andre Noll [Thu, 8 Mar 2018 20:39:24 +0000 (21:39 +0100)]
send_common: Remove outdated comment.

Commit 8dab386f (Rework para_accept()) from eight years ago changed
the function to receive also a pointer to the read fd set and pass
this pointer to para_accept() which performs the check for readability
of the socket file descriptor. Since then the comment which says that
the caller must check the fd set is stale.

6 years agouser_list: Make list head static.
Andre Noll [Sun, 18 Feb 2018 14:48:42 +0000 (15:48 +0100)]
user_list: Make list head static.

It is only used in user_list.c.

6 years agoafs: Allow database switching on sighup.
Andre Noll [Wed, 3 Jan 2018 01:49:22 +0000 (02:49 +0100)]
afs: Allow database switching on sighup.

Currently the database dir is set at startup and stays unmodified even
after the sighup handler has reloaded a configuration which specifies
a different database path.

This patch makes it possible to switch to a different database after
SIGHUP was received. To make this work, we only have invalidate the
database_dir pointer after the database has been closed.