From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12133 invoked by alias); 15 Nov 2001 22:32:11 -0000 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@sources.redhat.com Received: (qmail 12094 invoked from network); 15 Nov 2001 22:32:06 -0000 Received: from unknown (HELO chi.ik.ca) (209.202.82.174) by sourceware.cygnus.com with SMTP; 15 Nov 2001 22:32:06 -0000 Received: (qmail 29470 invoked from network); 15 Nov 2001 23:31:21 -0000 Received: from apastourelles-101-1-4-169.abo.wanadoo.fr (HELO neo) (193.253.204.169) by 0 with SMTP; 15 Nov 2001 23:31:21 -0000 Message-ID: <012801c16e25$c6fa1cd0$0200000a@dyn.ik.ca> From: "Gerald Villemure" To: "Corinna Vinschen" References: <3BF274A3.D7E5F5DA@s3group.com> <00c901c16d7b$da23f880$0200000a@dyn.ik.ca> <20011115222527.C27452@cygbert.vinschen.de> Subject: Re: Win98se and using SSHD as a TRUE service (solution) Date: Sun, 11 Nov 2001 08:26:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2001-11/txt/msg00346.txt.bz2 ----- Original Message ----- From: "Corinna Vinschen" To: 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 #include #include #include #include #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/