2019-04-08 23:22:26 +08:00

1 line
5.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="body" role="main"><div class="section" id="module-grp"><h1><span class="yiyi-st" id="yiyi-10">35.4. <a class="reference internal" href="#module-grp" title="grp: The group database (getgrnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">grp</span></code></a> - 组数据库</span></h1><p><span class="yiyi-st" id="yiyi-11">此模块提供对Unix组数据库的访问。</span><span class="yiyi-st" id="yiyi-12">它在所有Unix版本上可用。</span></p><p><span class="yiyi-st" id="yiyi-13">组数据库条目被报告为类元组对象,其属性对应于<code class="docutils literal"><span class="pre">group</span></code>结构的成员(下面的属性字段,参见<code class="docutils literal"><span class="pre">&lt;pwd.h&gt;</span></code></span></p><table border="1" class="docutils"><thead valign="bottom"><tr class="row-odd"><th class="head"><span class="yiyi-st" id="yiyi-14">指数</span></th><th class="head"><span class="yiyi-st" id="yiyi-15">属性</span></th><th class="head"><span class="yiyi-st" id="yiyi-16">含义</span></th></tr></thead><tbody valign="top"><tr class="row-even"><td><span class="yiyi-st" id="yiyi-17">0</span></td><td><span class="yiyi-st" id="yiyi-18">gr_name</span></td><td><span class="yiyi-st" id="yiyi-19">组的名称</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-20">1</span></td><td><span class="yiyi-st" id="yiyi-21">gr_passwd</span></td><td><span class="yiyi-st" id="yiyi-22">(加密)组密码;经常空</span></td></tr><tr class="row-even"><td><span class="yiyi-st" id="yiyi-23">2</span></td><td><span class="yiyi-st" id="yiyi-24">gr_gid</span></td><td><span class="yiyi-st" id="yiyi-25">数字组ID</span></td></tr><tr class="row-odd"><td><span class="yiyi-st" id="yiyi-26">3</span></td><td><span class="yiyi-st" id="yiyi-27">gr_mem</span></td><td><span class="yiyi-st" id="yiyi-28">所有组成员的用户名</span></td></tr></tbody></table><p><span class="yiyi-st" id="yiyi-29">gid是一个整数名称和密码是字符串成员列表是一个字符串列表。</span><span class="yiyi-st" id="yiyi-30">(请注意,大多数用户没有根据密码数据库显式列为他们所在组的成员。</span><span class="yiyi-st" id="yiyi-31">检查这两个数据库以获取完整的成员资格信息。</span><span class="yiyi-st" id="yiyi-32">另请注意,以<code class="docutils literal"><span class="pre">+</span></code><code class="docutils literal"><span class="pre">-</span></code>开头的<code class="docutils literal"><span class="pre">gr_name</span></code>可能是YP / NIS参考可能无法通过<a class="reference internal" href="#grp.getgrnam" title="grp.getgrnam"><code class="xref py py-func docutils literal"><span class="pre">getgrnam()</span></code></a><a class="reference internal" href="#grp.getgrgid" title="grp.getgrgid"><code class="xref py py-func docutils literal"><span class="pre">getgrgid()</span></code></a>。)</span></p><p><span class="yiyi-st" id="yiyi-33">它定义以下项目:</span></p><dl class="function"><dt id="grp.getgrgid"><span class="yiyi-st" id="yiyi-34"> <code class="descclassname">grp.</code><code class="descname">getgrgid</code><span class="sig-paren">(</span><em>gid</em><span class="sig-paren">)</span></span></dt><dd><p><span class="yiyi-st" id="yiyi-35">返回给定数字组ID的组数据库条目。</span><span class="yiyi-st" id="yiyi-36">如果无法找到要求的条目,则会引发<a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal"><span class="pre">KeyError</span></code></a></span></p></dd></dl><dl class="function"><dt id="grp.getgrnam"><span class="yiyi-st" id="yiyi-37"> <code class="descclassname">grp.</code><code class="descname">getgrnam</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span></span></dt><dd><p><span class="yiyi-st" id="yiyi-38">返回给定组名的组数据库条目。</span><span class="yiyi-st" id="yiyi-39">如果无法找到要求的条目,则会引发<a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal"><span class="pre">KeyError</span></code></a></span></p></dd></dl><dl class="function"><dt id="grp.getgrall"><span class="yiyi-st" id="yiyi-40"> <code class="descclassname">grp.</code><code class="descname">getgrall</code><span class="sig-paren">(</span><span class="sig-paren">)</span></span></dt><dd><p><span class="yiyi-st" id="yiyi-41">以任意顺序返回所有可用组条目的列表。</span></p></dd></dl><div class="admonition seealso"><p class="first admonition-title"><span class="yiyi-st" id="yiyi-42">也可以看看</span></p><dl class="last docutils"><dt><span class="yiyi-st" id="yiyi-43">模块<a class="reference internal" href="pwd.html#module-pwd" title="pwd: The password database (getpwnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">pwd</span></code></a></span></dt><dd><span class="yiyi-st" id="yiyi-44">与用户数据库的接口,类似于此。</span></dd><dt><span class="yiyi-st" id="yiyi-45">模块<a class="reference internal" href="spwd.html#module-spwd" title="spwd: The shadow password database (getspnam() and friends). (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">spwd</span></code></a></span></dt><dd><span class="yiyi-st" id="yiyi-46">一个到shadow密码数据库的接口类似这样。</span></dd></dl></div></div></div>