2004-06-17 Pierre Humblet <pierre.humblet@ieee.org>
* fhandler.cc (fhandler_base::open_9x): Do not check for null name. Move debug_printf to common code line. (fhandler_base::open): Ditto. Initialize upath. Remove second argument of pc.get_nt_native_path. * path.h (path_conv::get_nt_native_path): Remove second argument. * path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat. * security.h (str2buf2uni_cat): Delete declaration. (str2uni_cat): New declaration. * security.cc (str2buf2uni): Get length from sys_mbstowcs call. (str2buf2uni_cat): Delete function. (str2uni_cat): New function. * miscfuncs.cc (sys_mbstowcs): Add debug_printf.
This commit is contained in:
parent
9f35b46456
commit
bd0e9c7aa6
|
@ -1,3 +1,18 @@
|
||||||
|
2004-06-17 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_base::open_9x): Do not check for null name.
|
||||||
|
Move debug_printf to common code line.
|
||||||
|
(fhandler_base::open): Ditto. Initialize upath. Remove second argument
|
||||||
|
of pc.get_nt_native_path.
|
||||||
|
* path.h (path_conv::get_nt_native_path): Remove second argument.
|
||||||
|
* path.cc (path_conv::get_nt_native_path): Ditto. Call str2uni_cat.
|
||||||
|
* security.h (str2buf2uni_cat): Delete declaration.
|
||||||
|
(str2uni_cat): New declaration.
|
||||||
|
* security.cc (str2buf2uni): Get length from sys_mbstowcs call.
|
||||||
|
(str2buf2uni_cat): Delete function.
|
||||||
|
(str2uni_cat): New function.
|
||||||
|
* miscfuncs.cc (sys_mbstowcs): Add debug_printf.
|
||||||
|
|
||||||
2004-06-17 Corinna Vinschen <corinna@vinschen.de>
|
2004-06-17 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler.cc (fhandler_base::open): Substitute FILE_SUPERSEDE with
|
* fhandler.cc (fhandler_base::open): Substitute FILE_SUPERSEDE with
|
||||||
|
|
|
@ -437,12 +437,6 @@ fhandler_base::open_9x (int flags, mode_t mode)
|
||||||
|
|
||||||
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
||||||
|
|
||||||
if (get_win32_name () == NULL)
|
|
||||||
{
|
|
||||||
set_errno (ENOENT);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
|
if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
|
||||||
access = GENERIC_READ;
|
access = GENERIC_READ;
|
||||||
else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY)
|
else if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY)
|
||||||
|
@ -512,16 +506,16 @@ fhandler_base::open_9x (int flags, mode_t mode)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
|
|
||||||
x, get_win32_name (), access, shared, &sa,
|
|
||||||
creation_distribution, file_attributes);
|
|
||||||
|
|
||||||
set_io_handle (x);
|
set_io_handle (x);
|
||||||
set_flags (flags, pc.binmode ());
|
set_flags (flags, pc.binmode ());
|
||||||
|
|
||||||
res = 1;
|
res = 1;
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
done:
|
done:
|
||||||
|
debug_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
|
||||||
|
x, get_win32_name (), access, shared, &sa,
|
||||||
|
creation_distribution, file_attributes);
|
||||||
|
|
||||||
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
||||||
flags);
|
flags);
|
||||||
return res;
|
return res;
|
||||||
|
@ -534,11 +528,11 @@ fhandler_base::open (int flags, mode_t mode)
|
||||||
if (!wincap.is_winnt ())
|
if (!wincap.is_winnt ())
|
||||||
return fhandler_base::open_9x (flags, mode);
|
return fhandler_base::open_9x (flags, mode);
|
||||||
|
|
||||||
UNICODE_STRING upath;
|
|
||||||
WCHAR wpath[CYG_MAX_PATH + 10];
|
WCHAR wpath[CYG_MAX_PATH + 10];
|
||||||
pc.get_nt_native_path (upath, wpath);
|
UNICODE_STRING upath = {0, sizeof (wpath), wpath};
|
||||||
|
pc.get_nt_native_path (upath);
|
||||||
|
|
||||||
if (RtlIsDosDeviceName_U (wpath))
|
if (RtlIsDosDeviceName_U (upath.Buffer))
|
||||||
return fhandler_base::open_9x (flags, mode);
|
return fhandler_base::open_9x (flags, mode);
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
@ -554,11 +548,6 @@ fhandler_base::open (int flags, mode_t mode)
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
syscall_printf ("(%s, %p)", get_win32_name (), flags);
|
||||||
if (get_win32_name () == NULL)
|
|
||||||
{
|
|
||||||
set_errno (ENOENT);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
||||||
sa.lpSecurityDescriptor, NULL);
|
sa.lpSecurityDescriptor, NULL);
|
||||||
|
@ -657,17 +646,17 @@ fhandler_base::open (int flags, mode_t mode)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_printf ("%x = NtCreateFile "
|
|
||||||
"(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
|
||||||
status, x, access, get_win32_name (), file_attributes, shared,
|
|
||||||
create_disposition, create_options);
|
|
||||||
|
|
||||||
set_io_handle (x);
|
set_io_handle (x);
|
||||||
set_flags (flags, pc.binmode ());
|
set_flags (flags, pc.binmode ());
|
||||||
|
|
||||||
res = 1;
|
res = 1;
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
done:
|
done:
|
||||||
|
debug_printf ("%x = NtCreateFile "
|
||||||
|
"(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
||||||
|
status, x, access, get_win32_name (), file_attributes, shared,
|
||||||
|
create_disposition, create_options);
|
||||||
|
|
||||||
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
||||||
flags);
|
flags);
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -312,7 +312,10 @@ sys_wcstombs (char *tgt, const WCHAR *src, int len)
|
||||||
int __stdcall
|
int __stdcall
|
||||||
sys_mbstowcs (WCHAR *tgt, const char *src, int len)
|
sys_mbstowcs (WCHAR *tgt, const char *src, int len)
|
||||||
{
|
{
|
||||||
return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
|
int res = MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
|
||||||
|
if (!res)
|
||||||
|
debug_printf ("MultiByteToWideChar %E");
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
|
|
|
@ -459,25 +459,25 @@ path_conv::set_normalized_path (const char *path_copy)
|
||||||
}
|
}
|
||||||
|
|
||||||
PUNICODE_STRING
|
PUNICODE_STRING
|
||||||
path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath)
|
path_conv::get_nt_native_path (UNICODE_STRING &upath)
|
||||||
{
|
{
|
||||||
if (path[0] != '\\') /* X:\... or NUL, etc. */
|
if (path[0] != '\\') /* X:\... or NUL, etc. */
|
||||||
{
|
{
|
||||||
str2buf2uni (upath, wpath, "\\??\\");
|
str2uni_cat (upath, "\\??\\");
|
||||||
str2buf2uni_cat (upath, path);
|
str2uni_cat (upath, path);
|
||||||
}
|
}
|
||||||
else if (path[1] != '\\') /* \Device\... */
|
else if (path[1] != '\\') /* \Device\... */
|
||||||
str2buf2uni (upath, wpath, path);
|
str2uni_cat (upath, path);
|
||||||
else if (path[2] != '.'
|
else if (path[2] != '.'
|
||||||
|| path[3] != '\\') /* \\server\share\... */
|
|| path[3] != '\\') /* \\server\share\... */
|
||||||
{
|
{
|
||||||
str2buf2uni (upath, wpath, "\\??\\UNC\\");
|
str2uni_cat (upath, "\\??\\UNC\\");
|
||||||
str2buf2uni_cat (upath, path + 2);
|
str2uni_cat (upath, path + 2);
|
||||||
}
|
}
|
||||||
else /* \\.\device */
|
else /* \\.\device */
|
||||||
{
|
{
|
||||||
str2buf2uni (upath, wpath, "\\??\\");
|
str2uni_cat (upath, "\\??\\");
|
||||||
str2buf2uni_cat (upath, path + 4);
|
str2uni_cat (upath, path + 4);
|
||||||
}
|
}
|
||||||
return &upath;
|
return &upath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ class path_conv
|
||||||
|
|
||||||
~path_conv ();
|
~path_conv ();
|
||||||
inline char *get_win32 () { return path; }
|
inline char *get_win32 () { return path; }
|
||||||
PUNICODE_STRING get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath);
|
PUNICODE_STRING get_nt_native_path (UNICODE_STRING &upath);
|
||||||
operator char *() {return path;}
|
operator char *() {return path;}
|
||||||
operator const char *() {return path;}
|
operator const char *() {return path;}
|
||||||
operator DWORD &() {return fileattr;}
|
operator DWORD &() {return fileattr;}
|
||||||
|
|
|
@ -156,23 +156,28 @@ str2buf2lsa (LSA_STRING &tgt, char *buf, const char *srcstr)
|
||||||
memcpy (buf, srcstr, tgt.MaximumLength);
|
memcpy (buf, srcstr, tgt.MaximumLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The dimension of buf is assumed to be at least strlen(srcstr) + 1,
|
||||||
|
The result will be shorter if the input has multibyte chars */
|
||||||
void
|
void
|
||||||
str2buf2uni (UNICODE_STRING &tgt, WCHAR *buf, const char *srcstr)
|
str2buf2uni (UNICODE_STRING &tgt, WCHAR *buf, const char *srcstr)
|
||||||
{
|
{
|
||||||
tgt.Length = strlen (srcstr) * sizeof (WCHAR);
|
|
||||||
tgt.MaximumLength = tgt.Length + sizeof (WCHAR);
|
|
||||||
tgt.Buffer = (PWCHAR) buf;
|
tgt.Buffer = (PWCHAR) buf;
|
||||||
sys_mbstowcs (buf, srcstr, tgt.MaximumLength);
|
tgt.MaximumLength = (strlen (srcstr) + 1) * sizeof (WCHAR);
|
||||||
|
tgt.Length = sys_mbstowcs (buf, srcstr, tgt.MaximumLength / sizeof (WCHAR))
|
||||||
|
* sizeof (WCHAR);
|
||||||
|
if (tgt.Length)
|
||||||
|
tgt.Length -= sizeof (WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
str2buf2uni_cat (UNICODE_STRING &tgt, const char *srcstr)
|
str2uni_cat (UNICODE_STRING &tgt, const char *srcstr)
|
||||||
{
|
{
|
||||||
DWORD len = strlen (srcstr) * sizeof (WCHAR);
|
int len = sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr,
|
||||||
sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), srcstr,
|
(tgt.MaximumLength - tgt.Length) / sizeof (WCHAR));
|
||||||
len + tgt.MaximumLength);
|
if (len)
|
||||||
tgt.Length += len;
|
tgt.Length += (len - 1) * sizeof (WCHAR);
|
||||||
tgt.MaximumLength += len;
|
else
|
||||||
|
tgt.Length = tgt.MaximumLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* unused */
|
#if 0 /* unused */
|
||||||
|
|
|
@ -276,7 +276,7 @@ int setacl (HANDLE, const char *, int, __acl32 *);
|
||||||
|
|
||||||
struct _UNICODE_STRING;
|
struct _UNICODE_STRING;
|
||||||
void __stdcall str2buf2uni (_UNICODE_STRING &, WCHAR *, const char *) __attribute__ ((regparm (3)));
|
void __stdcall str2buf2uni (_UNICODE_STRING &, WCHAR *, const char *) __attribute__ ((regparm (3)));
|
||||||
void __stdcall str2buf2uni_cat (_UNICODE_STRING &, const char *) __attribute__ ((regparm (2)));
|
void __stdcall str2uni_cat (_UNICODE_STRING &, const char *) __attribute__ ((regparm (2)));
|
||||||
|
|
||||||
/* Try a subauthentication. */
|
/* Try a subauthentication. */
|
||||||
HANDLE subauth (struct passwd *pw);
|
HANDLE subauth (struct passwd *pw);
|
||||||
|
|
Loading…
Reference in New Issue