* fhandler.h (executable_states): For now, make dont_care_if_executable

equivalent to not_executable.
* sys/mount.h: Define MOUNT_NOTEXEC.
* path.h (fs_info): New class.
(path_conv): Move fs-specific fields to new 'fs' structure.
(path_conv::update_fs_info): Move to fs_info and rename to just 'update'.
* path.cc (fs_info::update): Ditto.  Return 'true' if successful.
(fillout_mntent): Add ',noexec' to list of reported options.
This commit is contained in:
Christopher Faylor 2002-05-12 03:08:59 +00:00
parent b84621d2e3
commit 29ee580d07
5 changed files with 80 additions and 60 deletions

View File

@ -1,3 +1,14 @@
2002-05-11 Christopher Faylor <cgf@redhat.com>
* fhandler.h (executable_states): For now, make dont_care_if_executable
equivalent to not_executable.
* sys/mount.h: Define MOUNT_NOTEXEC.
* path.h (fs_info): New class.
(path_conv): Move fs-specific fields to new 'fs' structure.
(path_conv::update_fs_info): Move to fs_info and rename to just 'update'.
* path.cc (fs_info::update): Ditto. Return 'true' if successful.
(fillout_mntent): Add ',noexec' to list of reported options.
2002-05-11 Christopher Faylor <cgf@redhat.com> 2002-05-11 Christopher Faylor <cgf@redhat.com>
* fhandler_virtual.cc (fhandler_virtual::close): Quiet a compiler * fhandler_virtual.cc (fhandler_virtual::close): Quiet a compiler

View File

@ -123,8 +123,8 @@ enum bg_check_types
enum executable_states enum executable_states
{ {
is_executable, is_executable,
not_executable,
dont_care_if_executable, dont_care_if_executable,
not_executable = dont_care_if_executable,
dont_know_if_executable dont_know_if_executable
}; };

View File

@ -24,7 +24,9 @@ enum
MOUNT_AUTO = 0x020, /* mount point refers to auto device mount */ MOUNT_AUTO = 0x020, /* mount point refers to auto device mount */
MOUNT_CYGWIN_EXEC = 0x040, /* file or directory is or contains a cygwin MOUNT_CYGWIN_EXEC = 0x040, /* file or directory is or contains a cygwin
executable */ executable */
MOUNT_MIXED = 0x080, /* reads are text, writes are binary */ MOUNT_MIXED = 0x080, /* reads are text, writes are binary
not yet implemented */
MOUNT_NOTEXEC = 0x100 /* don't check files for executable magic */
}; };
int mount (const char *, const char *, unsigned __flags); int mount (const char *, const char *, unsigned __flags);

View File

@ -324,8 +324,8 @@ mkrelpath (char *path)
strcpy (path, "."); strcpy (path, ".");
} }
void bool
path_conv::update_fs_info (const char* win32_path) fs_info::update (const char *win32_path)
{ {
char tmp_buf [MAX_PATH]; char tmp_buf [MAX_PATH];
strncpy (tmp_buf, win32_path, MAX_PATH); strncpy (tmp_buf, win32_path, MAX_PATH);
@ -333,39 +333,37 @@ path_conv::update_fs_info (const char* win32_path)
if (!rootdir (tmp_buf)) if (!rootdir (tmp_buf))
{ {
debug_printf ("Cannot get root component of path %s", win32_path); debug_printf ("Cannot get root component of path %s", win32_path);
root_dir [0] = fs_name [0] = '\0'; name [0] = '\0';
fs_flags = fs_serial = 0; sym_opt = flags = serial = 0;
sym_opt = 0; return false;
return;
} }
if (strcmp (tmp_buf, root_dir) != 0) if (strcmp (tmp_buf, root_dir) == 0)
return 1;
strncpy (root_dir, tmp_buf, MAX_PATH);
drive_type = GetDriveType (root_dir);
if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\')))
is_remote_drive = 1;
else
is_remote_drive = 0;
if (!GetVolumeInformation (root_dir, NULL, 0, &serial, NULL, &flags,
name, sizeof (name)))
{ {
strncpy (root_dir, tmp_buf, MAX_PATH); debug_printf ("Cannot get volume information (%s), %E", root_dir);
drive_type = GetDriveType (root_dir); name [0] = '\0';
if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\'))) sym_opt = flags = serial = 0;
is_remote_drive = 1; return false;
else
is_remote_drive = 0;
if (!GetVolumeInformation (root_dir, NULL, 0, &fs_serial, NULL, &fs_flags,
fs_name, sizeof (fs_name)))
{
debug_printf ("Cannot get volume information (%s), %E", root_dir);
fs_name [0] = '\0';
fs_flags = fs_serial = 0;
sym_opt = 0;
}
else
{
/* FIXME: Samba by default returns "NTFS" in file system name, but
* doesn't support Extended Attributes. If there's some fast way to
* distinguish between samba and real ntfs, it should be implemented
* here.
*/
sym_opt = (!is_remote_drive && strcmp (fs_name, "NTFS") == 0) ? PC_CHECK_EA : 0;
}
} }
/* FIXME: Samba by default returns "NTFS" in file system name, but
* doesn't support Extended Attributes. If there's some fast way to
* distinguish between samba and real ntfs, it should be implemented
* here.
*/
sym_opt = (!is_remote_drive && strcmp (name, "NTFS") == 0) ? PC_CHECK_EA : 0;
return true;
} }
void void
@ -429,12 +427,12 @@ path_conv::check (const char *src, unsigned opt,
fileattr = INVALID_FILE_ATTRIBUTES; fileattr = INVALID_FILE_ATTRIBUTES;
case_clash = false; case_clash = false;
devn = unit = 0; devn = unit = 0;
root_dir[0] = '\0'; fs.root_dir[0] = '\0';
fs_name[0] = '\0'; fs.name[0] = '\0';
fs_flags = fs_serial = 0; fs.flags = fs.serial = 0;
sym_opt = 0; fs.sym_opt = 0;
drive_type = 0; fs.drive_type = 0;
is_remote_drive = 0; fs.is_remote_drive = 0;
normalized_path = NULL; normalized_path = NULL;
if (!(opt & PC_NULLEMPTY)) if (!(opt & PC_NULLEMPTY))
@ -548,7 +546,8 @@ path_conv::check (const char *src, unsigned opt,
goto out; /* Found a device. Stop parsing. */ goto out; /* Found a device. Stop parsing. */
} }
update_fs_info (full_path); if (!fs.update (full_path))
fs.root_dir[0] = '\0';
/* Eat trailing slashes */ /* Eat trailing slashes */
char *dostail = strchr (full_path, '\0'); char *dostail = strchr (full_path, '\0');
@ -572,7 +571,7 @@ path_conv::check (const char *src, unsigned opt,
goto out; goto out;
} }
int len = sym.check (full_path, suff, opt | sym_opt); int len = sym.check (full_path, suff, opt | fs.sym_opt);
if (sym.case_clash) if (sym.case_clash)
{ {
@ -742,9 +741,9 @@ out:
if (devn == FH_BAD) if (devn == FH_BAD)
{ {
update_fs_info (path); if (!fs.update (path))
if (!fs_name[0])
{ {
fs.root_dir[0] = '\0';
set_has_acls (false); set_has_acls (false);
set_has_buggy_open (false); set_has_buggy_open (false);
} }
@ -752,14 +751,14 @@ out:
{ {
set_isdisk (); set_isdisk ();
debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)", debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
root_dir, this->path, fs_flags & FS_PERSISTENT_ACLS); fs.root_dir, this->path, fs.flags & FS_PERSISTENT_ACLS);
if (!allow_smbntsec && is_remote_drive) if (!allow_smbntsec && fs.is_remote_drive)
set_has_acls (false); set_has_acls (false);
else else
set_has_acls (fs_flags & FS_PERSISTENT_ACLS); set_has_acls (fs.flags & FS_PERSISTENT_ACLS);
/* Known file systems with buggy open calls. Further explanation /* Known file systems with buggy open calls. Further explanation
in fhandler.cc (fhandler_disk_file::open). */ in fhandler.cc (fhandler_disk_file::open). */
set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0); set_has_buggy_open (strcmp (fs.name, "SUNWNFS") == 0);
} }
} }
#if 0 #if 0
@ -2418,6 +2417,8 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
strcat (_reent_winsup ()->mnt_opts, (char *) ",cygexec"); strcat (_reent_winsup ()->mnt_opts, (char *) ",cygexec");
else if (flags & MOUNT_EXEC) else if (flags & MOUNT_EXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",exec"); strcat (_reent_winsup ()->mnt_opts, (char *) ",exec");
else if (flags & MOUNT_NOTEXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",noexec");
if ((flags & MOUNT_AUTO)) /* cygdrive */ if ((flags & MOUNT_AUTO)) /* cygdrive */
strcat (_reent_winsup ()->mnt_opts, (char *) ",noumount"); strcat (_reent_winsup ()->mnt_opts, (char *) ",noumount");

View File

@ -44,10 +44,10 @@ enum path_types
PATH_SYMLINK = MOUNT_SYMLINK, PATH_SYMLINK = MOUNT_SYMLINK,
PATH_BINARY = MOUNT_BINARY, PATH_BINARY = MOUNT_BINARY,
PATH_EXEC = MOUNT_EXEC, PATH_EXEC = MOUNT_EXEC,
PATH_NOTEXEC = MOUNT_NOTEXEC,
PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC, PATH_CYGWIN_EXEC = MOUNT_CYGWIN_EXEC,
PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC), PATH_ALL_EXEC = (PATH_CYGWIN_EXEC | PATH_EXEC),
PATH_ISDISK = 0x04000000, PATH_ISDISK = 0x04000000,
PATH_NOTEXEC = 0x08000000,
PATH_HAS_SYMLINKS = 0x10000000, PATH_HAS_SYMLINKS = 0x10000000,
PATH_HASBUGGYOPEN = 0x20000000, PATH_HASBUGGYOPEN = 0x20000000,
PATH_SOCKET = 0x40000000, PATH_SOCKET = 0x40000000,
@ -55,18 +55,22 @@ enum path_types
}; };
class symlink_info; class symlink_info;
struct fs_info
{
char name[MAX_PATH];
char root_dir[MAX_PATH];
DWORD flags;
DWORD serial;
DWORD sym_opt; /* additional options to pass to symlink_info resolver */
DWORD is_remote_drive;
DWORD drive_type;
bool update (const char *);
};
class path_conv class path_conv
{ {
char path[MAX_PATH]; char path[MAX_PATH];
char root_dir[MAX_PATH]; fs_info fs;
char fs_name[MAX_PATH];
DWORD fs_flags;
DWORD fs_serial;
DWORD sym_opt; /* additional options to pass to symlink_info resolver */
void add_ext_from_sym (symlink_info&); void add_ext_from_sym (symlink_info&);
void update_fs_info (const char*);
DWORD drive_type;
bool is_remote_drive;
public: public:
unsigned path_flags; unsigned path_flags;
@ -79,7 +83,7 @@ class path_conv
char *normalized_path; char *normalized_path;
int isdisk () const { return path_flags & PATH_ISDISK;} int isdisk () const { return path_flags & PATH_ISDISK;}
int isremote () const {return is_remote_drive;} int isremote () const {return fs.is_remote_drive;}
int has_acls () const {return path_flags & PATH_HASACLS;} int has_acls () const {return path_flags & PATH_HASACLS;}
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;} int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
@ -126,7 +130,9 @@ class path_conv
check (src, opt | PC_NULLEMPTY, suffixes); check (src, opt | PC_NULLEMPTY, suffixes);
} }
path_conv (): path_flags (0), known_suffix (NULL), error (0), devn (0), unit (0), fileattr (INVALID_FILE_ATTRIBUTES), normalized_path (NULL) {path[0] = '\0';} path_conv (): path_flags (0), known_suffix (NULL), error (0), devn (0),
unit (0), fileattr (INVALID_FILE_ATTRIBUTES),
normalized_path (NULL) {path[0] = '\0';}
~path_conv (); ~path_conv ();
inline char *get_win32 () { return path; } inline char *get_win32 () { return path; }
@ -138,8 +144,8 @@ class path_conv
DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;} DWORD get_devn () {return devn == FH_BAD ? (DWORD) FH_DISK : devn;}
short get_unitn () {return devn == FH_BAD ? 0 : unit;} short get_unitn () {return devn == FH_BAD ? 0 : unit;}
DWORD file_attributes () {return fileattr;} DWORD file_attributes () {return fileattr;}
DWORD get_drive_type () {return drive_type;} DWORD get_drive_type () {return fs.drive_type;}
BOOL fs_fast_ea () {return sym_opt & PC_CHECK_EA;} BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
void set_path (const char *p) {strcpy (path, p);} void set_path (const char *p) {strcpy (path, p);}
void clear_normalized_path (); void clear_normalized_path ();
}; };