* autoload.cc (NtSetSecurityObject): Add.
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only request READ_CONTROL rights when opening the file. * ntdll.h (NtSetSecurityObject): Add declaration. * security.cc (write_sd): Call NtSetSecurityObject instead of BackupWrite. (get_nt_object_security): Don't free security descriptor here. * syscalls.cc (ttyname): Use buffer of length TTY_NAME_MAX + 1. * sysconf.cc (sysconf): Handle _SC_TTY_NAME_MAX request. * include/limits.h: Define TTY_NAME_MAX and _POSIX_TTY_NAME_MAX.
This commit is contained in:
parent
93d66ddc20
commit
f4ae6dc62c
@ -1,3 +1,19 @@
|
|||||||
|
2004-04-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* autoload.cc (NtSetSecurityObject): Add.
|
||||||
|
* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Only request
|
||||||
|
READ_CONTROL rights when opening the file.
|
||||||
|
* ntdll.h (NtSetSecurityObject): Add declaration.
|
||||||
|
* security.cc (write_sd): Call NtSetSecurityObject instead of
|
||||||
|
BackupWrite.
|
||||||
|
(get_nt_object_security): Don't free security descriptor here.
|
||||||
|
|
||||||
|
2004-04-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* syscalls.cc (ttyname): Use buffer of length TTY_NAME_MAX + 1.
|
||||||
|
* sysconf.cc (sysconf): Handle _SC_TTY_NAME_MAX request.
|
||||||
|
* include/limits.h: Define TTY_NAME_MAX and _POSIX_TTY_NAME_MAX.
|
||||||
|
|
||||||
2004-04-14 Corinna Vinschen <corinna@vinschen.de>
|
2004-04-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygwin.din: Export rand_r and ttyname_r.
|
* cygwin.din: Export rand_r and ttyname_r.
|
||||||
|
@ -394,6 +394,7 @@ LoadDLLfuncEx2 (NtQueryObject, 20, ntdll, 1, 1)
|
|||||||
LoadDLLfuncEx (NtQuerySystemInformation, 16, ntdll, 1)
|
LoadDLLfuncEx (NtQuerySystemInformation, 16, ntdll, 1)
|
||||||
LoadDLLfuncEx (NtQuerySecurityObject, 20, ntdll, 1)
|
LoadDLLfuncEx (NtQuerySecurityObject, 20, ntdll, 1)
|
||||||
LoadDLLfuncEx (NtQueryVirtualMemory, 24, ntdll, 1)
|
LoadDLLfuncEx (NtQueryVirtualMemory, 24, ntdll, 1)
|
||||||
|
LoadDLLfuncEx (NtSetSecurityObject, 12, ntdll, 1)
|
||||||
LoadDLLfuncEx (NtUnmapViewOfSection, 8, ntdll, 1)
|
LoadDLLfuncEx (NtUnmapViewOfSection, 8, ntdll, 1)
|
||||||
LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1)
|
LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1)
|
||||||
LoadDLLfuncEx (RtlNtStatusToDosError, 4, ntdll, 1)
|
LoadDLLfuncEx (RtlNtStatusToDosError, 4, ntdll, 1)
|
||||||
|
@ -377,7 +377,8 @@ fhandler_disk_file::fchmod (mode_t mode)
|
|||||||
if (pc.is_fs_special ())
|
if (pc.is_fs_special ())
|
||||||
return chmod_device (pc, mode);
|
return chmod_device (pc, mode);
|
||||||
|
|
||||||
if (!get_io_handle () && !(oret = open_fs (O_RDONLY | O_BINARY, 0)))
|
query_open (query_read_control);
|
||||||
|
if (!get_io_handle () && !(oret = open_fs (O_BINARY, 0)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
SetFileAttributes (get_win32_name (), (DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
|
SetFileAttributes (get_win32_name (), (DWORD) pc & ~FILE_ATTRIBUTE_READONLY);
|
||||||
|
@ -151,6 +151,10 @@ details. */
|
|||||||
#undef TIMER_MAX
|
#undef TIMER_MAX
|
||||||
#define TIMER_MAX 32
|
#define TIMER_MAX 32
|
||||||
|
|
||||||
|
/* Maximum number of characters in a tty name. */
|
||||||
|
#undef TTY_NAME_MAX
|
||||||
|
#define TTY_NAME_MAX 12
|
||||||
|
|
||||||
/* POSIX values */
|
/* POSIX values */
|
||||||
/* These should never vary from one system type to another */
|
/* These should never vary from one system type to another */
|
||||||
/* They represent the minimum values that POSIX systems must support.
|
/* They represent the minimum values that POSIX systems must support.
|
||||||
@ -170,6 +174,7 @@ details. */
|
|||||||
#define _POSIX_TZNAME_MAX 3
|
#define _POSIX_TZNAME_MAX 3
|
||||||
#define _POSIX_RTSIG_MAX 8
|
#define _POSIX_RTSIG_MAX 8
|
||||||
#define _POSIX_TIMER_MAX 32
|
#define _POSIX_TIMER_MAX 32
|
||||||
|
#define _POSIX_TTY_NAME_MAX 9
|
||||||
|
|
||||||
#define RTSIG_MAX _POSIX_RTSIG_MAX
|
#define RTSIG_MAX _POSIX_RTSIG_MAX
|
||||||
|
|
||||||
|
@ -412,6 +412,8 @@ extern "C"
|
|||||||
PSECURITY_DESCRIPTOR, ULONG, PULONG);
|
PSECURITY_DESCRIPTOR, ULONG, PULONG);
|
||||||
NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS,
|
NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS,
|
||||||
PVOID, ULONG, PULONG);
|
PVOID, ULONG, PULONG);
|
||||||
|
NTSTATUS NTAPI NtSetSecurityObject (HANDLE, SECURITY_INFORMATION,
|
||||||
|
PSECURITY_DESCRIPTOR);
|
||||||
NTSTATUS NTAPI NtUnmapViewOfSection (HANDLE, PVOID);
|
NTSTATUS NTAPI NtUnmapViewOfSection (HANDLE, PVOID);
|
||||||
VOID NTAPI RtlInitUnicodeString (PUNICODE_STRING, PCWSTR);
|
VOID NTAPI RtlInitUnicodeString (PUNICODE_STRING, PCWSTR);
|
||||||
ULONG NTAPI RtlNtStatusToDosError (NTSTATUS);
|
ULONG NTAPI RtlNtStatusToDosError (NTSTATUS);
|
||||||
|
@ -1141,64 +1141,33 @@ write_sd (const char *file, security_descriptor &sd)
|
|||||||
else
|
else
|
||||||
res = saved_res;
|
res = saved_res;
|
||||||
if (res == 1 && owner != cygheap->user.sid ())
|
if (res == 1 && owner != cygheap->user.sid ())
|
||||||
|
{
|
||||||
|
set_errno (EPERM);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
fh = CreateFile (file,
|
if ((fh = CreateFile (file,
|
||||||
WRITE_OWNER | WRITE_DAC,
|
WRITE_OWNER | WRITE_DAC,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
&sec_none_nih,
|
&sec_none_nih,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
|
||||||
NULL);
|
NULL)) == INVALID_HANDLE_VALUE)
|
||||||
|
|
||||||
if (fh == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
NTSTATUS ret = NtSetSecurityObject (fh,
|
||||||
LPVOID context = NULL;
|
DACL_SECURITY_INFORMATION
|
||||||
DWORD bytes_written = 0;
|
| GROUP_SECURITY_INFORMATION
|
||||||
WIN32_STREAM_ID header;
|
| OWNER_SECURITY_INFORMATION,
|
||||||
|
sd);
|
||||||
memset (&header, 0, sizeof (header));
|
|
||||||
/* write new security info header */
|
|
||||||
header.dwStreamId = BACKUP_SECURITY_DATA;
|
|
||||||
header.dwStreamAttributes = STREAM_CONTAINS_SECURITY;
|
|
||||||
header.Size.HighPart = 0;
|
|
||||||
header.Size.LowPart = sd.size ();
|
|
||||||
header.dwStreamNameSize = 0;
|
|
||||||
if (!BackupWrite (fh, (LPBYTE) &header,
|
|
||||||
3 * sizeof (DWORD) + sizeof (LARGE_INTEGER),
|
|
||||||
&bytes_written, FALSE, TRUE, &context))
|
|
||||||
{
|
|
||||||
__seterrno ();
|
|
||||||
CloseHandle (fh);
|
CloseHandle (fh);
|
||||||
|
if (ret != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write new security descriptor */
|
|
||||||
if (!BackupWrite (fh, (LPBYTE) (PSECURITY_DESCRIPTOR) sd,
|
|
||||||
header.Size.LowPart + header.dwStreamNameSize,
|
|
||||||
&bytes_written, FALSE, TRUE, &context))
|
|
||||||
{
|
|
||||||
/* Samba returns ERROR_NOT_SUPPORTED.
|
|
||||||
FAT returns ERROR_INVALID_SECURITY_DESCR.
|
|
||||||
This shouldn't return as error, but better be ignored. */
|
|
||||||
DWORD ret = GetLastError ();
|
|
||||||
if (ret != ERROR_NOT_SUPPORTED && ret != ERROR_INVALID_SECURITY_DESCR)
|
|
||||||
{
|
|
||||||
__seterrno ();
|
|
||||||
BackupWrite (fh, NULL, 0, &bytes_written, TRUE, TRUE, &context);
|
|
||||||
CloseHandle (fh);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* terminate the restore process */
|
|
||||||
BackupWrite (fh, NULL, 0, &bytes_written, TRUE, TRUE, &context);
|
|
||||||
CloseHandle (fh);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1391,7 +1360,6 @@ get_nt_object_security (HANDLE handle, SE_OBJECT_TYPE object_type,
|
|||||||
}
|
}
|
||||||
if (ret != STATUS_SUCCESS)
|
if (ret != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
sd_ret.free ();
|
|
||||||
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
__seterrno_from_win_error (RtlNtStatusToDosError (ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1536,8 +1536,8 @@ ttyname_r (int fd, char *buf, size_t buflen)
|
|||||||
extern "C" char *
|
extern "C" char *
|
||||||
ttyname (int fd)
|
ttyname (int fd)
|
||||||
{
|
{
|
||||||
static char name[CYG_MAX_PATH];
|
static char name[TTY_NAME_MAX + 1];
|
||||||
int ret = ttyname_r (fd, name, CYG_MAX_PATH);
|
int ret = ttyname_r (fd, name, TTY_NAME_MAX + 1);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
set_errno (ret);
|
set_errno (ret);
|
||||||
|
@ -122,6 +122,8 @@ sysconf (int in)
|
|||||||
}
|
}
|
||||||
case _SC_RTSIG_MAX:
|
case _SC_RTSIG_MAX:
|
||||||
return RTSIG_MAX;
|
return RTSIG_MAX;
|
||||||
|
case _SC_TTY_NAME_MAX:
|
||||||
|
return TTY_NAME_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalid input or unimplemented sysconf name */
|
/* Invalid input or unimplemented sysconf name */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user