paraslash.git
4 years agocommand.c: Improve documentation of handle_connect().
Andre Noll [Tue, 17 Mar 2020 08:30:22 +0000 (09:30 +0100)]
command.c: Improve documentation of handle_connect().

This text was not very precise, and it had some language issues.

4 years ago.gitignore: Remove web/dia/overview.pdf.
Andre Noll [Sun, 15 Mar 2020 13:53:35 +0000 (14:53 +0100)]
.gitignore: Remove web/dia/overview.pdf.

The overview has been removed long ago.

4 years agoMerge branch 'refs/heads/t/mixer'
Andre Noll [Sun, 15 Mar 2020 14:51:20 +0000 (15:51 +0100)]
Merge branch 'refs/heads/t/mixer'

A single patch for para_mixer which makes the subcommands which
sleep a bit more robust.

The merge conflicted due to commit d6b25bf854c1 (mixer: fade: Handle
empty mood strings gracefully) from half a year ago, but the resolution
was obvious.

Cooking for nine months.

* refs/heads/t/mixer:
  mixer: sleep/snooze: Close mixer during sleep.

4 years agoafs.c: Remove two pointless casts.
Andre Noll [Thu, 5 Mar 2020 17:50:55 +0000 (18:50 +0100)]
afs.c: Remove two pointless casts.

The type of ->data is void *, so no casts are needed.

4 years agomp3_afh: Don't bail out on short files.
Andre Noll [Sun, 24 Nov 2019 16:33:51 +0000 (17:33 +0100)]
mp3_afh: Don't bail out on short files.

It's perfectly OK to have mp3 files which are shorter than two seconds.
For example lexico.com offers mp3 downloads to learn the pronuciation
of single words. These files are often shorter than one second.

The check for short length files predates the git history. Most likely
it was added for no good reason, so drop it.

4 years agoopenssl: Fix (harmless) memory leaks at exit.
Andre Noll [Wed, 11 Sep 2019 20:12:32 +0000 (22:12 +0200)]
openssl: Fix (harmless) memory leaks at exit.

Without this, valgrind --leak-check=full --show-leak-kinds=all
complains about four memory blocks reachable at exit, see below.

The first leak is fixed by the new call to ERR_remove_thread_state(),
which frees the error queue of the current thread. To squash the
other three, the call to EVP_cleanup() is needed to remove all of
openssl's internal ciphers and digests.

To make this work on both openssl-1.0 and for openssl-1.1, we need
to add additional header checks for configure.

---
==2818== 12 bytes in 1 blocks are still reachable in loss record 1 of 4
==2818==    at 0x40355EE: malloc (vg_replace_malloc.c:309)
==2818==    by 0x41B887C: CRYPTO_malloc (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x42459B7: lh_insert (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4248542: int_thread_set_item (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4249920: ERR_get_state (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424A255: ERR_put_error (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4222EF6: RSA_padding_check_PKCS1_OAEP_mgf1 (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x422306A: RSA_padding_check_PKCS1_OAEP (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x421F921: RSA_eay_private_decrypt (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x804F2E9: apc_priv_decrypt (openssl.c:206)
==2818==    by 0x804DB59: client_post_select (client_common.c:321)
==2818==    by 0x804CC57: call_post_select (sched.c:80)
==2818==    by 0x804CC57: sched_post_select (sched.c:106)
==2818==    by 0x804CC57: schedule (sched.c:159)
==2818==
==2818== 64 bytes in 1 blocks are still reachable in loss record 2 of 4
==2818==    at 0x40355EE: malloc (vg_replace_malloc.c:309)
==2818==    by 0x41B887C: CRYPTO_malloc (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4245643: lh_new (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424811F: int_thread_get (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4248511: int_thread_set_item (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4249920: ERR_get_state (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424A255: ERR_put_error (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4222EF6: RSA_padding_check_PKCS1_OAEP_mgf1 (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x422306A: RSA_padding_check_PKCS1_OAEP (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x421F921: RSA_eay_private_decrypt (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x804F2E9: apc_priv_decrypt (openssl.c:206)
==2818==    by 0x804DB59: client_post_select (client_common.c:321)
==2818==
==2818== 96 bytes in 1 blocks are still reachable in loss record 3 of 4
==2818==    at 0x40355EE: malloc (vg_replace_malloc.c:309)
==2818==    by 0x41B887C: CRYPTO_malloc (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4245628: lh_new (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424811F: int_thread_get (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4248511: int_thread_set_item (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4249920: ERR_get_state (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424A255: ERR_put_error (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4222EF6: RSA_padding_check_PKCS1_OAEP_mgf1 (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x422306A: RSA_padding_check_PKCS1_OAEP (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x421F921: RSA_eay_private_decrypt (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x804F2E9: apc_priv_decrypt (openssl.c:206)
==2818==    by 0x804DB59: client_post_select (client_common.c:321)
==2818==
==2818== 400 bytes in 1 blocks are still reachable in loss record 4 of 4
==2818==    at 0x40355EE: malloc (vg_replace_malloc.c:309)
==2818==    by 0x41B887C: CRYPTO_malloc (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424988C: ERR_get_state (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x424A255: ERR_put_error (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x4222EF6: RSA_padding_check_PKCS1_OAEP_mgf1 (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x422306A: RSA_padding_check_PKCS1_OAEP (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x421F921: RSA_eay_private_decrypt (in /usr/local/lib/libcrypto.so.1.0.0)
==2818==    by 0x804F2E9: apc_priv_decrypt (openssl.c:206)
==2818==    by 0x804DB59: client_post_select (client_common.c:321)
==2818==    by 0x804CC57: call_post_select (sched.c:80)
==2818==    by 0x804CC57: sched_post_select (sched.c:106)
==2818==    by 0x804CC57: schedule (sched.c:159)
==2818==    by 0x804AB2D: main (client.c:656)

4 years agoMerge branch 'refs/heads/t/ogg_afh'
Andre Noll [Fri, 28 Feb 2020 17:13:50 +0000 (18:13 +0100)]
Merge branch 'refs/heads/t/ogg_afh'

A patch which teaches the ogg/* audio format handlers to report the
correct length for files with holes. A bug was found in that patch
after the branch had been merged to next, so there's a fixup commit
on top.

The second patch in this series fixes an issue with
ogg_page_granulepos() that can result in incorrect estimates for the
duration of files that use the ogg container format.

Cooking for a year.

* refs/heads/t/ogg_afh:
  ogg_afh_common.c: Check return value of ogg_page_granulepos().
  ogg_afh_common: Fix signedness issue.
  ogg: Detect missing ogg pages.

4 years agovss: Improve error diagnostics.
Andre Noll [Sat, 2 Nov 2019 13:47:15 +0000 (14:47 +0100)]
vss: Improve error diagnostics.

Unless in debug loglevel, para_server prints

Nov 01 17:06:03 (4) (18596) open_next_audio_file: key not found in rbtree
Nov 01 17:06:03 (4) (18595) recv_afs_result: did not receive open fd from afs

which does not include information about what was actually received.

4 years agovss: Fix harmless memory leaks at exit.
Andre Noll [Sun, 1 Sep 2019 12:26:40 +0000 (14:26 +0200)]
vss: Fix harmless memory leaks at exit.

The leaks were introduced in commit 4fbe16430b47 (server: Add
--http-listen-address and --dccp-listen-address) from last year.

Found by valgrind.

4 years agomp3_afh: Fix whitespace issue in debug log message.
Andre Noll [Sun, 24 Nov 2019 16:32:29 +0000 (17:32 +0100)]
mp3_afh: Fix whitespace issue in debug log message.

There was no space character between the number and the word
"chunks". Add it.

4 years agocommand.c: Also invalidate play time if no audio file is open.
Andre Noll [Sat, 2 Nov 2019 13:59:29 +0000 (14:59 +0100)]
command.c: Also invalidate play time if no audio file is open.

Without this, the time string of the previous audio file is continued
to be shown in the top window of para_gui when stopped. It gets
wiped out eventually, but this can take a few seconds. With the patch
applied, the time string disappears immediately.

4 years agoMerge branch 'refs/heads/t/ssh'
Andre Noll [Sat, 23 Nov 2019 17:20:21 +0000 (18:20 +0100)]
Merge branch 'refs/heads/t/ssh'

A medium sized series which teaches both crypto backends about the
RFC4716 key format, which has become the default for ssh-keygen as
of openssh-7.8.

Was cooking for almost a year.

* refs/heads/t/ssh:
  manual: Instruct the user to create RFC4716 keys.
  openssl: Add support for RFC4716 keys
  openssl: Move get_private_key() down.
  gcrypt: Add support for RFC4716 private keys.
  crypt: Rename decoding functions.
  gcrypt: Introduce read_openssh_bignum().
  gcrypt: Factor out read_pem_rsa_params().
  gcrypt: Let read_bignum() return bits, not bytes.
  gcrypt: Let decode_key() return blob size through additional argument.
  gcrypt: Drop unnecessary arguments of decode_key().

4 years agomixer: fade: Handle empty mood strings gracefully.
Andre Noll [Sun, 1 Sep 2019 08:20:37 +0000 (10:20 +0200)]
mixer: fade: Handle empty mood strings gracefully.

Treat them as if the option was not given to prevent "para_client
select" to fail.

4 years agoMerge branch 'refs/heads/t/openssl-header-check'
Andre Noll [Sat, 2 Nov 2019 15:43:59 +0000 (16:43 +0100)]
Merge branch 'refs/heads/t/openssl-header-check'

* refs/heads/t/openssl-header-check:
  build: Check also for CRYPTO_cleanup_all_ex_data.
  build: Detect openssl library/header mismatch.

Two simple fixes for FreeBSD. Tested on 12.0-RELEASE-p10.

Cooking for nine months.

4 years agoerror.h: Document LLS_ERROR_BIT.
Andre Noll [Fri, 13 Sep 2019 06:30:47 +0000 (08:30 +0200)]
error.h: Document LLS_ERROR_BIT.

Also reformat the similar comment of OSL_ERROR_BIT to make it fit
into a single line.

4 years agosend.h: Document cpp magic.
Andre Noll [Wed, 11 Sep 2019 20:52:52 +0000 (22:52 +0200)]
send.h: Document cpp magic.

These macros are not completely trivial, so give the interested reader
an idea about how the macros help to avoid code duplication.

4 years agoSimplify and improve freep().
Andre Noll [Sun, 1 Sep 2019 11:41:01 +0000 (13:41 +0200)]
Simplify and improve freep().

Make it a no-op if NULL is passed. Also the comment to \param was
slightly incorrect and the code contained an unnecessary cast.

4 years agoMerge branch 'refs/heads/t/ONESHELL'
Andre Noll [Sun, 8 Sep 2019 09:07:45 +0000 (11:07 +0200)]
Merge branch 'refs/heads/t/ONESHELL'

A single patch which instructs the build system to run multi-line
statements in Makefiles in a single shell instance.

Cooking in next for nine months.

* refs/heads/t/ONESHELL:
  build: Use .ONESHELL.

4 years agoAvoid warning about sys/sysctl.h on glibc-2.30.
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__.

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

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

4 years agoMerge branch 'refs/heads/t/afh-preserve'
Andre Noll [Sun, 28 Jul 2019 12:24:45 +0000 (14:24 +0200)]
Merge branch 'refs/heads/t/afh-preserve'

A single patch which adds --preserve to para_afh.

* refs/heads/t/afh-preserve:
  afh: Implement --preserve.

4 years agoMerge branch 'refs/heads/t/ff'
Andre Noll [Sun, 14 Jul 2019 10:56:19 +0000 (12:56 +0200)]
Merge branch 'refs/heads/t/ff'

A short series which overhauls the ff server command.

Cooking for almost a year (for no good reason).

* refs/heads/t/ff:
  com_ff(): Fix bad grammar in help text.
  com_ff(): Depreciate "n-" syntax.
  com_ff(): Simplify code for jumping backwards.
  com_ff(): Avoid "unsigned i".

4 years agoogg_afh_common.c: Check return value of ogg_page_granulepos().
Andre Noll [Thu, 4 Jul 2019 07:04:56 +0000 (09:04 +0200)]
ogg_afh_common.c: Check return value of ogg_page_granulepos().

This function may return -1, and we do not want to use a negative
granule position for the computation of the duration of the ogg file.

Note that oac_get_file_info() loops over all ogg pages twice, but
the second loop does not have the same problem as we already check
the return value there.

4 years agoogg_afh_common: Fix signedness issue.
Andre Noll [Thu, 6 Jun 2019 06:28:58 +0000 (08:28 +0200)]
ogg_afh_common: Fix signedness issue.

The previous patch introduced a regression because "granule" was made
unsigned by mistake but needs to be a signed variable. This can cause
the loop in oac_get_file_info() to not terminate which eventually
results in an abort due to an allocation failure:

para_realloc: realloc failed (size = 2097152000), aborting

4 years agocom_ff(): Fix bad grammar in help text.
Andre Noll [Sun, 2 Jun 2019 10:21:12 +0000 (12:21 +0200)]
com_ff(): Fix bad grammar in help text.

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 agoogg: Detect missing ogg pages.
Andre Noll [Sat, 22 Dec 2018 17:04:28 +0000 (18:04 +0100)]
ogg: Detect missing ogg pages.

If pages of an ogg file were cut out, for example with a command like

para_afh -r 'afh -b 100 -f foo.ogg'

the ogg audio format handler still reports the duration of the
full file. This commit makes it detect this case and adjust the
duration accordingly.

This affects all audio formats which employ the ogg container format.

5 years agobuild: Check also for CRYPTO_cleanup_all_ex_data.
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.

5 years agobuild: Detect openssl library/header mismatch.
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.

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 agomanual: Instruct the user to create RFC4716 keys.
Andre Noll [Fri, 31 Aug 2018 10:59:06 +0000 (12:59 +0200)]
manual: Instruct the user to create RFC4716 keys.

We support both types of keys, but it would be lovely to get rid of
the open-coded parser for PEM keys in grcypt.c. This is the first
step to deprecate the use of PEM keys.

5 years agoopenssl: Add support for RFC4716 keys
Andre Noll [Thu, 30 Aug 2018 13:32:34 +0000 (15:32 +0200)]
openssl: Add support for RFC4716 keys

The decode_private_key() helper of gcrypt.c base64-decodes the key
but does not read the RSA bignums. It is thus independent of gcrypt
and openssl. To add support for RFC4716 keys to the openssl backend,
we need to move it to crypt_common.c, making it a crypo backend
function. That is, non-static and declared in crypt_backend.h. The
patch also documents the function using doxgen comments.

With decode_private_key() and find_openssh_bignum_offset() to
our disposal, supporting RFC4716 keys is simple. We only need to
initialize the openssl-specific rsa structure with the six bignums
stored in a private RFC4716 key. This is implemented in the new
read_private_rsa_params() which calls the existing read_bignum()
six times.

The fields of the rsa structure are exposed to applications in
openssl-1.0, but the structure was made opaque in openssl-1.1. We
use the existing HAVE_RSA_SET0_KEY macro to decide whether or not
we must use the accessor functions of openssl-1.1 to initialize the
rsa structure.

5 years agoopenssl: Move get_private_key() down.
Andre Noll [Wed, 29 Aug 2018 09:56:20 +0000 (11:56 +0200)]
openssl: Move get_private_key() down.

Prep patch for supporting RFC4716 keys. The function now comes after
read_bignum() and thus may call it.

Pure code movement, no actual changes.

5 years agogcrypt: Add support for RFC4716 private keys.
Andre Noll [Tue, 28 Aug 2018 18:38:52 +0000 (20:38 +0200)]
gcrypt: Add support for RFC4716 private keys.

This teaches the gcrypt backend to parse private keys generated
with ssh-keygen -m RFC4716. Support for the openssl backend will be
implemented in a subsequent patch. The new find_openssh_bignum_offset()
is independent of the gcrypt API. We put this function into
crypt_common.c rather then into gcrypt.c so that openssh.c can also
use it.

5 years agocrypt: Rename decoding functions.
Andre Noll [Tue, 28 Aug 2018 19:38:33 +0000 (21:38 +0200)]
crypt: Rename decoding functions.

decode_ssh_key() and decode_key() operate on public and private keys
respectively. This should be obvious from the naming. Also, the
two functions will soon be grouped together in the same file. The
inconsistent naming would even increase the possible confusion,
so it's better to rename the functions now.

5 years agogcrypt: Introduce read_openssh_bignum().
Andre Noll [Wed, 29 Aug 2018 10:20:39 +0000 (12:20 +0200)]
gcrypt: Introduce read_openssh_bignum().

This functionality was open-coded twice in apc_get_pubkey() which
reads the two public rsa params.  Use the new function instead to
get rid of the duplication. It will be turn out to be useful for
the subsequent work which adds support for RFC4716 keys. Since the
function is specific to libgcrypt, it has to stay in gcrypt.c.

5 years agogcrypt: Factor out read_pem_rsa_params().
Andre Noll [Tue, 28 Aug 2018 18:50:53 +0000 (20:50 +0200)]
gcrypt: Factor out read_pem_rsa_params().

We'll soon add a similar function which reads bignums from an RFC4716
key file, so it's good to separate this functionality from the rest
of get_private_key().

The patch also introduces struct rsa_params which contains
the six bignums used for RSA private key operations. This way
read_pem_rsa_params() only needs three arguments.

5 years agogcrypt: Let read_bignum() return bits, not bytes.
Andre Noll [Tue, 28 Aug 2018 18:18:02 +0000 (20:18 +0200)]
gcrypt: Let read_bignum() return bits, not bytes.

Callers need this to check if the size of the public key is acceptable.
Since sizes of cryptographic keys are generally measured in bits,
its natural to return bits here.

5 years agogcrypt: Let decode_key() return blob size through additional argument.
Andre Noll [Mon, 27 Aug 2018 16:32:58 +0000 (18:32 +0200)]
gcrypt: Let decode_key() return blob size through additional argument.

Currently we communicate the blob size through the return value, which
implies an implicit conversion from size_t to int. The new blob_size
argument guarantees type safety and simplifies the logic a bit.

After this patch the return value is only used for the (negative)
error code in the failure case while non-negative return values have
no meaning other than indicating success. Therefore this change also
allows us to convey the key type via the return value. This will turn
out to be handy for supporting RFC4716 keys.

5 years agogcrypt: Drop unnecessary arguments of decode_key().
Andre Noll [Mon, 27 Aug 2018 15:30:33 +0000 (17:30 +0200)]
gcrypt: Drop unnecessary arguments of decode_key().

Its single caller passes string literals, which are known at compile
time. So we may get rid of the two arguments.

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 agobuild: Use .ONESHELL.
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.

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 agoRemove ->init() of struct receiver.
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.

5 years agoafh: Constify definition of audio format handlers.
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.

5 years agoafh: Introduce audio_format_names[].
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.

5 years agoafh: Get rid of dummy entry at the end of afl[].
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.

5 years agoafh: Minor simplification for afh_get_chunk().
Andre Noll [Thu, 20 Sep 2018 20:25:12 +0000 (22:25 +0200)]
afh: Minor simplification for afh_get_chunk().

The function already defines a shortcut for the pointer to the audio
format handler, so use it.

5 years agoafh: Move audio_format_name() up.
Andre Noll [Wed, 19 Sep 2018 19:51:35 +0000 (21:51 +0200)]
afh: Move audio_format_name() up.

So that all its callers are further down. Not really necessary because
the function is non-static and declared in afh.h. But still..

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 agoafh: Implement --preserve.
Andre Noll [Tue, 31 Jul 2018 11:21:06 +0000 (13:21 +0200)]
afh: Implement --preserve.

This is easy because we already have the inode information of the
old file from the existing call to stat(2).

5 years agocompress: Overhaul the meaning of --aggressiveness.
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.

5 years agocompress: Apply damping later.
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.

5 years agocompress: Warn when samples are clipped.
Andre Noll [Sat, 18 Aug 2018 17:17:11 +0000 (19:17 +0200)]
compress: Warn when samples are clipped.

5 years agocompress: Document and sanity-check command line options.
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.

5 years agocompress: Fix off by one in help of --target-level.
Andre Noll [Wed, 18 Jul 2018 19:32:42 +0000 (21:32 +0200)]
compress: Fix off by one in help of --target-level.

The maximal value of a signed 16 bit integer is 32767.

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 agocom_ff(): Depreciate "n-" syntax.
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.

5 years agocom_ff(): Simplify code for jumping backwards.
Andre Noll [Tue, 1 May 2018 12:12:08 +0000 (14:12 +0200)]
com_ff(): Simplify code for jumping backwards.

With i being a signed integer, "ff -10" does the right thing. So we
can get of the "backwards" helper variable.

5 years agocom_ff(): Avoid "unsigned i".
Andre Noll [Tue, 1 May 2018 12:04:57 +0000 (14:04 +0200)]
com_ff(): Avoid "unsigned i".

It's an act of violence. The change should have no visible effect in
the common cases

ff n and ff n-

where n is a (small) non-negative integer. The behaviour of the command
changes for negative values of n, but this case was never documented.

After this patch negative arguments instruct the subcommand to jump
backwards, which should meet the expected behaviour.