Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

208 lines
11KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Auto-loading safe path (Debugging with GDB)</title>
  17. <meta name="description" content="Auto-loading safe path (Debugging with GDB)">
  18. <meta name="keywords" content="Auto-loading safe path (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Auto_002dloading.html#Auto_002dloading" rel="up" title="Auto-loading">
  26. <link href="Auto_002dloading-verbose-mode.html#Auto_002dloading-verbose-mode" rel="next" title="Auto-loading verbose mode">
  27. <link href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file" rel="prev" title="libthread_db.so.1 file">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Auto_002dloading-safe-path"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Auto_002dloading-verbose-mode.html#Auto_002dloading-verbose-mode" accesskey="n" rel="next">Auto-loading verbose mode</a>, Previous: <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file" accesskey="p" rel="prev">libthread_db.so.1 file</a>, Up: <a href="Auto_002dloading.html#Auto_002dloading" accesskey="u" rel="up">Auto-loading</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Security-restriction-for-auto_002dloading"></a>
  64. <h4 class="subsection">22.8.3 Security restriction for auto-loading</h4>
  65. <a name="index-auto_002dloading-safe_002dpath"></a>
  66. <p>As the files of inferior can come from untrusted source (such as submitted by
  67. an application user) <small>GDB</small> does not always load any files automatically.
  68. <small>GDB</small> provides the &lsquo;<samp>set auto-load safe-path</samp>&rsquo; setting to list
  69. directories trusted for loading files not explicitly requested by user.
  70. Each directory can also be a shell wildcard pattern.
  71. </p>
  72. <p>If the path is not set properly you will see a warning and the file will not
  73. get loaded:
  74. </p>
  75. <div class="smallexample">
  76. <pre class="smallexample">$ ./gdb -q ./gdb
  77. Reading symbols from /home/user/gdb/gdb...
  78. warning: File &quot;/home/user/gdb/gdb-gdb.gdb&quot; auto-loading has been
  79. declined by your `auto-load safe-path' set
  80. to &quot;$debugdir:$datadir/auto-load&quot;.
  81. warning: File &quot;/home/user/gdb/gdb-gdb.py&quot; auto-loading has been
  82. declined by your `auto-load safe-path' set
  83. to &quot;$debugdir:$datadir/auto-load&quot;.
  84. </pre></div>
  85. <p>To instruct <small>GDB</small> to go ahead and use the init files anyway,
  86. invoke <small>GDB</small> like this:
  87. </p>
  88. <div class="smallexample">
  89. <pre class="smallexample">$ gdb -q -iex &quot;set auto-load safe-path /home/user/gdb&quot; ./gdb
  90. </pre></div>
  91. <p>The list of trusted directories is controlled by the following commands:
  92. </p>
  93. <dl compact="compact">
  94. <dd><a name="set-auto_002dload-safe_002dpath"></a><a name="index-set-auto_002dload-safe_002dpath"></a>
  95. </dd>
  96. <dt><code>set auto-load safe-path <span class="roman">[</span><var>directories</var><span class="roman">]</span></code></dt>
  97. <dd><p>Set the list of directories (and their subdirectories) trusted for automatic
  98. loading and execution of scripts. You can also enter a specific trusted file.
  99. Each directory can also be a shell wildcard pattern; wildcards do not match
  100. directory separator - see <code>FNM_PATHNAME</code> for system function <code>fnmatch</code>
  101. (see <a href="http://www.gnu.org/software/libc/manual/html_node/Wildcard-Matching.html#Wildcard-Matching">fnmatch</a> in <cite>GNU C Library Reference Manual</cite>).
  102. If you omit <var>directories</var>, &lsquo;<samp>auto-load safe-path</samp>&rsquo; will be reset to
  103. its default value as specified during <small>GDB</small> compilation.
  104. </p>
  105. <p>The list of directories uses path separator (&lsquo;<samp>:</samp>&rsquo; on GNU and Unix
  106. systems, &lsquo;<samp>;</samp>&rsquo; on MS-Windows and MS-DOS) to separate directories, similarly
  107. to the <code>PATH</code> environment variable.
  108. </p>
  109. <a name="show-auto_002dload-safe_002dpath"></a><a name="index-show-auto_002dload-safe_002dpath"></a>
  110. </dd>
  111. <dt><code>show auto-load safe-path</code></dt>
  112. <dd><p>Show the list of directories trusted for automatic loading and execution of
  113. scripts.
  114. </p>
  115. <a name="add_002dauto_002dload_002dsafe_002dpath"></a><a name="index-add_002dauto_002dload_002dsafe_002dpath"></a>
  116. </dd>
  117. <dt><code>add-auto-load-safe-path</code></dt>
  118. <dd><p>Add an entry (or list of entries) to the list of directories trusted for
  119. automatic loading and execution of scripts. Multiple entries may be delimited
  120. by the host platform path separator in use.
  121. </p></dd>
  122. </dl>
  123. <p>This variable defaults to what <code>--with-auto-load-dir</code> has been configured
  124. to (see <a href="objfile_002dgdbdotext-file.html#with_002dauto_002dload_002ddir">with-auto-load-dir</a>). <samp>$debugdir</samp> and <samp>$datadir</samp>
  125. substitution applies the same as for <a href="objfile_002dgdbdotext-file.html#set-auto_002dload-scripts_002ddirectory">set auto-load scripts-directory</a>.
  126. The default <code>set auto-load safe-path</code> value can be also overriden by
  127. <small>GDB</small> configuration option <samp>--with-auto-load-safe-path</samp>.
  128. </p>
  129. <p>Setting this variable to <samp>/</samp> disables this security protection,
  130. corresponding <small>GDB</small> configuration option is
  131. <samp>--without-auto-load-safe-path</samp>.
  132. This variable is supposed to be set to the system directories writable by the
  133. system superuser only. Users can add their source directories in init files in
  134. their home directories (see <a href="Startup.html#Home-Directory-Init-File">Home Directory Init File</a>). See also deprecated
  135. init file in the current directory
  136. (see <a href="Startup.html#Init-File-in-the-Current-Directory-during-Startup">Init File in the Current Directory during Startup</a>).
  137. </p>
  138. <p>To force <small>GDB</small> to load the files it declined to load in the previous
  139. example, you could use one of the following ways:
  140. </p>
  141. <dl compact="compact">
  142. <dt><samp>~/.gdbinit</samp>: &lsquo;<samp>add-auto-load-safe-path ~/src/gdb</samp>&rsquo;</dt>
  143. <dd><p>Specify this trusted directory (or a file) as additional component of the list.
  144. You have to specify also any existing directories displayed by
  145. by &lsquo;<samp>show auto-load safe-path</samp>&rsquo; (such as &lsquo;<samp>/usr:/bin</samp>&rsquo; in this example).
  146. </p>
  147. </dd>
  148. <dt><kbd>gdb -iex &quot;set auto-load safe-path /usr:/bin:~/src/gdb&quot; &hellip;</kbd></dt>
  149. <dd><p>Specify this directory as in the previous case but just for a single
  150. <small>GDB</small> session.
  151. </p>
  152. </dd>
  153. <dt><kbd>gdb -iex &quot;set auto-load safe-path /&quot; &hellip;</kbd></dt>
  154. <dd><p>Disable auto-loading safety for a single <small>GDB</small> session.
  155. This assumes all the files you debug during this <small>GDB</small> session will come
  156. from trusted sources.
  157. </p>
  158. </dd>
  159. <dt><kbd>./configure --without-auto-load-safe-path</kbd></dt>
  160. <dd><p>During compilation of <small>GDB</small> you may disable any auto-loading safety.
  161. This assumes all the files you will ever debug with this <small>GDB</small> come from
  162. trusted sources.
  163. </p></dd>
  164. </dl>
  165. <p>On the other hand you can also explicitly forbid automatic files loading which
  166. also suppresses any such warning messages:
  167. </p>
  168. <dl compact="compact">
  169. <dt><kbd>gdb -iex &quot;set auto-load no&quot; &hellip;</kbd></dt>
  170. <dd><p>You can use <small>GDB</small> command-line option for a single <small>GDB</small> session.
  171. </p>
  172. </dd>
  173. <dt><samp>~/.gdbinit</samp>: &lsquo;<samp>set auto-load no</samp>&rsquo;</dt>
  174. <dd><p>Disable auto-loading globally for the user
  175. (see <a href="Startup.html#Home-Directory-Init-File">Home Directory Init File</a>). While it is improbable, you could also
  176. use system init file instead (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>).
  177. </p></dd>
  178. </dl>
  179. <p>This setting applies to the file names as entered by user. If no entry matches
  180. <small>GDB</small> tries as a last resort to also resolve all the file names into
  181. their canonical form (typically resolving symbolic links) and compare the
  182. entries again. <small>GDB</small> already canonicalizes most of the filenames on its
  183. own before starting the comparison so a canonical form of directories is
  184. recommended to be entered.
  185. </p>
  186. <hr>
  187. <div class="header">
  188. <p>
  189. Next: <a href="Auto_002dloading-verbose-mode.html#Auto_002dloading-verbose-mode" accesskey="n" rel="next">Auto-loading verbose mode</a>, Previous: <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file" accesskey="p" rel="prev">libthread_db.so.1 file</a>, Up: <a href="Auto_002dloading.html#Auto_002dloading" accesskey="u" rel="up">Auto-loading</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  190. </div>
  191. </body>
  192. </html>