delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/08/03/10:32:37

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=cJfYjKU8xSDKDMhu8+LaV8w1VOLNrjQflx6pgJuAkzfqSSMBbo1US
74qV/lyWpFARDFXyQsBlfSkB34aeuytTnQ4ERyCI79wj8wUF4muSTZDWVq4YVY5a
vN+YWa6wMUG8aYjKNvX24+EcdE7obTufF5OAudsmgDWKfgxpS/9GHI=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=HalC2gdL4R5YGd61wnYmFR+yi4U=; b=gvDW0NVj+v9q4QAb6iLJHUBRIQx3
DD3Xk4r+lxnNTd07xBvgbaagS2rn/os7SCB2eRhe/CYaZ79OLvVIM+ox4HGJuugH
FSWgdBH3SfXLw2voKftYoNM7l8/+UMswFCUtnbZrh2cl7pecxJDGP8YnDXvdH6wJ
B2Qr7LMF8CyXfZU=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-94.3 required=5.0 tests=AWL,BAYES_05,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_PBL,RCVD_IN_SORBS_DUL,RDNS_DYNAMIC autolearn=ham version=3.3.2 spammy=thick, Trusted, skull, messing
X-HELO: calimero.vinschen.de
Date: Wed, 3 Aug 2016 16:32:07 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: /dev/ptmx fails with Azure accounts
Message-ID: <20160803143207.GB17526@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <1470156870 DOT 684316691 AT apps DOT rackspace DOT com>
MIME-Version: 1.0
In-Reply-To: <1470156870.684316691@apps.rackspace.com>
User-Agent: Mutt/1.6.2 (2016-07-01)

--FsscpQKzF/jJk6ya
Content-Type: multipart/mixed; boundary="tsOsTdHNUZQcU9Ye"
Content-Disposition: inline


--tsOsTdHNUZQcU9Ye
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Aug  2 12:54, rmora AT aboutgolf DOT com wrote:
> [I'm so sorry I'm messing up the mailing list by not replying to the prop=
er email.... I only just got it through my thick skull now to subscribe to =
the mailing list. I think my brain is on vacation already....]
>=20
>=20
> Unfortunately your prediction was correct - RunAs Administrator CMD gives=
 this:

Thanks!

In the meantime I prepared my test application.  Can you please fetch
the attached source and store it as, e.g., azure-check.c.  Then build
and run it like this:

  $ gcc -g -o azure-check azure-check.c -lnetapi32
  $ ./azure-check

Then run it and paste the complete output into your reply.

I have an idea for an extension of this testcase, but I think I have
to see the output of this one first.


Thanks in advance,
Corinna

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--tsOsTdHNUZQcU9Ye
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="azure-check.c"
Content-Transfer-Encoding: quoted-printable

#include <stdio.h>
#define _WIN32_WINNT 0x0a00
#define WINVER 0x0a00
#include <windows.h>
#include <winternl.h>
#include <ntsecapi.h>
#include <dsgetdc.h>
#include <sddl.h>

int
main ()
{
  HANDLE lsa;
  NTSTATUS status;
  ULONG ret;
  PPOLICY_DNS_DOMAIN_INFO pdom;
  PPOLICY_ACCOUNT_DOMAIN_INFO adom;
  PDS_DOMAIN_TRUSTSW td;
  ULONG tdom_cnt;
  static LSA_OBJECT_ATTRIBUTES oa =3D { 0, 0, 0, 0, 0, 0 };
  LPSTR str;
  BOOL has_dom;
  HANDLE tok;
  WCHAR name[256];
  WCHAR dom[256];
  DWORD nlen, dlen;
  SID_NAME_USE type;

  status =3D LsaOpenPolicy (NULL, &oa, POLICY_VIEW_LOCAL_INFORMATION, &lsa);
  if (!NT_SUCCESS (status))
    {
      printf ("LsaOpenPolicy: 0x%08x\n", status);
      return 1;
    }
  status =3D LsaQueryInformationPolicy (lsa, PolicyDnsDomainInformation,
				      (PVOID *) &pdom);
  if (NT_SUCCESS (status))
    {
      if (pdom->Name.Length)
	printf ("PDom.Name: %ls\n", pdom->Name.Buffer);
      if (pdom->DnsDomainName.Length)
	printf ("PDom.DnsDomainName: %ls\n", pdom->DnsDomainName.Buffer);
      if (pdom->DnsForestName.Length)
	printf ("PDom.DnsForestName: %ls\n", pdom->DnsForestName.Buffer);
      has_dom =3D !!pdom->Sid;
      if (has_dom)
      	{
	  ConvertSidToStringSidA (pdom->Sid, &str);
	  printf ("PDom.Sid: %s\n", str);
	  LocalFree (str);
	}
      LsaFreeMemory (pdom);
    }
  else
    printf ("LsaQueryInformationPolicy (PDOM): 0x%08x\n", status);
=20=20=20=20
  status =3D LsaQueryInformationPolicy (lsa, PolicyAccountDomainInformation,
				      (PVOID *) &adom);
  if (NT_SUCCESS (status))
    {
      if (adom->DomainName.Length)
	  printf ("ADom.DomainName: %ls\n", adom->DomainName.Buffer);
      ConvertSidToStringSidA (adom->DomainSid, &str);
      printf ("ADom.DomainSid: %s\n", str);
      LocalFree (str);
      LsaFreeMemory (adom);
    }
  else
    printf ("LsaQueryInformationPolicy (ADOM): 0x%08x\n", status);
  if (dom)
    {
      ret =3D DsEnumerateDomainTrustsW (NULL, DS_DOMAIN_DIRECT_INBOUND
					    | DS_DOMAIN_DIRECT_OUTBOUND
					    | DS_DOMAIN_IN_FOREST,
				       &td, &tdom_cnt);
      if (ret =3D=3D ERROR_SUCCESS)
	for (ULONG idx =3D 0; idx < tdom_cnt; ++idx)
	  {
	    printf ("Trusted Domain %u:\n", idx);
	    printf ("  NetbiosDomainName: %ls\n", td[idx].NetbiosDomainName);
	    if (td[idx].DnsDomainName)
	      printf ("  DnsDomainName: %ls\n", td[idx].DnsDomainName);
	    printf ("  Flags: 0x%08x\n", td[idx].Flags);
	    printf ("  TrustType: 0x%08x\n", td[idx].TrustType);
	    printf ("  TrustAttributes: 0x%08x\n", td[idx].TrustAttributes);
	    if (td[idx].DomainSid)
	      {
		ConvertSidToStringSidA (td[idx].DomainSid, &str);
		printf ("DomainSid: %s\n", str);
		LocalFree (str);
	      }
	  }
      else
	printf ("DsEnumerateDomainTrustsW: %u\n", ret);
    }
  LsaClose (lsa);
  if (OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &tok))
    {
      PTOKEN_USER tp =3D (PTOKEN_USER) malloc (65536);
      if (GetTokenInformation (tok, TokenUser, tp, 65536, &ret))
      	{
	  printf ("User:\n");
	  ConvertSidToStringSidA (tp->User.Sid, &str);
	  printf ("  Sid: %s\n", str);
	  LocalFree (str);

	  nlen =3D dlen =3D 256;
	  if (LookupAccountSidW (NULL, tp->User.Sid, name, &nlen,=20
				 dom, &dlen, &type))
	    printf ("  Dom\\Name: %ls\\%ls\n", dom, name);
	  else
	    printf ("  LookupAccountSidW: %u\n", GetLastError ());
	  printf ("  Attributes: 0x%08x\n", tp->User.Attributes);
	}
      else
	printf ("GetTokenInformation(user): %u\n", GetLastError ());
      free (tp);

      PTOKEN_GROUPS tg =3D (PTOKEN_GROUPS) malloc (65536);
      if (GetTokenInformation (tok, TokenGroups, tg, 65536, &ret))
	for (ULONG idx =3D 0; idx < tg->GroupCount; ++idx)
	  {
	    printf ("Group %u\n", idx);
	    ConvertSidToStringSidA (tg->Groups[idx].Sid, &str);
	    printf ("  Sid: %s\n", str);
	    LocalFree (str);

	    nlen =3D dlen =3D 256;
	    if (LookupAccountSidW (NULL, tg->Groups[idx].Sid, name, &nlen,=20
				   dom, &dlen, &type))
	      printf ("  Dom\\Name: %ls\\%ls\n", dom, name);
	    else
	      printf ("  LookupAccountSidW: %u\n", GetLastError ());
	    printf ("  Attributes: 0x%08x\n", tg->Groups[idx].Attributes);
	  }
      else
	printf ("GetTokenInformation(groups): %u\n", GetLastError ());
      free (tg);
    }
  else
    printf ("OpenProcessToken: %u\n", GetLastError ());
  return 0;
}

--tsOsTdHNUZQcU9Ye--

--FsscpQKzF/jJk6ya
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJXogBnAAoJEPU2Bp2uRE+g6sQP/1QADnd3T9rl4ww2J8JcXKYB
+MZdZNCXylqKxwVugk8t6ZdNawr/OiyVeseFfQK5lXaCG4xIfWjlx4UgmIDo0Llc
1yuFAmoA2ZFzCL2CEg/jKD7RO6sGIdjd6BDQ26MoyDSRk+B7sczDmoTpQdbsdwYR
mnN6jaAc2UAR/0omI7ykkvlfz5RFTZqwRnldzgG/RWBSwHFGwGzis5GE0MXv61FE
49IDwozFDwDMX4DnvpBbTeaN5ekNmKqt/RDwmZuYlVt0p1OaRPEVXQuyJqEj+CL/
CZEKu70o3vViqR2XTkuGqakaQnJNBYApf+cY8lunfyNEAoiKNINkqYk3nHdc6Mfa
zQ7xR3HgE6OQ7LcmzNfxbOHR+cUhOy6s2VqhEJjW+MxRFfN3bEhwFTwZe+L5E8f7
7BvB8fj1Vo0gah1147n8s9yPNiLsbjXzJmjp8jPX4MXmHtKP6hcqubR91tzpmYJ2
PnZ0PcMaTDDuUVGtSCNfZSrqIZMM7Y1sUKkmY3mBhPUYL5VV9pDL32zMUrpODUth
Hqxc8+zhKFZPcxHDMBXpOFn8ytyZBSR0CC7+rUTfUpZ+AtfjvPrklCdR+a37kC0T
zgGaVdsxzC3adExxp+Jw9aFZAHObVJUWV9L4DuH5jtCm7NJqYOQ/VW9p8EAx3m/7
REKObKrm0/DD5evTDT5B
=izzD
-----END PGP SIGNATURE-----

--FsscpQKzF/jJk6ya--

- Raw text -


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