Re: change dir using a menu command

I understand what you say, is there a better way to do such a thing,
I use for an smb mounter script, what the script does is use smbclient
to get a list of available shares, the user chooses one from a menu
(using 'dialog'), and it mounts the share (if the it is already mounted
then it jumps to the share's dir).
I wanted the %cd macro so I won't have to look for the folder every time
(sometimes the share names are changed).

  David E.

On 11:53 Fri 23 Jan     , Pavel Roskin wrote:
On Fri, 23 Jan 2004, David E wrote:

I did as you advised and added a "%cd" macro, I changed the code to do 2

1. add an environment variable: CDFILE=~/.mc_cdfile
  (I used sprintf(dir_file,"CDFILE=%s/.mc_cdfile", home_dir) in the
   subshell.c file)

I'm concerned about security aspects of such change.  You use a
predictable name.  An attacker could overwrite this file and put a
different directory name there.  It could be possible to make mc change to
a different directory without user noticing.  In particular, the name
could be on VFS.  This opens the possibility to make mc connect to a
remote server or open an archive.

Also, there is a possibility that two instances of mc will run commands
that will write to the same file.  It would be better to put process ID in
the name.

Do you really need to change to a directory that is not known before the
menu commands are executed?

Pavel Roskin

Web Hosting from $2.5/mo, Special Offers:
Free Email, Free WebMail, Free Banners Exchange:

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]