1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

Improve /upgrade command: expand "~" with user home, check that binary exists with execution permissions (only if user gives path to binary)

This commit is contained in:
Sebastien Helleu
2008-12-17 18:57:30 +01:00
parent b1b0c759fc
commit e16b12428b
8 changed files with 197 additions and 60 deletions
+22 -9
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2008-09-17 16:19+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -638,15 +638,25 @@ msgstr "Volba odebrána: %s"
msgid "%d option(s) reset, %d option(s) removed"
msgstr "%d volba/volby resetovány, %d volba/volby smazány"
msgid "Upgrading WeeChat..."
msgstr "Upgraduji WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, fuzzy, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "%s nemohu vytvořit soubor \"%s\"\n"
#, c-format
msgid "%sError: unable to save session in file"
msgstr "%sChyba: nemohu uložit sezení do souboru"
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
#, fuzzy, c-format
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "Chyba: exec selhal (program: \"%s\"), ukončuji WeeChat"
#, c-format
@@ -5136,6 +5146,13 @@ msgstr "%s DCC: nemohu nastavit 'neblokovaci' volbu na soket\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s chybí argument pro volbu \"%s\"\n"
#, fuzzy
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%s plugin \"%s\" nenalezen\n"
#~ msgid "Upgrading WeeChat..."
#~ msgstr "Upgraduji WeeChat..."
#, fuzzy
#~ msgid "timeout for relay request (in seconds)"
#~ msgstr "časový limit pro dcc požadavek (v sekundách)"
@@ -5258,10 +5275,6 @@ msgstr "%s chybí argument pro volbu \"%s\"\n"
#~ msgid "%sError: filter not \"%s\" found"
#~ msgstr "%s plugin \"%s\" nenalezen\n"
#, fuzzy
#~ msgid "%sError: filter not found"
#~ msgstr "%s plugin \"%s\" nenalezen\n"
#, fuzzy
#~ msgid "Filter added"
#~ msgstr "uživatel byl zablokován"
+21 -8
View File
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -695,8 +695,17 @@ msgstr "Sie sind nicht im Channel"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, fuzzy, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "Aktualisiere WeeChat...\n"
#, fuzzy, c-format
@@ -704,7 +713,7 @@ msgid "%sError: unable to save session in file"
msgstr "%s kann die Sitzung nicht in eine Datei speichern\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s Ausführung schlug fehl (Programm: \"%s\"), WeeChat wird beendet\n"
#, c-format
@@ -5099,6 +5108,14 @@ msgstr "%s DCC: kann die 'nonblock'-Option für den Socket nicht festlegen\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
#, fuzzy
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%s Plugin \"%s\" nicht gefunden\n"
#, fuzzy
#~ msgid "Upgrading WeeChat..."
#~ msgstr "Aktualisiere WeeChat...\n"
#, fuzzy
#~ msgid "timeout for relay request (in seconds)"
#~ msgstr "DCC-Timeout in Sekunden"
@@ -5223,10 +5240,6 @@ msgstr "%s fehlende Argumente für die \"--dir\"-Option\n"
#~ msgid "%sError: filter not \"%s\" found"
#~ msgstr "%s Plugin \"%s\" nicht gefunden\n"
#, fuzzy
#~ msgid "%sError: filter not found"
#~ msgstr "%s Plugin \"%s\" nicht gefunden\n"
#, fuzzy
#~ msgid "Filter added"
#~ msgstr "/users wurde deaktiviert"
+21 -8
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2007-09-19 12:09+0200\n"
"Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -690,8 +690,17 @@ msgstr "no presente en el canal"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, fuzzy, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "Actualizando Weechat...\n"
#, fuzzy, c-format
@@ -699,7 +708,7 @@ msgid "%sError: unable to save session in file"
msgstr "%s no ha sido posible guardar la sesión en el archivo\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s exec ha fallado (programa: \"%s\"), saliendo de Weechat\n"
#, c-format
@@ -5103,6 +5112,14 @@ msgstr "%s no es posible crear el servidor\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s falta un argumento para la opción --dir\n"
#, fuzzy
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%s plugin \"%s\" no encontrado\n"
#, fuzzy
#~ msgid "Upgrading WeeChat..."
#~ msgstr "Actualizando Weechat...\n"
#, fuzzy
#~ msgid "timeout for relay request (in seconds)"
#~ msgstr "tiempo de espera para la petición dcc (en segundos)"
@@ -5227,10 +5244,6 @@ msgstr "%s falta un argumento para la opción --dir\n"
#~ msgid "%sError: filter not \"%s\" found"
#~ msgstr "%s plugin \"%s\" no encontrado\n"
#, fuzzy
#~ msgid "%sError: filter not found"
#~ msgstr "%s plugin \"%s\" no encontrado\n"
#, fuzzy
#~ msgid "Filter added"
#~ msgstr "los usuarios han sido desactivados"
+24 -6
View File
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"PO-Revision-Date: 2008-12-16 11:33+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2008-12-17 18:54+0100\n"
"Last-Translator: FlashCode <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"MIME-Version: 1.0\n"
@@ -639,16 +639,28 @@ msgstr "Option supprimée: %s"
msgid "%d option(s) reset, %d option(s) removed"
msgstr "%d option(s) réinitialisée(s), %d option(s) supprimée(s)"
msgid "Upgrading WeeChat..."
msgstr "Mise à jour de WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr "%sImpossible de mettre à jour: le binaire WeeChat \"%s\" n'existe pas"
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
"%sImpossible de mettre à jour: le binaire WeeChat \"%s\" n'a pas les droits "
"d'exécution"
#, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "Mise à jour de WeeChat avec le fichier binaire: \"%s\"..."
#, c-format
msgid "%sError: unable to save session in file"
msgstr "%sErreur: impossible de sauvegarder la session dans le ficheir"
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "Error: exec a échoué (programme: \"%s\"), sortie de WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "***** Error: exec a échoué (programme: \"%s\"), sortie de WeeChat"
#, c-format
msgid "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"
@@ -5248,3 +5260,9 @@ msgstr "%s%s: impossible de positionner l'option \"nonblock\" pour la socket"
#, c-format
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s%s: délai d'attente dépassé pour \"%s\" avec %s"
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%sFichier binaire non trouvé: \"%s\""
#~ msgid "Upgrading WeeChat..."
#~ msgstr "Mise à jour de WeeChat..."
+21 -8
View File
@@ -12,7 +12,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2007-10-10 18:07+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -696,8 +696,17 @@ msgstr "nincs a szobában"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, fuzzy, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "WeeChat frissítése...\n"
#, fuzzy, c-format
@@ -705,7 +714,7 @@ msgid "%sError: unable to save session in file"
msgstr "%s nem sikerült a folyamatot menteni\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s futtatási hiba (program: \"%s\"), a WeeChat kilép\n"
#, c-format
@@ -5121,6 +5130,14 @@ msgstr "%s DCC: nem sikerült 'nonblock' opciót beállítani a csatornán\n"
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#, fuzzy
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%s a \"%s\" modul nem található\n"
#, fuzzy
#~ msgid "Upgrading WeeChat..."
#~ msgstr "WeeChat frissítése...\n"
#, fuzzy
#~ msgid "timeout for relay request (in seconds)"
#~ msgstr "dcc kérések időkorlátja (másodpercben)"
@@ -5245,10 +5262,6 @@ msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#~ msgid "%sError: filter not \"%s\" found"
#~ msgstr "%s a \"%s\" modul nem található\n"
#, fuzzy
#~ msgid "%sError: filter not found"
#~ msgstr "%s a \"%s\" modul nem található\n"
#, fuzzy
#~ msgid "Filter added"
#~ msgstr "a felhasználók le lettek tiltva"
+21 -8
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.2.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: 2007-09-06 12:44+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -691,8 +691,17 @@ msgstr "не на канале"
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
#, fuzzy
msgid "Upgrading WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, fuzzy, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr "Обновляю WeeChat...\n"
#, fuzzy, c-format
@@ -700,7 +709,7 @@ msgid "%sError: unable to save session in file"
msgstr "%s не могу сохранить сессию в файл\n"
#, fuzzy, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr "%s запуск не удался (программа: \"%s\"), выхожу из WeeChat\n"
#, c-format
@@ -5103,6 +5112,14 @@ msgstr "%s DCC: не могу установить неблокирующий р
msgid "%s%s: timeout for \"%s\" with %s"
msgstr "%s нет аргумента для параметра \"%s\"\n"
#, fuzzy
#~ msgid "%sBinary file not found: \"%s\""
#~ msgstr "%s plugin \"%s\" не найден\n"
#, fuzzy
#~ msgid "Upgrading WeeChat..."
#~ msgstr "Обновляю WeeChat...\n"
#, fuzzy
#~ msgid "timeout for relay request (in seconds)"
#~ msgstr "таймаут запросов dcc-соединений (в секундах)"
@@ -5227,10 +5244,6 @@ msgstr "%s нет аргумента для параметра \"%s\"\n"
#~ msgid "%sError: filter not \"%s\" found"
#~ msgstr "%s plugin \"%s\" не найден\n"
#, fuzzy
#~ msgid "%sError: filter not found"
#~ msgstr "%s plugin \"%s\" не найден\n"
#, fuzzy
#~ msgid "Filter added"
#~ msgstr "команда users отключена"
+13 -3
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2008-12-16 11:32+0100\n"
"POT-Creation-Date: 2008-12-17 18:53+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -612,7 +612,17 @@ msgstr ""
msgid "%d option(s) reset, %d option(s) removed"
msgstr ""
msgid "Upgrading WeeChat..."
#, c-format
msgid "%sCan't upgrade: WeeChat binary \"%s\" does not exist"
msgstr ""
#, c-format
msgid ""
"%sCan't upgrade: WeeChat binary \"%s\" does not have execute permissions"
msgstr ""
#, c-format
msgid "Upgrading WeeChat with binary file: \"%s\"..."
msgstr ""
#, c-format
@@ -620,7 +630,7 @@ msgid "%sError: unable to save session in file"
msgstr ""
#, c-format
msgid "Error: exec failed (program: \"%s\"), exiting WeeChat"
msgid "***** Error: exec failed (program: \"%s\"), exiting WeeChat"
msgstr ""
#, c-format
+54 -10
View File
@@ -28,6 +28,8 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "weechat.h"
#include "wee-command.h"
@@ -215,7 +217,7 @@ command_bar (void *data, struct t_gui_buffer *buffer,
gui_chat_printf (NULL,
_("%sNot enough memory"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return WEECHAT_RC_ERROR;
return WEECHAT_RC_ERROR;
}
type = gui_bar_search_type (str_type);
if (type < 0)
@@ -2927,18 +2929,59 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
{
char *ptr_binary;
char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--upgrade", NULL };
struct stat stat_buf;
int rc;
/* make C compiler happy */
(void) data;
(void) buffer;
(void) argc;
(void) argv;
(void) argv_eol;
ptr_binary = (argc > 1) ? argv_eol[1] : weechat_argv0;
if (argc > 1)
{
ptr_binary = string_replace (argv_eol[1], "~", getenv ("HOME"));
if (ptr_binary)
{
/* check if weechat binary is here and executable by user */
rc = stat (ptr_binary, &stat_buf);
if ((rc != 0) || (!S_ISREG(stat_buf.st_mode)))
{
gui_chat_printf (NULL,
_("%sCan't upgrade: WeeChat binary \"%s\" "
"does not exist"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
ptr_binary);
free (ptr_binary);
return WEECHAT_RC_ERROR;
}
if ((!(stat_buf.st_mode & S_IXUSR)) && (!(stat_buf.st_mode & S_IXGRP))
&& (!(stat_buf.st_mode & S_IXOTH)))
{
gui_chat_printf (NULL,
_("%sCan't upgrade: WeeChat binary \"%s\" "
"does not have execute permissions"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
ptr_binary);
free (ptr_binary);
return WEECHAT_RC_ERROR;
}
}
}
else
ptr_binary = strdup (weechat_argv0);
if (!ptr_binary)
{
gui_chat_printf (NULL,
_("%sNot enough memory"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return WEECHAT_RC_ERROR;
}
gui_chat_printf (NULL,
_("Upgrading WeeChat..."));
_("Upgrading WeeChat with binary file: \"%s\"..."),
ptr_binary);
/* send "upgrade" signal to plugins */
hook_signal_send ("upgrade", WEECHAT_HOOK_SIGNAL_STRING, NULL);
@@ -2948,10 +2991,11 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
gui_chat_printf (NULL,
_("%sError: unable to save session in file"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
free (ptr_binary);
return WEECHAT_RC_ERROR;
}
exec_args[0] = strdup (ptr_binary);
exec_args[0] = ptr_binary;
exec_args[3] = strdup (weechat_home);
/* save layout, unload plugins, save config, then upgrade */
@@ -2965,11 +3009,11 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
execvp (exec_args[0], exec_args);
/* this code should not be reached if execvp is ok */
plugin_init (1, 0, NULL);
string_iconv_fprintf (stderr, "\n\n*****\n");
string_iconv_fprintf (stderr,
_("Error: exec failed (program: \"%s\"), exiting WeeChat"),
exec_args[0]);
_("***** Error: exec failed (program: \"%s\"), exiting WeeChat"),
exec_args[0]);
string_iconv_fprintf (stderr, "\n*****\n\n");
free (exec_args[0]);
free (exec_args[3]);