delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/10/10/15:06:58

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <30BDEE18E474D511BB0A00D0B7BB87AF09294F@camel.mha.ca>
From: Kris Erickson <kris AT mha DOT ca>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Cc: "'jpeacock AT rowman DOT com'" <jpeacock AT rowman DOT com>
Subject: RE: Perl 5.7.2 (GDB breaks in 1.3.3-2 on certain Win2000 machines
)
Date: Wed, 10 Oct 2001 12:05:11 -0700
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)

More weirdness...  The latest CVS version version of uinfo.cc does not 
seem to break, although the compiler seems to have optimized out the 
second call to NetUserGetInfo()...  However, the first call to
NetUserGetInfo
seems to succeed...  Here is a debugging session...

(gdb) break uinfo.cc:85
Breakpoint 1 at 0x61067b29: file
../../../../cygwin-1.3.3-2/winsup/cygwin/uinfo.cc, line 85.
(gdb) run
Starting program: /mnt/c/cygdeb/test.exe
Breakpoint 1, internal_getlogin (user=@0x614e0094)
    at ../../../../cygwin-1.3.3-2/winsup/cygwin/uinfo.cc:85
85            sys_mbstowcs (wuser, user.name (), UNLEN + 1);
(gdb) n
117       const char *logsrv () const { return plogsrv; }
(gdb)
86            if (NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui) &&
user.logsrv ())
(gdb)
88                strcat (strcpy (buf, "\\\\"), user.logsrv ());
(gdb)
89                sys_mbstowcs (wlogsrv, buf,
INTERNET_MAX_HOST_NAME_LENGTH + 3);
(gdb)
92                  ui = NULL;
(gdb) 
95              {
(gdb)
179                       else
(gdb)


(for all you following at home here is the code...)

85       sys_mbstowcs (wuser, user.name (), UNLEN + 1);
86       if (NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui) &&
user.logsrv ())
87     {
88       strcat (strcpy (buf, "\\\\"), user.logsrv ());
89       sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
90       ui = NULL;
91       if (NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *) &ui))
92         ui = NULL;
93     }
94       if (ui)
95     {
96       sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
...

John, have you tried compiling from the latest CVS version?  The
snapshot 
(cygwin1-20011009.dll.bz2) doesn't work, but compiling from CVS seems to
work for me...

Kris

-----Original Message-----
From: John Peacock [mailto:jpeacock AT rowman DOT com]
Sent: Wednesday, October 10, 2001 11:33 AM
To: Kris Erickson
Cc: 'cygwin AT cygwin DOT com'
Subject: Re: Perl 5.7.2 (GDB breaks in 1.3.3-2 on certain Win2000
machines)


Kris Erickson wrote:
> 
> >
> >Let's try and at least document what systems are exhibiting this
> >behavior.  My setup:
> >
> >-Win2k workstation with Service pack 1
> Yes.
> >-Logged into NT domain (NOT ActiveDirectory!)
> Yes.

Thanks Kris, that settles it.  I understand why we are getting the 2221
error.  And I am not sure how to fix CygWin.

OK, the deal is this: when a domain user logs into a domain managed
machine, he does NOT have a local account, he has a domain account.
What this means is that this documentation:

--------------------------------------------------------------------
NET_API_STATUS NetUserGetInfo(
  LPWSTR servername,  
  LPWSTR username,    
  DWORD level,        
  LPBYTE *bufptr      
);
 
Parameters
servername 
Pointer to a Unicode string containing the name of the remote server 
on which the function is to execute. A NULL pointer or string 
specifies the local computer. 

username 
Pointer to a Unicode string containing the name of the user account 
on which to return information. 
--------------------------------------------------------------------

is misleading at best and wrong in practice.  You cannot sucessfully
call it with a NULL servername for a domain user, because the domain
user has no local account.  You must have the PDC/BDC name in the
servername.  Here is the output from Kris' program run first against 
my machine then against the PDC:

	D:\working\Test\Debug>test JPeacock
	A system error has occurred: 2221

	D:\working\Test\Debug>test \\JPEACOCK JPeacock
	A system error has occurred: 2221

	D:\working\Test\Debug>test \\CIMARRON JPeacock

	        Account:      JPeacock
	        Comment:
	        User comment:
	        Full name:    John Peacock


where 2221 is NERR_UserNotFound.  QED.

What this means is that this code:

 if (NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui) && user.logsrv ())
   {
      strcat (strcpy (buf, "\\\\"), user.logsrv ());
      sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH + 3);
      ui = NULL;
      if (NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *) &ui))
        ui = NULL;
   }

needs to be rewritten so that NetUserGetInfo() is only called with the
NULL iff !user.logsrv().  I think just turning this if{} to an if{}
else{} would have the appropriate effect.  Something like this maybe?

--- uinfo.cc.orig       Wed Oct 10 14:28:57 2001
+++ uinfo.cc    Wed Oct 10 14:31:25 2001
@@ -83,7 +83,7 @@
       /* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
         after changing user context! */
       sys_mbstowcs (wuser, user.name (), UNLEN + 1);
-      if (NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui) &&
user.logsrv ())
+      if ( user.logsrv () ) /* domain user */
        {
          strcat (strcpy (buf, "\\\\"), user.logsrv ());
          sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH +
3);
@@ -91,6 +91,10 @@
          if (NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *) &ui))
            ui = NULL;
        }
+      else /* local user */
+        {
+          NetUserGetInfo (NULL, wuser, 3, (LPBYTE *) &ui);
+        }
       if (ui)
        {
          sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);


John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019