(regex_command_for): execute the required action from the 'Default'
section if this action is not specified in the found section.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
zip archive can contain files outside archive root:
$ unzip -l tmp.zip
Archive: tmp.zip
Length Date Time Name
--------- ---------- ----- ----
0 2023-01-04 19:43 a
0 2023-01-04 19:43 b
0 2023-01-04 19:43 ../c
0 2023-01-04 19:43 ../../d
--------- -------
0 4 files
Enter into such archive leads to a segfault.
(extfs_find_entry_int): fix possible NULL dereference. The result of this
fix is an impossibility to enter into such archive.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix location of all user's syntax related stuff. Now it is the
~/.local/share/mc/syntax/ directory.
Don't use the system configuration directory (/etc/mc) as a storage
of syntax definitions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If subshell is initializing more than 1 second - we have no subshell.
(feed_subshell): change timeout to 10 secons. I belive that is more than
enough time to run subshell.
Thanks Alexandr Zamaraev (aka Tonal) <tonal.promsoft@gmail.com> and
antonio_so <sozonnik@gmail.com> for finding out the cause of the
problem.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Directory comparision expects only file names in both panels.
In panelized panel, files named can contain paths:
| boxes.c | 43220|| 1/boxes.c | 43220|
| boxes.h | 1429 || 1/boxes.h | 1429|
| | || boxes.c | 43220|
| | || boxes.h | 1429|
Even if boxes.c and 1/boxes.c files are the same, they are marked as
different because strings "boxes.c" and "1/boxes.c" are different.
The solution: for panelized panel, ignore path and use file name only
(like output of basename(3)) for comparision.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(mc_search_t): use GString to keep original search string. Join search string
and charset to structure.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If file name is too long, message window is wider than screen.
Truncate file name to fit it in the screen.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Ticket #2773: 'include' keyword (for command class def) have no effect
if it was defined before 'Include' keyword (for command def).
Ticket #3742: update comment in mc.ext.ini.
doc: remove mc.ext.ini format description from manual page.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (mcview_growbuf_read_until): the previous call to mcview_show_error()
invalidates sp by freeing view->ds_stdio_pipe. Reintroduce the check
that was removed in a68f2d1202 but take
sp's invalidity into account.
* (mc_pclose): add a NULL pointer check to play safe.
Signed-off-by: Michael Schuster <michael@schuster.ms>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Most of mc uses of PERL is to embed path to the interpreter in VFS
helpers. There we can use path to perl for --host. But
`date-of-man-include.am` is the place where perl is used for --build.
On most systems both paths are expected to be /usr/bin/perl.
But on some systems paths might differ a bit. Most prominent
example is NixOS, where packages get installed into unique prefixes:
$ file /nix/store/...-perl-5.36.0/bin/perl \
/nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl
/nix/store/...-perl-5.36.0/bin/perl:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ...
/nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl:
ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, ...
This allows running both binaries via qemu-user if needed for tests.
The change introduces PERL_FOR_BUILD (similar to autoconf's CC_FOR_BUILD
and friends) to allow passing both PERLs when needed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use it instead of direct access to WInput's buffer.
(handle_cmdline_enter): additional minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (input_get_text): never return NULL. If buffer is empty, return an
empty allocated string.
* (input_push_history): use new input_get_text.
* (find_parameters): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When files are selected keeping the right mouse button pressed,
some files are not selected.
* Add new macros for mouse pointer location relative to file list.
* (mark_if_marking): select/unselect all files between previous
selected file and new one.
* (panel_mouse_is_on_item): return clarified value of mouse pointer location.
* (panel_mouse_callback): modify mouse drag event handling in accordance with
the mouse pointer location relatively to the file list.
Also fixes ticket #4119: "Cannot scroll panel listing upwards using mouse".
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Menu according for "Sort order" item was changed in
d19b247c6d in order to fix shotrcut
conflict. Restore it back according to user requests.
óhange accelerator for "SFTP link" from S to N.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* configure.ac: test if "file" utility has -b option.
* (regex_check_type): don't compare file names if "file -b" is used.
Reduce variable scope. Rename variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Get rid of sort condition double check.
Condition
ad == bd || panels_options.mix_all_files
was checked twice: first in sort_xxx(), then in sort_name() called in
sort_xxx().
Now this condition is checked in sort_xxx() only.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Handle errors of bind(), getsockname(), and listen() calls.
Return if one of these functions fails and setup errno to indicate the
cause of the error.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Call of mc_build_filename(remote_path, ".") is pointless
because the path canonicalization is performed and trailing
"/." is removed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_load_file_from_filename): make public, use it as main function to
load file and create editor window.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(ftpfs_init_data_socket): handle return value of
getpeername()/getsockname() and try to reconnect to FTP server
for 10 attempts in case of error.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
How to reproduce:
start mc (with fish as your shell);
resize mc window;
type any command in the command prompt, for example, "ls";
result: nothing happens;
type the same command again;
it works now, the second time.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The main idea is apply same options for file filter as for file
selection and use the same dialog window.
Initial commit: refactoring: move creation of the file selection dialog
to the separate function.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Allocate buffer only if charset converter is created successfully.
g_string_free() returns NULL if second argument is TRUE. Use that to get
rig of 'if' statement.
Reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(copy_cmd, copy_cmd_local, rename_cmd, rename_cmd_local, delete_cmd,
delete_cmd_local): move same code to panel_operate(), make inline.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
handle_console_linux() passes the address of action to write() and intends
to send one byte of data (the LSB). On LE this works, but one BE machines
this sends the MSB which is always zero. Fix this by assigning the value
first to a char type, and use that instead.
Thanks Sven Schnelle <svens@stackframe.org> for the original patch.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The mc's built-in samba library which is used to access data across
smb links is taken from an old samba version.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (sftpfs_symlink): don't call sftpfs_fix_filename() for target file
bacause it breaks symlink: relative symlinks became an absolute one.
* (sftpfs_utime): set timestamps only, don't touch other attributes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
fish/utime: use `touch -h` to change the times of the link itself
rather than the file that the link points to. -h implies -c
and thus will not create any new files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
src/filemanager/file.c: reimplement erase_list using GQueue instead of
GSlist to get rid of walk each time through the whole linked list.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The old 'w' pointer became invalid after widget_destroy() call, so we need
to get the new widget directly after find_editor.
Found using PVS-Studio 7.14 with intermodular analysis mode.
Signed-off-by: Sergey Larin <cerg2010cerg2010@mail.ru>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use ~/.ssh/known_hosts file to verify server fingerprint
using ssh way:
$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ED25519 key fingerprint is SHA256:FzqKTNTroFuNUj1wUzSeV2x/1lpcESnT0ZRCmq5H6o8.
Are you sure you want to continue connecting (yes/no)? no
ssh: Host key verification failed.
$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ED25519 key fingerprint is SHA256:FzqKTNTroFuNUj1wUzSeV2x/1lpcESnT0ZRCmq5H6o8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
andrew@localhost's password:
Thanks the Curl project for the used code.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Yury V. Zaytsev <yury.zaytsev@moneymeets.com>
This vulnerability was discovered by AUT-milCERT during an audit of open
source software.
Initial changeset: set minimal version of libssh2 to 1.2.8.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The bug happens because MC tells the shell to perform a "cd" command,
and waits indefinitely for the command to complete. If the shell, for
some reason, cannot complete the "cd" command, MC just freezes
indefinitely.
This patch removes all instances of MC waiting indefinitely for "cd"
commands. Now, if the shell freezes while doing a "cd", MC will timeout
after 1 second, and just set the subshell state to ACTIVE. If the user
tries to run a command, they will get the error "The shell is already
running a command".
Some other stuff where MC waits on the shell if an error occurred is
also simplified.
In feed_subshell(), the timeout time is changed from 10 seconds to
1 second. Ten seconds seemed like far too long to wait.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Previous fix 443a8106f1
makes the command line inaccessible if mc runs with
disabled subshell (mc -u).
This commit fixes the command line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Sync with gnulib 9a38d499ca16f2f4304992eb1ab0894cd0b478e1.
Add "fuse.portal" as a dummy file system (used in flatpak
implementations).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
syntax.c:523:25: warning: Value stored to 'found_right' is never read [deadcode.DeadStores]
found_right = TRUE;
^ ~~~~
Found by Clang-11 analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
editsearch.c:915:13: warning: Value stored to 'i' is never read [deadcode.DeadStores]
i = edit->found_len = len;
^ ~~~~~~~~~~~~~~~~~~~~~
Found by Clang-11 analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
editdraw.c:536:5: warning: Value stored to 'color' is never read [deadcode.DeadStores]
color = edit_get_syntax_color (edit, b - 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found by Clang-11 analyzer.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_search_init): new function: initialization of search handler.
(edit_search_deinit): new function: deinitialization of search handler.
(edit_replace_cmd): use edit_search_init().
(edit_search_cmd): likewise.
(editcmd_dialog_search_show): use edit_search_init() and
edit_search_deinit().
(edit_search_options): move definition from editcmd_dialogs.c to editsearch.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(mcview_search_init): new function: initialization of search handler.
(mcview_search_deinit): new function: deinitialization of search handler.
(mcview_dialog_search): use mcview_search_init() and mcview_search_deinit().
(mcview_continue_search_cmd): use mcview_search_init().
(mcview_dialog_search): use mcview_search_deinit().
(mcview_search_options) move definition from dialogs.c to search.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
S_IWRITE is an obsolete synonym provided for BSD compatibility.
It can be safely replaced with S_IWUSR.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In the read_subshell_prompt() (src/subshell/common.c:1546) the first
call of select() returns 0. Therefore subshell_prompt is NULL.
NULL dereference is the cause of crash.
This commit isn't a real fix but just a workaround.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If some small dialog (error message or password request) is displayed
before main mc window gets visible, the segfault occures.
The cause of segfault is update of prompt that is not created yet.
(setup_mc, create_file_manager): move creation of event channel from
setup_mc() to create_file_manager(), make that after creation of all
file manager widgets.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...to fix segault introduced in daf21d8315.
Both actions MSG_INIT and MSG_DESTROY should be send to widget. In editor,
if file cannot be open, MSG_INIT isn't sent to, but MSG_DESTROY is. As a
result, a double free is occured in edit_dlg_deinit().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The build system runs configure script after switching to another branch
or changeset, which basically means that each git operation which
modifies HEAD will cause a full rebuild. This is highly annoying, in
particular during bisecting.
Solution:
Don't define version in config.h.
Add mc_version member to mc_global_t structure and use it instead of
VERSION macro.
Now only lib/global.c depends on MC version.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (local_utime): pass AT_SYMLINK_NOFOLLOW to utimensat() to update
timestamps of the link, rather than the file to which it refers.
* (move_file_file): preserve timestamp of the link.
* (copy_file_file): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...to free or not to free the string representation
of vfs_path_t object.
It allows to get rid of string duplication in following cases:
vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = g_strdup (vfs_path_as_str (vpath));
vfs_path_free (vpath);
Now we can write:
vfs_path_t *vpath;
char *path;
...
vpath = vfs_path_from_str (...);
path = vfs_path_free (vpath, FALSE);
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
src/keymap.[ch]: rename from src/keybind-defaults.[ch].
(keymap_load): rename from load_keymap_defs().
(keymap_free): rename from free_keymap_defs().
Move keymap load/save functions from src/setup.c to src/keymap.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
m4.include/vfs/mc-vfs-undelfs.m4: simplify test of required libraries.
Don't test Linux kernel specific header.
src/vfs/undelfs/undelfs.c: don't include Linux kernel specific header.
Use headers from ext2fs library only.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Return position of found macro in global variable macro_list or -1 if
nothing found.
(edit_delete_macro): related changes.
(edit_execute_macro): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>