1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: check "weechat" binary with command /upgrade

Always check that "weechat" binary exists and is executable with command
`/upgrade`, even when the path to binary is not given.
This commit is contained in:
Sébastien Helleu
2025-01-04 18:07:30 +01:00
parent 16346255f1
commit d665e2d489
2 changed files with 25 additions and 28 deletions
+1
View File
@@ -8,6 +8,7 @@
### Fixed
- core: always check that "weechat" binary exists and is executable with command `/upgrade`, even when the path to binary is not given
- relay: fix crash after `/upgrade` when relay clients are connected
- api: fix creation of empty buffer in function infolist_new_var_buffer
- core: fix detection of dl library ([#2218](https://github.com/weechat/weechat/issues/2218))
+24 -28
View File
@@ -7516,36 +7516,9 @@ COMMAND_CALLBACK(upgrade)
if (string_strcmp (argv[index_args], "-quit") == 0)
quit = 1;
else
{
ptr_binary = string_expand_home (argv_eol[index_args]);
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;
}
}
}
}
if (!ptr_binary && !quit)
{
ptr_binary = (weechat_argv0) ? strdup (weechat_argv0) : NULL;
@@ -7569,6 +7542,29 @@ COMMAND_CALLBACK(upgrade)
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;
}
gui_chat_printf (NULL,
_("Upgrading WeeChat with binary file: \"%s\"..."),
ptr_binary);