paraslash.git
7 years agoMerge branch 'maint'
Andre Noll [Sun, 1 Jan 2017 01:24:17 +0000 (02:24 +0100)]
Merge branch 'maint'

* maint:
  Update copyright year to 2017.

7 years agoUpdate copyright year to 2017.
Andre Noll [Sun, 1 Jan 2017 01:21:36 +0000 (02:21 +0100)]
Update copyright year to 2017.

7 years agoparaslash 0.5.7 v0.5.7
Andre Noll [Sat, 31 Dec 2016 20:49:52 +0000 (21:49 +0100)]
paraslash 0.5.7

7 years agoMerge branch 'maint'
Andre Noll [Sat, 31 Dec 2016 20:12:33 +0000 (21:12 +0100)]
Merge branch 'maint'

A trivial conflict in configure.ac and remove/modify conflicts in
web/index.in.html and NEWS. The last file has been renamed to NEWS.md
in master. The conflict was resolved by copying the new text of the
NEWS file from maint (the release notes for v0.4.14) to NEWS.md and
to adjust the formatting to markdown syntax.

7 years agoparaslash 0.4.14 v0.4.14
Andre Noll [Sat, 31 Dec 2016 19:40:51 +0000 (20:40 +0100)]
paraslash 0.4.14

7 years agoMerge branch 'refs/heads/t/simple_error_codes'
Andre Noll [Sat, 31 Dec 2016 15:50:02 +0000 (16:50 +0100)]
Merge branch 'refs/heads/t/simple_error_codes'

Two patches which get rid of the concept of per-subsystem error
codes. The host-compiled error2.c program can be removed, configure.ac
and error.h simplified.

The merge conflicted because both sides modified error.h, but this
was easy to resolve.

* refs/heads/t/simple_error_codes:
  Sort errors alphabetically.
  Simplify the error subsystem, get rid of error2.[ch].

7 years agoMerge branch 'refs/heads/t/doc'
Andre Noll [Sat, 31 Dec 2016 15:43:01 +0000 (16:43 +0100)]
Merge branch 'refs/heads/t/doc'

The contributing section for the user manual and a few other
documentation updates.

* refs/heads/t/doc:
  signal.h: Add documentation of signal_pre_select().
  manual: Fix kernel coding style link.
  user manual: Add section on contributing.

7 years agoMerge branch 'refs/heads/t/invalid-ids'
Andre Noll [Fri, 30 Dec 2016 14:58:41 +0000 (15:58 +0100)]
Merge branch 'refs/heads/t/invalid-ids'

A single patch that was in misc for a while, and two follow up fixups
that were detected after the branch was merged into next.

* refs/heads/t/invalid-ids (cooking for two weeks):
  Makefile: Don't compile with -Wformat-signedness unconditionally.
  aft.c: Use correct format string for error output.
  touch: Refuse to set an invalid image or lyrics ID.

7 years agoMakefile: Don't compile with -Wformat-signedness unconditionally.
Andre Noll [Fri, 30 Dec 2016 14:49:59 +0000 (15:49 +0100)]
Makefile: Don't compile with -Wformat-signedness unconditionally.

This went in by mistake in the previous patch.

7 years agosignal.h: Add documentation of signal_pre_select().
Andre Noll [Tue, 27 Dec 2016 01:01:55 +0000 (02:01 +0100)]
signal.h: Add documentation of signal_pre_select().

It is a public function which should be annotated.

7 years agomanual: Fix kernel coding style link.
Andre Noll [Mon, 26 Dec 2016 20:37:26 +0000 (21:37 +0100)]
manual: Fix kernel coding style link.

The location of the coding style document for the linux kernel
has moved.

7 years agouser manual: Add section on contributing.
Andre Noll [Mon, 26 Dec 2016 16:13:28 +0000 (17:13 +0100)]
user manual: Add section on contributing.

7 years agot0004: Specify proper options for ls commands.
Andre Noll [Wed, 28 Dec 2016 20:40:42 +0000 (21:40 +0100)]
t0004: Specify proper options for ls commands.

The -p option is deprecated, and the default behaviour (if none of -p,
-F and -b is given) will change in v0.6.0. Although the tests succeed
at the moment, it seems prudent to switch to the modern syntax to
make sure the tests won't break when -p is removed and the default
behaviour is changed.

7 years agoMerge branch 'refs/heads/t/format-signedness'
Andre Noll [Wed, 28 Dec 2016 19:38:34 +0000 (20:38 +0100)]
Merge branch 'refs/heads/t/format-signedness'

This series fixes all warnings produced by compiling with
-Wformat-signedness and adds the flag to CFLAGS if the compiler
supports it.

* refs/heads/t/format-signedness (cooking for ~2 weeks):
  gcrypt: Fix a few format-signedness issues.
  Compile with -Wformat-signedness if possible.
  Fix signedness issues in format strings.

7 years agoresample: Simplify initialization().
Andre Noll [Tue, 27 Dec 2016 18:29:38 +0000 (19:29 +0100)]
resample: Simplify initialization().

In resample_init(), the first check removed in this commit was bogus
because in case there is no parent buffer tree node, we must only
abort if there is no input pending either.

In resample_post_select(), we move up the check of the node status
so that we now call resample_init() only after we know that there
is input available. This makes the second check in resample_init()
pointless as the condition can never be true.

7 years agoafh: Make sure we never return a negative chunk number.
Andre Noll [Tue, 20 Dec 2016 20:18:27 +0000 (21:18 +0100)]
afh: Make sure we never return a negative chunk number.

With the old code this could happen if chunk zero is empty.

7 years agofade: Add documentation for main() and include it in doxygen.
Andre Noll [Wed, 28 Dec 2016 01:08:54 +0000 (02:08 +0100)]
fade: Add documentation for main() and include it in doxygen.

The two mixer implementations for OSS and ALSA are also included,
both of which are only used by para_fade. So it makes sense to include
para_fade as well. main() is the only a non-static function, so let's
doxify that.

7 years agosched: Log task termination status.
Andre Noll [Sat, 29 Oct 2016 20:23:14 +0000 (22:23 +0200)]
sched: Log task termination status.

This is generally useful information, so let's include it in the
log message.

7 years agoMerge branch 'refs/heads/t/wma_fixes'
Andre Noll [Wed, 28 Dec 2016 12:05:34 +0000 (13:05 +0100)]
Merge branch 'refs/heads/t/wma_fixes'

The series also contains a fix for a silly bug which causes the decoder
to abort on empty output sizes, and a couple of cosmetic cleanups.

* refs/heads/t/wma_fixes (cooking for two weeks):
  wmadec: Remove two pointless variables.
  wmadec: Remove a pointless cast.
  wmadec: Set data size to 0 if nothing was decoded.
  wma: Fix packet size calculation.
  wmadec: Properly handle empty outputs.
  wma_common: Fix typo in log message.

7 years agoMerge branch 'refs/heads/t/openssl-1.1'
Andre Noll [Tue, 27 Dec 2016 15:29:29 +0000 (16:29 +0100)]
Merge branch 'refs/heads/t/openssl-1.1'

In openssl-1.1 several structures have been made opaque, breaking both
the stream cipher and the public key functions in crypt.c. This series
deals with these issues, trying to minimize the ifdeffery.

* refs/heads/t/openssl-1.1 (cooking for three months):
  openssl: RSA fixes for openssl-1.1.
  openssl: Use EVP API for AES.

7 years agoMerge branch 'refs/heads/t/ls-p_deprecation'
Andre Noll [Mon, 26 Dec 2016 12:27:01 +0000 (13:27 +0100)]
Merge branch 'refs/heads/t/ls-p_deprecation'

Preparation for changing the semantics of the -p option to com_ls()
of para_server. Cooking for four months.

* refs/heads/t/ls-p_deprecation:
  server: Deprecate ls -p.

7 years agoweb: Fix link to git branches.
Andre Noll [Sun, 25 Dec 2016 21:47:14 +0000 (22:47 +0100)]
web: Fix link to git branches.

The link broke several months ago in commit a2c5e36 which converted
the manual to markdown.

7 years agoafh.h: Trivial whitespace fix.
Andre Noll [Sun, 25 Dec 2016 15:02:26 +0000 (16:02 +0100)]
afh.h: Trivial whitespace fix.

Git complains about this: "space before tab in indent".

7 years agoMerge branch 'refs/heads/t/daemonize-fix'
Andre Noll [Sat, 24 Dec 2016 22:25:54 +0000 (23:25 +0100)]
Merge branch 'refs/heads/t/daemonize-fix'

Two bug fixes for race conditions during server startup, and an
improved log message. Cooking for two months.

* refs/heads/t/daemonize-fix:
  server: Fix race condition in afs startup.
  daemon: Fix race condition in daemonize().
  daemon: Improve "daemonizing" log message.

7 years agoportable_io.h: Provide big-endian versions and use them for aac.
Andre Noll [Mon, 16 Dec 2013 21:18:27 +0000 (22:18 +0100)]
portable_io.h: Provide big-endian versions and use them for aac.

The aac audio format handler code contains some instances that read a
big-endian encoded 32 or 64 bit number from a buffer. While for the
32 bit case there is a helper function aac_read_int32(), the 64 bit
case is open-coded.

We already have similar functions for the conversion of little-endian
entities. This patch adds their big endian counterparts as inline
functions to portable_io.h and changes the callers to use those.

The patch also gets rid of two fprintf() statements in write_portable()
which were commented out for ages.

7 years agoaac: Switch from unsigned char to char.
Andre Noll [Mon, 16 Dec 2013 21:06:44 +0000 (22:06 +0100)]
aac: Switch from unsigned char to char.

The faad library functions take unsigned char pointers while most of
the paraslash code prefers plain char *. It's easier to use char *
in all paraslash functions and cast the arguments of the faad library
function calls than to have a mix of both types.

7 years agoplay: Minor log message improvements.
Andre Noll [Tue, 31 Mar 2015 01:33:11 +0000 (01:33 +0000)]
play: Minor log message improvements.

open_new_file() returns an error code on failure, so it should not print
the corresponding strerror text.

The patch also adds messages which logs the active decoder and the
buffer tree with loglevel INFO.

7 years agoSort errors alphabetically.
Andre Noll [Sun, 28 Aug 2016 17:00:11 +0000 (19:00 +0200)]
Sort errors alphabetically.

Keeping the list sorted minimizes the potential for merge conflicts in the
common case where two branches introduce new error codes.

7 years agoSimplify the error subsystem, get rid of error2.[ch].
Andre Noll [Sun, 28 Aug 2016 16:46:22 +0000 (18:46 +0200)]
Simplify the error subsystem, get rid of error2.[ch].

This commit removes error2.c and the surrounding infrastructure of
the build system, getting rid of ~600 LOC.

After the change there are no more subsystems for error codes, and we
don't need to host-compile error2.c any more. Since all executables
now contain the text of every error code, the change has some impact
on the sizes of the (stripped) executables:

     Before:                         After:

 64K para_afh               71K para_afh
 43K para_audioc            47K para_audioc
256K para_audiod           259K para_audiod
 64K para_client            71K para_client
 39K para_fade              47K para_fade
141K para_filter           144K para_filter
 51K para_gui               59K para_gui
252K para_play             255K para_play
 97K para_recv             104K para_recv
227K para_server           230K para_server
 60K para_write             67K para_write

This increase in size is justified by the major simplification.

7 years agoMerge branch 'refs/heads/t/base64'
Andre Noll [Tue, 20 Dec 2016 14:40:09 +0000 (15:40 +0100)]
Merge branch 'refs/heads/t/base64'

A couple of patches which move the base64 code to a separate file,
and improve on it. Was cooking for several months.

* refs/heads/t/base64:
  base64: Speed up decoder by using a table.
  base64: Use para_isspace() everywhere.
  base64: Trivial whitespace fixes.
  base64: Replace Pad64 variable by macro.
  base64: Remove unnecessary overflow checks.
  base64: Saner semantics for base64_decode() and uudecode().
  Move base64 implementation to own file.

7 years agoaft.c: Use correct format string for error output.
Andre Noll [Mon, 19 Dec 2016 23:12:19 +0000 (00:12 +0100)]
aft.c: Use correct format string for error output.

Both ->image_id and ->lyrics_id are of signed type.

7 years agoMerge branch 'refs/heads/t/rm_source_browser'
Andre Noll [Mon, 19 Dec 2016 17:06:52 +0000 (18:06 +0100)]
Merge branch 'refs/heads/t/rm_source_browser'

Cooking for five months.

A single patch which gets rid of the source browser generated with
global, reducing the size of the web pages considerably.

* refs/heads/t/rm_source_browser:
  web: Remove extra source browser.

7 years agowmadec: Remove two pointless variables.
Andre Noll [Thu, 8 Dec 2016 23:22:57 +0000 (00:22 +0100)]
wmadec: Remove two pointless variables.

The local variables n and incr of wma_decode_frame() shadow the
values of their counterparts in struct private_wmadec_data, and they
remain constant within the function. Referring directly to the private
structure instead makes the code shorter and improves readability.

7 years agowmadec: Remove a pointless cast.
Andre Noll [Thu, 8 Dec 2016 22:59:26 +0000 (23:59 +0100)]
wmadec: Remove a pointless cast.

The address of "in" is already of type char **.

7 years agowmadec: Set data size to 0 if nothing was decoded.
Andre Noll [Thu, 8 Dec 2016 20:32:32 +0000 (21:32 +0100)]
wmadec: Set data size to 0 if nothing was decoded.

Without this, we might feed uninitialized data into the output stream.

7 years agowma: Fix packet size calculation.
Andre Noll [Tue, 1 Nov 2016 10:44:53 +0000 (11:44 +0100)]
wma: Fix packet size calculation.

Usually the (fixed) packet size of a wma file equals the block align
value plus WMA_FRAME_SKIP. However, this is not true in general,
and if the two values differ, we fail to decode the file and bail
out with an "incoherent block length" error.

This patch adds code to read the correct packet size from the file
properties object and uses this value in the decoder and the audio
format handler.

7 years agogcrypt: Fix a few format-signedness issues.
Andre Noll [Sun, 11 Dec 2016 10:55:31 +0000 (11:55 +0100)]
gcrypt: Fix a few format-signedness issues.

These were missed in the first batch because gcrypt.c is not compiled
in unless --enable-cryptolib=gcrypt is given.

7 years agowmadec: Properly handle empty outputs.
Andre Noll [Tue, 1 Nov 2016 05:10:00 +0000 (06:10 +0100)]
wmadec: Properly handle empty outputs.

If out_size is zero we try to shrink the buffer to size zero. POSIX
says that the behavior is implementation-defined in this case, and
para_realloc() aborts due to an assert() statement that checks for
size zero. This patch makes sure the wma decoder never calls realloc()
with a zero size argument.

7 years agowma_common: Fix typo in log message.
Andre Noll [Sun, 30 Oct 2016 16:51:50 +0000 (17:51 +0100)]
wma_common: Fix typo in log message.

7 years agoCompile with -Wformat-signedness if possible.
Andre Noll [Wed, 23 Nov 2016 22:17:10 +0000 (23:17 +0100)]
Compile with -Wformat-signedness if possible.

We can't activate this warning unconditionally because it is not
supported on older compilers, including clang. Therefore we introduce
a build time check and add the option only if the compiler supports it.

7 years agoFix signedness issues in format strings.
Andre Noll [Wed, 23 Nov 2016 22:16:50 +0000 (23:16 +0100)]
Fix signedness issues in format strings.

Compiling with -Wformat-signedness (not enabled so far) causes many
warnings because of format strings which specify an unsigned type but
correspond to an argument of signed type, or vice versa. This commit
fixes all these mismatches.

For "%u", "%d", "%lu", "%ld" we let the format string match the
type of the argument, but for "%x" we need to cast the argument to
a suitable unsigned type.

After this patch the tree compiles cleanly with -Wformat-signedness
given. The warning will be enabled in a subsequent commit.

7 years agoMerge branch 'refs/heads/t/sideband-cleanup'
Andre Noll [Sun, 4 Dec 2016 10:10:36 +0000 (11:10 +0100)]
Merge branch 'refs/heads/t/sideband-cleanup'

started on 2016-07-03, cooking since 2016-07-16

para_server announces sideband as an optional feature, which is
pointless since sideband connections have become mandatory in
paraslash-0.5.x, so they are always used. This patch set removes
the feature negitiation during the initial handshake. The sideband
protocol remains and is not affected.

Overwiew of the handshake in v0.5.x:
(SA) server announces sideband
(CC) client fails connection if server did not announce sideband
(CR) client requests sideband
(SC) server fails connection if sideband was not requested
already broken
- client-0.4/server-0.5 (!CR, SC)
- client-0.5/server-0.4 (!SA, CC)

Conversion plan:
rm (CC): breaks nothing
rm (SC): breaks nothing
rm (CR): breaks cl-0.6/server-0.5 (!CR, SC)
rm (SA): breaks cl-0.5/server-0.6 (!SA, CC)
server fails connection if client requests sideband

In this series only the first two conversion steps are done as they
can be merged early without breaking anything.

* refs/heads/t/sideband-cleanup:
  server: Do not fail if client does not request sideband.
  client: No longer fail connection if sideband was not announced.

7 years agoserver: Fix race condition in afs startup.
Andre Noll [Tue, 23 Aug 2016 20:58:46 +0000 (22:58 +0200)]
server: Fix race condition in afs startup.

After server_init() returns, the server accepts connections on the
TCP command socket. If an afs command arrives on the command socket,
the server process forks and the resulting child process (the command
handler) connects to the local afs socket. However, this socket is
created by the afs process which was forked from the server process
in server_init(). It is therefore possible that the command handler
connects before the afs process started to listen on the local afs
socket. In this case, the connection, hence the command fails.

This commit fixes the race condition by letting the parent process
block on read(2) on the afs socket. The afs process writes a byte
to the other end of the socket after it has completed its setup,
causing the parent process to resume.

For this to work, we need a connection-mode byte stream for the
communication between the server and the afs process, rather
than the connectionless datagram socket we have now. There is no
particular reason to prefer a datagram socket here, so let's switch
to SOCK_STREAM.

7 years agodaemon: Fix race condition in daemonize().
Andre Noll [Thu, 16 Jun 2016 18:17:21 +0000 (20:17 +0200)]
daemon: Fix race condition in daemonize().

If parent_waits is true, the parent process waits for a signal from
the child before it exits. However, this signal can arive before the
parent has set up its signal handler.

This patch closes the race window by switching from signals to
pipes. We now create a pipe before the new process is forked, and
let the parent block on read(2) until the child exits or indicates
success by writing a byte to one end of the pipe. The child process
receives the file descriptor of the writing end of the pipe as the
return value of daemonize().

The only user of the parent_waits feature is para_server, which is
changed accordingly.

7 years agotouch: Refuse to set an invalid image or lyrics ID.
Andre Noll [Sat, 26 Mar 2016 22:27:09 +0000 (22:27 +0000)]
touch: Refuse to set an invalid image or lyrics ID.

This makes the callback of the touch command fail the command if the
given ID does not exist in the corresponding blob table.

To this aim we call blob_get_name_by_id() to look up the ID. Since
we are not interested in the name, the function now allows a NULL
result pointer in which case it only checks whether the ID is valid.

With this patch applied the attempt to set an invalid image or lyrics
ID results in an error message like this:

invalid image ID: 456565
remote: key not found in rbtree
main: command failed

7 years agotest-lib: Fix a bash-4.4 issue.
Andre Noll [Sun, 25 Sep 2016 13:56:43 +0000 (15:56 +0200)]
test-lib: Fix a bash-4.4 issue.

Apparently bash-4.4 changed how unquoted here strings are treated.
We want to process only the first line of the output, so the right
thing to do is to ask awk to exit after processing the first line.
This works regardless of the bash version.

7 years agodaemon: Improve "daemonizing" log message.
Andre Noll [Mon, 26 Sep 2016 16:44:39 +0000 (18:44 +0200)]
daemon: Improve "daemonizing" log message.

The function name "daemonize" is shown anyway, so let's print the
path to the log file instead.

7 years agoserver: Deprecate ls -p.
Andre Noll [Wed, 24 Aug 2016 20:18:36 +0000 (22:18 +0200)]
server: Deprecate ls -p.

In v0.6.0 the -p option will have the same meaning as for the rm and
touch commands: perform pathname match. Also the default for the ls
command will be changed to list full paths while the new -b option
must be given to print only the basename (i.e., the current behaviour
if -p is not given).

This commit is a preparation for these incompatible changes which
does not break existing scripts. It does the following

* The -p option is deprecated in favor of its synonym, the new -F
option (for full path).

* The new -b option instructs the command to perform basename matching
and print only the basename of the matching files. It is currently
a no-op.

With the patch applied, scripts are supposed to specify either -b or
-F as appropriate.  In v0.6.0 the semantics of -p will be changed as
described above, the default will be changed to print the full path,
and -F will be deprecated because it is a no-op then.

7 years agoopenssl: RSA fixes for openssl-1.1.
Andre Noll [Sun, 28 Aug 2016 13:35:11 +0000 (15:35 +0200)]
openssl: RSA fixes for openssl-1.1.

In openssl-1.1 the RSA structure has been made opaque, causing
compilation of crypt.c to fail because the code accesses ->n and ->e
directly to set the modulus and the public exponent according to the
values read from the public ssh key.

With openssl-1.1 applications are supposed to call RSA_set0_key()
to set n and e. Unfortunately, this function does not exist in
openssl-1.0.2.

This patch adds a configure check which defines HAVE_RSA_SET0_KEY if
RSA_set0_key() is available. In crypt.c we either call the function
or set ->n and ->e directly, depending on whether HAVE_RSA_SET0_KEY
is defined. This results in code which works on both openssl-1.0.2
and openssl-1.1.0.

7 years agoopenssl: Use EVP API for AES.
Andre Noll [Sun, 28 Aug 2016 13:35:53 +0000 (15:35 +0200)]
openssl: Use EVP API for AES.

opensssl-1.1 no longer exports AES_set_encrypt_key() and
AES_ctr128_encrypt(). Applications are supposed to use the high-level
EVP interface instead.

Fortunately, the EVP library functions necessary for our use of
the AES_ctr128 stream cipher are available in openssl version 1.0.1
and above, so switching to the EVP API makes the code work with all
versions >= 1.0.1.

7 years agobuild: Remove target "dep".
Andre Noll [Sat, 16 Jul 2016 20:47:57 +0000 (22:47 +0200)]
build: Remove target "dep".

It is not needed at all. The attempt to include non-existent or
outdated .d files instructs make to rebuild them.

7 years agoafs: Fix error handling of the select command.
Andre Noll [Sat, 11 Jun 2016 18:44:01 +0000 (20:44 +0200)]
afs: Fix error handling of the select command.

com_select() returns success even if the mood or playlist could not
be activated. This commit changes the function to return the error
code from activate_mood_or_playlist() instead.

The function had another minor issue: If the current mood is the
dummy mood, and we failed to switch to the given mood or playlist,
and also failed to switch back to the dummy mood, we try a second
time to activate the dummy mood. This should not happen, but let's
fix it anyway.

7 years agonet.c: Fix two trivial whitespace issues.
Andre Noll [Fri, 26 Aug 2016 18:56:14 +0000 (20:56 +0200)]
net.c: Fix two trivial whitespace issues.

7 years agofilter: Make ->open() optional.
Andre Noll [Sun, 28 Jun 2015 14:18:22 +0000 (16:18 +0200)]
filter: Make ->open() optional.

There is no need to force each filter to supply this method, so teach
the three callers of ->open() to check for NULL pointers.

The commit also fixes some trivial language issues in the documentation
of ->open() and ->close().

7 years agobase64: Speed up decoder by using a table.
Andre Noll [Sat, 9 Apr 2016 18:44:28 +0000 (20:44 +0200)]
base64: Speed up decoder by using a table.

The current implementation calls strchr() for each character in the
decoded data to find the offset in the Base64[] array that corresponds
to six decoded bits. This makes the algorithm scale poorly.

This commit introduces a lookup table of size 256 which simplifies
the code and improves the performance of the decoder.

7 years agobase64: Use para_isspace() everywhere.
Andre Noll [Sat, 9 Apr 2016 18:42:59 +0000 (20:42 +0200)]
base64: Use para_isspace() everywhere.

Should not matter because we only test for zero, but let's be
consistent.

7 years agobase64: Trivial whitespace fixes.
Andre Noll [Thu, 30 Apr 2015 07:06:35 +0000 (09:06 +0200)]
base64: Trivial whitespace fixes.

7 years agobase64: Replace Pad64 variable by macro.
Andre Noll [Wed, 29 Apr 2015 17:02:20 +0000 (19:02 +0200)]
base64: Replace Pad64 variable by macro.

There is no need to define a variable for this.

7 years agobase64: Remove unnecessary overflow checks.
Andre Noll [Tue, 28 Apr 2015 16:17:42 +0000 (18:17 +0200)]
base64: Remove unnecessary overflow checks.

Since we decode no more than encoded_size many bytes, and the output
buffer is allocated large enough to store the decoded data, we won't
ever overflow the output buffer. This commit removes the pointless
checks.

7 years agobase64: Saner semantics for base64_decode() and uudecode().
Andre Noll [Sun, 26 Apr 2015 21:41:00 +0000 (23:41 +0200)]
base64: Saner semantics for base64_decode() and uudecode().

Currently the callers of these functions must allocate a suitably
sized buffer for the decoded data. It is easier to let the decoders
allocate the result buffer, as implemented in this commit. The callers
in crypt.c and gcrypt.c are adjusted accordingly.

7 years agoMove base64 implementation to own file.
Andre Noll [Tue, 10 Jun 2014 15:52:22 +0000 (17:52 +0200)]
Move base64 implementation to own file.

The base64 decoder is independent of anything else, so it should not
be part of the crypto API. This patch moves the two public functions
uudecode() and base64_decode() to a new file, base64.c, and introduces
base64.h to declare them.

7 years agogcrypt: Check file permissions of private keys.
Andre Noll [Sun, 10 Jul 2016 19:33:18 +0000 (21:33 +0200)]
gcrypt: Check file permissions of private keys.

Before opening a private key, crypt.c checks that the permissions
are restrictive enough. However, the gcrypt implementation contains
no such check. This commit adds it.

7 years agogcrypt: Always initialize result pointer.
Andre Noll [Sun, 10 Jul 2016 18:59:34 +0000 (20:59 +0200)]
gcrypt: Always initialize result pointer.

If the call to mmap_full_file() at the beginning of decode_key() fails,
we return without initializing the result pointer to NULL. This does not
matter now, because the only caller of decode_key() does not look at the
pointer value in the error case. Let's be defensive here and initialize
the pointer anyway.

7 years agoConstify argument of check_filter_arg().
Andre Noll [Wed, 17 Aug 2016 18:15:11 +0000 (20:15 +0200)]
Constify argument of check_filter_arg().

The function does not modify the memory pointed to by "fa".

7 years agodaemon: Make daemon_init_colors_or_die() independent of gengetopt.
Andre Noll [Tue, 21 Jun 2016 07:19:57 +0000 (09:19 +0200)]
daemon: Make daemon_init_colors_or_die() independent of gengetopt.

The function receives the values given to the --log-color option as
a char * array, which is the type that gengetopt provides for the
arguments to string options which may be given multiple times.

This patch gets get rid of this implementation detail. The function no
longer takes the arguments to --log-color at all and applications now
must call daemon_set_log_color_or_die() themselves to set user-defined
per-loglevel colors.

To make this work, we let daemon_init_colors_or_die() return a
boolean which indicates whether color mode should be enabled, and
daemon_set_log_color_or_die() is made public. The two users of this
API, para_server and para_audiod, are adjusted accordingly.

7 years agoaudiod: Move UID check from audiod_command.c to audiod.c.
Andre Noll [Mon, 20 Jun 2016 21:20:59 +0000 (23:20 +0200)]
audiod: Move UID check from audiod_command.c to audiod.c.

check_perms() is the only reason for the gengetopt config pointer
being public and for passing the whitelist pointer to handle_connect()
in audiod_command.c. The code get less convoluted by moving the
permission check to audiod.c where both the conf pointer and the
uid_whitelist are defined.

This introduces the new public function uid_is_whitelisted() in
audiod.c which replaces check_perms(). This allows to

* pass only the UID to the check function,
* drop the whitelist pointer argument from handle_connect(),
* make the conf pointer in audiod.c static.

The patch also reorders the function declarations in audiod.h a bit
to separate the functions defined in audiod.c from those defined
in audiod_command.c.

7 years agostring.c: Improve documentation of create_argv().
Andre Noll [Sun, 24 Jul 2016 09:32:43 +0000 (11:32 +0200)]
string.c: Improve documentation of create_argv().

Mention that it is OK to pass NULL, and that the returned array is
NULL terminated.

7 years agoSet copyright year in Makefile.real.
Andre Noll [Sun, 26 Jun 2016 17:11:05 +0000 (19:11 +0200)]
Set copyright year in Makefile.real.

Hopefully this helps to update the copyright year more timely in the
future. It also allows to pass this information to other commands in
the receipts of the Makefile should this become necessary.

7 years agomood.c: Improve log output for current mood.
Andre Noll [Mon, 4 Apr 2016 22:44:42 +0000 (00:44 +0200)]
mood.c: Improve log output for current mood.

When a new mood is loaded, we print some information about the score
table, like the number of admissible files, the average last_played
and num_played values, and the empiric standard deviation of these
quantities. However, since last_played is measured in seconds after
the epoch, the reported numbers are rather large.

This commit changes log_statistics() of mood.c to report the mean
value and the standard deviation in number of days.

Since loading a new mood happens not very frequently, let's increase
the severity of these log messages from INFO to NOTICE. If the new
mood has no admissible files we now log the message as a warning
rather than with severity NOTICE.

7 years agoafh: Print help if no arguments are given.
Andre Noll [Sun, 19 Jun 2016 20:16:41 +0000 (22:16 +0200)]
afh: Print help if no arguments are given.

Currently, if para_afh is invoked with no non-option arguments,
the command fails with

main: afh syntax error

This message is not very helpful, so let's print the short help in
this case, and exit successfully.

7 years agoafh: Improve error diagnostics.
Andre Noll [Sun, 8 May 2016 09:56:23 +0000 (11:56 +0200)]
afh: Improve error diagnostics.

If compute_afhi() can not figure out the type of an audio file, it
prints a rather incomprehensive error message for each audiod format
which was tried to no avail. This commit improves the readability of
these error messages by including the path and the name of the audio
format that caused the error.

Before:

$ para_afh /etc/resolv.conf
mp3_read_info: could not read mp3 info
compute_afhi: could not read mp3 info
compute_afhi: ogg sync page-out error (no ogg file?)
compute_afhi: mp4v2 library error
compute_afhi: asf/wma format not recognized
compute_afhi: ogg sync page-out error (no ogg file?)
compute_afhi: could not read meta chain
compute_afhi: ogg sync page-out error (no ogg file?)
main: audio format not recognized

After:

$ para_afh /etc/resolv.conf
get_file_info: /etc/resolv.conf: mp3 format not detected: could not read mp3 info
get_file_info: /etc/resolv.conf: ogg format not detected: ogg sync page-out error (no ogg file?)
get_file_info: /etc/resolv.conf: aac format not detected: did not find esds atom
get_file_info: /etc/resolv.conf: wma format not detected: asf/wma format not recognized
get_file_info: /etc/resolv.conf: spx format not detected: ogg sync page-out error (no ogg file?)
get_file_info: /etc/resolv.conf: flac format not detected: could not read meta chain
get_file_info: /etc/resolv.conf: opus format not detected: ogg sync page-out error (no ogg file?)
main: audio format not recognized

The patch also removes a call to PARA_ERROR_LOG() in the mp3 audio
format handler which is unnecessary because we return the error code
and print the message in the caller anyway.

A new helper, get_file_info(), is introduced to print the diagnostic
messages. Since audio_format_name() is called from this helper,
that function needed to be moved up to avoid a forward declaration.

7 years agoafh_recv: Improve error message of E_AFH_RECV_BAD_FILENAME.
Andre Noll [Sun, 24 Jul 2016 12:14:34 +0000 (14:14 +0200)]
afh_recv: Improve error message of E_AFH_RECV_BAD_FILENAME.

This error code is only used if no file name was given, so the old
error message was misleading.

7 years agoFix documentation of check_filter_arg().
Andre Noll [Sun, 24 Jul 2016 09:50:32 +0000 (11:50 +0200)]
Fix documentation of check_filter_arg().

Filter name and filter options are separated by whitespace rather
than a colon as stated in the documentation.

7 years agoweb: Remove extra source browser.
Andre Noll [Sun, 10 Jul 2016 15:04:06 +0000 (17:04 +0200)]
web: Remove extra source browser.

There are two versions of the browsable source code on the paraslash
web pages: the one generated by doxygen and another one which we
create directly with global. The html is identical, modulo style
issues, so let's get rid of the directly generated one.

With the patch applied, the size of the paraslash web pages reduces
by 21M to 80M (55M doxygen + 25M release tarballs).

7 years agobuild: Remove @socket_ldflags@ and @nsl_ldflags@.
Andre Noll [Mon, 18 Jul 2016 19:51:10 +0000 (21:51 +0200)]
build: Remove @socket_ldflags@ and @nsl_ldflags@.

These are not needed on any supported platform and the corresponding
make variables are always empty.

7 years agobuild: Remove undefined autoconf macro in Makefile.in.
Andre Noll [Sun, 17 Jul 2016 15:28:00 +0000 (17:28 +0200)]
build: Remove undefined autoconf macro in Makefile.in.

The autconf variable @arch_cppflags@ was removed from configure.ac
last year in commit d38109ab, but the patch missed to remove it
from Makefile.in.

7 years agoMake local sockets world-readable.
Andre Noll [Tue, 19 Jul 2016 17:03:15 +0000 (19:03 +0200)]
Make local sockets world-readable.

We already have S_IWOTH, so it's kind of pointless to not permit read
access to the socket special. This patch changes afs.c and audiod.c
to create sockets with mode 666 which was probably intended anyway.

The patch should not cause any compatibility issues since on Linux we
check credentials with SCM_CREDENTIALS while *BSD ignores permissions
for UNIX domain sockets. According to unix(7), portable programs
should not rely on them.

7 years agobuild: Add -Wdeclaration-after-statement.
Andre Noll [Sat, 18 Jun 2016 18:25:28 +0000 (20:25 +0200)]
build: Add -Wdeclaration-after-statement.

No code in the tree has declarations after statements, so this
change produces no new warnings. It makes sure, however, that we do
not introduce such declarations in the future. The option was not
enabled only because old gcc versions do not support it. Since we
require gcc-4.2.x or newer these days, we can count on the option
and enable it unconditionally.

7 years agotest suite: Fail test if para_server could not be started.
Andre Noll [Sun, 26 Jun 2016 13:13:30 +0000 (15:13 +0200)]
test suite: Fail test if para_server could not be started.

In t0004-server.sh, we start the server in daemon mode without checking
the exit code. If it fails to start, there is no point in trying to
run the tests of this file.

This commit adds the missing check.

7 years agoserver: Do not fail if client does not request sideband.
Andre Noll [Sun, 3 Jul 2016 10:45:15 +0000 (12:45 +0200)]
server: Do not fail if client does not request sideband.

Currently we insist that clients request the sideband feature during
the initial handshake. This check was introduced long ago to detect
incompatible 0.4.x clients and fail the connection early and gracefully
for those clients. These days the check is no longer needed and can
be removed.

para_server still announces the sideband feature and accepts the
sideband request, although it makes no difference any more whether
or not the client requests the feature. Therefore this change has no
impact on compatibility with 0.5.x clients.

7 years agoclient: No longer fail connection if sideband was not announced.
Andre Noll [Sun, 3 Jul 2016 10:40:47 +0000 (12:40 +0200)]
client: No longer fail connection if sideband was not announced.

Sideband has become mandatory in paraslash-0.5.0, and the current
para_client does not work with older server versions anyway. Hence
this change has no impact on compatibility.

The E_INCOMPAT_FEAT error code is now unused and can be removed.

7 years agoparaslash 0.5.6 v0.5.6
Andre Noll [Sun, 10 Jul 2016 17:01:56 +0000 (19:01 +0200)]
paraslash 0.5.6

7 years agoMerge branch 'refs/heads/t/autoplay-fix'
Andre Noll [Sun, 10 Jul 2016 10:04:55 +0000 (12:04 +0200)]
Merge branch 'refs/heads/t/autoplay-fix'

A single commit which was cooking for a month.

* refs/heads/t/autoplay-fix:
  server: Fix --autoplay-delay.

7 years agodaemon: Constify argument of two functions.
Andre Noll [Tue, 21 Jun 2016 21:27:54 +0000 (23:27 +0200)]
daemon: Constify argument of two functions.

daemon_set_logfile() and daemon_set_loglevel() do not modify the
passed string, so the type of the argument should be const char *.

7 years agograb_client.c: Do not include filter.h.
Andre Noll [Sun, 26 Jun 2016 10:20:43 +0000 (12:20 +0200)]
grab_client.c: Do not include filter.h.

The code in this source file is independent of filters.

7 years agoMerge branch 'refs/heads/t/i9e'
Andre Noll [Sun, 3 Jul 2016 08:20:35 +0000 (10:20 +0200)]
Merge branch 'refs/heads/t/i9e'

Started on 2016-03-08, cooking for three months.

* refs/heads/t/i9e:
  i9e: Replace assertion with warning.
  i9e: Fix compilation on Ubuntu-12.04.
  i9e: print warning if keyseq can not be mapped.
  i9e: Zero out private pointer on open.

7 years agoMerge branch 'refs/heads/t/kill-compiletime-ll'
Andre Noll [Sat, 2 Jul 2016 10:52:11 +0000 (12:52 +0200)]
Merge branch 'refs/heads/t/kill-compiletime-ll'

Started on 2016-03-19, cooking for six weeks.

* refs/heads/t/kill-compiletime-ll:
  Remove support for compile-time loglevel.

7 years agoserver: Improve documentation of dccp-slices-per-group.
Andre Noll [Sat, 25 Jun 2016 09:23:59 +0000 (11:23 +0200)]
server: Improve documentation of dccp-slices-per-group.

This text was worded rather badly. The new text tries to say the
same, without duplicated words and typos.

7 years agouser-list.h: Improve documentation of permission flags.
Andre Noll [Sun, 12 Jun 2016 13:36:00 +0000 (15:36 +0200)]
user-list.h: Improve documentation of permission flags.

The documentation of the server_command_permissions enum is a bit
sparse, and doxygen complains about it because the members of the
enumeration are not documented.

The new documentation of the permission flags avoids to talk about
commands because the flags are not only about commands but also about
the per-user permission settings.

7 years agoMerge branch 'refs/heads/t/mp3_afh'
Andre Noll [Sun, 26 Jun 2016 11:37:49 +0000 (13:37 +0200)]
Merge branch 'refs/heads/t/mp3_afh'

Two patches that have been cooking for three months.

* refs/heads/t/mp3_afh:
  mp3_afh: Always create id3v2 tags.
  mp3_afh: Let free_tag() accept NULL pointer.

7 years agodaemon: Improve color error message.
Andre Noll [Tue, 21 Jun 2016 07:22:29 +0000 (09:22 +0200)]
daemon: Improve color error message.

If the string passed to daemon_set_log_color_or_die() can not be
parsed, we don't have a syntax error but an invalid argument.

7 years agoversion.c: Change year from 2015 to 2016.
Andre Noll [Wed, 22 Jun 2016 16:50:00 +0000 (18:50 +0200)]
version.c: Change year from 2015 to 2016.

This should be automated somehow...

7 years agowrite: Improve help text of --writer.
Andre Noll [Sun, 12 Jun 2016 10:30:39 +0000 (12:30 +0200)]
write: Improve help text of --writer.

The stated default value applies only to Linux, and is only correct if
alsa is supported. This patch removes the default line for this option
and explains in the help text how the default writer is determined.

7 years agofilter.h: Remove stale comment.
Andre Noll [Sun, 19 Jun 2016 21:02:03 +0000 (23:02 +0200)]
filter.h: Remove stale comment.

The array this comment refers to was moved to filter.c in commit
f0c49ce0, leaving a stale comment in the header file.

7 years agoAdd documentation of filter_get().
Andre Noll [Sun, 19 Jun 2016 20:55:48 +0000 (22:55 +0200)]
Add documentation of filter_get().

It's a public function that should be documented.

7 years agoplay: Remove unnecessary inclusion of filter.cmdline.h.
Andre Noll [Sun, 12 Jun 2016 18:38:10 +0000 (20:38 +0200)]
play: Remove unnecessary inclusion of filter.cmdline.h.

This header defines the gengetopt structure of para_filter, which is
not needed for para_play.

7 years agoerror.h: Fix typo in error string of E_ID3_ATTACH.
Andre Noll [Sun, 5 Jun 2016 18:41:13 +0000 (20:41 +0200)]
error.h: Fix typo in error string of E_ID3_ATTACH.

7 years agomanual: Fix typo in description of blob tables.
Andre Noll [Sun, 5 Jun 2016 18:00:31 +0000 (20:00 +0200)]
manual: Fix typo in description of blob tables.

Blob indices start at one, so "positive" is correct.

7 years agoRemove explicit uses of _GNU_SOURCE.
Andre Noll [Sun, 27 Mar 2016 02:22:40 +0000 (02:22 +0000)]
Remove explicit uses of _GNU_SOURCE.

The best way to add these flags is to use the autoconf helper
AC_USE_SYSTEM_EXTENSIONS. This macro adds defines to config.h, so we
must include config.h (via para.h) before anything else. The two files
for which this matters are fixed by moving the include directive for
para.h to the top.

The AC_USE_SYSTEM_EXTENSIONS macro was introduced in Autoconf 2.60,
which was released ten years ago. The existing AC_PREREQ([2.61])
check in configure.ac makes sure the macro is defined.

7 years agobuild: Remove duplicate para_fade in configure summary.
Andre Noll [Sun, 12 Jun 2016 10:44:07 +0000 (12:44 +0200)]
build: Remove duplicate para_fade in configure summary.