Author: sedwards
Date: Mon Dec 1 12:34:15 2008
New Revision: 37799
URL:
http://svn.reactos.org/svn/reactos?rev=37799&view=rev
Log:
I hope I did not screw up the propset...
Simple telnet daemon, I found, hacked in to a service.
Its wrong, I know, humor me, it works, someone more
interested can finish this off and follow the spec.txt
Added:
trunk/rosapps/applications/sysutils/telnetd/
trunk/rosapps/applications/sysutils/telnetd/serviceentry.c (with props)
trunk/rosapps/applications/sysutils/telnetd/spec.txt (with props)
trunk/rosapps/applications/sysutils/telnetd/telnetd.c (with props)
trunk/rosapps/applications/sysutils/telnetd/telnetd.h (with props)
trunk/rosapps/applications/sysutils/telnetd/telnetd.vcproj (with props)
Added: trunk/rosapps/applications/sysutils/telnetd/serviceentry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/teln…
==============================================================================
--- trunk/rosapps/applications/sysutils/telnetd/serviceentry.c (added)
+++ trunk/rosapps/applications/sysutils/telnetd/serviceentry.c [iso-8859-1] Mon Dec 1
12:34:15 2008
@@ -1,0 +1,84 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: services/TelnetD/TelnetD.c
+ * PURPOSE: Printer spooler
+ * PROGRAMMER: Eric Kohl
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "telnetd.h"
+#define DPRINT printf
+
+/* GLOBALS ******************************************************************/
+
+#define SERVICE_NAME TEXT("TelnetD")
+
+SERVICE_STATUS_HANDLE ServiceStatusHandle;
+
+
+/* FUNCTIONS *****************************************************************/
+
+
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+ DWORD dwEventType,
+ LPVOID lpEventData,
+ LPVOID lpContext)
+{
+ switch (dwControl)
+ {
+ case SERVICE_CONTROL_STOP:
+ case SERVICE_CONTROL_SHUTDOWN:
+ return ERROR_SUCCESS;
+
+ default :
+ return ERROR_CALL_NOT_IMPLEMENTED;
+ }
+}
+
+
+
+static VOID CALLBACK
+ServiceMain(DWORD argc, LPTSTR *argv)
+{
+ UNREFERENCED_PARAMETER(argc);
+ UNREFERENCED_PARAMETER(argv);
+
+ DPRINT("ServiceMain() called\n");
+
+ ServiceStatusHandle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
+ ServiceControlHandler,
+ NULL);
+
+ DPRINT("ServiceMain() done\n");
+}
+
+
+int
+wmain(int argc, WCHAR *argv[])
+{
+ SERVICE_TABLE_ENTRY ServiceTable[2] =
+ {
+ {SERVICE_NAME, ServiceMain},
+ {NULL, NULL}
+ };
+
+ UNREFERENCED_PARAMETER(argc);
+ UNREFERENCED_PARAMETER(argv);
+
+ DPRINT("TelnetD: main() started\n");
+
+ StartServiceCtrlDispatcher(ServiceTable);
+
+ telnetd_main();
+
+ DPRINT("TelnetD: main() done\n");
+
+ ExitThread(0);
+
+ return 0;
+}
+
+/* EOF */
Propchange: trunk/rosapps/applications/sysutils/telnetd/serviceentry.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rosapps/applications/sysutils/telnetd/spec.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/teln…
==============================================================================
--- trunk/rosapps/applications/sysutils/telnetd/spec.txt (added)
+++ trunk/rosapps/applications/sysutils/telnetd/spec.txt [iso-8859-1] Mon Dec 1 12:34:15
2008
@@ -1,0 +1,8 @@
+Here is the short product spec
+
+1. Fix the service stuff
+2. Use the event log
+3. Do real authentication ( I suspect you could hack PAM-GINA to do remote auth)
+4. Properly Set the environment
+
+
Propchange: trunk/rosapps/applications/sysutils/telnetd/spec.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rosapps/applications/sysutils/telnetd/telnetd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/teln…
==============================================================================
--- trunk/rosapps/applications/sysutils/telnetd/telnetd.c (added)
+++ trunk/rosapps/applications/sysutils/telnetd/telnetd.c [iso-8859-1] Mon Dec 1 12:34:15
2008
@@ -1,0 +1,680 @@
+/*
+ * File: TelnetD.c
+ *
+ * Abstract: a simple telnet 'daemon' for Windows hosts.
+ *
+ * Compiled & run successfully using MSVC 5.0 under Windows95 (requires
+ * Winsock2 update) and Windows98 and MSVC 6.0 under WindowsNT4
+ *
+ * Compiler options : no special options needed
+ * Linker options : add wsock32.lib or ws2_32.lib
+ *
+ * Written by fred.van.lieshout 'at' zonnet.nl
+ * Use freely, no copyrights.
+ * Use Linux.
+ *
+ * TODO:
+ * - access control
+ * - will/won't handshake
+ * - (run as) Windows NT service
+ */
+
+#include <stdio.h>
+#include <windows.h>
+
+/*
+** macro definitions
+*/
+#define TELNET_PORT (23)
+
+#define BUFSIZE (4096)
+#define USERID_SIZE (64)
+#define CTRLC (3)
+#define BS (8)
+#define CR (13)
+#define LF (10)
+#define DEL (127)
+
+#define IAC (255)
+#define DONT (254)
+#define WONT (253)
+#define DO (252)
+#define WILL (251)
+#define ECHO (1)
+
+#define HANDSHAKE_TIMEOUT (3)
+
+/*
+** types
+*/
+
+typedef struct client_s
+{
+ char userID[USERID_SIZE];
+ int socket;
+ BOOLEAN bTerminate;
+ BOOLEAN bReadFromPipe;
+ BOOLEAN bWriteToPipe;
+ HANDLE hProcess;
+ DWORD dwProcessId;
+ HANDLE hChildStdinWr;
+ HANDLE hChildStdoutRd;
+} client_t;
+
+typedef enum
+{
+ NoEcho = 0,
+ Echo = 1,
+ Password = 2
+} EchoMode;
+
+/*
+** Local data
+*/
+
+static BOOLEAN bShutdown = 0;
+static BOOLEAN bSocketInterfaceInitialised = 0;
+
+static int sock;
+
+/*
+** Forward function declarations
+*/
+static BOOL WINAPI Cleanup(DWORD dwControlType);
+static void WaitForConnect(void);
+static BOOLEAN StartSocketInterface(void);
+static void CreateSocket(void);
+static void UserLogin(int client_socket);
+static DWORD WINAPI UserLoginThread(LPVOID);
+static int DoTelnetHandshake(int sock);
+static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo);
+static void RunShell(client_t *client);
+static BOOL CreateChildProcess(const char *);
+static DWORD WINAPI MonitorChildThread(LPVOID);
+static DWORD WINAPI WriteToPipeThread(LPVOID);
+static DWORD WINAPI ReadFromPipeThread(LPVOID);
+static void TerminateShell(client_t *client);
+static VOID ErrorExit(LPTSTR);
+
+
+/*
+** main
+*/
+DWORD telnetd_main()
+{
+ SetConsoleCtrlHandler(Cleanup, 1);
+
+ if (!StartSocketInterface()) {
+ ErrorExit("Unable to start socket interface\n");
+ }
+
+ CreateSocket();
+
+ while(!bShutdown) {
+ WaitForConnect();
+ }
+
+ WSACleanup();
+ return 0;
+}
+
+/*
+** Cleanup
+*/
+static BOOL WINAPI Cleanup(DWORD dwControlType)
+{
+ if (bSocketInterfaceInitialised) {
+ printf("Cleanup...\n");
+ WSACleanup();
+ }
+ return 0;
+}
+
+/*
+** StartSocketInterface
+*/
+static BOOLEAN StartSocketInterface(void)
+{
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ wVersionRequested = MAKEWORD( 2, 0 );
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ printf("requested winsock version not supported\n");
+ return 0;
+ }
+
+ bSocketInterfaceInitialised = 1; /* for ErrorExit function */
+
+ if ( wsaData.wVersion != wVersionRequested) {
+ printf("requested winsock version not supported\n");
+ return 0;
+ }
+ printf("TelnetD, using %s\n", wsaData.szDescription);
+ return 1;
+}
+
+/*
+** CreateSocket
+*/
+static void CreateSocket(void)
+{
+ struct sockaddr_in sa;
+
+ sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sock < 0) {
+ ErrorExit("Cannot create socket");
+ }
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = INADDR_ANY;
+ sa.sin_port = htons(TELNET_PORT);
+ if (bind(sock, (struct sockaddr*) &sa, sizeof(sa)) != 0) {
+ ErrorExit("Cannot bind address to socket");
+ }
+}
+
+/*
+** WaitForConnect
+*/
+static void WaitForConnect(void)
+{
+ struct sockaddr_in sa;
+ int new_sock;
+
+ if (listen(sock, 1) < 0) {
+ ErrorExit("Cannot listen on socket");
+ }
+
+ if ((new_sock = accept(sock, (struct sockaddr*) &sa, NULL)) < 0) {
+ fprintf(stderr, "Failed to accept incoming call\n");
+ } else {
+ printf("user connected on socket %d, port %d, address %lx\n", new_sock,
+ htons(sa.sin_port), sa.sin_addr.s_addr);
+ UserLogin(new_sock);
+ }
+}
+
+
+/*
+** Function: UserLogin
+*/
+static void UserLogin(int client_socket)
+{
+ DWORD threadID;
+ client_t *client = malloc(sizeof(client_t));
+
+ if (client == NULL) {
+ ErrorExit("failed to allocate memory for client");
+ }
+
+ client->socket = client_socket;
+ CreateThread(NULL, 0, UserLoginThread, client, 0, &threadID);
+}
+
+/*
+** Function: UserLoginThread
+*/
+static DWORD WINAPI UserLoginThread(LPVOID data)
+{
+ client_t *client = (client_t *) data;
+ char welcome[256];
+ char hostname[64] = "Unknown";
+ char *pwdPrompt = "\r\npass:";
+ char *logonPrompt = "\r\nLogin OK, please wait...";
+ char *byebye = "\r\nWrong! bye bye...\r\n";
+ char userID[USERID_SIZE];
+ char password[USERID_SIZE];
+ int received;
+ char *terminator;
+
+ if (DoTelnetHandshake(client->socket)) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ }
+
+ gethostname(hostname, sizeof(hostname));
+ sprintf(welcome, "\r\nWelcome to %s, please identify yourself\r\n\r\nuser:",
hostname);
+
+ if (send(client->socket, welcome, strlen(welcome), 0) < 0) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ }
+ received = ReceiveLine(client->socket, userID, sizeof(userID), Echo );
+ if (received < 0) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ } else if (received) {
+ if ((terminator = strchr(userID, CR)) != NULL) {
+ *terminator = '\0';
+ }
+ }
+
+ if (send(client->socket, pwdPrompt, strlen(pwdPrompt), 0) < 0) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ }
+ received = ReceiveLine(client->socket, password, sizeof(password), Password );
+ if (received < 0) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ } else if (received) {
+ if ((terminator = strchr(password, CR)) != NULL) {
+ *terminator = '\0';
+ }
+ }
+
+
+ /* TODO: do authentication here */
+
+
+ printf("User '%s' logged on\n", userID);
+ strcpy(client->userID, userID);
+ if (send(client->socket, logonPrompt, strlen(logonPrompt), 0) < 0) {
+ closesocket(client->socket);
+ free(client);
+ return 0;
+ }
+ RunShell(client);
+ return 0;
+}
+
+/*
+** Function: DoTelnetHandshake
+*/
+static int DoTelnetHandshake(int sock)
+{
+ int retval;
+ int received;
+ fd_set set;
+ struct timeval timeout = { HANDSHAKE_TIMEOUT, 0 };
+ unsigned char will_echo[3] = { IAC, WILL, ECHO };
+ unsigned char client_reply[256];
+
+ if (send(sock, (const char *) will_echo, sizeof(will_echo), 0) < 0) {
+ return -1;
+ }
+
+ /* Now wait for client response (and ignore it) */
+ FD_ZERO(&set);
+ FD_SET(sock, &set);
+
+ do {
+ retval = select(0, &set, NULL, NULL, &timeout);
+ /* check for error */
+ if (retval < 0) {
+ return -1;
+ /* check for timeout */
+ } else if (retval == 0) {
+ return 0;
+ }
+ /* no error and no timeout, we have data in our sock */
+ received = recv(sock, client_reply, sizeof(client_reply), 0);
+ if (received <= 0) {
+ return -1;
+ }
+ } while (retval);
+
+ return 0;
+}
+
+/*
+** Function: ReceiveLine
+**
+** Abstract: receive until timeout or CR
+** In : sock, len
+** Out : buffer
+** Result : int
+** Pre : 'sock' must be valid socket
+** Post : (result = the number of bytes read into 'buffer')
+** OR (result = -1 and error)
+*/
+static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo)
+{
+ int i = 0;
+ int retval;
+ fd_set set;
+ struct timeval timeout = { 0, 100000 };
+ char del[3] = { BS, ' ', BS };
+ char asterisk[1] = { '*' };
+
+ FD_ZERO(&set);
+ FD_SET(sock, &set);
+
+ memset(buffer, '\0', len);
+
+ do {
+ /* When we're in echo mode, we do not need a timeout */
+ retval = select(0, &set, NULL, NULL, (echo ? NULL : &timeout) );
+ /* check for error */
+ if (retval < 0) {
+ return -1;
+ /* check for timeout */
+ } else if (retval == 0) {
+ /* return number of characters received so far */
+ return i;
+ }
+ /* no error and no timeout, we have data in our sock */
+ if (recv(sock, &buffer[i], 1, 0) <= 0) {
+ return -1;
+ }
+ if ((buffer[i] == '\0') || (buffer[i] == LF)) {
+ /* ignore null characters and linefeeds from DOS telnet clients */
+ buffer[i] = '\0';
+ } else if ((buffer[i] == DEL) || (buffer[i] == BS)) {
+ /* handle delete and backspace */
+ buffer[i] = '\0';
+ if (echo) {
+ if (i > 0) {
+ i--;
+ buffer[i] = '\0';
+ if (send(sock, del, sizeof(del), 0) < 0) {
+ return -1;
+ }
+ }
+ } else {
+ buffer[i] = BS; /* Let shell process handle it */
+ i++;
+ }
+ } else {
+ /* echo typed characters */
+ if (echo == Echo && send(sock, &buffer[i], 1, 0) < 0) {
+ return -1;
+ } else if (echo == Password && send(sock, asterisk, sizeof(asterisk), 0)
< 0) {
+ return -1;
+ }
+ if (buffer[i] == CR) {
+ i++;
+ buffer[i] = LF; /* append LF for DOS command processor */
+ i++;
+ return i;
+ }
+
+ i++;
+ }
+ } while (i < len);
+
+ return i;
+}
+
+/*
+** Function: RunShell
+*/
+static void RunShell(client_t *client)
+{
+ DWORD threadID;
+ HANDLE hChildStdinRd;
+ HANDLE hChildStdinWr;
+ HANDLE hChildStdoutRd;
+ HANDLE hChildStdoutWr;
+ STARTUPINFO si;
+ PROCESS_INFORMATION piProcInfo;
+ SECURITY_ATTRIBUTES saAttr;
+
+ const char *name = "c:\\windows\\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;
+
+ // Create a pipe for the child process's STDOUT.
+ if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
+ ErrorExit("Stdout pipe creation failed\n");
+
+ if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
+ ErrorExit("Stdin pipe creation failed\n");
+
+
+ client->bTerminate = FALSE;
+ client->bWriteToPipe = TRUE;
+ client->bReadFromPipe = TRUE;
+ client->hChildStdinWr = hChildStdinWr;
+ client->hChildStdoutRd = hChildStdoutRd;
+
+
+ // Create the child process (the shell)
+ printf("Creating child process...\n");
+
+ ZeroMemory( &si, sizeof(STARTUPINFO) );
+ si.cb = sizeof(STARTUPINFO);
+
+ si.dwFlags = STARTF_USESTDHANDLES;
+ si.hStdInput = hChildStdinRd;
+ si.hStdOutput = hChildStdoutWr;
+ si.hStdError = hChildStdoutWr;
+
+ //si.dwFlags |= STARTF_USESHOWWINDOW;
+ //si.wShowWindow = SW_SHOW;
+
+ if (!CreateProcess((LPSTR) name, // executable module
+ (LPSTR) cmd, // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ //DETACHED_PROCESS + // creation flags
+ CREATE_NEW_PROCESS_GROUP,
+ NULL, // use parent's environment
+ NULL, // use parent's current directory
+ &si, // startup info
+ &piProcInfo)) {
+ ErrorExit("Create process failed");
+ }
+
+ client->hProcess = piProcInfo.hProcess;
+ client->dwProcessId = piProcInfo.dwProcessId;
+
+ printf("New child created (groupid=%lu)\n", client->dwProcessId);
+
+ // No longer need these in the parent...
+ if (!CloseHandle(hChildStdoutWr))
+ ErrorExit("Closing handle failed");
+ if (!CloseHandle(hChildStdinRd))
+ ErrorExit("Closing handle failed");
+
+ CreateThread(NULL, 0, WriteToPipeThread, client, 0, &threadID);
+ CreateThread(NULL, 0, ReadFromPipeThread, client, 0, &threadID);
+ CreateThread(NULL, 0, MonitorChildThread, client, 0, &threadID);
+}
+
+
+/*
+** Function: MonitorChildThread
+**
+** Abstract: Monitor the child (shell) process
+*/
+static DWORD WINAPI MonitorChildThread(LPVOID data)
+{
+ DWORD exitCode;
+ client_t *client = (client_t *) data;
+
+ printf("Monitor thread running...\n");
+
+ WaitForSingleObject(client->hProcess, INFINITE);
+
+ GetExitCodeProcess(client->hProcess, &exitCode);
+ printf("Child process terminated with code %d\n", exitCode);
+
+ /* signal the other threads to give up */
+ client->bTerminate = TRUE;
+
+ Sleep(500);
+
+ CloseHandle(client->hChildStdoutRd);
+ CloseHandle(client->hChildStdinWr);
+ CloseHandle(client->hProcess);
+
+ closesocket(client->socket);
+
+ printf("Waiting for all threads to give up..\n");
+
+ while (client->bWriteToPipe || client->bReadFromPipe) {
+ printf(".");
+ fflush(stdout);
+ Sleep(1000);
+ }
+
+ printf("Cleanup for user '%s'\n", client->userID);
+ free(client);
+ return 0;
+}
+
+/*
+** Function: WriteToPipeThread
+**
+** Abstract: read data from the telnet client socket
+** and pass it on to the shell process.
+*/
+static DWORD WINAPI WriteToPipeThread(LPVOID data)
+{
+ int iRead;
+ DWORD dwWritten;
+ CHAR chBuf[BUFSIZE];
+ client_t *client = (client_t *) data;
+
+ while (!client->bTerminate) {
+ iRead = ReceiveLine(client->socket, chBuf, BUFSIZE, FALSE);
+ if (iRead < 0) {
+ printf("Client disconnect\n");
+ break;
+ } else if (iRead > 0) {
+ if (strchr(chBuf, CTRLC)) {
+ GenerateConsoleCtrlEvent(CTRL_C_EVENT, client->dwProcessId);
+ }
+ if (send(client->socket, chBuf, iRead, 0) < 0) {
+ printf("error writing to socket\n");
+ break;
+ }
+ if (! WriteFile(client->hChildStdinWr, chBuf, (DWORD) iRead, &dwWritten,
NULL)) {
+ printf("Error writing to pipe\n");
+ break;
+ }
+ }
+ }
+
+ if (!client->bTerminate) {
+ TerminateShell(client);
+ }
+
+ printf("WriteToPipeThread terminated\n");
+
+ client->bWriteToPipe = FALSE;
+ return 0;
+}
+
+/*
+** Function: ReadFromPipeThread
+**
+** Abstract: Read data from the shell's stdout handle and
+** pass it on to the telnet client socket.
+*/
+static DWORD WINAPI ReadFromPipeThread(LPVOID data)
+{
+ DWORD dwRead;
+ DWORD dwAvail;
+ CHAR chBuf[BUFSIZE];
+ CHAR txBuf[BUFSIZE*2];
+ DWORD from,to;
+ char warning[] = "warning: rl_prep_terminal: cannot get terminal settings";
+
+ client_t *client = (client_t *) data;
+
+ while (!client->bTerminate && client->bWriteToPipe) {
+ // Since we do not want to block, first peek...
+ if (PeekNamedPipe(client->hChildStdoutRd, NULL, 0, NULL, &dwAvail, NULL) == 0)
{
+ printf("Failed to peek in pipe\n");
+ break;
+ }
+ if (dwAvail) {
+ if( ! ReadFile( client->hChildStdoutRd, chBuf, BUFSIZE, &dwRead, NULL) ||
+ dwRead == 0) {
+ printf("Failed to read from pipe\n");
+ break;
+ }
+ for (from=0, to=0; from<dwRead; from++, to++) {
+ txBuf[to] = chBuf[from];
+ if (txBuf[to] == '\n') {
+ txBuf[to] = '\r';
+ to++;
+ txBuf[to] = '\n';
+ }
+ }
+ if (send(client->socket, txBuf, to, 0) < 0) {
+ printf("error writing to socket\n");
+ break;
+ }
+ }
+ Sleep(100); /* Hmmm, oh well... what the heck! */
+ }
+
+ if (!client->bTerminate) {
+ TerminateShell(client);
+ }
+
+ printf("ReadFromPipeThread terminated\n");
+
+ client->bReadFromPipe = FALSE;
+ return 0;
+}
+
+/*
+** TerminateShell
+*/
+static void TerminateShell(client_t *client)
+{
+ DWORD exitCode;
+ DWORD dwWritten;
+ char stop[] = "\003\r\nexit\r\n"; /* Ctrl-C + exit */
+
+ GetExitCodeProcess(client->hProcess, &exitCode);
+ if (exitCode == STILL_ACTIVE) {
+ printf("user shell still active, send Ctrl-Break to group-id %lu\n",
client->dwProcessId );
+
+ if (!GenerateConsoleCtrlEvent( CTRL_BREAK_EVENT, client->dwProcessId )) {
+ printf("Failed to send Ctrl_break\n");
+ }
+
+ Sleep(500);
+
+ if (!GenerateConsoleCtrlEvent( CTRL_C_EVENT, client->dwProcessId )) {
+ printf("Failed to send Ctrl_C\n");
+ }
+
+ Sleep(500);
+
+ if (! WriteFile(client->hChildStdinWr, stop, sizeof(stop), &dwWritten, NULL))
{
+ printf("Error writing to pipe\n");
+ }
+
+ Sleep(500);
+
+ GetExitCodeProcess(client->hProcess, &exitCode);
+ if (exitCode == STILL_ACTIVE) {
+ printf("user shell still active, attempt to terminate it now...\n");
+ TerminateProcess(client->hProcess, 0);
+ }
+ }
+}
+
+/*
+** ErrorExit
+*/
+static VOID ErrorExit (LPTSTR lpszMessage)
+{
+ fprintf(stderr, "%s\n", lpszMessage);
+ if (bSocketInterfaceInitialised) {
+ printf("WSAGetLastError=%d\n", WSAGetLastError());
+ WSACleanup();
+ }
+ ExitProcess(0);
+}
Propchange: trunk/rosapps/applications/sysutils/telnetd/telnetd.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rosapps/applications/sysutils/telnetd/telnetd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/teln…
==============================================================================
--- trunk/rosapps/applications/sysutils/telnetd/telnetd.h (added)
+++ trunk/rosapps/applications/sysutils/telnetd/telnetd.h [iso-8859-1] Mon Dec 1 12:34:15
2008
@@ -1,0 +1,8 @@
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <stdio.h>
+#include <winsock2.h>
+#include <tchar.h>
+#include <time.h>
+
+DWORD telnetd_main();
Propchange: trunk/rosapps/applications/sysutils/telnetd/telnetd.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rosapps/applications/sysutils/telnetd/telnetd.vcproj
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/teln…
==============================================================================
--- trunk/rosapps/applications/sysutils/telnetd/telnetd.vcproj (added)
+++ trunk/rosapps/applications/sysutils/telnetd/telnetd.vcproj [iso-8859-1] Mon Dec 1
12:34:15 2008
@@ -1,0 +1,196 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="telnetd"
+ ProjectGUID="{3B4D6C18-202E-41C8-B1E8-0FC5CD940819}"
+ RootNamespace="telnetd"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ MinimalRebuild="true"
+ ExceptionHandling="0"
+ BasicRuntimeChecks="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CallingConvention="2"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="msvcrt.lib advapi32.lib ws2_32.lib"
+ IgnoreAllDefaultLibraries="true"
+ GenerateDebugInformation="true"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\serviceentry.c"
+ >
+ </File>
+ <File
+ RelativePath=".\telnetd.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\telnetd.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Propchange: trunk/rosapps/applications/sysutils/telnetd/telnetd.vcproj
------------------------------------------------------------------------------
svn:eol-style = native