Re: exec: redefine search path



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
.



Relevant Pages

  • Re: How to prepare a kernel driver pdb file for TraceView
    ... Do I need to do something else to get tracing turned on? ... Win16 system directory. ... BTW, my supposition as to why this is working for Eliyas and not you is that Eliyas is using Windows Vista, and you are using a non-Vista/Windows Server "Longhorn" version that ships an old dbghelp which does not meet the requriements of tracepdb.exe. ... SymSearch at 145 and 146. ...
    (microsoft.public.development.device.drivers)
  • Re: How to prepare a kernel driver pdb file for TraceView
    ... In the absense of manifests or .local files, the following algorithm is used to find DLLs ... Win16 system directory. ... BTW, my supposition as to why this is working for Eliyas and not you is that Eliyas is using Windows Vista, and you are using a non-Vista/Windows Server "Longhorn" version that ships an old dbghelp which does not meet the requriements of tracepdb.exe. ... 145 90 00037E40 SymSearch ...
    (microsoft.public.development.device.drivers)
  • Re: ERROR MESSAGE when installing MS-DOS or 16 bit progam.....
    ... Windows is on the BOOT drive. ... C:\ is the System Drive (ie where NTLDR is). ... > It means the root of your system directory, ... I keep getting that error message: ...
    (microsoft.public.windowsxp.general)
  • Re: ERROR MESSAGE when installing MS-DOS or 16 bit progam.....
    ... Windows is on the BOOT drive. ... C:\ is the System Drive (ie where NTLDR is). ... > It means the root of your system directory, ... I keep getting that error message: ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Question about offering solutions here (head up, MVPs!)
    ... I think that people think of searching Help as searching ... Ken Blake - Microsoft MVP Windows: ... of computer terminology that people are just plain afraid of. ... Teach them to fish instead of just giving them a fish. ...
    (microsoft.public.windowsxp.general)