Add option to disable access to the global filesystem namespace.
authorEd Schouten <ed@nuxi.nl>
Thu, 12 Mar 2015 15:44:39 +0000 (15:44 +0000)
committerEd Schouten <ed@nuxi.nl>
Thu, 12 Mar 2015 15:44:39 +0000 (15:44 +0000)
commit97fdea618ea5f1d8837779917cab160376528cff
treef755f73cadad10b034b8035bd4d62fce19063683
parent02e55ef3fb85f0549cb3690c0a0ed40451829c1a
Add option to disable access to the global filesystem namespace.

Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.

This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:

- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
  all tests that use the global filesystem namespace to break, but will
  at least make all the other tests run (as get_temp_file_name will not
  build anyway).

It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).

Differential revision: http://reviews.llvm.org/D8194
Reviewed by: jroelofs (thanks!)

llvm-svn: 232049
15 files changed:
libcxx/CMakeLists.txt
libcxx/include/__config
libcxx/include/cstdio
libcxx/include/fstream
libcxx/test/CMakeLists.txt
libcxx/test/libcxx/test/config.py
libcxx/test/libcxx/test/format.py
libcxx/test/lit.site.cfg.in
libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
libcxx/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/fopen.fail.cpp [new file with mode: 0644]
libcxx/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/lit.local.cfg [new file with mode: 0644]
libcxx/test/std/input.output/file.streams/c.files/no.global.filesystem.namespace/rename.fail.cpp [new file with mode: 0644]
libcxx/test/std/input.output/file.streams/fstreams/lit.local.cfg [new file with mode: 0644]
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/lit.local.cfg [new file with mode: 0644]
libcxx/test/support/platform_support.h