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>
Get rid of create and free of an empty array and string. Create macros
array and string if needed.
Fix typo.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(group_default_callback): NULLify list of widgets after destroy.
(dlg_default_callback): do nothing in MSG_INIT and MSG_DESTROY handlers.
(dlg_destroy): send MSG_DESTORY to dialog to allow it destroy it's
private data. MSG_DESTROY is a last message sent to dialog before
desctuction.
(edit_dialog_callback): use MSG_DESTROY instead of MSG_END to deinit
editor.
(midnight_callback): use MSG_DESTROY instead of MSG_DESTORY to deinit
file manager.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(etags_set_definition_hash): return GPtraArray.
(editcmd_dialog_select_definition_show): take GPtraArray.
(edit_get_match_keyword_cmd): sync with modified functions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Custom .zshrc file is ~/.local/share/mc/.zshrc.
If ZDOTDIR environment variable is not set, set it to ~/.local/share/mc
if a .zshrc is found there. It is the only way to point zsh to an other
rc file than the default.
Thanks Sebastian Gniazdowski <sgniazdowski@gmail.com> for the original
patch.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
After 8857423e4e zip archives opened with
an error:
file -L -z archive.zip: Bad system call
This caused by using /usr/bin/file with -z option, because seccomp (a
security sandbox) doesn't allow it..
Solution: use -S option together with -z one.
The file command accepts the -S option since 5.33.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Add "Follow symlinks" checkbox. Default state is off (following
current hardcoded behavior).
Signed-off-by: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_collect_completion_from_one_buffer): new function. Main loop of
completion searching is here now.
(edit_collect_completions): use edit_collect_completion_from_one_buffer().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_collect_completions): return GQueue. Use GQueue inside.
Do not return an empty queue, create it if needed only.
(edit_complete_word_cmd): Use GQueue inside. Ged rid of limitation
of completions count. Rename variable.
(editcmd_dialog_completion_show): take GQueue. Rename and reorder
arguments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Initial step: refactoring.
(edit_collect_completions_get_current_word): return GString. Get rid of
allocate and free an empty string, create string if needed instead.
Reduce variable scope.
(edit_collect_completions): related changes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(execute_menu_command): prepare terminal to run system() and restore
after.
(user_menu_cmd): fix comment.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(do_update_prompt): fix NULL dereference. In case of running mc
as standalone editor/viewer/diffviewer, the subshell_prompt variable
is NULL.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If function failed, fail early.
Found by Coverity.
Coverity id #32538.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Statement cannot be true at this state.
Found by Coverity.
Coverity id #32572.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...because the pointer can't be NULL.
Found by Coverity.
Coverity id #313667.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...because the pointer can't be NULL.
Found by Coverity.
Coverity id #110819.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If c_filesizes[0] is greater than 0x7fff implicit sign extension will happen on bit shift.
Found by Coverity.
Coverity id #32611.
Coverity id #32612.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Handle open failure properly.
Found by Coverity.
Coverity id #32608.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Found by Coverity.
Coverity id #32627.
Coverity id #313665.
Covertiy id #313669.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
fallthrough annotation does not directly precede switch label.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Sync with gnulib dd1fc46be12d671c1a9d9dc5a6fa8c766e99aa2f.
Sync "remote" file systems from stat.c in coreutils.
Note we only consider file systems that do not use host:resource
mount source. I.e. those that don't generally use a colon when
mounting, as that case is already considered. Searching for
"<fstype> /etc/fstab" was informative for identifying these.
The full list of "remote" file systems in coreutils is currently:
acfs afs ceph cifs coda fhgfs fuseblk fusectl
gfs gfs2 gpfs ibrix k-afs lustre novell nfs nfsd
ocfs2 panfs prl_fs smb smb2 snfs vboxsf vmhgfs vxfs
Note also we do not include virtual machine file systems,
as even though they're remote to the current kernel,
they are generally not distributed to separate hosts.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(chdir_other_panel): use result of change_panel() instead of global
variable current_panel. (chdir_to_readlink): likewise.
(tree_chdir_sel): likewise.
(quick_view_cmd): mark that we don't use the result of change_panel().
(midnight_execute_cmd): likewise.
(panel_mouse_callback): likewise.
(tree_mouse_callback): likewise.
(mcview_mouse_callback): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
On Linux >= 5.1, MC sometimes shows empty directpries on mounted CIFS
shares. Rereading directory restores the directory content.
(local_opendir): reopen directory, if first readdir() returns NULL and
errno == EINTR.
Signed-off-by: Andrij Abyzov <aabyzov@slb.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
In the function vfs_expire(), curr_time and exp_time are declared
guint64. curr_time is initialised with a timestamp and exp_time
with this timestamp minus vfs_timeout seconds. Later there is if
(stamping->time <= exp_time). Prior to commit
a94dd7d2de curr_time was initialised with
a value larger than vfs_timeout seconds, so everything was fine. This
commit changed the initialisation to a timer starting when mc is
started. So for the first vfs_timeout seconds, the result of the
subtraction is negative, but it is a guint64, so we just get a VERY
large unsigned value and the if (stamping->time <= exp_time) is always
true. So mc thinks the vfs hasn't been used recently and goes into an
infinite loop.
If one opens a .rpm file with mc and goes into the CONTENTS.cpio and
then tries to go into the .tar.gz there (this is the usual structure of
a .rpm) after waiting vfs_timeout seconds, everything is fine. However,
before vfs_timeout seconds, mc hangs.
Solution: use g_get_real_time() instead of mc_timer_elapsed().
Thanks nvwarr at hotmail.com for finding out the reason for this bug.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Avoid limitation of file name length.
(vfs_dirent): redefined to use instead of standard "struct direct"
to hold file name of any length.
(vfs_class::readdir): return newly allocated vfs_dirent structure.
Related changes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This can be used for running a clipboard script (from a virtual terminal)
that autodetects (or requests from sytemctl) the proper values of DISPLAY
and XAUTHORITY without the need of exporting these variables to the whole
virtual terminal session.
(clipboard_file_to_ext_clip): don't test DISPLAY environment variable.
(clipboard_file_from_ext_clip): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (extfs_open_archive): skip leading ./ in file names. extfs plug-ins
are added leading ./ to handle files with name started with space.
* (extfs_cmd): skip leading ./ added in name_quote(). ./ is added to
handle files with name started with dash.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Move declaration of {advanced_chown,chattr,chmod,chown}_cmd() into cmd.h.
Delete src/filemanager/{achown,chattr,chmod,chown}.h
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
call 'file' with -z switch to enable getting the type of compressed files,
and use that capability extensively.
the /logs?/ hacks in ext.d/text.sh need to remain for the time being, as
file -z doesn't handle .lz4 files as encapsulated content.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
the changelog clearly states that the position is now returned as a
character offset.
amends ff0fc17a.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
when the command buffer started with a valid option to the "echo"
command, weird things would happen. use "printf" instead, which doesn't
have this problem. this affected only the bash and zsh code paths.
amends ff0fc17a.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
this avoids inadvertent whitespace normalization (compression and
trimming), which is annoying and additionally invalidates the cursor
position.
for bash and zsh that meant quoting the variable expansion, while for
fish it meant removing the pointless indirection through echo.
for bash we had to introduce an indirection through a function, as there
is apparently no way to get the quoting right inside the binding. zsh
already had such an indirection - maybe for the same reason?
amends ff0fc17a.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
move binding commands out of the fish_prompt function definition, use
consistent command separators, and remove excess backslashes from the
bindings.
amends ff0fc17a.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Subshell: don't setup command line promt if MC is run as standalone
editor/viewer/diffviewer.
Fix ff0fc17ae3.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
How to reproduce:
Use tsch as your shell.
ctrl-o
ctrl-c
ctrl-o
mc gives the error:
The Commander can't change to the directory that the subshell claims you
are in. Perhaps you have deleted your working directory, or given
yourself extra permissions with the "su" command?
This commit is really simple workaround that makes the problem go away.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commi allows the user to start typing a command in the MC's command
line, and then continue typing it in the subshell, or to start typing a
command in the subshell, and then finish typing it in the MC's command
line.
It also fixes#2269 and #2110, bugs in which mc can unexpectedly execute
commands without the user's permission.
The new feature works with bash4, zsh, and fish. The bugfix works on all
shells.
How to test the feature:
Run mc
Type any command in the command line, but don't hit enter.
Press Ctrl-O.
The command you typed will show up in the subshell.
Type any command in the subshell, but don't hit enter.
Press Ctrl-O.
The command you typed will show up in the command line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
After ef5f1fa3eb ctrl-i stopped working
on some terminals including native Linux console.
To fix this, add default binging ctrl-i shortcut to ChangePanel action.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (do_compute_dir_size): fix directory size calculation.
Use mc_lstat() if "Follow links" option is set, mc_stat() otherwise.
* (single_dirsize_cmd): fix compute_dir_size() call.
* (dirsize_cmd): likewise.
* (panel_compute_totals): process symlink to directory as directory if
follow_symlink is set.
* (panel_operate_init_totals): process symlink to directory as
directory if "Follow links" option is set.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (find_cmd): remove.
* (find_file): rename to find_cmd() and move declaration to cmd.h.
* find.h: remove.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (complete): rename to input_complete() and move declaration to
input.h.
* input_complete.h: remove.
* (input_free_completions): rename to input_complete_free() and move
definition to input_complete.c.
* lib/widget/input_complete.c: rename variables and function from
query_* to complete_*.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(panel_operate_init_totals): set ctx->progress_totals_computed to TRUE
in case of copy/move operation for single file.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (widget_destroy): new API to destroy widget.
* (group_del_widget): rename to group_remove_widget. Don't destroy
widget after remove it from group.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
WGroup is the base widget for complex objects such as windows, dialog
windows, etc.
Initial steps:
* move widget list of dialog into WGroup class;
* inherit WGroup from Widget;
* inherit WDialog from WGroup.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
src/filemanager/mountlist.c: consider AFS filesystems as remote.
Treat mounts of type 'afs' (OpenAFS, kernel kafs) and 'auristorfs'
(AuriStorFS) as remote.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Don't show message "GNU Midnight Commander is already running on this
terminal. Subshell support will be disabled." if standalone
mcedit/mcview/mcdiffview is run from mc. Show this message only in case
of mc run from another mc, as was before commit
41abcbf706 (ticket #3380).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (widget_destroy): new API to destroy widget.
* (del_widget): don't destroy widget after remove it from dialog.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Embedding the configure time options into the executable can lead to
non-reproducible builds, since configure options often have embedded
paths. Add a configure time option to control if the configure args are
embedded so this can be disabled.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Each VSF entry is added to VFS using vfs_s_insert_entry() via
g_list_append(). For long lists, a lot of walking through entire list
is performed. To get rid that, change type of vfs_s_inode::subdir from
GList to GQueue.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix regression introduced in 37ffc02422.
(tty_got_winch): don't read FIFO, just check whether it os empty or not.
It can be called many times without lost of info about SIGWINCH raises.
(tty_flush_winch): read from FIFO to make it empty.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
autogen.sh generates a bunch of files aren't .gitignore'd yet.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use dir_list callback to show rotaing dash.
Now src/filenamager/dir.c does not depend on the Widget subsystem.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use pipe to collect consecutive raised SIGWINCH events.
Then handle multiple events at a time treating them
as a single one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...from temporary directory.
Initial step: don't insert "." and ".." to file/directory tree while
reading archive.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Prepare to support CK_Delete in editor and viewer history.
The filepos file contains file positions and bookmarks. We must keep
them.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Based on patch by Filip Sefrna <fsefrna@gmail.com>
added action 'EditorHistory' for call history dialog.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
If SSH server does not support cleartext tunneled password
authentication and only 'keyboard interactive' authentication
instead, then we need to use different authentication
function along with a interactive callback.
Signed-off-by: Adam Majer <amajer@suse.de>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Variation 1:
Steps to reproduce:
* create empty .iso file (touch foo.iso)
* run 'mc' and press enter on empty .iso
Expected result: some error about invalid file format (sililar to what
F3 view would yield).
Actual result: mc elters a file as if it would be empty valid file.
Variation 2:
Steps to reproduce:
* pick valid .iso file
* deinstall all helper tools that handle .sio (isoinfo, xorriso, etc.)
* run 'mc' and press enter on empty .iso
Expected result: some error about invalid file format (sililar to what
F3 view would yield)
Actual result: mc enters a file as if it would be empty valid file
Variation 2 is especially confusing for users as it does not hint them
that they should install a tool to get it working. They just observe
silently broken behaviour.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...to fix the warning:
sfs.c:281:10: warning: declaration of 'sfs_info' shadows a global declaration [-Wshadow]
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>