Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 9a9cef5a3a2b597a6e4663b51cfdf030 > files > 98

incron-0.5.12-3.mga7.armv7hl.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>incron: usertable.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">incron
   &#160;<span id="projectnumber">0.5.10</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">usertable.h</div>  </div>
</div>
<div class="contents">
<a href="usertable_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00003"></a>00003 
<a name="l00016"></a>00016 <span class="preprocessor">#ifndef _USERTABLE_H_</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#define _USERTABLE_H_</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;deque&gt;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;sys/poll.h&gt;</span>
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="inotify-cxx_8h.html" title="inotify C++ interface header">inotify-cxx.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="incrontab_8h.html" title="inotify cron table manipulator classes header">incrontab.h</a>&quot;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 
<a name="l00027"></a><a class="code" href="usertable_8h.html#a9aa598e8878c4709e214b51047e52e13">00027</a> <span class="keyword">class </span><a class="code" href="classUserTable.html" title="User table class.">UserTable</a>;
<a name="l00028"></a>00028 
<a name="l00030"></a>00030 <span class="keyword">typedef</span> std::map&lt;std::string, UserTable*&gt; <a class="code" href="usertable_8h.html#a9aa598e8878c4709e214b51047e52e13" title="User name to user table mapping definition.">SUT_MAP</a>;
<a name="l00031"></a>00031 
<a name="l00033"></a><a class="code" href="usertable_8h.html#ab343d33ef1c176775c0af73257536085">00033</a> <span class="keyword">typedef</span> void (*<a class="code" href="usertable_8h.html#ab343d33ef1c176775c0af73257536085" title="Callback for calling after a process finishes.">proc_done_cb</a>)(<a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>*);
<a name="l00034"></a>00034 
<a name="l00036"></a><a class="code" href="structProcData__t.html">00036</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00037"></a>00037 {
<a name="l00038"></a><a class="code" href="structProcData__t.html#ab5ee2269e153269fd3eb0a717841f017">00038</a>   <a class="code" href="usertable_8h.html#ab343d33ef1c176775c0af73257536085" title="Callback for calling after a process finishes.">proc_done_cb</a> <a class="code" href="structProcData__t.html#ab5ee2269e153269fd3eb0a717841f017" title="function called after process finishes">onDone</a>;  
<a name="l00039"></a><a class="code" href="structProcData__t.html#a671cbf6b356480d028bd30369ef910fe">00039</a>   <a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* <a class="code" href="structProcData__t.html#a671cbf6b356480d028bd30369ef910fe" title="related watch">pWatch</a>; 
<a name="l00040"></a>00040 } <a class="code" href="structProcData__t.html" title="Child process data.">ProcData_t</a>;
<a name="l00041"></a>00041 
<a name="l00043"></a><a class="code" href="usertable_8h.html#adc4c5ffeb65092ff03c5ded400e5081d">00043</a> <span class="keyword">typedef</span> std::map&lt;int, UserTable*&gt; <a class="code" href="usertable_8h.html#adc4c5ffeb65092ff03c5ded400e5081d" title="fd-to-usertable mapping">FDUT_MAP</a>;
<a name="l00044"></a>00044 
<a name="l00046"></a><a class="code" href="usertable_8h.html#a55918270b71da47229c8ac3b39671808">00046</a> <span class="keyword">typedef</span> std::map&lt;InotifyWatch*, IncronTabEntry*&gt; <a class="code" href="usertable_8h.html#a55918270b71da47229c8ac3b39671808" title="Watch-to-tableentry mapping.">IWCE_MAP</a>;
<a name="l00047"></a>00047 
<a name="l00049"></a><a class="code" href="usertable_8h.html#a5b7ba5788fc9c6f1c0b0082eee9dde72">00049</a> <span class="keyword">typedef</span> std::map&lt;pid_t, ProcData_t&gt; <a class="code" href="usertable_8h.html#a5b7ba5788fc9c6f1c0b0082eee9dde72" title="Child process list.">PROC_MAP</a>;
<a name="l00050"></a>00050 
<a name="l00052"></a>00052 
<a name="l00055"></a><a class="code" href="classEventDispatcher.html">00055</a> <span class="keyword">class </span><a class="code" href="classEventDispatcher.html" title="Event dispatcher class.">EventDispatcher</a>
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="keyword">public</span>:
<a name="l00059"></a>00059 
<a name="l00065"></a>00065   <a class="code" href="classEventDispatcher.html#aa85c268c8fa835ded477659ecd017ad4" title="Constructor.">EventDispatcher</a>(<span class="keywordtype">int</span> iPipeFd, <a class="code" href="classInotify.html" title="inotify class">Inotify</a>* pIn, <a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* pSys, <a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* pUser);
<a name="l00066"></a>00066   
<a name="l00068"></a>00068   <a class="code" href="classEventDispatcher.html#abb5f401014e87f03027d6c4450964e55" title="Destructor.">~EventDispatcher</a>();
<a name="l00069"></a>00069 
<a name="l00071"></a>00071 
<a name="l00074"></a>00074   <span class="keywordtype">bool</span> <a class="code" href="classEventDispatcher.html#ac2b9520436761282001d8c5ea539482a" title="Processes events.">ProcessEvents</a>();
<a name="l00075"></a>00075   
<a name="l00077"></a>00077 
<a name="l00080"></a>00080   <span class="keywordtype">void</span> <a class="code" href="classEventDispatcher.html#a35f9789ceaf15a9cbeeae65717c0a068" title="Registers an user table.">Register</a>(<a class="code" href="classUserTable.html" title="User table class.">UserTable</a>* pTab);
<a name="l00081"></a>00081   
<a name="l00083"></a>00083 
<a name="l00086"></a>00086   <span class="keywordtype">void</span> <a class="code" href="classEventDispatcher.html#a6bd699c73e11db92ffc737ece3c30715" title="Unregisters an user table.">Unregister</a>(<a class="code" href="classUserTable.html" title="User table class.">UserTable</a>* pTab);
<a name="l00087"></a>00087   
<a name="l00089"></a>00089 
<a name="l00092"></a><a class="code" href="classEventDispatcher.html#a438297748715864a0b7d974754ebdcb4">00092</a>   <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="classEventDispatcher.html#a438297748715864a0b7d974754ebdcb4" title="Returns the poll data size.">GetSize</a>()<span class="keyword"> const</span>
<a name="l00093"></a>00093 <span class="keyword">  </span>{
<a name="l00094"></a>00094     <span class="keywordflow">return</span> m_size;
<a name="l00095"></a>00095   }
<a name="l00096"></a>00096   
<a name="l00098"></a>00098 
<a name="l00101"></a><a class="code" href="classEventDispatcher.html#a1309b15de686e9bdbf8f1ff8a1285e79">00101</a>   <span class="keyword">inline</span> <span class="keyword">struct </span>pollfd* <a class="code" href="classEventDispatcher.html#a1309b15de686e9bdbf8f1ff8a1285e79" title="Returns the poll data.">GetPollData</a>()
<a name="l00102"></a>00102   {
<a name="l00103"></a>00103     <span class="keywordflow">return</span> m_pPoll;
<a name="l00104"></a>00104   }
<a name="l00105"></a>00105   
<a name="l00107"></a>00107   <span class="keywordtype">void</span> <a class="code" href="classEventDispatcher.html#a4a847781965ff8539df8fab05720cb8f" title="Rebuilds the poll array data.">Rebuild</a>();
<a name="l00108"></a>00108   
<a name="l00110"></a>00110 
<a name="l00113"></a><a class="code" href="classEventDispatcher.html#ab1c59d7635d5aedbe6cc2f4315c2d269">00113</a>   <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classEventDispatcher.html#ab1c59d7635d5aedbe6cc2f4315c2d269" title="Removes all registered user tables.">Clear</a>()
<a name="l00114"></a>00114   {
<a name="l00115"></a>00115     m_maps.clear();
<a name="l00116"></a>00116   }
<a name="l00117"></a>00117   
<a name="l00118"></a>00118 <span class="keyword">private</span>:
<a name="l00119"></a>00119   <span class="keywordtype">int</span> m_iPipeFd;    
<a name="l00120"></a>00120   <span class="keywordtype">int</span> m_iMgmtFd;    
<a name="l00121"></a>00121   <a class="code" href="classInotify.html" title="inotify class">Inotify</a>* m_pIn;   
<a name="l00122"></a>00122   <a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* m_pSys;   
<a name="l00123"></a>00123   <a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* m_pUser;  
<a name="l00124"></a>00124   <a class="code" href="usertable_8h.html#adc4c5ffeb65092ff03c5ded400e5081d" title="fd-to-usertable mapping">FDUT_MAP</a> m_maps;  
<a name="l00125"></a>00125   <span class="keywordtype">size_t</span> m_size;    
<a name="l00126"></a>00126   <span class="keyword">struct </span>pollfd* m_pPoll; 
<a name="l00127"></a>00127   
<a name="l00129"></a>00129   <span class="keywordtype">void</span> ProcessMgmtEvents();
<a name="l00130"></a>00130 };
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 
<a name="l00134"></a>00134 
<a name="l00139"></a><a class="code" href="classUserTable.html">00139</a> <span class="keyword">class </span><a class="code" href="classUserTable.html" title="User table class.">UserTable</a>
<a name="l00140"></a>00140 {
<a name="l00141"></a>00141 <span class="keyword">public</span>:
<a name="l00143"></a>00143 
<a name="l00148"></a>00148   <a class="code" href="classUserTable.html#ae9c8e2d54f6d131fa0c46a724cb5ab94" title="Constructor.">UserTable</a>(<a class="code" href="classEventDispatcher.html" title="Event dispatcher class.">EventDispatcher</a>* pEd, <span class="keyword">const</span> std::string&amp; rUser, <span class="keywordtype">bool</span> fSysTable);
<a name="l00149"></a>00149   
<a name="l00151"></a>00151   <span class="keyword">virtual</span> <a class="code" href="classUserTable.html#a0ef59efae87ec768c26290982408a8fa" title="Destructor.">~UserTable</a>();
<a name="l00152"></a>00152   
<a name="l00154"></a>00154 
<a name="l00159"></a>00159   <span class="keywordtype">void</span> <a class="code" href="classUserTable.html#a08f1b2836694e3f8c5b13c890a08df9f" title="Loads the table.">Load</a>();
<a name="l00160"></a>00160   
<a name="l00162"></a>00162 
<a name="l00166"></a>00166   <span class="keywordtype">void</span> <a class="code" href="classUserTable.html#ae24db4723aa83fc966ee60f0bb942eac" title="Removes all entries from the table.">Dispose</a>();
<a name="l00167"></a>00167   
<a name="l00169"></a>00169 
<a name="l00172"></a>00172   <span class="keywordtype">void</span> <a class="code" href="classUserTable.html#a795e26a707b148a092f85d1f2da02196" title="Processes an inotify event.">OnEvent</a>(<a class="code" href="classInotifyEvent.html" title="inotify event class">InotifyEvent</a>&amp; rEvt);
<a name="l00173"></a>00173   
<a name="l00175"></a>00175 
<a name="l00179"></a>00179   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classUserTable.html#a69af22ff6f6b2dc109e227f56731aceb" title="Cleans-up all zombie child processes and enables disabled watches.">FinishDone</a>();
<a name="l00180"></a>00180   
<a name="l00182"></a>00182 
<a name="l00189"></a>00189   <span class="keywordtype">bool</span> <a class="code" href="classUserTable.html#af4dff514ae940802e062f067835c83bf" title="Checks whether the user may access a file.">MayAccess</a>(<span class="keyword">const</span> std::string&amp; rPath, <span class="keywordtype">bool</span> fNoFollow) <span class="keyword">const</span>;
<a name="l00190"></a>00190   
<a name="l00192"></a>00192 
<a name="l00195"></a>00195   <span class="keywordtype">bool</span> <a class="code" href="classUserTable.html#a1f614a23987028538cded38c2c4c15db" title="Checks whether it is a system table.">IsSystem</a>() <span class="keyword">const</span>;
<a name="l00196"></a>00196   
<a name="l00198"></a>00198 
<a name="l00201"></a><a class="code" href="classUserTable.html#a2ae939d2227dc168554d1b13aaeddcbb">00201</a>   <a class="code" href="classInotify.html" title="inotify class">Inotify</a>* <a class="code" href="classUserTable.html#a2ae939d2227dc168554d1b13aaeddcbb" title="Returns the related inotify object.">GetInotify</a>()
<a name="l00202"></a>00202   {
<a name="l00203"></a>00203     <span class="keywordflow">return</span> &amp;m_in;
<a name="l00204"></a>00204   }
<a name="l00205"></a>00205   
<a name="l00207"></a>00207 
<a name="l00217"></a><a class="code" href="classUserTable.html#afa3c0512fa34aaea9d0b2909ca07595b">00217</a>   <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classUserTable.html#afa3c0512fa34aaea9d0b2909ca07595b" title="Checks whether an user exists and has permission to use incron.">CheckUser</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* user)
<a name="l00218"></a>00218   {
<a name="l00219"></a>00219     <span class="keyword">struct </span>passwd* pw = getpwnam(user);
<a name="l00220"></a>00220     <span class="keywordflow">if</span> (pw == NULL)
<a name="l00221"></a>00221       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00222"></a>00222       
<a name="l00223"></a>00223     <span class="keywordflow">return</span> <a class="code" href="classUserTable.html#afa3c0512fa34aaea9d0b2909ca07595b" title="Checks whether an user exists and has permission to use incron.">IncronTab::CheckUser</a>(user);
<a name="l00224"></a>00224   }
<a name="l00225"></a>00225   
<a name="l00227"></a>00227 
<a name="l00230"></a>00230   <span class="keywordtype">void</span> <a class="code" href="classUserTable.html#ae22959dbccee9b31d8c732c65e660391" title="Runs a program as the table&#39;s user.">RunAsUser</a>(<span class="keywordtype">char</span>* <span class="keyword">const</span>* argv) <span class="keyword">const</span>;
<a name="l00231"></a>00231   
<a name="l00232"></a>00232 <span class="keyword">private</span>:
<a name="l00233"></a>00233   <a class="code" href="classInotify.html" title="inotify class">Inotify</a> m_in;           
<a name="l00234"></a>00234   <a class="code" href="classEventDispatcher.html" title="Event dispatcher class.">EventDispatcher</a>* m_pEd; 
<a name="l00235"></a>00235   std::string m_user;     
<a name="l00236"></a>00236   <span class="keywordtype">bool</span> m_fSysTable;       
<a name="l00237"></a>00237   <a class="code" href="classIncronTab.html" title="Incron table class.">IncronTab</a> m_tab;        
<a name="l00238"></a>00238   <a class="code" href="usertable_8h.html#a55918270b71da47229c8ac3b39671808" title="Watch-to-tableentry mapping.">IWCE_MAP</a> m_map;         
<a name="l00239"></a>00239 
<a name="l00240"></a>00240   <span class="keyword">static</span> <a class="code" href="usertable_8h.html#a5b7ba5788fc9c6f1c0b0082eee9dde72" title="Child process list.">PROC_MAP</a> s_procMap;  
<a name="l00241"></a>00241   
<a name="l00243"></a>00243 
<a name="l00247"></a>00247   <a class="code" href="classIncronTabEntry.html" title="Incron table entry class.">IncronTabEntry</a>* FindEntry(<a class="code" href="classInotifyWatch.html" title="inotify watch class">InotifyWatch</a>* pWatch);
<a name="l00248"></a>00248   
<a name="l00250"></a>00250 
<a name="l00256"></a>00256   <span class="keywordtype">bool</span> PrepareArgs(<span class="keyword">const</span> std::string&amp; rCmd, <span class="keywordtype">int</span>&amp; argc, <span class="keywordtype">char</span>**&amp; argv);
<a name="l00257"></a>00257   
<a name="l00259"></a>00259 
<a name="l00263"></a>00263   <span class="keywordtype">void</span> CleanupArgs(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv);
<a name="l00264"></a>00264   
<a name="l00265"></a>00265 };
<a name="l00266"></a>00266 
<a name="l00267"></a>00267 <span class="preprocessor">#endif //_USERTABLE_H_</span>
</pre></div></div>
</div>


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>