summaryrefslogtreecommitdiff
path: root/file.c
AgeCommit message (Collapse)Author
2019-04-28Always mark the string returned by File.realpath as taintedJeremy Evans
This string can include elements that were not in either string passed to File.realpath, even if one of the strings is an absolute path, due to symlinks: ```ruby Dir.mkdir('b') unless File.directory?('b') File.write('b/a', '') unless File.file?('b/a') File.symlink('b', 'c') unless File.symlink?('c') path = File.realpath('c/a'.untaint, Dir.pwd.untaint) path # "/home/testr/ruby/b/a" path.tainted? # should be true, as 'b' comes from file system ``` [Bug #15803]
2019-03-23file.c: raise NotImplementedError instread of Errno::ENOSYSglass
[Misc #15615] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-24Check stx_btime in struct statxnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-22Support File#birthtime on Linuxnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-22Unified rb_file_s_birthtimenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-21Constifiednobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-21Path for AT_EMPTY_PATH must not be NULLnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-21Separate fstatx_without_gvl from statx_without_gvlnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20fix r67097 with castko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20Try statx syscallnobu
* file.c (rb_file_s_birthtime): export for pathname to check if birthtime is supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20revert r67093 because it breaks testsko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-20Try statx syscallnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-19* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-19file.c: enable File.birthtime on Linuxglass
enable File.birthtime on Linux if statx(2) is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23file.c: use correct integer-conversion functionmame
The return value of major() and minor() is unsigned int, not dev_t. So, UINT2NUM() is a better choice than DEVT2NUM(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20Document File.{setuid?,setgid?,sticky?} support for IO objects [Bug #13972]aycabta
* file.c (rb_file_setuid_p): rdoc for IO object support (rb_file_sgid_p): ditto (rb_file_sticky_p): ditto * NEWS: inform users of new feature * test/file/test_file_exhaustive.rb (io_open): wrapper for bare IO object (test_suid): test for bare IO support (test_sgid): ditto (test_sticky): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19array.c, file.c, string.c: [DOC] fix typosstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu
The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-13file.c: chardev is loadablenobu
* file.c (ruby_is_fd_loadable): allow character devices to load, e.g., `ruby /dev/null` exits successfully. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-28file.c: realpath on special symlinknobu
* file.c (realpath_rec): fallback to symlink path when it is accessible but the link target is not actual entry on file systems. [ruby-dev:50487] [Bug #14557] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-28file.c: get rid of useless conversionnobu
* file.c (rb_file_s_stat): File.stat does not accept an IO object as trying conversion to path name string first. skip conversion to IO and try stat(2) only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23[DOC] missing docs at toplevelnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06share ruby_null_devicenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24ruby/ruby.h: remove unnecessary exports from C-APInormal
Needlessly exporting can reduce performance locally and increase binary size. Increasing the footprint of our C-API larger is also detrimental to our development as it encourages tighter coupling with our internals; making it harder for us to preserve compatibility. If some parts of the core codebase needs access to globals, internal.h should be used instead of anything in include/ruby/*. "Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote: > On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote: > > shyouhei@ruby-lang.org wrote: > >> https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908 > >> > >> export rb_mFConst > > > > Why are we exporting all these and making the public C-API bigger? > > If anything, we should make these static. Thanks. > > No concrete reason, except they have already been externed in 2.5. > These variables had lacked declarations so far, which resulted in their > visibility to be that of extern. The commit is just confirming the status quo. > > I'm not against to turn them into static. This reverts changes from r61910, r61909, r61908, r61907, and r61906. * transcode.c (rb_eUndefinedConversionError): make static (rb_eInvalidByteSequenceError): ditto (rb_eConverterNotFoundError): ditto * process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto * file.c (rb_mFConst): ditto * error.c (rb_mWarning, rb_cWarningBuffer): ditto * enumerator.c (rb_cLazy): ditto [Misc #14381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19there is no guarantee that mode_t is as wide as intshyouhei
POSIX only defines mode_t to be "an integer typea", and in fact MacOS defines it to be uint16_t. We didn't have NUM2USHORT before so it did not make sense but now that we have it. Why not check apptopriately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14exclude flexible array size with old compilersnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-13file.c (struct apply_arg): Use FLEX_ARY_LENmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09internal.h: remove dependecy on ruby/encoding.hnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22[DOC] Fix indent [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22[DOC] Remove unmatched parenthesis [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10support 128bit ino on Windows (if available)usa
* win32/win32.c, include/ruby/win32.h (stati128, rb_{,u,l,ul}stati128): rename from stati64ns, change the type of st_ino to 64bit and added st_inohigh. * dir.c, file.c (stat, lstat): follow above changes. * file.c (rb_stat_ino): support 128bit ino. * win32/win32.c (rb_{,u,l,ul}stati128): ditto. [Feature #13731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04[DOC] improve rdoc formatting for links [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04support nanosec file timestamp on newer Windowsusa
Support nanosec file timestamp on Windows 8 or later. Original patches are written by kubo (Kubo Takehiro). Windows 7 and earlier also supports nanosec file timestamp, but it's too accurate than system time. so, this feature is disabled on such versions. [Feature #13726] this change also includes [Misc #13702] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04support `File.identical?` on ReFSusa
* file.c (rb_file_idenitical_p): move Windows dependent code to win32/win32.c. * win32/win32.c (rb_w32_file_identical_p): support ReFS. see [Feature #13731] [ruby-dev:50166] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29file.c: File.lutimenobu
* file.c (utime_internal): add File.lutime. [Feature #4052] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-28file: release GVL for access(2) syscallsnormal
Like stat(2), the access(2) syscall may take an indeterminate amount of time on slow/remote filesystems. This lets the following methods release the GVL to avoid choking the entire VM while one thread is stuck on a slow or non-responsive filesystem: - File.readable? - File.readable_real? - File.writable? - File.writable_real? - File.executable? - File.executable_real? * file.c (nogvl_eaccess): new function (nogvl_access): ditto (rb_access): new wrapper function (rb_eaccess): release GVL (rb_file_readable_real_p): use rb_access (rb_file_writable_real_p): ditto (rb_file_executable_real_p): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-26util.h: remove my_getcwdnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24file.c: simplify eaccess(3) callersnormal
This will make future work to release GVL here simpler. * file.c (rb_eaccess): new function (rb_file_readable_p): use rb_eaccess (rb_file_writable_p): ditto (rb_file_executable_p): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-21Fix a typokazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20File.mkfifo releases GVLnormal
mkfifo(3) is subject to the same problems as open(2) on slow filesystems. Release the GVL and let the rest of the VM run while we call mkfifo. * file.c (nogvl_mkfifo): new function (rb_file_s_mkfifo): release GVL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-19file.c (rb_file_s_mkfifo): use mode_t instead of intnormal
mode_t is the correct type for mkfifo(3). This fixes an oversight from r60592 which made the same change to several other functions. * file.c (rb_file_s_mkfifo): use mode_t instead of int git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-19file.c: fix 64-bit conversion warnings from r60844normal
* file.c (nogvl_truncate): cast int to VALUE before "void *" (rb_file_s_truncate): cast "void *" to VALUE before int git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-19File.readlink and rb_readlink releases GVLnormal
The `readlink' can stall on slow filesystems like `open' and `read' syscalls. Release the GVL and let the rest of the VM function while `readlink' runs. * file.c (nogvl_readlink): new function (readlink_without_gvl): ditto (rb_readlink): use readlink_without_gvl git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18file: File#truncate and File.truncate release GVLnormal
Like IO#write and IO.open, these file operations have unpredictable performance on slow file systems. Allow other threads of the VM to proceed while they are taking place. * file.c (nogvl_truncate): extract from rb_file_s_truncate (rb_file_s_truncate): release GVL (nogvl_ftruncate): extract from rb_file_truncate (rb_file_truncate): release GVL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07file.c: improve docs for File#pathstomar
* file.c: [DOC] fix grammar in docs for File#path and use a stronger description than "inaccurate". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01file.c: infect from argumentsnobu
* file.c (rb_check_realpath_internal): infetct the result with arguments, no taint if none are tainted and cwd is not used. [ruby-core:83583] [Bug #14060] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01revert r60596 because it cause faulure on TestFile#test_realpath_taintednessko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01file.c: infect from argumentsnobu
* file.c (rb_check_realpath_internal): infetct the result with arguments, no taint if none are tainted and cwd is not used. [ruby-core:83583] [Bug #14060] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31use mode_t where applicable (instead of int)normal
mode_t is the correct type for these syscalls and it can be easier-to-understand. It may also help portability to future platforms and improve type checking. * dir.c (dir_s_mkdir): use mode_t for mkdir(2) * file.c (chmod_internal): use mode_t for chmod(2) (rb_file_s_chmod): s/int/mode_t/ (lchmod_internal): ditto, deref pointer as in chmod_internal (rb_file_s_lchmod): pass pointer as in rb_file_s_chmod (rb_file_s_rename): use mode_t for umask(2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e