📄 ch22_06.htm
字号:
<html><head><title>Win32::FileSecurity (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch22_05.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch22_07.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">22.6. Win32::FileSecurity</h2><p><a name="INDEX-3228" /><a name="INDEX-3229" />The Win32::FileSecurity moduleallows you to work with NT File System (NTFS) file permissions. Filepermissions are stored as Discretionary Access Control Lists (DACLs)for each file or directory. These lists contain a bitmask specifyingthe permission rights for users on the file or directory. This moduleimplements a DACL as a <em class="replaceable"><tt>permissions</tt></em> hash inwhich each key is a username, and the value is the bitmask for thepermissions.</p><p>The FileSecurity module exports the following constants to describeuser permissions:</p><blockquote><pre class="code">ACCESS_SYSTEM_SECURITY READ or RCHANGE or C SPECIFIC_RIGHTS_ALLDELETE STANDARD_RIGHTS_ALLFULL or F STANDARD_RIGHTS_EXECUTEGENERIC_ALL STANDARD_RIGHTS_READGENERIC_EXECUTE STANDARD_RIGHTS_REQUIREDGENERIC_READ STANDARD_RIGHTS_WRITEGENERIC_WRITE SYNCHRONIZEMAXIMUM_ALLOWED WRITE_DACREAD_CONTROL WRITE_OWNER</pre></blockquote><p>Using the <tt class="literal">constant</tt> function on one of theseconstants gives its value, and bitmasks or multiple permissionssettings can be made by supplying a list of these constants to the<tt class="literal">MakeMask</tt> function.</p><p>The following functions are exported by the Win32::FileSecuritymodule.</p><a name="INDEX-3230" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>constant</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>constant (<em class="replaceable">name</em> $<em class="replaceable">val</em>)</pre><p><a name="INDEX-3230" />Takes the<em class="replaceable"><tt>name</tt></em> of a permission constant and savesits value in the variable <em class="replaceable"><tt>val</tt></em>.</p></div><a name="INDEX-3231" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>EnumerateRights</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>EnumerateRights (<em class="replaceable">mask</em>, \@<em class="replaceable">rights</em>)</pre><p><a name="INDEX-3231" />Takes a permissionsbitmask (as returned by <tt class="literal">MakeMask</tt> or<tt class="literal">constant</tt>) and saves the corresponding list ofstring constants in <em class="replaceable"><tt>rights</tt></em>.</p></div><a name="INDEX-3232" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Get</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>Get (<em class="replaceable">filename</em>, \%<em class="replaceable">permissions</em>)</pre><p><a name="INDEX-3232" />Gets the access control list for<em class="replaceable"><tt>filename</tt></em> (or directory) and saves in thespecified <em class="replaceable"><tt>permissions</tt></em> hash.</p></div><a name="INDEX-3233" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>MakeMask</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>MakeMask (<em class="replaceable">stringlist</em>)</pre><p><a name="INDEX-3233" />Takes a list ofpermission string constants and returns the bitmask.</p></div><a name="INDEX-3234" /><a name="INDEX-3235" /><a name="INDEX-3236" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>Set</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>Set (<em class="replaceable">filename</em>, \%<em class="replaceable">permissions</em>)</pre><p><a name="INDEX-3234" />Sets the access control list for thegiven <em class="replaceable"><tt>filename</tt></em> (or directory) to thesettings in the specified <em class="replaceable"><tt>permissions</tt></em>hash.<a name="INDEX-3235" /><a name="INDEX-3236" /> </p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch22_05.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch22_07.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">22.5. Win32::File</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">22.7. Win32::Internet</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -