]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/fd into master
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2023 16:38:05 +0000 (18:38 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2023 16:39:01 +0000 (18:39 +0200)
A rash of patches which clean up a good part of fd.c. Nothing major
here, mostly simplifications and documentation improvements.

* refs/heads/t/fd:
  fd: Simplify and move for_each_file_in_dir().
  fd.c: Improve error checking of para_mkdir().
  fd: Revamp para_mkdir().
  fd: Improve read_pattern(), rename it to read_and_compare().
  fd: Remove log message from para_munmap().
  fd: Open-code para_chdir().
  fd: Remove file_exists().
  fd: Improve documentation of xwritev().
  fd: Improve documentation of write_all().
  fd: Improve documentation of write_va_buffer().

13 files changed:
NEWS.md
afs.c
audiod.c
audiod_command.c
client_common.c
configure.ac
crypt.h
crypt_common.c
error.h
gcrypt.c
mood.c
mp3_afh.c
t/test-lib.sh

diff --git a/NEWS.md b/NEWS.md
index 598db71fae93734158509fa5f76853ceb09ccb7b..a0484f09d177cb3f7effdd4962650cdce28281ad 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,21 @@
 NEWS
 ====
 
+----------------------------------------------
+0.7.3 (to be announced) "weighted correctness"
+----------------------------------------------
+
+- Old style PEM keys are now deprecated. They still work but their
+  use results in a run-time warning. The removal of PEM key support is
+  scheduled for paraslash-0.8.0.
+- Version 1.0 of the openssl library has been deprecated. A warning
+  is printed at compile-time on systems which have this outdated version
+  because it will no longer be supported once paraslash-0.8.0 comes out.
+- A spring cleanup for the senescent code in fd.c.
+
+Downloads:
+[tarball](./releases/paraslash-git.tar.xz)
+
 -------------------------------------
 0.7.2 (2023-03-08) "optical friction"
 -------------------------------------
diff --git a/afs.c b/afs.c
index 8bd52c9af282c59c31106bf667625bd586ca1c53..865effde671a4848298ab09d502898c6225a937c 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -448,7 +448,7 @@ static int activate_mood_or_playlist(const char *arg, struct para_buffer *pb)
                mode = PLAY_MODE_MOOD;
        } else {
                ret = -ERRNO_TO_PARA_ERROR(EINVAL);
-               msg = make_message("%s: parse error", arg);
+               msg = make_message("%s: parse error\n", arg);
        }
        if (pb)
                para_printf(pb, "%s", msg);
@@ -529,8 +529,8 @@ static void init_admissible_files(const char *arg)
 {
        int ret = activate_mood_or_playlist(arg, NULL);
        if (ret < 0) {
-               PARA_WARNING_LOG("could not activate %s: %s\n", arg,
-                       para_strerror(-ret));
+               PARA_WARNING_LOG("could not activate %s: %s\n", arg?
+                       arg : "dummy", para_strerror(-ret));
                if (arg)
                        activate_mood_or_playlist(NULL, NULL);
        }
@@ -952,6 +952,7 @@ __noreturn void afs_init(int socket_fd)
        ret = schedule(&s);
        sched_shutdown(&s);
        mood_unload();
+       playlist_unload();
 out_close:
        close_afs_tables();
 out:
index 0e8e5981085b7d05b8a2a08f35a9bb7944a4d72d..0d8f039c768938bd563b7f928cb7a9aa0f2776ab 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -958,7 +958,7 @@ static int init_default_filters(void)
                 */
                if (strcmp(name, "udp") == 0 || strcmp(name, "dccp") == 0) {
                        tmp = para_strdup("fecdec");
-                       add_filter(i, tmp);
+                       ret = add_filter(i, tmp);
                        free(tmp);
                        if (ret < 0)
                                goto out;
index 743d73a9277802fbb966b373c2af357c14a88155..df357c7a708b77a6c7327572c6b3abfc1daa8d34 100644 (file)
@@ -81,13 +81,6 @@ static int num_clients;
 /** The list of all status items used by para_{server,audiod,gui}. */
 const char *status_item_list[] = {STATUS_ITEMS};
 
-static void dump_stat_client_list(void)
-{
-       struct stat_client *sc;
-
-       list_for_each_entry(sc, &client_list, node)
-               PARA_INFO_LOG("stat client on fd %d\n", sc->fd);
-}
 /**
  * Add a status client to the list.
  *
@@ -121,7 +114,6 @@ static int stat_client_add(int fd, uint64_t mask, int parser_friendly)
        if (parser_friendly)
                new_client->flags = SCF_PARSER_FRIENDLY;
        para_list_add(&new_client->node, &client_list);
-       dump_stat_client_list();
        num_clients++;
        return 1;
 }
@@ -180,7 +172,6 @@ void stat_client_write_item(int item_num)
                        continue;
                /* write error or short write */
                close_stat_client(sc);
-               dump_stat_client_list();
        }
        free(pb.buf);
        free(pfpb.buf);
index 642852ec6b8751454538ac9f3a021970f5cfbdef..3b90000f90ccdcc64be78e98e564bddc9cff3adb 100644 (file)
@@ -262,7 +262,7 @@ static bool has_feature(const char *feature, struct client_task *ct)
                return false;
        for (int i = 0; ct->features[i]; i++)
                if (strcmp(feature, ct->features[i]) == 0)
-                       return i;
+                       return true;
        return false;
 }
 
index c72581118326924a25b5ca9b020316439135d60b..92560e00ec50b7fa7ae4fcfd7d8966bdca2c63bf 100644 (file)
@@ -102,9 +102,14 @@ if test $HAVE_OPENSSL = yes; then
        if test "$ac_cv_have_decl_RSA_set0_key" != "$ac_cv_lib_crypto_RSA_set0_key"; then
                AC_MSG_ERROR([openssl header/library mismatch])
        fi
-       test "$ac_cv_have_decl_RSA_set0_key" = yes &&
+       if test "$ac_cv_have_decl_RSA_set0_key" = yes; then
                AC_DEFINE([HAVE_RSA_SET0_KEY], [1], [openssl >= 1.1])
-
+       else
+               AC_MSG_WARN([
+       Old openssl library detected. Support for openssl-1.0 and earlier
+       will be removed in the next major paraslash release. Please upgrade
+       your openssl installation.])
+       fi
        HAVE_CRYPTO_CLEANUP_ALL_EX_DATA=yes
        AC_CHECK_DECL([CRYPTO_cleanup_all_ex_data], [],
                [HAVE_CRYPTO_CLEANUP_ALL_EX_DATA=no],
diff --git a/crypt.h b/crypt.h
index 5ca6a54112b60f6d61b16485248fb28ff708df6b..5578cd563fae4dc24d673e653dcf21329eba90bc 100644 (file)
--- a/crypt.h
+++ b/crypt.h
@@ -48,7 +48,7 @@ int apc_priv_decrypt(const char *key_file, unsigned char *outbuf,
  * \param key_file The file containing the key.
  * \param result The key structure is returned here.
  *
- * \return The size of the key on success, negative on errors.
+ * \return The size of the key in bytes on success, negative on errors.
  */
 int apc_get_pubkey(const char *key_file, struct asymmetric_key **result);
 
index d7471235682855d3f376f0d5796b39567498937b..286ebe38f2215b879c3171183490b2199779f500 100644 (file)
@@ -295,7 +295,7 @@ int decode_private_key(const char *key_file, unsigned char **result,
                key_type = PKT_PEM;
                begin = map + strlen(PRIVATE_PEM_KEY_HEADER);
                footer = strstr(map, PRIVATE_PEM_KEY_FOOTER);
-               PARA_INFO_LOG("detected legacy PEM key %s\n", key_file);
+               PARA_WARNING_LOG("detected legacy PEM key %s\n", key_file);
        } else if (strncmp(map, PRIVATE_OPENSSH_KEY_HEADER,
                        strlen(PRIVATE_OPENSSH_KEY_HEADER)) == 0) {
                key_type = PKT_OPENSSH;
diff --git a/error.h b/error.h
index 94f315ce9948c2a042c3014c5b5c334af1129da8..8805c9c7a4c0de6fe958e1523df883ad47effaad 100644 (file)
--- a/error.h
+++ b/error.h
@@ -290,18 +290,20 @@ static const char *weak_lls_strerror(int) __attribute__ ((weakref("lls_strerror"
  */
 _static_inline_ const char *para_strerror(int num)
 {
+       unsigned idx = num & ~((1U << OSL_ERROR_BIT) | (1U << LLS_ERROR_BIT)
+               | (1U << SYSTEM_ERROR_BIT));
        assert(num > 0);
        if (IS_OSL_ERROR(num)) {
                assert(weak_osl_strerror);
-               return weak_osl_strerror(num & ~(1U << OSL_ERROR_BIT));
+               return weak_osl_strerror(idx);
        }
        if (IS_LLS_ERROR(num)) {
                assert(weak_lls_strerror);
-               return weak_lls_strerror(num & ~(1U << LLS_ERROR_BIT));
+               return weak_lls_strerror(idx);
        }
        if (IS_SYSTEM_ERROR(num))
-               return strerror(num & ~(1U << SYSTEM_ERROR_BIT));
-       return para_errlist[num];
+               return strerror(idx);
+       return para_errlist[idx];
 }
 
 /**
index 763fa6de3252d2f5f188fc3f447f2029d0f5775a..f9a849067f3ef1084b36e36ccef72cf1826a12a9 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -460,7 +460,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result)
        key->num_bytes = ret;
        key->sexp = sexp;
        *result = key;
-       ret = bits;
+       ret = bits / 8;
 release_n:
        gcry_mpi_release(n);
 release_e:
diff --git a/mood.c b/mood.c
index 9cdfd011a6ef4f2ab9fb180892f6412247eb68fe..e85cf36a35b9e533370bddd95c5c5db74a214e85 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -630,9 +630,10 @@ int mood_load(const char *mood_name, char **msg)
        ret = aa.m->stats.num;
        mood_unload();
        current_mood = aa.m;
+       ret = 1;
 out:
        free(aa.array);
-       if (ret < 0)
+       if (ret <= 0) /* error, or no admissible files */
                destroy_mood(aa.m);
        return ret;
 }
index d7493ac01e28bba581b7112a41a37e84426be11a..56f28a09d8eb9fd18a9ba2262f14a58c6cec7997 100644 (file)
--- a/mp3_afh.c
+++ b/mp3_afh.c
@@ -37,9 +37,6 @@ struct mp3header {
        unsigned int freq;
        unsigned int padding;
        unsigned int mode;
-       unsigned int copyright;
-       unsigned int original;
-       unsigned int emphasis;
 };
 
 static const int frequencies[3][4] = {
@@ -473,7 +470,7 @@ static int frame_length(struct mp3header *header)
                + header->padding;
 }
 
-static int compare_headers(struct mp3header *h1,struct mp3header *h2)
+static int compare_headers(struct mp3header *h1, struct mp3header *h2)
 {
        if ((*(unsigned int*)h1) == (*(unsigned int*)h2))
                return 1;
@@ -481,10 +478,7 @@ static int compare_headers(struct mp3header *h1,struct mp3header *h2)
                        (h1->layer == h2->layer) &&
                        (h1->crc == h2->crc) &&
                        (h1->freq == h2->freq) &&
-                       (h1->mode == h2->mode) &&
-                       (h1->copyright == h2->copyright) &&
-                       (h1->original == h2->original) &&
-                       (h1->emphasis == h2->emphasis))
+                       (h1->mode == h2->mode))
                return 1;
        return 0;
 }
index 75249fe32b0b0e159b4b6ad1773efa2673b2cd22..1ba70632a95d585de16eb5b0e961291fe4ca83f1 100644 (file)
@@ -17,9 +17,12 @@ get_audio_file_paths()
 
 say_color()
 {
+       local severity=$1
+
+       shift
        if [[ "$o_nocolor" != "true" && -n "$1" ]]; then
                export TERM=$ORIGINAL_TERM
-               case "$1" in
+               case "$severity" in
                        error) tput $C_BOLD; tput $C_SETAF 1;;
                        skip)  tput $C_SETAF 5;;
                        ok)
@@ -32,8 +35,11 @@ say_color()
                                tput $C_SETAF 6;;
                esac
        fi
-       shift
-       printf "%s\n" "$*"
+       if [[ "$severity" == 'error' ]]; then
+               printf "%s\n" "$*" 1>&2
+       else
+               printf "%s\n" "$*"
+       fi
        if [[ "$o_nocolor" != "true" && -n "$1" ]]; then
                tput $C_SGR0
                export TERM=dumb
@@ -279,7 +285,7 @@ fixup_dirs()
        [[ -z "$o_trash_dir" ]] && o_trash_dir="$test_dir/trashes"
        [[ -z "$o_man_dir" ]] && o_man_dir="$test_dir/../build/man/man1"
 
-       # we want alsolute paths because relative paths become invalid
+       # we want absolute paths because relative paths become invalid
        # after changing to the trash dir
        [[ -n "${o_results_dir##/*}" ]] && o_results_dir="$wd/$o_results_dir"
        [[ -n "${o_executables_dir##/*}" ]] && o_executables_dir="$wd/$o_results_dir"