public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* accept() doesn't block while running as NT service
@ 2003-08-19 13:42 linamat
  2003-08-19 14:27 ` Corinna Vinschen
       [not found] ` <200308191332.h7JDWVKF026466@bevo.che.wisc.edu>
  0 siblings, 2 replies; 11+ messages in thread
From: linamat @ 2003-08-19 13:42 UTC (permalink / raw)
  To: cygwin

I have a problem with accept() on TCP socket. Al things works well when I
start the program under .\\Administrator credentials, but fails in NT
service.

{
 struct sockaddr_in sa;
 int sa_len = sizeof sa;

  for (;;) {

    t = accept(s,(struct sockaddr *)&sa,&sa_len);

    if (t == -1) continue;

// working with client....
    .......
   }
}

It returns -1 and enters in infinite loop.
I've tried such with UNIX socket and it behaved normally.
Can you explain me why?


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-19 13:42 accept() doesn't block while running as NT service linamat
@ 2003-08-19 14:27 ` Corinna Vinschen
  2003-08-19 14:33   ` help-octave-request
       [not found] ` <200308191332.h7JDWVKF026466@bevo.che.wisc.edu>
  1 sibling, 1 reply; 11+ messages in thread
From: Corinna Vinschen @ 2003-08-19 14:27 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 19, 2003 at 04:30:47PM +0300, linamat@moldtelecom.md wrote:
> I have a problem with accept() on TCP socket. Al things works well when I
> start the program under .\\Administrator credentials, but fails in NT
> service.
> 
> {
>  struct sockaddr_in sa;
>  int sa_len = sizeof sa;
> 
>   for (;;) {
> 
>     t = accept(s,(struct sockaddr *)&sa,&sa_len);
> 
>     if (t == -1) continue;
> 
> // working with client....
>     .......
>    }
> }
> 
> It returns -1 and enters in infinite loop.
> I've tried such with UNIX socket and it behaved normally.
> Can you explain me why?

No.  No details, no explanation.  Debugging could help.  And reading
http://cygwin.com/problems.html, probably.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-19 14:27 ` Corinna Vinschen
@ 2003-08-19 14:33   ` help-octave-request
  0 siblings, 0 replies; 11+ messages in thread
From: help-octave-request @ 2003-08-19 14:33 UTC (permalink / raw)
  To: cygwin

Your message has been received, but you are not subscribed to the
help-octave mailing list using the address from which you sent your
mail, so your message will not be posted automatically.

If the list moderator decides your message is appropriate for the
purposes of the list, then it will be posted.

--
On Tue, Aug 19, 2003 at 04:30:47PM +0300, linamat@moldtelecom.md wrote:
> I have a problem with accept() on TCP socket. Al things works well when I
> start the program under .\\Administrator credentials, but fails in NT
> service.
> 
> {
>  struct sockaddr_in sa;
>  int sa_len = sizeof sa;
> 
>   for (;;) {
> 
>     t = accept(s,(struct sockaddr *)&sa,&sa_len);
> 
>     if (t == -1) continue;
> 
> // working with client....
>     .......
>    }
> }
> 
> It returns -1 and enters in infinite loop.
> I've tried such with UNIX socket and it behaved normally.
> Can you explain me why?

No.  No details, no explanation.  Debugging could help.  And reading
http://cygwin.com/problems.html, probably.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
       [not found] ` <200308191332.h7JDWVKF026466@bevo.che.wisc.edu>
@ 2003-08-19 16:36   ` linamat
  2003-08-20 12:13     ` Nedko Arnaudov
  0 siblings, 1 reply; 11+ messages in thread
From: linamat @ 2003-08-19 16:36 UTC (permalink / raw)
  To: cygwin

The problem exists under Win2k sp4, cygwin-1.3.22 and cygwin-1.5.2.

Anyhow an explanation would be much appreciated.

I've read cygrunsrv last version and inetd sources, but couldn't find any
error in my code.

Some parameters from CreateService() which I used:
SERVICE_WIN32_OWN_PROCESS
".\\LocalSystem" or NULL served as lpServiceStartName

I also could post all service source.
Does exist any difference for Cygwin call accept() in such case between
executing in a process token level and in user space?

An interesting thing: the TCP port is not even binded, while listen
returns 0.




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-19 16:36   ` linamat
@ 2003-08-20 12:13     ` Nedko Arnaudov
  2003-08-20 13:10       ` Corinna Vinschen
  0 siblings, 1 reply; 11+ messages in thread
From: Nedko Arnaudov @ 2003-08-20 12:13 UTC (permalink / raw)
  To: cygwin

Process that is run under local system credentials cannot use
network. This is why ot is called *local*. Don't know if this WinNT
behaviour can be customized.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-20 12:13     ` Nedko Arnaudov
@ 2003-08-20 13:10       ` Corinna Vinschen
  2003-08-20 15:48         ` Nedko Arnaudov
  0 siblings, 1 reply; 11+ messages in thread
From: Corinna Vinschen @ 2003-08-20 13:10 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 20, 2003 at 11:23:01AM +0300, Nedko Arnaudov wrote:
> Process that is run under local system credentials cannot use
> network. This is why ot is called *local*. Don't know if this WinNT
> behaviour can be customized.

That's wrong.  How should eg. sshd work then?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-20 13:10       ` Corinna Vinschen
@ 2003-08-20 15:48         ` Nedko Arnaudov
  2003-08-20 16:02           ` Corinna Vinschen
  0 siblings, 1 reply; 11+ messages in thread
From: Nedko Arnaudov @ 2003-08-20 15:48 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen <corinna-cygwin@cygwin.com> writes:

> On Wed, Aug 20, 2003 at 11:23:01AM +0300, Nedko Arnaudov wrote:
>> Process that is run under local system credentials cannot use
>> network. This is why ot is called *local*. Don't know if this WinNT
>> behaviour can be customized.
>
> That's wrong.  How should eg. sshd work then?
>

Actually i don't know how sshd is implemented but i guess that it logs
the user into LSA or impersonates him.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-20 15:48         ` Nedko Arnaudov
@ 2003-08-20 16:02           ` Corinna Vinschen
  2003-08-21 10:44             ` Nedko Arnaudov
  0 siblings, 1 reply; 11+ messages in thread
From: Corinna Vinschen @ 2003-08-20 16:02 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 20, 2003 at 06:10:06PM +0300, Nedko Arnaudov wrote:
> Corinna Vinschen <corinna-cygwin@cygwin.com> writes:
> 
> > On Wed, Aug 20, 2003 at 11:23:01AM +0300, Nedko Arnaudov wrote:
> >> Process that is run under local system credentials cannot use
> >> network. This is why ot is called *local*. Don't know if this WinNT
> >> behaviour can be customized.
> >
> > That's wrong.  How should eg. sshd work then?
> 
> Actually i don't know how sshd is implemented but i guess that it logs
> the user into LSA or impersonates him.

And before authentication?  What about the parent process which is
running under SYSTEM account and which is listening for incoming
connections on port 22?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept() doesn't block while running as NT service
  2003-08-20 16:02           ` Corinna Vinschen
@ 2003-08-21 10:44             ` Nedko Arnaudov
  0 siblings, 0 replies; 11+ messages in thread
From: Nedko Arnaudov @ 2003-08-21 10:44 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen <corinna-cygwin@cygwin.com> writes:

> On Wed, Aug 20, 2003 at 06:10:06PM +0300, Nedko Arnaudov wrote:
>> Corinna Vinschen <corinna-cygwin@cygwin.com> writes:
>> 
>> > On Wed, Aug 20, 2003 at 11:23:01AM +0300, Nedko Arnaudov wrote:
>> >> Process that is run under local system credentials cannot use
>> >> network. This is why ot is called *local*. Don't know if this WinNT
>> >> behaviour can be customized.
>> >
>> > That's wrong.  How should eg. sshd work then?
>> 
>> Actually i don't know how sshd is implemented but i guess that it logs
>> the user into LSA or impersonates him.
>
> And before authentication?  What about the parent process which is
> running under SYSTEM account and which is listening for incoming
> connections on port 22?
>

Ok, your are right. But using windows redirector functions (netbios
shares) is impossible from local system account or at least it was
some years ago. Of course this is not directly realted to the subject
of this thread. I just wanted to help.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept doesn't block while running as NT service
@ 2003-08-22  9:03 linamat
  0 siblings, 0 replies; 11+ messages in thread
From: linamat @ 2003-08-22  9:03 UTC (permalink / raw)
  To: cygwin

As Corinna said "debugging could help" and she was right.
One of my functions closed file descriptors 0 and 1 after successfull
listen() call. Socket fd is 0 in my case. And so accept()'s errno was EBADF.
Now my service is working.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: accept doesn't block while running as NT service
@ 2003-08-20 17:32 linamat
  0 siblings, 0 replies; 11+ messages in thread
From: linamat @ 2003-08-20 17:32 UTC (permalink / raw)
  To: cygwin

SYSTEM can use network resources without doubts, because UNIX domain
socket works under NT service, inetd also works as NT service.

Turning to accept() problem errno was set to EBADF.
I parsed fhandler_socket.cc's method accept(); there are 2 places where
EBADF might be set: 1st after sock_event handling if blocking (but I use
FASYNC | O_NONBLOCK), 2nd after ancestor's accept() which checks for
invalid handle.
It seems that socket descriptor is suddenly closed or invalidated under NT
service. I've even tried to run some very simple TCP socket servers
through SCM, but it fail. Don't forget that all OK with it while it runs
from console as application.
Is such behaveour normal?



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-08-22  8:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-19 13:42 accept() doesn't block while running as NT service linamat
2003-08-19 14:27 ` Corinna Vinschen
2003-08-19 14:33   ` help-octave-request
     [not found] ` <200308191332.h7JDWVKF026466@bevo.che.wisc.edu>
2003-08-19 16:36   ` linamat
2003-08-20 12:13     ` Nedko Arnaudov
2003-08-20 13:10       ` Corinna Vinschen
2003-08-20 15:48         ` Nedko Arnaudov
2003-08-20 16:02           ` Corinna Vinschen
2003-08-21 10:44             ` Nedko Arnaudov
2003-08-20 17:32 accept " linamat
2003-08-22  9:03 linamat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).