* cygcheck.cc (dump_sysinfo): Handle Windows 10/Server 2014(?).

This commit is contained in:
Corinna Vinschen 2014-11-10 16:21:52 +00:00
parent fbb8f1a2c7
commit df59ab7e7a
4 changed files with 57 additions and 30 deletions

View File

@ -1,3 +1,7 @@
2014-11-10 Corinna Vinschen <corinna@vinschen.de>
* cygcheck.cc (dump_sysinfo): Handle Windows 10/Server 2014(?).
2014-11-03 Corinna Vinschen <corinna@vinschen.de> 2014-11-03 Corinna Vinschen <corinna@vinschen.de>
* mkgroup.c (enum_local_groups): Don't generate leading separator char * mkgroup.c (enum_local_groups): Don't generate leading separator char

View File

@ -1480,11 +1480,14 @@ dump_sysinfo ()
? "8" : "2012"); ? "8" : "2012");
break; break;
case 3: case 3:
default:
osversion.dwMinorVersion = 3;
strcpy (osname, osversion.wProductType == VER_NT_WORKSTATION strcpy (osname, osversion.wProductType == VER_NT_WORKSTATION
? "8.1" : "2012 R2"); ? "8.1" : "2012 R2");
break; break;
case 4:
default:
strcpy (osname, osversion.wProductType == VER_NT_WORKSTATION
? "10" : "2014");
break;
} }
DWORD prod; DWORD prod;
if (GetProductInfo (osversion.dwMajorVersion, if (GetProductInfo (osversion.dwMajorVersion,

View File

@ -47,7 +47,6 @@ typedef struct
{ {
char *str; char *str;
BOOL domain; BOOL domain;
BOOL with_dom;
} domlist_t; } domlist_t;
static void static void
@ -168,8 +167,8 @@ enum_unix_groups (domlist_t *mach, const char *sep, DWORD id_offset,
(dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen), (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
&acc_type)) &acc_type))
printf ("%s%s%ls:%s:%" PRIu32 ":\n", printf ("%s%s%ls:%s:%" PRIu32 ":\n",
mach->with_dom ? "Unix_Group" : "", "Unix_Group",
mach->with_dom ? sep : "", sep,
p, p,
put_sid (psid), put_sid (psid),
(unsigned int) (id_offset + (unsigned int) (id_offset +
@ -205,8 +204,8 @@ enum_unix_groups (domlist_t *mach, const char *sep, DWORD id_offset,
&acc_type) &acc_type)
&& !iswdigit (grp[0])) && !iswdigit (grp[0]))
printf ("%s%s%ls:%s:%" PRIu32 ":\n", printf ("%s%s%ls:%s:%" PRIu32 ":\n",
mach->with_dom ? "Unix_Group" : "", "Unix_Group",
mach->with_dom ? sep : "", sep,
grp, grp,
put_sid (psid), put_sid (psid),
(unsigned int) (id_offset + start)); (unsigned int) (id_offset + start));
@ -341,8 +340,8 @@ enum_local_groups (domlist_t *mach, const char *sep,
gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1); gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
printf ("%ls%s%ls:%s:%" PRIu32 ":\n", printf ("%ls%s%ls:%s:%" PRIu32 ":\n",
mach->with_dom && !is_builtin ? domain_name : L"", !is_builtin ? domain_name : L"",
mach->with_dom && !is_builtin ? sep : "", !is_builtin ? sep : "",
buffer[i].lgrpi0_name, buffer[i].lgrpi0_name,
put_sid (psid), put_sid (psid),
(unsigned int) (gid + (is_builtin ? 0 : id_offset))); (unsigned int) (gid + (is_builtin ? 0 : id_offset)));
@ -455,8 +454,8 @@ enum_groups (domlist_t *mach, const char *sep, DWORD id_offset,
got_curr_pgrp = TRUE; got_curr_pgrp = TRUE;
printf ("%ls%s%ls:%s:%" PRIu32 ":\n", printf ("%ls%s%ls:%s:%" PRIu32 ":\n",
mach->with_dom ? domain_name : L"", domain_name,
mach->with_dom ? sep : "", sep,
buffer[i].grpi2_name, buffer[i].grpi2_name,
put_sid (psid), put_sid (psid),
(unsigned int) (id_offset + gid)); (unsigned int) (id_offset + gid));
@ -481,9 +480,8 @@ usage (FILE * stream)
"\n" "\n"
"Options:\n" "Options:\n"
"\n" "\n"
" -l,--local [machine] print local groups\n" " -l,--local [machine] print local groups of \"machine\"\n"
" (from local machine if no machine specified)\n" " (from local machine if no machine specified)\n"
" -L,--Local machine ditto, but generate groupname with machine prefix\n"
" -d,--domain [domain] print domain groups\n" " -d,--domain [domain] print domain groups\n"
" (from current domain if no domain specified)\n" " (from current domain if no domain specified)\n"
" -c,--current print current group\n" " -c,--current print current group\n"
@ -616,7 +614,7 @@ main (int argc, char **argv)
program_invocation_short_name, program_invocation_short_name,
domlist[i].domain ? "domain" : "machine", domlist[i].domain ? "domain" : "machine",
domlist[i].str); domlist[i].str);
goto skip; break;
} }
domlist[print_domlist].str = opt; domlist[print_domlist].str = opt;
if (opt && (p = strchr (opt, ','))) if (opt && (p = strchr (opt, ',')))
@ -629,8 +627,20 @@ main (int argc, char **argv)
} }
*p = '\0'; *p = '\0';
} }
domlist[print_domlist++].with_dom = (c == 'L'); if ((c == 'l' || c == 'L') && opt)
skip: {
char cname[1024];
DWORD csize = sizeof cname;
/* Check if machine name is local machine. Keep it simple. */
if (GetComputerNameExA (strchr (opt, '.')
? ComputerNameDnsFullyQualified
: ComputerNameNetBIOS,
cname, &csize)
&& strcasecmp (opt, cname) == 0)
domlist[print_domlist].str = NULL;
}
++print_domlist;
break; break;
case 'S': case 'S':
sep_char = optarg; sep_char = optarg;

View File

@ -48,7 +48,6 @@ typedef struct
{ {
char *str; char *str;
BOOL domain; BOOL domain;
BOOL with_dom;
} domlist_t; } domlist_t;
static void static void
@ -170,8 +169,8 @@ enum_unix_users (domlist_t *mach, const char *sep, DWORD id_offset,
(dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen), (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
&acc_type)) &acc_type))
printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n", printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n",
mach->with_dom ? "Unix_User" : "", "Unix_User",
mach->with_dom ? sep : "", sep,
user + 10, user + 10,
(unsigned int) (id_offset + (unsigned int) (id_offset +
*GetSidSubAuthority (psid, *GetSidSubAuthority (psid,
@ -207,8 +206,8 @@ enum_unix_users (domlist_t *mach, const char *sep, DWORD id_offset,
&acc_type) &acc_type)
&& !iswdigit (user[0])) && !iswdigit (user[0]))
printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n", printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n",
mach->with_dom ? "Unix_User" : "", "Unix_User",
mach->with_dom ? sep : "", sep,
user, user,
(unsigned int) (id_offset + start), (unsigned int) (id_offset + start),
put_sid (psid)); put_sid (psid));
@ -335,8 +334,8 @@ enum_users (domlist_t *mach, const char *sep, const char *passed_home_path,
printf ("%ls%s%ls:unused:%" PRIu32 ":%" PRIu32 printf ("%ls%s%ls:unused:%" PRIu32 ":%" PRIu32
":%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n", ":%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n",
mach->with_dom ? domain_name : L"", domain_name,
mach->with_dom ? sep : "", sep,
buffer[i].usri3_name, buffer[i].usri3_name,
(unsigned int) (id_offset + uid), (unsigned int) (id_offset + uid),
(unsigned int) (id_offset + gid), (unsigned int) (id_offset + gid),
@ -370,16 +369,15 @@ usage (FILE * stream)
"\n" "\n"
"Options:\n" "Options:\n"
"\n" "\n"
" -l,--local [machine] print local user accounts\n" " -l,--local [machine] print local user accounts of \"machine\"\n"
" (from local machine if no machine specified)\n" " (from local machine if no machine specified)\n"
" -L,--Local machine ditto, but generate username with machine prefix\n"
" -d,--domain [domain] print domain accounts\n" " -d,--domain [domain] print domain accounts\n"
" (from current domain if no domain specified)\n" " (from current domain if no domain specified)\n"
" -c,--current print current user\n" " -c,--current print current user\n"
" -S,--separator char for -l use character char as domain\\user\n" " -S,--separator char for -l use character char as domain\\user\n"
" separator in username instead of the default '%s'\n" " separator in username instead of the default '%s'\n"
" -o,--id-offset offset change the default offset (0x10000) added to uids\n" " -o,--id-offset offset change the default offset (0x10000) added to uids\n"
" in domain or foreign server accounts.\n" " of foreign local machine accounts. Use with -l.\n"
" -u,--username username only return information for the specified user\n" " -u,--username username only return information for the specified user\n"
" one of -l, -d must be specified, too\n" " one of -l, -d must be specified, too\n"
" -b,--no-builtin don't print BUILTIN users\n" " -b,--no-builtin don't print BUILTIN users\n"
@ -513,21 +511,33 @@ main (int argc, char **argv)
program_invocation_short_name, program_invocation_short_name,
domlist[i].domain ? "domain" : "machine", domlist[i].domain ? "domain" : "machine",
domlist[i].str); domlist[i].str);
goto skip; break;
} }
domlist[print_domlist].str = opt; domlist[print_domlist].str = opt;
if (opt && (p = strchr (opt, ','))) if (opt && (p = strchr (opt, ',')))
{ {
if (p == opt) if (p == opt)
{ {
fprintf (stderr, "%s: Malformed domain,offset string '%s'. " fprintf (stderr, "%s: Malformed domain string '%s'. "
"Skipping...\n", program_invocation_short_name, opt); "Skipping...\n", program_invocation_short_name, opt);
break; break;
} }
*p = '\0'; *p = '\0';
} }
domlist[print_domlist++].with_dom = (c == 'L'); if ((c == 'l' || c == 'L') && opt)
skip: {
char cname[1024];
DWORD csize = sizeof cname;
/* Check if machine name is local machine. Keep it simple. */
if (GetComputerNameExA (strchr (opt, '.')
? ComputerNameDnsFullyQualified
: ComputerNameNetBIOS,
cname, &csize)
&& strcasecmp (opt, cname) == 0)
domlist[print_domlist].str = NULL;
}
++print_domlist;
break; break;
case 'S': case 'S':
sep_char = optarg; sep_char = optarg;