Setting module directory as working directory of sshd deamon and forked processes

Doing so will allow sshd.exe to be launched from any directory - thereby
enabling sshd to be launched from SCM. With this change - following
works:
- sshd.exe install
- net start sshd
- net stop sshd
- sshd.exe uninstall
This commit is contained in:
Manoj Ampalam 2015-11-05 22:27:42 -08:00
parent 264509c2f4
commit c174b10d2c
1 changed files with 5 additions and 10 deletions

15
sshd.c
View File

@ -192,7 +192,6 @@ FIXME: GFPZR: Function stat() may be undeclared.
#include <tlhelp32.h> #include <tlhelp32.h>
char *fake_fork_args; char *fake_fork_args;
char *start_dir;
extern int logfd; extern int logfd;
extern int sfd_start; extern int sfd_start;
@ -1727,7 +1726,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
*/ */
b = CreateProcess(NULL, fake_fork_args, NULL, NULL, TRUE, b = CreateProcess(NULL, fake_fork_args, NULL, NULL, TRUE,
CREATE_NEW_PROCESS_GROUP, NULL, start_dir, CREATE_NEW_PROCESS_GROUP, NULL, NULL,
&si, &pi); &si, &pi);
if (!b) if (!b)
{ {
@ -2013,14 +2012,6 @@ main(int ac, char **av)
fake_fork_args = create_fake_fork_args(ac, av); fake_fork_args = create_fake_fork_args(ac, av);
{
int start_dir_len = GetCurrentDirectory(0, NULL);
start_dir = xmalloc(start_dir_len + 1);
GetCurrentDirectory(start_dir_len, start_dir);
}
#endif /* WIN32_FIXME */ #endif /* WIN32_FIXME */
#ifndef HAVE_SETPROCTITLE #ifndef HAVE_SETPROCTITLE
@ -2316,6 +2307,10 @@ main(int ac, char **av)
if (GetCurrentModulePath(basePath, PATH_SIZE) == 0) if (GetCurrentModulePath(basePath, PATH_SIZE) == 0)
{ {
#ifdef WIN32_FIXME
chdir(basePath);
#endif
/* /*
* Try './sshd_config' first. * Try './sshd_config' first.
*/ */