|
||||
File indexing completed on 2025-01-18 09:50:14
0001 // Copyright (c) 2006, 2007 Julio M. Merino Vidal 0002 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling 0003 // Copyright (c) 2009 Boris Schaeling 0004 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling 0005 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling 0006 // Copyright (c) 2016 Klemens D. Morgenstern 0007 // 0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0010 0011 #ifndef BOOST_PROCESS_SHELL_PATH_HPP 0012 #define BOOST_PROCESS_SHELL_PATH_HPP 0013 0014 #include <boost/process/detail/config.hpp> 0015 #include <boost/process/detail/traits/wchar_t.hpp> 0016 0017 #if defined(BOOST_POSIX_API) 0018 #include <boost/process/detail/posix/shell_path.hpp> 0019 #elif defined(BOOST_WINDOWS_API) 0020 #include <boost/process/detail/windows/shell_path.hpp> 0021 #endif 0022 0023 /** \file boost/process/shell.hpp 0024 * 0025 * Header which provides the shell property. This provides the 0026 * property to launch a process through the system shell. 0027 * It also allows the user to obtain the shell-path via shell(). 0028 \xmlonly 0029 <programlisting> 0030 namespace boost { 0031 namespace process { 0032 <emphasis>unspecified</emphasis> <globalname alt="boost::process::shell">shell</globalname>; 0033 } 0034 } 0035 </programlisting> 0036 \endxmlonly 0037 0038 */ 0039 0040 namespace boost { namespace process { namespace detail { 0041 0042 0043 struct shell_ 0044 { 0045 constexpr shell_() {} 0046 0047 boost::process::filesystem::path operator()() const 0048 { 0049 return boost::process::detail::api::shell_path(); 0050 } 0051 boost::process::filesystem::path operator()(std::error_code & ec) const noexcept 0052 { 0053 return boost::process::detail::api::shell_path(ec); 0054 } 0055 }; 0056 0057 template<> 0058 struct is_wchar_t<shell_> : is_wchar_t<boost::process::filesystem::path> 0059 { 0060 }; 0061 0062 } 0063 /** 0064 The shell property enables to launch a program through the shell of the system. 0065 0066 \code{.cpp} 0067 system("gcc", shell); 0068 \endcode 0069 0070 The shell argument goes without any expression. The operator() is overloaded, to 0071 obtain the path of the system shell. 0072 0073 \code{.cpp} 0074 auto shell_cmd = shell(); 0075 //avoid exceptions 0076 std::error_code ec; 0077 shell_cmd = shell(ec); 0078 \endcode 0079 0080 \attention Launching through the shell will NOT provide proper error handling, i.e. 0081 you will get an error via the return code. 0082 0083 \attention Executing shell commands that incorporate unsanitized input from an untrusted source makes a program vulnerable to shell injection, a serious security flaw which can result in arbitrary command execution. For this reason, the use of `shell` is strongly discouraged in cases where the command string is constructed from external input: 0084 0085 */ 0086 constexpr ::boost::process::detail::shell_ shell; 0087 0088 }} 0089 0090 0091 0092 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |