freeswitch-stable: improve init script 528/head
authorSebastian Kemper <sebastian_ml@gmx.net>
Sun, 3 May 2020 10:15:01 +0000 (12:15 +0200)
committerSebastian Kemper <sebastian_ml@gmx.net>
Mon, 4 May 2020 17:26:41 +0000 (19:26 +0200)
commitd3df6110c86376c1511660a3f4ba74774dc6d351
treec7dcf967a59cb219a4121220158f4ecd77171b10
parentb2980d146403b15681846858affc64141f7577ae
freeswitch-stable: improve init script

This is in response to a posting on oss-security ([1]).

This commit removes the ability to choose a user/group via
/etc/config/freeswitch. This makes the init script simpler. If anybody
wants to play around with the user/group, then it's up to them to fix
the permissions.

The complex awk script is deleted and replaced by two for-loops,
basically. The first loop creates "/var/lib/freeswitch" and
"/var/run/freeswitch" and chowns them to freeswitch, in case they don't
exist already.

The second loop checks if the other directories (either the default ones
or the ones specified by the user) exist. If any is missing it uses "su"
to create that directory as user "freeswitch".

The reasoning behind this is that a) this works for the defaults
(example: "/tmp/freeswitch/db") and b) the user can specify anything
he/she wants in "/etc/config/freeswitch", which could be all kinds of
strange directories. "mkdir" may now fail, as we're not calling it as
root anymore, but we err on the side of caution, as the saying goes.

Calls to "chmod" are eliminated. Instead the desired mode is provided to
"mkdir". The latter applies the mode only to the final directory.
Possible parent directories are created with the regular umask alone.

A dependency on the "su" utility is added to the Makefile.

"local" also gets removed because it is undefined in POSIX.

[1] https://www.openwall.com/lists/oss-security/2020/04/30/1

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
net/freeswitch-stable/Makefile
net/freeswitch-stable/files/freeswitch.conf
net/freeswitch-stable/files/freeswitch.init