mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 17:23:15 +02:00
core: fix time-of-check/time-of-use race condition on theme files
Open theme files directly instead of probing them with access() first in commands /theme apply, /theme rename and /theme info. The renamed file is now created with O_CREAT | O_EXCL so an existing theme is never clobbered.
This commit is contained in:
@@ -23,8 +23,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-05-30 14:01+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:29+0200\n"
|
||||
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
|
||||
"Language-Team: Czech <weechat-dev@nongnu.org>\n"
|
||||
"Language: cs\n"
|
||||
@@ -6364,11 +6364,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%sUpozornění: %s, řádek %d: neznámý identifikátor sekce (\"%s\")"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: nemůžu parsovat soubor \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -26,8 +26,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:28+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:29+0200\n"
|
||||
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
|
||||
"Language-Team: German <weechatter@arcor.de>\n"
|
||||
"Language: de\n"
|
||||
@@ -7206,11 +7206,6 @@ msgstr ""
|
||||
"%sWarnung: %s, Zeile %d: ignoriert unbekannte Einstellung für Sektion "
|
||||
"\"%s\": %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: Datei \"%s\" Analyse nicht möglich"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -24,8 +24,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:46+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:29+0200\n"
|
||||
"Last-Translator: Santiago Forero <santiago@forero.xyz>\n"
|
||||
"Language-Team: Spanish <weechat-dev@nongnu.org>\n"
|
||||
"Language: es\n"
|
||||
@@ -6522,11 +6522,6 @@ msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr ""
|
||||
"%sAtención: %s, línea %d: opción desconocida para la sección \"%s\": %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: no es posible analizar el archivo \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -23,8 +23,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-07-04 22:02+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
|
||||
"Language-Team: French <flashcode@flashtux.org>\n"
|
||||
"Language: fr\n"
|
||||
@@ -7087,10 +7087,6 @@ msgstr "%s%s : ligne %d : séparateur '=' manquant"
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%s%s : ligne %d : clé [info] \"%s\" inconnue, ignorée"
|
||||
|
||||
#, c-format
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%sÉchec de l'analyse du fichier de thème \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
@@ -19043,51 +19039,3 @@ msgid ""
|
||||
msgstr ""
|
||||
"%s%s : impossible d'accepter de continuer le fichier \"%s\" (port : %d, "
|
||||
"position de départ : %llu) : xfer non trouvé ou non prêt pour le transfert"
|
||||
|
||||
#~ msgid "Automatic backup written before /theme apply"
|
||||
#~ msgstr "Sauvegarde automatique écrite avant /theme apply"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Welcome to WeeChat!\n"
|
||||
#~ "\n"
|
||||
#~ "If you are discovering WeeChat, it is recommended to read at least the "
|
||||
#~ "quickstart guide, and the user's guide if you have some time; they "
|
||||
#~ "explain main WeeChat concepts.\n"
|
||||
#~ "All WeeChat docs are available at: https://weechat.org/doc/\n"
|
||||
#~ "\n"
|
||||
#~ "Moreover, there is inline help with /help on all commands and options "
|
||||
#~ "(use Tab key to complete the name).\n"
|
||||
#~ "The command /fset can help to customize WeeChat.\n"
|
||||
#~ "\n"
|
||||
#~ "You can add and connect to an IRC server with /server and /connect "
|
||||
#~ "commands (see /help server)."
|
||||
#~ msgstr ""
|
||||
#~ "Bienvenue dans WeeChat !\n"
|
||||
#~ "\n"
|
||||
#~ "Si vous découvrez WeeChat, il est recommandé de lire au moins le guide de "
|
||||
#~ "démarrage rapide, et le guide utilisateur si vous avez le temps ; ils "
|
||||
#~ "expliquent les concepts principaux de WeeChat.\n"
|
||||
#~ "Toutes les documentations WeeChat sont disponibles ici : https://"
|
||||
#~ "weechat.org/doc/\n"
|
||||
#~ "\n"
|
||||
#~ "De plus, il y a de l'aide en ligne avec /help sur toutes les commandes et "
|
||||
#~ "options (utilisez la touche Tab pour compléter le nom).\n"
|
||||
#~ "La commande /fset peut aider à paramétrer WeeChat.\n"
|
||||
#~ "\n"
|
||||
#~ "Vous pouvez ajouter et vous connecter à un serveur IRC avec les "
|
||||
#~ "commandes /server et /connect (voir /help server)."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "raw[delete]: delete a user theme file (refuses to delete built-in themes, "
|
||||
#~ "which have no file)"
|
||||
#~ msgstr "raw[delete] : supprimer un fichier thème de l'utilisateur"
|
||||
|
||||
#~ msgid "No theme registered"
|
||||
#~ msgstr "Aucun thème enregistré"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "raw[list]: list registered themes (default action with no argument); "
|
||||
#~ "active theme is marked with \"->\""
|
||||
#~ msgstr ""
|
||||
#~ "raw[list] : afficher les thèmes enregistrés (sans paramètre, cette liste "
|
||||
#~ "est affichée), le thème actif est marqué avec \"->\""
|
||||
|
||||
@@ -22,8 +22,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
|
||||
"Language-Team: Hungarian <weechat-dev@nongnu.org>\n"
|
||||
"Language: hu\n"
|
||||
@@ -6030,10 +6030,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%s %s, %d. sor: ismeretlen csoportazonosító (\"%s\")\n"
|
||||
|
||||
#, fuzzy, c-format
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "Nem sikerült a(z) \"%s\" naplófájlt írni\n"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -22,8 +22,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-05-30 14:02+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
|
||||
"Language-Team: Italian <weechat-dev@nongnu.org>\n"
|
||||
"Language: it\n"
|
||||
@@ -6510,11 +6510,6 @@ msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr ""
|
||||
"%sAttenzione: %s, riga %d: opzione sconosciuta per la sezione \"%s\": %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: impossibile analizzare il file \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -22,8 +22,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-05-30 14:02+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
|
||||
"Language-Team: Japanese <weechat-dev@nongnu.org>\n"
|
||||
"Language: ja\n"
|
||||
@@ -6686,11 +6686,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%s警告: %s、行 %d: セクション \"%s\" の無効なオプション: %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: ファイル \"%s\" を解析できません"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -23,8 +23,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:55+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
|
||||
"Language-Team: Polish <soltys@soltys.info>\n"
|
||||
"Language: pl\n"
|
||||
@@ -6867,11 +6867,6 @@ msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr ""
|
||||
"%sOstrzeżenie: %s, linia %d: ignoruje nieznaną opcję dla sekcji \"%s\": %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: nie można przetworzyć pliku \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -22,8 +22,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:48+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
|
||||
"Language-Team: Portuguese <weechat-dev@nongnu.org>\n"
|
||||
"Language: pt\n"
|
||||
@@ -6742,11 +6742,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%sAviso: %s, linha %d: opção desconhecida na secção \"%s\": %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: não foi possível analisar o ficheiro \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
+2
-7
@@ -46,8 +46,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:49+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
|
||||
"Language-Team: Portuguese (Brazil) <weechat-dev@nongnu.org>\n"
|
||||
"Language: pt_BR\n"
|
||||
@@ -6408,11 +6408,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%sAviso: %s, linha %d: opção \"%s\" desconhecido para seção \"%s\""
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: não foi possível interpretar arquivo \"%s\""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -23,8 +23,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:28+0200\n"
|
||||
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
|
||||
"Language-Team: Russian <weechat-dev@nongnu.org>\n"
|
||||
"Language: ru\n"
|
||||
@@ -6067,10 +6067,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%s %s, строка %d: неизвестный идентификатор секции (\"%s\")\n"
|
||||
|
||||
#, fuzzy, c-format
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "Не могу записать лог-файл \"%s\"\n"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -22,8 +22,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:52+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:29+0200\n"
|
||||
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
|
||||
"Language-Team: Serbian <ivan.pesic@gmail.com>\n"
|
||||
"Language: sr\n"
|
||||
@@ -6849,11 +6849,6 @@ msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr ""
|
||||
"%sУпозорење: %s, линија %d: игнорише се непозната опција за одељак „%s”: %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: није успело парсирање фајла „%s”"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -23,8 +23,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"PO-Revision-Date: 2026-06-28 08:53+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2026-07-05 12:29+0200\n"
|
||||
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
|
||||
"Language-Team: Turkish <emir_sari@icloud.com>\n"
|
||||
"Language: tr\n"
|
||||
@@ -6646,11 +6646,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr "%sUyarı: %s, %d. satır: \"%s\" bölümü için bilinmeyen seçenek: %s"
|
||||
|
||||
#, fuzzy, c-format
|
||||
#| msgid "%s%s: unable to parse file \"%s\""
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr "%s%s: \"%s\" dosyası ayrıştırılamıyor"
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
+1
-5
@@ -23,7 +23,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WeeChat\n"
|
||||
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
|
||||
"POT-Creation-Date: 2026-07-04 22:01+0200\n"
|
||||
"POT-Creation-Date: 2026-07-05 12:20+0200\n"
|
||||
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
|
||||
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
|
||||
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
|
||||
@@ -5624,10 +5624,6 @@ msgstr ""
|
||||
msgid "%s%s: line %d: ignoring unknown [info] key \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%sFailed to parse theme file \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid ""
|
||||
"%sUnable to create theme backup; aborting apply (disable option "
|
||||
|
||||
@@ -7369,9 +7369,7 @@ COMMAND_CALLBACK(theme)
|
||||
COMMAND_MIN_ARGS(3, "info");
|
||||
/* file shadows registry: try user file first */
|
||||
path = theme_user_file_path (argv[2]);
|
||||
file_theme = NULL;
|
||||
if (path && (access (path, R_OK) == 0))
|
||||
file_theme = theme_file_parse (path);
|
||||
file_theme = (path) ? theme_file_parse (path) : NULL;
|
||||
if (!file_theme)
|
||||
{
|
||||
free (path);
|
||||
|
||||
+39
-32
@@ -25,6 +25,8 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -945,18 +947,11 @@ theme_apply (const char *name)
|
||||
* so user themes have no steady-state memory footprint.
|
||||
*/
|
||||
path = theme_user_file_path (name);
|
||||
if (path && (access (path, R_OK) == 0))
|
||||
{
|
||||
if (path)
|
||||
file_theme = theme_file_parse (path);
|
||||
if (!file_theme)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sFailed to parse theme file \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
path);
|
||||
free (path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
free (path);
|
||||
if (file_theme)
|
||||
{
|
||||
theme = file_theme;
|
||||
}
|
||||
else
|
||||
@@ -968,11 +963,9 @@ theme_apply (const char *name)
|
||||
_("%sTheme \"%s\" not found"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
name);
|
||||
free (path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
}
|
||||
free (path);
|
||||
|
||||
/* create a backup of current themable state, if enabled */
|
||||
if (CONFIG_BOOLEAN(config_look_theme_backup)
|
||||
@@ -1187,7 +1180,7 @@ theme_rename (const char *old_name, const char *new_name)
|
||||
char *old_path, *new_path, line[2048];
|
||||
FILE *fin, *fout;
|
||||
const char *trimmed;
|
||||
int in_info, name_done;
|
||||
int in_info, name_done, fd;
|
||||
|
||||
if (!old_name || !old_name[0] || !new_name || !new_name[0])
|
||||
return WEECHAT_RC_ERROR;
|
||||
@@ -1230,39 +1223,53 @@ theme_rename (const char *old_name, const char *new_name)
|
||||
old_path = theme_user_file_path (old_name);
|
||||
if (!old_path)
|
||||
return WEECHAT_RC_ERROR;
|
||||
if (access (old_path, R_OK) != 0)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sTheme \"%s\" not found"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
old_name);
|
||||
free (old_path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
new_path = theme_user_file_path (new_name);
|
||||
if (!new_path)
|
||||
{
|
||||
free (old_path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
if (access (new_path, F_OK) == 0)
|
||||
|
||||
fin = fopen (old_path, "r");
|
||||
if (!fin)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sTheme \"%s\" already exists"),
|
||||
_("%sTheme \"%s\" not found"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
new_name);
|
||||
old_name);
|
||||
free (old_path);
|
||||
free (new_path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
|
||||
fin = fopen (old_path, "r");
|
||||
fout = (fin) ? fopen (new_path, "w") : NULL;
|
||||
if (!fin || !fout)
|
||||
fd = open (new_path, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fin)
|
||||
fclose (fin);
|
||||
if (errno == EEXIST)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sTheme \"%s\" already exists"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
new_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("%sFailed to rename theme \"%s\" to \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
old_name, new_name);
|
||||
}
|
||||
fclose (fin);
|
||||
free (old_path);
|
||||
free (new_path);
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
fout = fdopen (fd, "w");
|
||||
if (!fout)
|
||||
{
|
||||
close (fd);
|
||||
unlink (new_path);
|
||||
fclose (fin);
|
||||
gui_chat_printf (NULL,
|
||||
_("%sFailed to rename theme \"%s\" to \"%s\""),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
|
||||
|
||||
@@ -942,7 +942,7 @@ TEST(CoreTheme, Delete)
|
||||
|
||||
TEST(CoreTheme, Rename)
|
||||
{
|
||||
char *src_path, *dst_path;
|
||||
char *src_path = NULL, *dst_path = NULL;
|
||||
struct stat st;
|
||||
FILE *file;
|
||||
char buf[2048];
|
||||
@@ -974,6 +974,17 @@ TEST(CoreTheme, Rename)
|
||||
/* refuses target that already exists */
|
||||
LONGS_EQUAL(WEECHAT_RC_OK, theme_save ("rn_dst"));
|
||||
LONGS_EQUAL(WEECHAT_RC_ERROR, theme_rename ("rn_src", "rn_dst"));
|
||||
/* the refused rename must not have clobbered the existing target */
|
||||
dst_path = theme_user_file_path ("rn_dst");
|
||||
CHECK(dst_path != NULL);
|
||||
file = fopen (dst_path, "r");
|
||||
CHECK(file != NULL);
|
||||
len = fread (buf, 1, sizeof (buf) - 1, file);
|
||||
buf[len] = '\0';
|
||||
fclose (file);
|
||||
CHECK(strstr (buf, "name = \"rn_dst\"") != NULL);
|
||||
free (dst_path);
|
||||
dst_path = NULL;
|
||||
LONGS_EQUAL(WEECHAT_RC_OK, theme_delete ("rn_dst"));
|
||||
|
||||
/* happy path: rename moves the file and rewrites the [info] name */
|
||||
|
||||
Reference in New Issue
Block a user