* dtable.cc (handle_to_fn): Accomodate new argument order in call to
sys_wcstombs. * fhandler_disk_file.cc (fhandler_disk_file::readdir): Call sys_wcstombs instead of just wcstombs to accomodate OEM codepages. * miscfuncs.cc (sys_wcstombs): Split len argument in source and target length. Always 0-terminate result in target string. * security.cc (lsa2wchar): Remove unused function. (lsa2str): Ditto. (get_lsa_srv_inf): Ditto. (get_logon_server): Accomodate new argument order in call to sys_wcstombs. (get_user_groups): Ditto. (get_user_local_groups): Ditto. (get_priv_list): Call sys_wcstombs directly instead of lsa2str. * uinfo.cc (cygheap_user::ontherange): Accomodate new argument order in call to sys_wcstombs. * winsup.h (sys_wcstombs): Change prototype to match new argument order.
This commit is contained in:
parent
3cb155a97f
commit
03a49a00ab
|
@ -1,3 +1,23 @@
|
|||
2006-02-07 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* dtable.cc (handle_to_fn): Accomodate new argument order in call to
|
||||
sys_wcstombs.
|
||||
* fhandler_disk_file.cc (fhandler_disk_file::readdir): Call sys_wcstombs
|
||||
instead of just wcstombs to accomodate OEM codepages.
|
||||
* miscfuncs.cc (sys_wcstombs): Split len argument in source and target
|
||||
length. Always 0-terminate result in target string.
|
||||
* security.cc (lsa2wchar): Remove unused function.
|
||||
(lsa2str): Ditto.
|
||||
(get_lsa_srv_inf): Ditto.
|
||||
(get_logon_server): Accomodate new argument order in call to
|
||||
sys_wcstombs.
|
||||
(get_user_groups): Ditto.
|
||||
(get_user_local_groups): Ditto.
|
||||
(get_priv_list): Call sys_wcstombs directly instead of lsa2str.
|
||||
* uinfo.cc (cygheap_user::ontherange): Accomodate new argument order
|
||||
in call to sys_wcstombs.
|
||||
* winsup.h (sys_wcstombs): Change prototype to match new argument order.
|
||||
|
||||
2006-02-07 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* init.cc (respawn_wow64_process): Exit with the exit code returned
|
||||
|
|
|
@ -848,7 +848,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
|
|||
ntfn->Name.Buffer[ntfn->Name.Length / sizeof (WCHAR)] = 0;
|
||||
|
||||
char win32_fn[CYG_MAX_PATH + 100];
|
||||
sys_wcstombs (win32_fn, ntfn->Name.Buffer, ntfn->Name.Length);
|
||||
sys_wcstombs (win32_fn, CYG_MAX_PATH + 100, ntfn->Name.Buffer);
|
||||
debug_printf ("nt name '%s'", win32_fn);
|
||||
if (!strncasematch (win32_fn, DEVICE_PREFIX, DEVICE_PREFIX_LEN)
|
||||
|| !QueryDosDevice (NULL, fnbuf, sizeof (fnbuf)))
|
||||
|
|
|
@ -1681,8 +1681,7 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
|
|||
}
|
||||
}
|
||||
}
|
||||
wcstombs (fname, FileName, buf->FileNameLength / 2);
|
||||
fname[buf->FileNameLength / 2] = '\0';
|
||||
sys_wcstombs (fname, CYG_MAX_PATH - 1, FileName, buf->FileNameLength / 2);
|
||||
}
|
||||
|
||||
if (!(res = readdir_helper (dir, de, RtlNtStatusToDosError (status),
|
||||
|
|
|
@ -210,10 +210,18 @@ get_cp ()
|
|||
return current_codepage == ansi_cp ? GetACP() : GetOEMCP();
|
||||
}
|
||||
|
||||
/* tlen is always treated as the maximum buffer size, including the '\0'
|
||||
character. sys_wcstombs will always return a 0-terminated result, no
|
||||
matter what. */
|
||||
int __stdcall
|
||||
sys_wcstombs (char *tgt, const WCHAR *src, int len)
|
||||
sys_wcstombs (char *tgt, int tlen, const WCHAR *src, int slen)
|
||||
{
|
||||
return WideCharToMultiByte (get_cp (), 0, src, -1, tgt, len, NULL, NULL);
|
||||
int ret;
|
||||
|
||||
ret = WideCharToMultiByte (get_cp (), 0, src, slen, tgt, tlen, NULL, NULL);
|
||||
if (ret)
|
||||
tgt[ret < tlen ? ret : tlen - 1] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __stdcall
|
||||
|
|
|
@ -188,28 +188,6 @@ str2uni_cat (UNICODE_STRING &tgt, const char *srcstr)
|
|||
tgt.Length = tgt.MaximumLength = 0;
|
||||
}
|
||||
|
||||
#if 0 /* unused */
|
||||
static void
|
||||
lsa2wchar (WCHAR *tgt, LSA_UNICODE_STRING &src, int size)
|
||||
{
|
||||
size = (size - 1) * sizeof (WCHAR);
|
||||
if (src.Length < size)
|
||||
size = src.Length;
|
||||
memcpy (tgt, src.Buffer, size);
|
||||
size >>= 1;
|
||||
tgt[size] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
lsa2str (char *tgt, LSA_UNICODE_STRING &src, int size)
|
||||
{
|
||||
if (src.Length / 2 < size)
|
||||
size = src.Length / 2;
|
||||
sys_wcstombs (tgt, src.Buffer, size);
|
||||
tgt[size] = 0;
|
||||
}
|
||||
|
||||
static LSA_HANDLE
|
||||
open_local_policy ()
|
||||
{
|
||||
|
@ -230,60 +208,6 @@ close_local_policy (LSA_HANDLE &lsa)
|
|||
lsa = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
#if 0 /* unused */
|
||||
static BOOL
|
||||
get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain)
|
||||
{
|
||||
NET_API_STATUS ret;
|
||||
WCHAR *buf;
|
||||
char name[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
WCHAR account[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
WCHAR primary[INTERNET_MAX_HOST_NAME_LENGTH + 1];
|
||||
PPOLICY_ACCOUNT_DOMAIN_INFO adi;
|
||||
PPOLICY_PRIMARY_DOMAIN_INFO pdi;
|
||||
|
||||
if ((ret = LsaQueryInformationPolicy (lsa, PolicyAccountDomainInformation,
|
||||
(PVOID *) &adi)) != STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_win_error (LsaNtStatusToWinError (ret));
|
||||
return FALSE;
|
||||
}
|
||||
lsa2wchar (account, adi->DomainName, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
LsaFreeMemory (adi);
|
||||
if ((ret = LsaQueryInformationPolicy (lsa, PolicyPrimaryDomainInformation,
|
||||
(PVOID *) &pdi)) != STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_win_error (LsaNtStatusToWinError (ret));
|
||||
return FALSE;
|
||||
}
|
||||
lsa2wchar (primary, pdi->Name, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
LsaFreeMemory (pdi);
|
||||
/* If the SID given in the primary domain info is NULL, the machine is
|
||||
not member of a domain. The name in the primary domain info is the
|
||||
name of the workgroup then. */
|
||||
if (pdi->Sid &&
|
||||
(ret =
|
||||
NetGetDCName (NULL, primary, (LPBYTE *) &buf)) == STATUS_SUCCESS)
|
||||
{
|
||||
sys_wcstombs (name, buf, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
strcpy (logonserver, name);
|
||||
if (domain)
|
||||
sys_wcstombs (domain, primary, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_wcstombs (name, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
strcpy (logonserver, "\\\\");
|
||||
strcat (logonserver, name);
|
||||
if (domain)
|
||||
sys_wcstombs (domain, account, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
}
|
||||
if (ret == STATUS_SUCCESS)
|
||||
NetApiBufferFree (buf);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
get_logon_server (const char *domain, char *server, WCHAR *wserver)
|
||||
{
|
||||
|
@ -306,7 +230,7 @@ get_logon_server (const char *domain, char *server, WCHAR *wserver)
|
|||
sys_mbstowcs (wdomain, domain, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
if ((ret = NetGetDCName (NULL, wdomain, (LPBYTE *) &buf)) == STATUS_SUCCESS)
|
||||
{
|
||||
sys_wcstombs (server, buf, INTERNET_MAX_HOST_NAME_LENGTH + 1);
|
||||
sys_wcstombs (server, INTERNET_MAX_HOST_NAME_LENGTH + 1, buf);
|
||||
if (wserver)
|
||||
for (WCHAR *ptr1 = buf; (*wserver++ = *ptr1++);)
|
||||
;
|
||||
|
@ -350,7 +274,7 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user,
|
|||
DWORD dlen = sizeof (domain);
|
||||
SID_NAME_USE use = SidTypeInvalid;
|
||||
|
||||
sys_wcstombs (dgroup + len, buf[i].grui0_name, GNLEN + 1);
|
||||
sys_wcstombs (dgroup + len, GNLEN + 1, buf[i].grui0_name);
|
||||
if (!LookupAccountName (NULL, dgroup, gsid, &glen, domain, &dlen, &use))
|
||||
debug_printf ("LookupAccountName(%s), %E", dgroup);
|
||||
else if (legal_sid_type (use))
|
||||
|
@ -445,7 +369,7 @@ get_user_local_groups (cygsidlist &grp_list, PSID pusersid)
|
|||
DWORD dlen = sizeof (domain);
|
||||
|
||||
use = SidTypeInvalid;
|
||||
sys_wcstombs (bgroup + blen, buf[i].lgrpi0_name, GNLEN + 1);
|
||||
sys_wcstombs (bgroup + blen, GNLEN + 1, buf[i].lgrpi0_name);
|
||||
if (!LookupAccountName (NULL, bgroup, gsid, &glen, domain, &dlen, &use))
|
||||
{
|
||||
if (GetLastError () != ERROR_NONE_MAPPED)
|
||||
|
@ -714,7 +638,8 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list)
|
|||
PTOKEN_PRIVILEGES tmp;
|
||||
DWORD tmp_count;
|
||||
|
||||
lsa2str (buf, privstrs[i], sizeof (buf) - 1);
|
||||
sys_wcstombs (buf, sizeof (buf),
|
||||
privstrs[i].Buffer, privstrs[i].Length / 2);
|
||||
if (!(priv = privilege_luid_by_name (buf)))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -306,11 +306,12 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
|
|||
sys_mbstowcs (wuser, winname (), sizeof (wuser) / sizeof (*wuser));
|
||||
if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3, (LPBYTE *) &ui)))
|
||||
{
|
||||
sys_wcstombs (homepath_env_buf, ui->usri3_home_dir, CYG_MAX_PATH);
|
||||
sys_wcstombs (homepath_env_buf, CYG_MAX_PATH,
|
||||
ui->usri3_home_dir);
|
||||
if (!homepath_env_buf[0])
|
||||
{
|
||||
sys_wcstombs (homepath_env_buf, ui->usri3_home_dir_drive,
|
||||
CYG_MAX_PATH);
|
||||
sys_wcstombs (homepath_env_buf, CYG_MAX_PATH,
|
||||
ui->usri3_home_dir_drive);
|
||||
if (homepath_env_buf[0])
|
||||
strcat (homepath_env_buf, "\\");
|
||||
else
|
||||
|
|
|
@ -119,7 +119,7 @@ extern codepage_type current_codepage;
|
|||
|
||||
UINT get_cp ();
|
||||
|
||||
int __stdcall sys_wcstombs(char *, const WCHAR *, int)
|
||||
int __stdcall sys_wcstombs(char *, int, const WCHAR *, int = -1)
|
||||
__attribute__ ((regparm(3)));
|
||||
|
||||
int __stdcall sys_mbstowcs(WCHAR *, const char *, int)
|
||||
|
|
Loading…
Reference in New Issue