Merge upstream/master into merge/upstream-full
Some checks failed
CI Code / Check coding style (pull_request) Failing after 7s
CI Code / Check spelling (pull_request) Successful in 17s
CI Code / Linux (debian) (pull_request) Successful in 7m1s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m44s
CI Code / Code Coverage (pull_request) Successful in 7m35s
Lint / DCO (pull_request) Failing after 7s
Lint / conventional commits (pull_request) Failing after 45s
CI Code / Linux (arch) (pull_request) Successful in 9m23s
Build / ubuntu | func | signal (pull_request) Has been cancelled
Lint / coding style (pull_request) Has been cancelled
Lint / spellcheck (pull_request) Has been cancelled
Build / cygwin / build only (pull_request) Has been cancelled
CodeQL / analyze (pull_request) Has been cancelled
Some checks failed
CI Code / Check coding style (pull_request) Failing after 7s
CI Code / Check spelling (pull_request) Successful in 17s
CI Code / Linux (debian) (pull_request) Successful in 7m1s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m44s
CI Code / Code Coverage (pull_request) Successful in 7m35s
Lint / DCO (pull_request) Failing after 7s
Lint / conventional commits (pull_request) Failing after 45s
CI Code / Linux (arch) (pull_request) Successful in 9m23s
Build / ubuntu | func | signal (pull_request) Has been cancelled
Lint / coding style (pull_request) Has been cancelled
Lint / spellcheck (pull_request) Has been cancelled
Build / cygwin / build only (pull_request) Has been cancelled
CodeQL / analyze (pull_request) Has been cancelled
Merge profanity-im/profanity master (373 commits) into cproof fork.
Source changes (manual merge):
- src/command/: cmd_defs, cmd_funcs, cmd_ac — upstream g_new0, auto_gchar,
launch_editor callback; keep our XEP-0308 LMC, force-encryption, CWE-134
- src/config/: preferences, tlscerts, account — upstream UNIQUE dedup,
dynamic pad capacity; keep our db_history_result_t, scroll logic
- src/database.*: upstream g_new0 memory mgmt; keep our return types,
add null-check fix for msg->timestamp
- src/omemo/, src/pgp/: upstream _gpgme_key_get_email, g_new0;
keep our replace_id in omemo_on_message_send
- src/tools/: editor, http_upload, bookmark_ignore — upstream launch_editor
callback API
- src/ui/: console, window, chatwin, mucwin, inputwin, buffer —
upstream win_warn_needed/sent dedup, PAD_MIN_HEIGHT dynamic pads;
keep our y_start_pos scroll, _truncate_datetime_suffix
- src/xmpp/: message, stanza, presence, roster_list, iq, session —
upstream connection_get_available_resources; keep our LMC stanza logic
- src/common.c: fix format-security (cons_show)
Build system:
- Makefile.am: updated test paths to subdirectory structure, added
test_cmd_ac, test_forced_encryption
- Restored autotools files deleted by upstream meson migration:
bootstrap.sh, autogen.sh, m4/ax_valgrind_check.m4, configure-debug
Tests:
- Unit tests: upstream unittests.c base + our forced_encryption tests
(482 passed, 0 failed across all 4 configurations)
- Functional tests: kept our version (93 passed, 0 failed)
upstream version requires stbbr_for_xmlns not yet in our stabber fork
- Updated test stubs: stub_xmpp.c, stub_omemo.c from upstream
Compile fixes:
- src/common.c: cons_show(errmsg) -> cons_show("%s", errmsg)
- src/database.c: null-check before msg->timestamp access
- src/ui/console.c: size_t -> (int) cast for format width
- src/config/tlscerts.c: %d -> %zu for size_t
This commit is contained in:
61
src/log.c
61
src/log.c
@@ -3,35 +3,9 @@
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
||||
* Copyright (C) 2018 - 2025 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link the code of portions of this program with the OpenSSL library under
|
||||
* certain conditions as described in each individual source file, and
|
||||
* distribute linked combinations including the two.
|
||||
*
|
||||
* You must obey the GNU General Public License in all respects for all of the
|
||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
||||
* may extend this exception to your version of the file(s), but you are not
|
||||
* obligated to do so. If you do not wish to do so, delete this exception
|
||||
* statement from your version. If you delete this exception statement from all
|
||||
* source files in the program, then also delete it here.
|
||||
* Copyright (C) 2018 - 2026 Michael Vetter <jubalh@iodoru.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -60,6 +34,7 @@ static FILE* logp;
|
||||
static gchar* mainlogfile = NULL;
|
||||
static gboolean user_provided_log = FALSE;
|
||||
static log_level_t level_filter;
|
||||
static pid_t prof_pid;
|
||||
|
||||
static int stderr_inited;
|
||||
static log_level_t stderr_level;
|
||||
@@ -75,6 +50,8 @@ enum {
|
||||
static void
|
||||
_rotate_log_file(void)
|
||||
{
|
||||
if (!mainlogfile)
|
||||
return;
|
||||
auto_gchar gchar* log_file = g_strdup(mainlogfile);
|
||||
size_t len = strlen(log_file);
|
||||
auto_gchar gchar* log_file_new = malloc(len + 5);
|
||||
@@ -198,6 +175,8 @@ log_init(log_level_t filter, const char* const log_file)
|
||||
|
||||
logp = fopen(mainlogfile, "a");
|
||||
g_chmod(mainlogfile, S_IRUSR | S_IWUSR);
|
||||
|
||||
prof_pid = getpid();
|
||||
}
|
||||
|
||||
const gchar*
|
||||
@@ -225,14 +204,11 @@ log_close(void)
|
||||
static void
|
||||
_log_msg(log_level_t level, const char* const area, const char* const msg)
|
||||
{
|
||||
GDateTime* dt = g_date_time_new_now_local();
|
||||
|
||||
char* level_str = _log_abbreviation_string_from_level(level);
|
||||
|
||||
auto_gchar gchar* date_fmt = g_date_time_format_iso8601(dt);
|
||||
auto_gchar gchar* date_fmt = prof_date_time_format_iso8601(NULL);
|
||||
|
||||
fprintf(logp, "%s: %s: %s: %s\n", date_fmt, area, level_str, msg);
|
||||
g_date_time_unref(dt);
|
||||
fprintf(logp, "%s: %08d: %s: %s: %s\n", date_fmt, prof_pid, area, level_str, msg);
|
||||
|
||||
fflush(logp);
|
||||
|
||||
@@ -359,11 +335,6 @@ log_stderr_init(log_level_t level)
|
||||
if (rc != 0)
|
||||
goto err;
|
||||
|
||||
close(STDERR_FILENO);
|
||||
rc = dup2(stderr_pipe[1], STDERR_FILENO);
|
||||
if (rc < 0)
|
||||
goto err_close;
|
||||
|
||||
rc = log_stderr_nonblock_set(stderr_pipe[0])
|
||||
?: log_stderr_nonblock_set(stderr_pipe[1]);
|
||||
if (rc != 0)
|
||||
@@ -371,15 +342,21 @@ log_stderr_init(log_level_t level)
|
||||
|
||||
stderr_buf = malloc(STDERR_BUFSIZE);
|
||||
stderr_msg = g_string_sized_new(STDERR_BUFSIZE);
|
||||
stderr_level = level;
|
||||
stderr_inited = 1;
|
||||
|
||||
prof_add_shutdown_routine(_log_stderr_close);
|
||||
|
||||
if (stderr_buf == NULL || stderr_msg == NULL) {
|
||||
errno = ENOMEM;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
int dup_fd = dup2(stderr_pipe[1], STDERR_FILENO);
|
||||
if (dup_fd < 0)
|
||||
goto err_free;
|
||||
close(dup_fd);
|
||||
|
||||
stderr_level = level;
|
||||
stderr_inited = 1;
|
||||
|
||||
prof_add_shutdown_routine(_log_stderr_close);
|
||||
return;
|
||||
|
||||
err_free:
|
||||
|
||||
Reference in New Issue
Block a user