1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

Fix bug with /upgrade: check existence of binary even when command is executed without argument

This commit is contained in:
Sebastien Helleu
2011-01-04 23:56:46 +01:00
parent 57102fef70
commit 3cd267ab23
2 changed files with 26 additions and 28 deletions
+2
View File
@@ -9,6 +9,8 @@ Version 0.3.4 (under dev!)
* core: add 256 colors support, new command /color, new section "palette" in
weechat.conf (task #6834)
* core: fix bug with /upgrade: check existence of binary even when command is
executed without argument
* core: add info "weechat_upgrading", signal "upgrade_ended", display duration
of upgrade
* core: replace the 10 nick color options and number of nick colors by a single
+24 -28
View File
@@ -3721,35 +3721,7 @@ COMMAND_CALLBACK(upgrade)
}
if (argc > 1)
{
ptr_binary = string_expand_home (argv_eol[1]);
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_OK;
}
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_OK;
}
}
}
else
ptr_binary = strdup (weechat_argv0);
@@ -3761,6 +3733,30 @@ COMMAND_CALLBACK(upgrade)
return WEECHAT_RC_OK;
}
/* 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_OK;
}
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_OK;
}
gui_chat_printf (NULL,
_("Upgrading WeeChat with binary file: \"%s\"..."),
ptr_binary);