* mkgroup.c: Drop support for NT4 domains.
* mkpasswd.c: Ditto. (psx_dir): Remove. (current_user): Drop support for -m option. Use $HOME as is since it's a POSIX path anyway. (enum_users): Drop support for -m option. (usage): Mention -m option as ignored. (main): Drop support for -m option. Mark ignored options as deprecated. * utils.sgml (mkpasswd): Remove description of -m option.
This commit is contained in:
parent
1aca2cb5f4
commit
13a20f9565
@ -1,3 +1,15 @@
|
||||
2011-12-01 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* mkgroup.c: Drop support for NT4 domains.
|
||||
* mkpasswd.c: Ditto.
|
||||
(psx_dir): Remove.
|
||||
(current_user): Drop support for -m option. Use $HOME as is since it's
|
||||
a POSIX path anyway.
|
||||
(enum_users): Drop support for -m option.
|
||||
(usage): Mention -m option as ignored.
|
||||
(main): Drop support for -m option. Mark ignored options as deprecated.
|
||||
* utils.sgml (mkpasswd): Remove description of -m option.
|
||||
|
||||
2011-11-28 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* locale.cc (print_locale_with_codeset): Fetch Windows path as UNICODE
|
||||
|
@ -39,8 +39,6 @@
|
||||
SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
|
||||
SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
|
||||
|
||||
NET_API_STATUS WINAPI (*dsgetdcname)(LPWSTR,LPWSTR,GUID*,LPWSTR,ULONG,PDOMAIN_CONTROLLER_INFOW*);
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
@ -69,58 +67,28 @@ _print_win_error (DWORD code, int line)
|
||||
fprintf (stderr, "mkgroup (%d): error %lu", line, code);
|
||||
}
|
||||
|
||||
static void
|
||||
load_dsgetdcname ()
|
||||
{
|
||||
HANDLE h = LoadLibrary ("netapi32.dll");
|
||||
if (h)
|
||||
dsgetdcname = (void *) GetProcAddress (h, "DsGetDcNameW");
|
||||
}
|
||||
|
||||
static PWCHAR
|
||||
get_dcname (char *domain)
|
||||
{
|
||||
static WCHAR server[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
DWORD rc;
|
||||
PWCHAR servername;
|
||||
WCHAR domain_name[MAX_DOMAIN_NAME_LEN + 1];
|
||||
PDOMAIN_CONTROLLER_INFOW pdci = NULL;
|
||||
|
||||
if (dsgetdcname)
|
||||
if (domain)
|
||||
{
|
||||
if (domain)
|
||||
{
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = dsgetdcname (NULL, domain_name, NULL, NULL, 0, &pdci);
|
||||
}
|
||||
else
|
||||
rc = dsgetdcname (NULL, NULL, NULL, NULL, 0, &pdci);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
print_win_error (rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, pdci->DomainControllerName);
|
||||
NetApiBufferFree (pdci);
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = DsGetDcNameW (NULL, domain_name, NULL, NULL, 0, &pdci);
|
||||
}
|
||||
else
|
||||
rc = DsGetDcNameW (NULL, NULL, NULL, NULL, 0, &pdci);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
rc = NetGetDCName (NULL, NULL, (void *) &servername);
|
||||
if (rc == ERROR_SUCCESS && domain)
|
||||
{
|
||||
LPWSTR server = servername;
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = NetGetDCName (server, domain_name, (void *) &servername);
|
||||
NetApiBufferFree (server);
|
||||
}
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
print_win_error(rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, servername);
|
||||
NetApiBufferFree ((PVOID) servername);
|
||||
print_win_error (rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, pdci->DomainControllerName);
|
||||
NetApiBufferFree (pdci);
|
||||
return server;
|
||||
}
|
||||
|
||||
@ -757,7 +725,6 @@ main (int argc, char **argv)
|
||||
setlocale (LC_CTYPE, "");
|
||||
if (!strcmp (setlocale (LC_CTYPE, NULL), "C"))
|
||||
setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
load_dsgetdcname ();
|
||||
in_domain = fetch_primary_domain ();
|
||||
fetch_current_pgrp_sid ();
|
||||
|
||||
|
@ -39,8 +39,6 @@
|
||||
SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
|
||||
SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
|
||||
|
||||
NET_API_STATUS WINAPI (*dsgetdcname)(LPWSTR,LPWSTR,GUID*,LPWSTR,ULONG,PDOMAIN_CONTROLLER_INFOW*);
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
@ -69,59 +67,28 @@ _print_win_error(DWORD code, int line)
|
||||
fprintf (stderr, "mkpasswd (%d): error %lu", line, code);
|
||||
}
|
||||
|
||||
static void
|
||||
load_dsgetdcname ()
|
||||
{
|
||||
HANDLE h = LoadLibrary ("netapi32.dll");
|
||||
|
||||
if (h)
|
||||
dsgetdcname = (void *) GetProcAddress (h, "DsGetDcNameW");
|
||||
}
|
||||
|
||||
static PWCHAR
|
||||
get_dcname (char *domain)
|
||||
{
|
||||
static WCHAR server[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
DWORD rc;
|
||||
PWCHAR servername;
|
||||
WCHAR domain_name[MAX_DOMAIN_NAME_LEN + 1];
|
||||
PDOMAIN_CONTROLLER_INFOW pdci = NULL;
|
||||
|
||||
if (dsgetdcname)
|
||||
if (domain)
|
||||
{
|
||||
if (domain)
|
||||
{
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = dsgetdcname (NULL, domain_name, NULL, NULL, 0, &pdci);
|
||||
}
|
||||
else
|
||||
rc = dsgetdcname (NULL, NULL, NULL, NULL, 0, &pdci);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
print_win_error(rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, pdci->DomainControllerName);
|
||||
NetApiBufferFree (pdci);
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = DsGetDcNameW (NULL, domain_name, NULL, NULL, 0, &pdci);
|
||||
}
|
||||
else
|
||||
rc = DsGetDcNameW (NULL, NULL, NULL, NULL, 0, &pdci);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
rc = NetGetDCName (NULL, NULL, (void *) &servername);
|
||||
if (rc == ERROR_SUCCESS && domain)
|
||||
{
|
||||
LPWSTR server = servername;
|
||||
mbstowcs (domain_name, domain, strlen (domain) + 1);
|
||||
rc = NetGetDCName (server, domain_name, (void *) &servername);
|
||||
NetApiBufferFree (server);
|
||||
}
|
||||
if (rc != ERROR_SUCCESS)
|
||||
{
|
||||
print_win_error(rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, servername);
|
||||
NetApiBufferFree ((PVOID) servername);
|
||||
print_win_error (rc);
|
||||
return (PWCHAR) -1;
|
||||
}
|
||||
wcscpy (server, pdci->DomainControllerName);
|
||||
NetApiBufferFree (pdci);
|
||||
return server;
|
||||
}
|
||||
|
||||
@ -143,29 +110,6 @@ put_sid (PSID sid)
|
||||
return s;
|
||||
}
|
||||
|
||||
static void
|
||||
psx_dir (char *in, char *out)
|
||||
{
|
||||
if (isalpha ((unsigned char) in[0]) && in[1] == ':')
|
||||
{
|
||||
sprintf (out, "/cygdrive/%c", in[0]);
|
||||
in += 2;
|
||||
out += strlen (out);
|
||||
}
|
||||
|
||||
while (*in)
|
||||
{
|
||||
if (*in == '\\')
|
||||
*out = '/';
|
||||
else
|
||||
*out = *in;
|
||||
in++;
|
||||
out++;
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
uni2ansi (LPWSTR wcs, char *mbs, int size)
|
||||
{
|
||||
@ -203,8 +147,8 @@ fetch_current_user_sid ()
|
||||
}
|
||||
|
||||
static void
|
||||
current_user (int print_cygpath, const char *sep, const char *passed_home_path,
|
||||
DWORD id_offset, const char *disp_username)
|
||||
current_user (const char *sep, const char *passed_home_path, DWORD id_offset,
|
||||
const char *disp_username)
|
||||
{
|
||||
WCHAR user[UNLEN + 1];
|
||||
WCHAR dom[MAX_DOMAIN_NAME_LEN + 1];
|
||||
@ -228,17 +172,9 @@ current_user (int print_cygpath, const char *sep, const char *passed_home_path,
|
||||
*GetSidSubAuthorityCount(curr_pgrp.psid) - 1);
|
||||
if (passed_home_path[0] == '\0')
|
||||
{
|
||||
char *envhome = getenv ("HOME");
|
||||
char *envhome = getenv ("HOME"); /* POSIX! */
|
||||
|
||||
if (envhome && envhome[0])
|
||||
{
|
||||
if (print_cygpath)
|
||||
cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE, envhome,
|
||||
homedir_psx, PATH_MAX);
|
||||
else
|
||||
psx_dir (envhome, homedir_psx);
|
||||
}
|
||||
else
|
||||
if (!envhome || envhome[0] == '\0')
|
||||
{
|
||||
wcstombs (stpncpy (homedir_psx, "/home/", sizeof (homedir_psx)),
|
||||
user, sizeof (homedir_psx) - 6);
|
||||
@ -370,8 +306,8 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
|
||||
|
||||
static int
|
||||
enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||
int print_cygpath, const char *passed_home_path, DWORD id_offset,
|
||||
char *disp_username, int print_current)
|
||||
const char *passed_home_path, DWORD id_offset, char *disp_username,
|
||||
int print_current)
|
||||
{
|
||||
WCHAR machine[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
PWCHAR servername = NULL;
|
||||
@ -438,7 +374,6 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||
for (i = 0; i < entriesread; i++)
|
||||
{
|
||||
char homedir_psx[PATH_MAX];
|
||||
char homedir_w32[MAX_PATH];
|
||||
WCHAR domain_name[MAX_DOMAIN_NAME_LEN + 1];
|
||||
DWORD domname_len = MAX_DOMAIN_NAME_LEN + 1;
|
||||
char psid_buffer[MAX_SID_LEN];
|
||||
@ -448,19 +383,13 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
|
||||
|
||||
int uid = buffer[i].usri3_user_id;
|
||||
int gid = buffer[i].usri3_primary_group_id;
|
||||
homedir_w32[0] = homedir_psx[0] = '\0';
|
||||
homedir_psx[0] = '\0';
|
||||
if (passed_home_path[0] == '\0')
|
||||
{
|
||||
uni2ansi (buffer[i].usri3_home_dir, homedir_w32,
|
||||
sizeof (homedir_w32));
|
||||
if (homedir_w32[0] != '\0')
|
||||
{
|
||||
if (print_cygpath)
|
||||
cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE,
|
||||
homedir_w32, homedir_psx, PATH_MAX);
|
||||
else
|
||||
psx_dir (homedir_w32, homedir_psx);
|
||||
}
|
||||
if (buffer[i].usri3_home_dir[0] != L'\0')
|
||||
cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE,
|
||||
buffer[i].usri3_home_dir, homedir_psx,
|
||||
PATH_MAX);
|
||||
else
|
||||
uni2ansi (buffer[i].usri3_name,
|
||||
stpcpy (homedir_psx, "/home/"), PATH_MAX - 6);
|
||||
@ -598,13 +527,13 @@ usage (FILE * stream)
|
||||
" one of -l, -L, -d, -D must be specified, too\n"
|
||||
" -p,--path-to-home path use specified path instead of user account home dir\n"
|
||||
" or /home prefix\n"
|
||||
" -m,--no-mount don't use mount points for home dir\n"
|
||||
" -U,--unix userlist additionally print UNIX users when using -l or -L\n"
|
||||
" on a UNIX Samba server\n"
|
||||
" userlist is a comma-separated list of usernames\n"
|
||||
" or uid ranges (root,-25,50-100).\n"
|
||||
" (enumerating large ranges can take a long time!)\n"
|
||||
" -s,--no-sids (ignored)\n"
|
||||
" -m,--no-mount (ignored)\n"
|
||||
" -g,--local-groups (ignored)\n"
|
||||
" -h,--help displays this message\n"
|
||||
" -V,--version version information and exit\n"
|
||||
@ -692,7 +621,6 @@ main (int argc, char **argv)
|
||||
int print_domlist = 0;
|
||||
domlist_t domlist[32];
|
||||
char *opt, *p, *ep;
|
||||
int print_cygpath = 1;
|
||||
int print_current = 0;
|
||||
char *print_unix = NULL;
|
||||
const char *sep_char = "\\";
|
||||
@ -711,7 +639,6 @@ main (int argc, char **argv)
|
||||
setlocale (LC_CTYPE, "");
|
||||
if (!strcmp (setlocale (LC_CTYPE, NULL), "C"))
|
||||
setlocale (LC_CTYPE, "en_US.UTF-8");
|
||||
load_dsgetdcname ();
|
||||
in_domain = fetch_primary_domain ();
|
||||
fetch_current_user_sid ();
|
||||
|
||||
@ -719,10 +646,10 @@ main (int argc, char **argv)
|
||||
{
|
||||
enum_std_accounts ();
|
||||
if (in_domain)
|
||||
enum_users (TRUE, NULL, sep_char, print_cygpath, passed_home_path,
|
||||
10000, disp_username, 0);
|
||||
enum_users (TRUE, NULL, sep_char, passed_home_path, 10000,
|
||||
disp_username, 0);
|
||||
else
|
||||
enum_users (FALSE, NULL, sep_char, print_cygpath, passed_home_path, 0,
|
||||
enum_users (FALSE, NULL, sep_char, passed_home_path, 0,
|
||||
disp_username, 0);
|
||||
return 0;
|
||||
}
|
||||
@ -813,13 +740,6 @@ skip:
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
break;
|
||||
case 's':
|
||||
break;
|
||||
case 'm':
|
||||
print_cygpath = 0;
|
||||
break;
|
||||
case 'p':
|
||||
if (optarg[0] != '/')
|
||||
{
|
||||
@ -840,6 +760,10 @@ skip:
|
||||
case 'V':
|
||||
print_version ();
|
||||
return 0;
|
||||
case 'g': /* deprecated */
|
||||
case 's': /* deprecated */
|
||||
case 'm': /* deprecated */
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "Try `%s --help' for more information.\n",
|
||||
program_invocation_short_name);
|
||||
@ -865,15 +789,14 @@ skip:
|
||||
enum_unix_users (domlist + i, sep_char, my_off, print_unix);
|
||||
if (!my_off && !disp_username)
|
||||
enum_std_accounts ();
|
||||
enum_users (domlist[i].domain, domlist + i, sep_char, print_cygpath,
|
||||
passed_home_path, my_off, disp_username, print_current);
|
||||
enum_users (domlist[i].domain, domlist + i, sep_char, passed_home_path,
|
||||
my_off, disp_username, print_current);
|
||||
if (my_off)
|
||||
off += id_offset;
|
||||
}
|
||||
|
||||
if (print_current && !got_curr_user)
|
||||
current_user (print_cygpath, sep_char, passed_home_path, off,
|
||||
disp_username);
|
||||
current_user (sep_char, passed_home_path, off, disp_username);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -960,13 +960,13 @@ Options:
|
||||
one of -l, -L, -d, -D must be specified, too
|
||||
-p,--path-to-home path use specified path instead of user account home dir
|
||||
or /home prefix
|
||||
-m,--no-mount don't use mount points for home dir
|
||||
-U,--unix userlist additionally print UNIX users when using -l or -L\
|
||||
on a UNIX Samba server
|
||||
userlist is a comma-separated list of usernames
|
||||
or uid ranges (root,-25,50-100).
|
||||
(enumerating large ranges can take a long time!)
|
||||
-s,--no-sids (ignored)
|
||||
-m,--no-mount (ignored)
|
||||
-g,--local-groups (ignored)
|
||||
-h,--help displays this message
|
||||
-V,--version version information and exit
|
||||
@ -1013,11 +1013,7 @@ domain/group separator, you can specify another separator using the
|
||||
<literal>-S</literal> option, similar to the <command>mkgroup</command>.
|
||||
The <literal>-o</literal> option allows for special cases
|
||||
(such as multiple domains) where the UIDs might match otherwise.
|
||||
The <literal>-m</literal> option bypasses the current
|
||||
mount table so that, for example, two users who have a Windows home
|
||||
directory of H: could mount them differently. For more information on
|
||||
SIDs, see <xref linkend="ntsec"></xref> in the Cygwin User's Guide. The
|
||||
<literal>-p</literal> option causes <command>mkpasswd</command> to
|
||||
The <literal>-p</literal> option causes <command>mkpasswd</command> to
|
||||
use the specified prefix instead of the account home dir or <literal>/home/
|
||||
</literal>. For example, this command:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user