Re: exec: redefine search path
- From: ekb@xxxxxxxxxxxxxxxxxx (Eric Kenneth Bustad)
- Date: 14 Jul 2005 16:46:00 GMT
In article <m3br59jmo7.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Benjamin Riefenstahl <b.riefenstahl@xxxxxxxxxxxxxxxxxx> wrote:
}Hi Jan,
}
}
}Jan Harnisch writes:
}> under Windows, I am experiencing the problem that exec does not only
}> follow the PATH variable, but searches in c:\windows\system and
}> system32 first. [...]
}
}"It's not a bug, it's a feature" :-(. A feature of Windows to be
}exact. MSDN has this to say in the documentation of the relevant API
}(CreateProcess()):
}
}>>>>>>>
}If the file name does not contain a directory path, the system
}searches for the executable file in the following sequence:
}
} 1. The directory from which the application loaded.
}
} 2. The current directory for the parent process.
}
} 3. The 32-bit Windows system directory. Use the GetSystemDirectory
} function to get the path of this directory.
}
} Windows Me/98/95: The Windows system directory. Use the
} GetSystemDirectory function to get the path of this
} directory.
}
} 4. The 16-bit Windows system directory. There is no function that
} obtains the path of this directory, but it is searched. The name
} of this directory is System.
}
} 5. The Windows directory. Use the GetWindowsDirectory function to
} get the path of this directory.
}
} 6. The directories that are listed in the PATH environment
} variable.
}<<<<<<<<
}
}
}The easiest way around this behaviour is to use full paths to your
}programs. You can get these paths by searching for the program file
}in the directories in $::env(PATH) yourself, if you like.
}
}Note that similar rules go for DLLs (actually the first rule only
}makes sense when applied to DLLs in the first place, I think).
Sounds like a dangerous way to do things, but what else would I expect
from Microsoft? I'm more of a UNIX guy and I have *always* excluded
the current directory from PATH to protect against someone placing a
trojan horse in a directory that I happen to be running in.
On the other hand, searching the system directories first does protect
against trojans sneaking into other directories in $PATH.
--
= Eric Bustad, Norwegian bachelor programmer
.
- Follow-Ups:
- Re: exec: redefine search path
- From: Benjamin Riefenstahl
- Re: exec: redefine search path
- References:
- exec: redefine search path
- From: Jan Harnisch
- Re: exec: redefine search path
- From: Benjamin Riefenstahl
- exec: redefine search path
- Prev by Date: Re: installing tcl/tk 8.5a3 on windows xp
- Next by Date: Re: exec: redefine search path
- Previous by thread: Re: exec: redefine search path
- Next by thread: Re: exec: redefine search path
- Index(es):
Relevant Pages
|