https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b8e98c4e66ae8b73c06ba…
commit b8e98c4e66ae8b73c06ba323b7536728a267441a
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Aug 23 02:40:11 2018 +0900
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed Aug 22 19:40:11 2018 +0200
[NFSD] [TELNET] Remove the hardcoded directory paths C:\ReactOS
CORE-14747
---
base/services/nfsd/idmap.c | 24 ++++++++++++++++++++++++
base/services/nfsd/nfs41_daemon.c | 24 ++++++++++++++++++++++++
base/services/telnetd/telnetd.c | 22 +++++++++++++++-------
base/services/telnetd/telnetd.h | 1 +
4 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/base/services/nfsd/idmap.c b/base/services/nfsd/idmap.c
index 328f887028..18f44b9427 100644
--- a/base/services/nfsd/idmap.c
+++ b/base/services/nfsd/idmap.c
@@ -74,8 +74,10 @@ struct idmap_lookup {
};
+#ifndef __REACTOS__
/* configuration */
static const char CONFIG_FILENAME[] =
"C:\\ReactOS\\System32\\drivers\\etc\\ms-nfs41-idmap.conf";
+#endif
struct idmap_config {
/* ldap server information */
@@ -361,6 +363,9 @@ static int config_init(
struct idmap_config *config)
{
int status;
+#ifdef __REACTOS__
+ char config_path[MAX_PATH];
+#endif
/* load default values */
status = config_defaults(config);
@@ -369,10 +374,29 @@ static int config_init(
goto out;
}
+#ifdef __REACTOS__
+ if (GetSystemDirectoryA(config_path, ARRAYSIZE(config_path)))
+ {
+ StringCchCatA(config_path, ARRAYSIZE(config_path),
"\\drivers\\etc\\ms-nfs41-idmap.conf");
+ }
+ else
+ {
+ StringCchCopyA(config_path, ARRAYSIZE(config_path),
"C:\\ReactOS\\system32\\drivers\\etc\\ms-nfs41-idmap.conf");
+ }
+#endif
+
/* load configuration from file */
+#ifdef __REACTOS__
+ status = config_load(config, config_path);
+#else
status = config_load(config, CONFIG_FILENAME);
+#endif
if (status) {
+#ifdef __REACTOS__
+ eprintf("config_load('%s') failed with %d\n", config_path,
status);
+#else
eprintf("config_load('%s') failed with %d\n", CONFIG_FILENAME,
status);
+#endif
goto out;
}
out:
diff --git a/base/services/nfsd/nfs41_daemon.c b/base/services/nfsd/nfs41_daemon.c
index 7ad4ad1b12..1a8f2dfbbe 100644
--- a/base/services/nfsd/nfs41_daemon.c
+++ b/base/services/nfsd/nfs41_daemon.c
@@ -23,6 +23,9 @@
#include <process.h>
#include <tchar.h>
#include <stdio.h>
+#ifdef __REACTOS__
+#include <strsafe.h>
+#endif
#include <devioctl.h>
#include <lmcons.h> /* UNLEN for GetUserName() */
@@ -38,7 +41,9 @@
#define MAX_NUM_THREADS 128
DWORD NFS41D_VERSION = 0;
+#ifndef __REACTOS__
static const char FILE_NETCONFIG[] =
"C:\\ReactOS\\System32\\drivers\\etc\\netconfig";
+#endif
/* Globals */
char localdomain_name[NFS41_HOSTNAME_LEN];
@@ -163,10 +168,29 @@ typedef struct _nfsd_args {
static bool_t check_for_files()
{
FILE *fd;
+#ifdef __REACTOS__
+ char config_path[MAX_PATH];
+
+ if (GetSystemDirectoryA(config_path, ARRAYSIZE(config_path)))
+ {
+ StringCchCatA(config_path, ARRAYSIZE(config_path),
"\\drivers\\etc\\netconfig");
+ }
+ else
+ {
+ StringCchCopyA(config_path, ARRAYSIZE(config_path),
"C:\\ReactOS\\system32\\drivers\\etc\\netconfig");
+ }
+
+ fd = fopen(config_path, "r");
+#else
fd = fopen(FILE_NETCONFIG, "r");
+#endif
if (fd == NULL) {
+#ifdef __REACTOS__
+ fprintf(stderr,"nfsd() failed to open file '%s'\n",
config_path);
+#else
fprintf(stderr,"nfsd() failed to open file '%s'\n",
FILE_NETCONFIG);
+#endif
return FALSE;
}
fclose(fd);
diff --git a/base/services/telnetd/telnetd.c b/base/services/telnetd/telnetd.c
index 920ddea694..927d2862ad 100644
--- a/base/services/telnetd/telnetd.c
+++ b/base/services/telnetd/telnetd.c
@@ -367,12 +367,20 @@ static void RunShell(client_t *client)
STARTUPINFO si;
PROCESS_INFORMATION piProcInfo;
SECURITY_ATTRIBUTES saAttr;
+ char cmd_path[MAX_PATH];
+
+ if (!GetEnvironmentVariableA("COMSPEC", cmd_path, ARRAYSIZE(cmd_path)))
+ {
+ if (GetSystemDirectoryA(cmd_path, ARRAYSIZE(cmd_path)))
+ {
+ StringCchCatA(cmd_path, ARRAYSIZE(cmd_path), "\\cmd.exe");
+ }
+ else
+ {
+ StringCchCopyA(cmd_path, ARRAYSIZE(cmd_path),
"C:\\ReactOS\\system32\\cmd.exe");
+ }
+ }
- const char *name = "c:\\reactos\\system32\\cmd.exe";
- const char *cmd = NULL;
- //const char *name = "d:\\cygwin\\bin\\bash.exe";
- //const char *cmd = "d:\\cygwin\\bin\\bash.exe --login -i";
-
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
@@ -406,8 +414,8 @@ static void RunShell(client_t *client)
//si.dwFlags |= STARTF_USESHOWWINDOW;
//si.wShowWindow = SW_SHOW;
- if (!CreateProcess((LPSTR) name, // executable module
- (LPSTR) cmd, // command line
+ if (!CreateProcess(cmd_path, // executable module
+ NULL, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
diff --git a/base/services/telnetd/telnetd.h b/base/services/telnetd/telnetd.h
index 05132a3c86..67927df41f 100644
--- a/base/services/telnetd/telnetd.h
+++ b/base/services/telnetd/telnetd.h
@@ -9,6 +9,7 @@
#include <wincon.h>
#define _INC_WINDOWS
#include <winsock2.h>
+#include <strsafe.h>
/*
** macro definitions