<i id='x9EcJ'><tr id='x9EcJ'><dt id='x9EcJ'><q id='x9EcJ'><span id='x9EcJ'><b id='x9EcJ'><form id='x9EcJ'><ins id='x9EcJ'></ins><ul id='x9EcJ'></ul><sub id='x9EcJ'></sub></form><legend id='x9EcJ'></legend><bdo id='x9EcJ'><pre id='x9EcJ'><center id='x9EcJ'></center></pre></bdo></b><th id='x9EcJ'></th></span></q></dt></tr></i><div id='x9EcJ'><tfoot id='x9EcJ'></tfoot><dl id='x9EcJ'><fieldset id='x9EcJ'></fieldset></dl></div>
    1. <tfoot id='x9EcJ'></tfoot>
      1. <legend id='x9EcJ'><style id='x9EcJ'><dir id='x9EcJ'><q id='x9EcJ'></q></dir></style></legend>

        <small id='x9EcJ'></small><noframes id='x9EcJ'>

          <bdo id='x9EcJ'></bdo><ul id='x9EcJ'></ul>

        Unix 权限,读取与执行(PHP 上下文)

        时间:2023-10-12
          <tbody id='TPhpG'></tbody>
            • <tfoot id='TPhpG'></tfoot>

                • <bdo id='TPhpG'></bdo><ul id='TPhpG'></ul>

                  <i id='TPhpG'><tr id='TPhpG'><dt id='TPhpG'><q id='TPhpG'><span id='TPhpG'><b id='TPhpG'><form id='TPhpG'><ins id='TPhpG'></ins><ul id='TPhpG'></ul><sub id='TPhpG'></sub></form><legend id='TPhpG'></legend><bdo id='TPhpG'><pre id='TPhpG'><center id='TPhpG'></center></pre></bdo></b><th id='TPhpG'></th></span></q></dt></tr></i><div id='TPhpG'><tfoot id='TPhpG'></tfoot><dl id='TPhpG'><fieldset id='TPhpG'></fieldset></dl></div>
                  <legend id='TPhpG'><style id='TPhpG'><dir id='TPhpG'><q id='TPhpG'></q></dir></style></legend>

                  <small id='TPhpG'></small><noframes id='TPhpG'>

                  本文介绍了Unix 权限,读取与执行(PHP 上下文)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个需要连接到数据库的 php 脚本.数据库的凭据存储在另一个 php 脚本中.

                  I have a php script which needs to connect to a database. The credentials for the database are stored in another php script.

                  如果我将凭据文件的权限设置为 661,以便 Public 具有执行权限但没有读取权限,这是否允许主脚本访问凭据并连接到数据库,同时防止有人在服务器上拥有用户帐户从查看凭据文件的内容?

                  If I set the permissions for the credentials file to 661 so that Public has execute permission but not read permission, does this allow the main script to access the credentials and connect to the DB while preventing someone with a user account on the server from viewing the contents of the credentials file?

                  我想我对读取和执行之间的区别感到困惑.php 脚本(以 www 或类似方式运行)是否需要读取权限才能包含另一个 php 脚本并使用其中的任何内容?还是只需要执行?读取权限是否隐式赋予执行权限?

                  I guess I'm confused as to the distinction between read and execute. Does a php script (running as www or something similar) need read-permission to include another php script and use any content inside? Or does it just need execute? Does read permission implicitly give execute permission?

                  子问题:如果我将所有脚本设置为仅具有执行权限而不具有读取权限,是否会出现任何陷阱?这是假设我将需要显式读取权限(数据文件)的所有文件设置为读取.

                  Sub-Question: If I set all of my scripts to only have execute permission and not read, are there any pitfalls I should expect? This is assuming that I will leave any files I need explicit read permission (data files) set to read.

                  推荐答案

                  就文件而言,执行权限与您无关 - 您的 Web 服务器运行的用户帐户需要访问和读取相关文件的权限.为了遍历目录,用户还需要对该目录的执行权限.

                  As far as files are concerned, execute permission is irrelevant to you - the user account your web server is running under needs permission to access and read the files in question. In order to traverse into a directory, the user will also require execute permission on that directory.

                  如果你试图让你的脚本被网络服务器读取(假设你以属于www"组的帐户www"运行),而不是系统上的其他用户,这就是我会做(假设您的帐户是myuser"):

                  If you are trying to make your scripts readable by the web server (let's say you're running as the account "www" which belongs to group "www"), and not by other users on the system, here's what I would do (assumes your account is "myuser"):

                  # Change owner to "myuser" and group to "www" for file(s) in question
                  chown myuser:www config.php
                  
                  # 640: myuser has rw-, www has r--, world has ---
                  chmod 640 config.php
                  

                  如果你想阻止世界读取secrets"目录中的任何文件,只需禁用执行位:

                  If you want to prevent the world from reading any file in a "secrets" directory, just disable the execute bit:

                  # 750: myuser has rwx, www has r-x, world has ---
                  chmod 750 secrets
                  

                  如果您将所有脚本设置为具有执行权限但没有读取权限,则没有人可以对它们做任何有用的事情(包括网络服务器);-)

                  If you set all your scripts to have execute permission but not read permission, nobody can do anything useful with them (including the webserver) ;-)

                  这篇关于Unix 权限,读取与执行(PHP 上下文)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP:fopen() 权限被拒绝 下一篇:在 Windows 7 上更改 XAMPP 中的 php 写入权限

                  相关文章

                  1. <i id='geRCh'><tr id='geRCh'><dt id='geRCh'><q id='geRCh'><span id='geRCh'><b id='geRCh'><form id='geRCh'><ins id='geRCh'></ins><ul id='geRCh'></ul><sub id='geRCh'></sub></form><legend id='geRCh'></legend><bdo id='geRCh'><pre id='geRCh'><center id='geRCh'></center></pre></bdo></b><th id='geRCh'></th></span></q></dt></tr></i><div id='geRCh'><tfoot id='geRCh'></tfoot><dl id='geRCh'><fieldset id='geRCh'></fieldset></dl></div>
                      <bdo id='geRCh'></bdo><ul id='geRCh'></ul>
                    <legend id='geRCh'><style id='geRCh'><dir id='geRCh'><q id='geRCh'></q></dir></style></legend>

                    <tfoot id='geRCh'></tfoot>

                    <small id='geRCh'></small><noframes id='geRCh'>