----- Original Message ----- From: "Corinna Vinschen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 15, 2001 10:25 PM Subject: Re: Win98se and using SSHD as a TRUE service
--stuff cut--- > You added the code to the parent's branch. It's the child which > has to register as service. Move the code (not the sleep(!)) > to the `case 0:' branch, right before the `break;'. > > Corinna Well Corinna.... THANK YOU, THANK YOU, THANK YOU!!! I finaly has a viable remote admin solution for win9x boxes. Needless to say I am very happy about this. Included is the new source for daemon.c which makes SSHD register itslef as a service in Win9x boxes. Its should be noted that only the master SSHD process is set at a service so if you hapen to be loged on while the user quits his session you will be bumped off. The point is that NOW you can get back on the system and manualy kill the zomby BASH proccess that was left behind. No more fear of being locked out of the system. I would like to say a thanks to: Max Bowsher James Coleman Corinna Vinschen I could not have done it without you... "Merci beaucoup" as they say here in Paris. Ok here is the code: $ cat daemon.c /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ //#include "includes.h" #include "windows.h" #include <sys/types.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define HAVE_CYGWIN #ifndef HAVE_DAEMON #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = "$OpenBSD: daemon.c,v 1.2 1996/08/19 08:22:13 tholo Exp $"; #endif /* LIBC_SCCS and not lint */ int daemon(nochdir, noclose) int nochdir, noclose; { int fd; HINSTANCE kerneldll; DWORD (*RegisterService)(DWORD, DWORD); switch (fork()) { case -1: return (-1); case 0: kerneldll = LoadLibrary("KERNEL32.DLL"); RegisterService = (DWORD (*)(DWORD, DWORD)) GetProcAddress(kerneldll, "RegisterServiceProcess"); RegisterService(NULL, 1); break; default: #ifdef HAVE_CYGWIN /* * This sleep avoids a race condition which kills the * child process if parent is started by a NT/W2K service. */ sleep(1); #endif _exit(0); } if (setsid() == -1) return (-1); if (!nochdir) (void)chdir("/"); if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); if (fd > 2) (void)close (fd); } return (0); } #endif /* !HAVE_DAEMON */ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/