<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2359589543351279601</id><updated>2012-02-16T07:09:25.616-08:00</updated><category term='Auditd'/><category term='RedHat'/><category term='Apache'/><category term='Security'/><category term='Networks'/><category term='Linux'/><title type='text'>Load Average</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-932882446617151275</id><published>2012-01-18T09:39:00.000-08:00</published><updated>2012-01-19T12:49:20.186-08:00</updated><title type='text'>Linux file descriptors and open modes</title><content type='html'>Ever want to find out what modes a file was opened with originally ?&lt;br /&gt;&lt;br /&gt;First find the file descriptor number&lt;br /&gt;&lt;pre style="CSS Text"&gt;&lt;br /&gt;ls /proc/&lt;pid&gt;/fd&lt;br /&gt;Eg&lt;br /&gt;ls -l /proc/32048/fd/30&lt;br /&gt;l-wx------ 1 apache apache 64 Jan 18 07:15 30 -&gt; /var/log/httpd/ntop-access_log&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then check fdinfo &lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;cat /proc/32048/fdinfo/30&lt;br /&gt;pos: 0&lt;br /&gt;flags: 0102001&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The flags are derived from the open system call http://linux.about.com/od/commands/l/blcmdl2_open.htm&lt;br /&gt;&lt;br /&gt;To actually decipher the octal codes , look under /usr/include/bits/fcntl.h&lt;br /&gt;&lt;br /&gt;If there are multiple codes, the codes are appended together.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-932882446617151275?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/932882446617151275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2012/01/linux-file-descriptors-and-open-modes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/932882446617151275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/932882446617151275'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2012/01/linux-file-descriptors-and-open-modes.html' title='Linux file descriptors and open modes'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-5226261198970359631</id><published>2012-01-12T13:38:00.000-08:00</published><updated>2012-01-12T13:38:22.070-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Linux ACLs</title><content type='html'>&lt;h2&gt;Filesystem options and commands&lt;/h2&gt;&lt;br /&gt;First check to make sure the file system is mounted with acl settings&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;cat /proc/mounts |grep acl&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;/dev/sda1 / ext3 rw,noatime,relatime,errors=remount-ro,acl,data=ordered 0 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If not update /etc/fstab and add 'acl' to the options section and remount the file system&lt;br /&gt;&lt;br /&gt;getfacl, setfacl, chacl are the two main commands. chacl is available for IRIX compatibility. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Use Cases&lt;/h2&gt;&lt;br /&gt;&lt;h3&gt;Grant 2 users permissions to the same directory and files under it&lt;/h3&gt;&lt;br /&gt;Let's say we want to grant user john and mary permissions to folder /var/www/mysite.com&lt;br /&gt;&lt;br /&gt;We can start by creating the directory. At this point we can leave it owned by root as the ACLs will help here.&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;ls -ld /var/www/mysite.com/&lt;br /&gt;drwxr-xr-x 2 root root 4096 Feb 11 15:21 /var/www/mysite.com/&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The first 2 commands grant users john and mary permissions. &lt;br /&gt;&lt;br /&gt;The second sets the default acl. This causes the acls to be applied with inhertiance set. So this makes good sense in a multi user multi edit environment. The next arguments between the : are the username and the permissions&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;setfacl -m john:rwx mysite.com &lt;br /&gt;setfacl -m mary:rwx mysite.com &lt;br /&gt;&lt;br /&gt;setfacl -m default:john:rwx mysite.com &lt;br /&gt;setfacl -m default:mary:rwx mysite.com&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;# file: mysite.com&lt;br /&gt;# owner: root&lt;br /&gt;# group: root&lt;br /&gt;user::rwx&lt;br /&gt;user:john:rwx&lt;br /&gt;group::r-x&lt;br /&gt;mask::rwx&lt;br /&gt;other::r-x&lt;br /&gt;default:user::rwx&lt;br /&gt;default:user:john:rwx&lt;br /&gt;default:user:mary:rwx&lt;br /&gt;default:group::r-x&lt;br /&gt;default:mask::rwx&lt;br /&gt;default:other::r-x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now create a file by logging in a user john.&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;john@slice01$ echo "john" &gt; file1&lt;br /&gt;&lt;br /&gt;john@slice01$ ls -l file1 &lt;br /&gt;-rw-rw-r--+ 1 john john 4 Feb 11 15:31 file1&lt;br /&gt;&lt;br /&gt;john@slice01$ getfacl file1 &lt;br /&gt;# file: file1&lt;br /&gt;# owner: john&lt;br /&gt;# group: john&lt;br /&gt;user::rw-&lt;br /&gt;user:john:rwx   #effective:rw-&lt;br /&gt;user:mary:rwx   #effective:rw-&lt;br /&gt;group::r-x   #effective:r--&lt;br /&gt;mask::rw-&lt;br /&gt;other::r--&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then create a directory&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;john@slice01$ mkdir john&lt;br /&gt;&lt;br /&gt;john@slice01$ getfacl john&lt;br /&gt;# file: john&lt;br /&gt;# owner: john&lt;br /&gt;# group: john&lt;br /&gt;user::rwx&lt;br /&gt;user:john:rwx&lt;br /&gt;user:mary:rwx&lt;br /&gt;group::r-x&lt;br /&gt;mask::rwx&lt;br /&gt;other::r-x&lt;br /&gt;default:user::rwx&lt;br /&gt;default:user:john:rwx&lt;br /&gt;default:user:mary:rwx&lt;br /&gt;default:group::r-x&lt;br /&gt;default:mask::rwx&lt;br /&gt;default:other::r-x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see mary is there in the ACLs also&lt;br /&gt;&lt;br /&gt;You can test it by logging in as user mary &amp; editing files created by john.&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;mary@slice01$ echo mary &gt;&gt; file1 &lt;br /&gt;&lt;br /&gt;mary@slice01$ cat file1 &lt;br /&gt;john&lt;br /&gt;mary&lt;br /&gt;&lt;br /&gt;mary@slice01$ cd john/&lt;br /&gt;&lt;br /&gt;mary@slice01 $ echo mary &gt; file2&lt;br /&gt;mary@slice01 $ getfacl file2 &lt;br /&gt;# file: file2&lt;br /&gt;# owner: mary&lt;br /&gt;# group: mary&lt;br /&gt;user::rw-&lt;br /&gt;user:john:rwx   #effective:rw-&lt;br /&gt;user:mary:rwx   #effective:rw-&lt;br /&gt;group::r-x   #effective:r--&lt;br /&gt;mask::rw-&lt;br /&gt;other::r--&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Grant 2 users permissions to the same directory and files under it except to 2 individual directories&lt;/h3&gt;Lets say we want john and mary to have permissions under /var/www/mysite.com/ and all files but still have individual directories&lt;br /&gt;/var/www/mysite.com/john &amp; /var/www/mysite.com/mary&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt; getfacl mary&lt;br /&gt;# file: mary&lt;br /&gt;# owner: mary&lt;br /&gt;# group: mary&lt;br /&gt;user::rwx&lt;br /&gt;user:john:rwx&lt;br /&gt;user:mary:rwx&lt;br /&gt;group::r-x&lt;br /&gt;mask::rwx&lt;br /&gt;other::r-x&lt;br /&gt;default:user::rwx&lt;br /&gt;default:user:john:rwx&lt;br /&gt;default:user:mary:rwx&lt;br /&gt;default:group::r-x&lt;br /&gt;default:mask::rwx&lt;br /&gt;default:other::r-x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The -k switch removes the default acls&lt;br /&gt;&lt;br /&gt;&lt;pre style="CSS Text"&gt;setfacl -k mary&lt;br /&gt;&lt;br /&gt;getfacl mary&lt;br /&gt;# file: mary&lt;br /&gt;# owner: mary&lt;br /&gt;# group: mary&lt;br /&gt;user::rwx&lt;br /&gt;user:john:rwx&lt;br /&gt;user:mary:rwx&lt;br /&gt;group::r-x&lt;br /&gt;mask::rwx&lt;br /&gt;other::r-x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then remove john from it also&lt;br /&gt;&lt;pre style="CSS Text"&gt;&lt;br /&gt;setfacl -x john mary&lt;br /&gt;&lt;br /&gt;getfacl mary&lt;br /&gt;# file: mary&lt;br /&gt;# owner: mary&lt;br /&gt;# group: mary&lt;br /&gt;user::rwx&lt;br /&gt;user:mary:rwx&lt;br /&gt;group::r-x&lt;br /&gt;mask::rwx&lt;br /&gt;other::r-x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Repeat the same with other folder&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-5226261198970359631?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/5226261198970359631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2012/01/linux-acls.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/5226261198970359631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/5226261198970359631'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2012/01/linux-acls.html' title='Linux ACLs'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-8167805974572594545</id><published>2011-02-07T02:39:00.000-08:00</published><updated>2011-02-14T08:23:38.549-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='RedHat'/><title type='text'>Redhat 6 - Part 1</title><content type='html'>Here are some new stuff in RHEL 6 &lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;Software versions &lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PHP 5.3.1. It also ships with APC (Alternative PHP Cache). &lt;/li&gt;&lt;li&gt;Apache is 2.2.14 &lt;/li&gt;&lt;li&gt;MySQL is 5.1.42 &lt;/li&gt;&lt;li&gt;Tomcat is 6.0.20 &lt;/li&gt;&lt;li&gt;PostgreSQL is version 8.4 &lt;/li&gt;&lt;li&gt;Python is 2.6&lt;/li&gt;&lt;li&gt;Perl is 5.10.1&lt;/li&gt;&lt;li&gt;Gcc is 44.4&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;File systems&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Ext4 support- Read more at &lt;br /&gt;&lt;a href="https://ext4.wiki.kernel.org/index.php/Ext4_Howto"&gt;https://ext4.wiki.kernel.org/index.php/Ext4_Howto&lt;/a&gt;&lt;/li&gt;&lt;li&gt;XFS support&lt;/li&gt;&lt;li&gt;Technology preview of btrfs filesystem&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Other Notable Changes &lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Default use of NFS v4&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SysV init is gone in favour of upstart. Upstart comes with legacy support for traditional init scripts in /etc/init.d.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Support for Fibre Channel over Ethernet (FCoE)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;iSCSI&amp;nbsp; can now be used as root or boot devices&lt;br /&gt;&lt;/li&gt;&lt;li&gt;As expected, Xen has been dropped in favour or KVM &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-8167805974572594545?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/8167805974572594545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2011/02/redhat-6-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/8167805974572594545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/8167805974572594545'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2011/02/redhat-6-part-1.html' title='Redhat 6 - Part 1'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-6865446106061389142</id><published>2011-01-17T14:12:00.000-08:00</published><updated>2011-02-07T05:33:53.296-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Networks'/><title type='text'>IPv6 Part 1</title><content type='html'>&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Some trivia&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Why 128 bit ? &amp;nbsp;&lt;/i&gt;- It was a compromise between a fixed 64 bit and a variable 160 bits (google OSI NSAP for more)&lt;br /&gt;&lt;br /&gt;&lt;i&gt;How many IP addresses ?&lt;/i&gt; - 340,282,366,920,938,463,463,374,607,431,768,211,456&lt;br /&gt;&lt;br /&gt;&lt;i&gt;What about IPv5 ? &lt;/i&gt;- &amp;nbsp;Used by ST - a stream protocol and not related to IP&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 0px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Key Differences&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;More IPs&lt;/li&gt;&lt;li&gt;Different Header format&lt;/li&gt;&lt;li&gt;Extension support&lt;/li&gt;&lt;li&gt;Flow labeling&lt;/li&gt;&lt;li&gt;Authentication support&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="margin: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Header&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin: 0px;"&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Very simplified (See&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/File:Ipv6_header.svg"&gt;http://en.wikipedia.org/wiki/File:Ipv6_header.svg&lt;/a&gt;)&lt;/li&gt;&lt;li&gt;20 bytes + Options in IPv4 Vs &amp;nbsp;12 fields (40 bytes) in IPv6&lt;/li&gt;&lt;li&gt;Base header no longer contains fragmentation options&lt;/li&gt;&lt;li&gt;Header no longer contains any checksum&lt;/li&gt;&lt;li&gt;Time to live (TTL) is now called Hop Limit&lt;/li&gt;&lt;li&gt;Support for traffic classes&lt;/li&gt;&lt;li&gt;Extensibility in headers. Options are not limited to the 40 bytes&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-6865446106061389142?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/6865446106061389142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2011/01/ipv6-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/6865446106061389142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/6865446106061389142'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2011/01/ipv6-part-1.html' title='IPv6 Part 1'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-6639399462776912379</id><published>2011-01-09T02:33:00.000-08:00</published><updated>2011-01-09T02:59:23.478-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Apache'/><title type='text'>TCP timers and keepalives</title><content type='html'>Netstat -o includes tcp timers which are useful for Apache keepalive analysis.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;netstat -ntpo | grep ESTAB | egrep ":80|:443"&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Output looks like this&lt;br /&gt;&lt;pre&gt;&lt;textarea cols="60" disabled="true" rows="8" style="height: 132px; margin-bottom: 2px; margin-top: 2px;"&gt;&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.7:41089   ESTAB  25812/httpd  keepalive  (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.7:41088   ESTAB  19385/httpd  keepalive  (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.45:41090  ESTAB  26995/httpd  keepalive  (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.37:41087  ESTAB  25813/httpd  keepalive  (7196.70/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.7:41088   ESTAB  19385/httpd  keepalive  (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.27:41090  ESTAB  26995/httpd  on         (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.17:41088  ESTABLISHED  19385/httpd  off        (7196.71/0/0)&lt;br /&gt;tcp  0  0  98.xxx.xxx.106:80  83.138.139.17:41090  ESTABLISHED  26995/httpd  off        (7196.71/0/0)&lt;br /&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The last column denotes what the connection is doing.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt; 'on' - Actively transfering data.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;'off' - Currently disconnecting&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;'keepalive' - Connections are using TCP keepalives. The first number denotes the time in seconds from when the last data was transferred until when the next TCP keepalive probe will be sent. By default this starts at 7200s, and resets again every time more data is sent. If the value is low , for eg. 4000 seconds , it means some of the keep alive connections are hanging or doing nothing for a long period. Note, connections to internal proxy or other internal processes might hang longer but this should not happen to web based connection.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The defaults are dictated by the sysctl values :-&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;''net.ipv4.tcp_keepalive_probes'' - How many keepalive probes TCP sends out, until it decides that the connection is broken. Default value: 9.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;''net.ipv4.tcp_keepalive_time'' - How often TCP sends out keepalive messages when keepalive is enabled. Default: 2hours (7200 seconds)&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;''net.ipv4.tcp_keepalive_intvl'' - How frequently the probes are send out. Multiplied by tcp_keepalive_probes it is time to kill not responding connection, after probes started. Default value: 75sec i.e. connection will be aborted after ~11 minutes of retries.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;More information on the sysctly values can be found in the kernel documentation ''/usr/share/doc/kernel-doc-/Documentation/networking/ip-sysctl.txt''&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-6639399462776912379?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/6639399462776912379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2011/01/tcp-timers-and-keepalives.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/6639399462776912379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/6639399462776912379'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2011/01/tcp-timers-and-keepalives.html' title='TCP timers and keepalives'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2359589543351279601.post-7638653207334691838</id><published>2010-12-30T02:40:00.000-08:00</published><updated>2011-01-09T09:09:31.689-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Auditd'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Linux and Auditd</title><content type='html'>&lt;i&gt;&lt;b&gt;Assumptions&lt;/b&gt;&lt;/i&gt;: Everything here is tested on Red Hat/Cent OS 5, and 2.6.24.XX kernel&lt;br /&gt;&lt;br /&gt;auditd is the userspace side of kernel auditing functions. It can be used to watch file accesses, monitory system calls, log events etc.The closest to a home page it has &lt;a class="external free" href="http://people.redhat.com/sgrubb/audit/" rel="nofollow" title="http://people.redhat.com/sgrubb/audit/"&gt;http://people.redhat.com/sgrubb/audit/&lt;/a&gt;.&amp;nbsp;It has some nice presentations done at different Red Hat conferences and some other articles.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 24px; font-weight: bold;"&gt;Installation&lt;/span&gt;&lt;br /&gt;Installing auditd is straightforward but to use it efficiently you need to tune it to your needs. To install use&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;yum install audit&lt;br /&gt;&lt;/pre&gt;To start the service do&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;/etc/init.d/auditd start&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2359589543351279601" id="Configuration" name="Configuration"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt;Configuration&lt;/span&gt;&lt;/h2&gt;Installation is a breeze but configuring to your needs requires some tweaking.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;auditd.conf&lt;/i&gt; can be used to tweak auditd's behaviour.  Common settings to review/tune are&amp;nbsp;:-&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;log_file&lt;/i&gt; (default:/var/log/audit/audit.log) &amp;amp; &lt;i&gt;log_format&lt;/i&gt;(default:raw)&lt;br /&gt;Set the log file name and the format. The format can be either raw or nolog.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;num_logs&lt;/i&gt;(default:0)&lt;br /&gt;Auditd does its own rotation and the default is no rotation.  This keyword specifies the number of log files to keep if rotate is given as the max_log_file_action. Note, there is a small catch to this setting. Turns out when Auditd is rotating logs it won't process any logs.  So on a high volume server you might miss logs during rotation. To avoid this raise the kernel backlog buffers by adding  -b &amp;lt;num&amp;gt; to /etc/audit/audit.rules. The default is 64 1K buffers. This cannot be greater than 99.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;max_log_file&lt;/i&gt; (default:5MB) &amp;amp; &lt;i&gt;max_log_file_action&lt;/i&gt; (default:ROTATE) &lt;br /&gt;The first sets the maximum log size in megabytes. Action defines what to do when it reaches that state. Valid values are ignore, syslog, suspend, rotate and keep_logs.  If set to ignore, the audit daemon does nothing.  syslog means that it will issue a warning to syslog.   suspend  will  cause  the audit daemon to stop writing records to the disk. The daemon will still be alive. The rotate option will cause the audit daemon to rotate the logs.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;space_left&lt;/i&gt; (default:75 MB) &amp;amp; &lt;i&gt;space_left_action&lt;/i&gt; (default:SYSLOG) &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; &lt;i&gt;admin_space_left&lt;/i&gt; (default:75 MB) &amp;amp; &lt;i&gt;admin_space_left_action&lt;/i&gt; (default:SUSPEND) &lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; &lt;i&gt;disk_full_action&lt;/i&gt; (default: SUSPEND) &amp;amp; &lt;i&gt;disk_error_action&lt;/i&gt; (default:SUSPEND)&lt;br /&gt;The first 2 can be explained as a warning threshold + action and critical threshold + action.&lt;br /&gt;The 3rd one defines what to do if the disk becomes full or disk errors occur when writing&lt;br /&gt;The valid actions are&lt;br /&gt;ignore - do nothing, syslog  - log to syslog, email - send email to &lt;i&gt;action_mail_acct&lt;/i&gt;,&lt;br /&gt;exec - execute a script, suspend - stop audit logging, single - single user mode, and halt - halt system&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;action_mail_acct&lt;/i&gt;&lt;br /&gt;Valid email address for email actions from above. This require /usr/lib/sendmail&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;flush&lt;/i&gt; &amp;amp; &lt;i&gt;freq&lt;/i&gt;The default is to use incremental and a count of 20 which means it will flush to disk after 20 events.  Valid values are none, incremental, data,  and sync.  This is a trade off between disk I/O and how much log data you can afford to lose if the server loses power or abruptly reboots. The data forces data to be synced at all times &amp;amp; the sync forced both data and meta data to be synced at all times. The sync option will off course cause the most amount of I/O. If you can afford to lose some log data, then leaving it at default would be fine.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;name_format &amp;amp; &lt;/i&gt;name&lt;br /&gt;This inserts the node name/host name to the log line. Default is to insert nothing. It can be set to hostname, IP address or FQDN. This makes sense if you are passing logs from several machine to a centralized location.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;tcp_listen_port&lt;/i&gt;You can tell auditd to listen for events from other machines.&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-size: 24px; font-weight: bold;"&gt;Auditd rules&lt;/span&gt;&lt;br /&gt;The main use of auditd is derived from the rules.  /etc/audit/audit.rules is used to set configuration like watch rules, buffers etc.  &lt;i&gt;auditctl&lt;/i&gt; can also be used to change rules on a live system. &lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;General Settings&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Backlog (default: 64 1K buffers)&lt;br /&gt;Turns out when Auditd is rotating logs it won't write any logs to file.  So on a high volume server you might miss logs during rotation. To avoid this raise the kernel backlog buffers by adding  -b &amp;lt;num&amp;gt; to /etc/audit/audit.rules. The default is 64 1K buffers. If the limit is reached the failure flag is consulted&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Rate&lt;br /&gt;Messages/sec can be set by -r. if the rate is exceeded the failure flag is consulted.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Failure flag (default: 1=printk)&lt;br /&gt;Determines how the kernel will handle errors. 0 - silent, 1 - printk , 2 - panic.&amp;nbsp;Even though panic sounds like a terrible idea, it can be important in high security environments, especially, if someone is trying to circumvent the logging.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Locking rules&lt;br /&gt;By adding &lt;i&gt;-e 2&lt;/i&gt; to end of the rules file,  the configuration is locked and cannot be changed by the auditctl command.  Attempts to do so will be logged and denied. Note, reverting this will require a reboot. This is another feature that is suited for very high security environments.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Listing current rules&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -l&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2359589543351279601" id="Watching_Files" name="Watching_Files"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;&lt;span class="mw-headline"&gt;Watching Files&lt;/span&gt;&lt;/h3&gt;&lt;i&gt;-w path&lt;/i&gt;&lt;br /&gt;Wildcards are not supported and will generate a warning. The way that watches work is by tracking the inode internally.&amp;nbsp;Unlike other syscall rules, watches  do not impact performance.&amp;nbsp;For more granular options like audit a specific user accessing a file, use the syscall auditing&lt;br /&gt;&lt;br /&gt;&lt;i&gt;-p r|w|x|a&lt;/i&gt;&lt;br /&gt;Set permissions filter for a file system watch. r=read, w=write, x=execute, a=attribute change. They are not standard file permissions but the syscall the gets executed for them&lt;br /&gt;&lt;br /&gt;&lt;i&gt;-k &amp;lt;key&amp;gt;&lt;/i&gt;&lt;br /&gt;The -k adds a key making it easy to search if there are several watches. One use for -k is to define different alert levels; eg. low, medium, high and then tag different rules with those levels.&lt;br /&gt;&lt;br /&gt;eg.&lt;br /&gt;Watch yum.conf for write and attribute changes&lt;br /&gt;Watch /sbin/service for execution&lt;br /&gt;Watch /etc/shadow  for read, write and attribute changes&lt;br /&gt;&lt;br /&gt;Note: The same can be added  to /etc/audit/audit.rules without the auditctl command&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;auditctl -w /etc/yum.conf -p wa  -k yum_watch&lt;br /&gt;auditctl -w /usr/bin/nmap -p x   -k nmap_watch&lt;br /&gt;auditctl -w /etc/shadow   -p rwa -k shadow_watch&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To report on watched files.  Date format is local to the server's date format. &lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;aureport -f --start 02/18/10 17:42:00&lt;br /&gt;aureport -f --start 02/18/10 17:00:00 --end 02/18/10 17:10:00&lt;br /&gt;aureport -f -ts this-week&lt;br /&gt;aureport -f -ts today&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Output will be similar to this&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;14742. 04/20/10 12:40:01 /etc/shadow 2 yes /usr/sbin/crond -1 977855&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;14743. 04/20/10 12:40:01 /etc/shadow 2 yes /usr/sbin/crond -1 977851&lt;br /&gt;14744. 04/20/10 12:40:24 /etc/shadow 89 no /opt/splunk/bin/splunkd 500 977863&lt;br /&gt;14745. 04/20/10 12:40:50 /etc/shadow 89 no /opt/splunk/bin/splunkd 500 977864&lt;br /&gt;14746. 04/20/10 12:41:16 /etc/shadow 89 no /opt/splunk/bin/splunkd 500 977865&lt;br /&gt;14747. 04/20/10 12:41:42 /etc/shadow 89 no /opt/splunk/bin/splunkd 500 977866&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;The 1st column is just an index&lt;br /&gt;&lt;br /&gt;The 2nd column is the date&lt;br /&gt;&lt;br /&gt;The 3nd column is the time&lt;br /&gt;&lt;br /&gt;The 4rd column is the file name&lt;br /&gt;&lt;br /&gt;The 5th column is the system call number. To convert this number into name use &lt;i&gt;aureport -f -i&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;The 6th column is the result of the system call. Success of failure. You can use &lt;i&gt;aureport --failed&lt;/i&gt; to list only failed&lt;br /&gt;&lt;br /&gt;The 7th column is the process accessing it&lt;br /&gt;&lt;br /&gt;The 8th column is the Actual/Audit UID (AUID). If you login as user joe(uid 500) and su to root (uid=0). The AUID is 500. &lt;br /&gt;&lt;br /&gt;The 9th column is the event number. You can use ausearch -a &amp;lt;event no&amp;gt; to look up further details&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;&amp;nbsp;: &lt;i&gt;-i&lt;/i&gt; is useful as it converts to more human readable value. However the conversion is done at the time of viewing. The log will contain numeric values only. So if uid 500 belongs to john at the time of logging and at a later date, uid 500 is assigned to user joe, there will be a discrepancy.&lt;br /&gt;&lt;br /&gt;The above produces more of a summary. You can use 'ausearch' to get more details.&lt;br /&gt;&lt;br /&gt;Let's take a closer look. &lt;br /&gt;&lt;br /&gt;nmap is set to 0700 permissions.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;[root@slice01 ~]# ls -l /usr/bin/nmap&lt;br /&gt;-rwx------ 1 root root 3580248 Jul  6  2009 /usr/bin/nmap&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Access by root yields the following log&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;# ausearch -i -k nmap_watch &lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;time-&amp;gt;Fri Apr 16 16:10:18 2010&lt;br /&gt;node=slice01 type=PATH msg=audit(04/16/10 16:10:18.044:954405)&amp;nbsp;: item=0 name=/usr/bin/nmap inode=721629 dev=08:01 mode=file,700 &lt;br /&gt;ouid=root ogid=root rdev=00:00 &lt;br /&gt;node=slice01 type=CWD msg=audit(04/16/10 16:10:18.044:954405)&amp;nbsp;:  cwd=/root &lt;br /&gt;node=slice01 type=EXECVE msg=audit(04/16/10 16:10:18.044:954405)&amp;nbsp;: a0=nmap &lt;br /&gt;node=slice01 type=SYSCALL msg=audit(04/16/10 16:10:18.044:954405)&amp;nbsp;: arch=x86_64 &lt;br /&gt;syscall=execve per=400000 success=yes exit=0 a0=6e2bd0 a1=6e5160 a2=7ae510 a3=0 items=1 &lt;br /&gt;ppid=7318 pid=14772 auid=sri uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts0 &lt;br /&gt;comm=nmap exe=/usr/bin/nmap key=nmap_watch &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Access by user with uid 500 who has been granted access results in this&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;----&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;time-&amp;gt;Fri Apr 16 16:11:44 2010&lt;br /&gt;node=slice01 type=PATH msg=audit(04/16/10 16:11:44.470:954410)&amp;nbsp;: item=0 name=/usr/bin/nmap inode=721629 dev=08:01 mode=file,700 &lt;br /&gt;ouid=root ogid=root rdev=00:00 &lt;br /&gt;node=slice01 type=CWD msg=audit(04/16/10 16:11:44.470:954410)&amp;nbsp;:  cwd=/root &lt;br /&gt;node=slice01 type=SYSCALL msg=audit(04/16/10 16:11:44.470:954410)&amp;nbsp;: arch=x86_64 &lt;br /&gt;syscall=execve success=no exit=-13(Permission denied) a0=6f26e0 a1=6f2260 a2=6cf8e0 a3=0 items=1 &lt;br /&gt;ppid=13286 pid=15089 auid=sri uid=sri gid=sri euid=sri suid=sri fsuid=sri egid=sri sgid=sri fsgid=sri tty=pts1 &lt;br /&gt;comm=bash exe=/bin/bash key=nmap_watch &lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;success=&amp;lt;yes|no&amp;gt; shows if the system call was successful&lt;br /&gt;&lt;br /&gt;Again the &lt;i&gt;-i&lt;/i&gt; lists output in more human readable format and converts syscall numbers and user ids into names.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To remove a rule using auditctl you can use the &lt;i&gt;-W&lt;/i&gt; switch&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;auditctl -W /etc/shadow -p rwa -k shadow_watch&lt;br /&gt;&lt;/pre&gt;Another way to watch files is via system calls. See below.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;Watching system calls&lt;/span&gt;&lt;br /&gt;You can use this to watch any system call. There are various options available here that can be combined to audit different types of events.&lt;br /&gt;&lt;br /&gt;Required switches with syscall monitoring are the &lt;i&gt;-a list,action&lt;/i&gt; &lt;i&gt;-A list,action&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;&lt;br /&gt;&lt;/span&gt;-a&lt;/i&gt; appends to the end of the list&lt;br /&gt;&lt;br /&gt;&lt;i&gt;-A&lt;/i&gt; appends to the start of the list&lt;br /&gt;&lt;br /&gt;The corresponding switch to the &lt;i&gt;-a&lt;/i&gt; is the &lt;i&gt;-d&lt;/i&gt; switch which can delete rules of a certain type&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;list&lt;/b&gt; values can be&lt;br /&gt;&lt;br /&gt;entry/exit - This determines when to log with respect to the system call invocation&lt;br /&gt;&lt;br /&gt;exclude  -  This can be used to filter events&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;action&lt;/b&gt; values can be&amp;nbsp;:-&lt;br /&gt;&lt;br /&gt;never - No  audit records will be generated. The order of rules in the audit.rules file matters. Normally you would put suppressions at the top&lt;br /&gt;&lt;br /&gt;always - Always write out a record&lt;br /&gt;&lt;br /&gt;The &lt;i&gt;-S&lt;/i&gt; switch defines the system call to watch. It can be name or the system call number&lt;br /&gt;&lt;br /&gt;The next switch is the &lt;i&gt;-F&lt;/i&gt;  which builds a rule field.  Several of these can be grouped together to filter various stuff.&lt;br /&gt;&lt;br /&gt;Common things to use with this are&amp;nbsp;:-&lt;br /&gt;&lt;br /&gt;arch - cpu architecture &lt;br /&gt;&lt;br /&gt;auid/uid - The original ID the user logged in with &amp;amp; the user id&lt;br /&gt;&lt;br /&gt;euid/egid - Effective user and group ID&lt;br /&gt;&lt;br /&gt;path/dir - Full path of the file or directory to watch. Directory watches are recursive&lt;br /&gt;&lt;br /&gt;filetype - Type of the file. file, dir, socket, symlink, char, block, or fifo&lt;br /&gt;&lt;br /&gt;perm - permission filter for file operation&lt;br /&gt;&lt;br /&gt;pid/ppid - process id and parent process id&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Watching for ptrace system call. Utilities like strace use it&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;auditctl -a entry,always -F arch=b64 -S ptrace -k info_scan&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Suppressing 32bit clock_gettime &amp;amp; fstat64 system calls&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;-a entry,never -F arch=b32 -S clock_gettime -k clock_gettime&lt;br /&gt;-a entry,never -F arch=b32 -S fstat64 -k fstat64&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Audit files opened by a specific user. The first rule will audit all open files. It is a good idea to watch for both auid and uid. &lt;br /&gt;Also the architecture is required with system calls like these&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a exit,always -S open -F auid=2010&lt;br /&gt;auditctl -a exit,always -F arch=b64 -F auid=2010  -F uid=2010 -F path=/etc/hosts -S open&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;To search you can use the key or use the &lt;i&gt;-sc&lt;/i&gt; switch&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;ausearch -k info_scan -i&lt;br /&gt;ausearch -sc ptrace -i&lt;br /&gt;&lt;/pre&gt;To search by user id&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;ausearch -ua 2010&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2359589543351279601" id="Authentication_Report" name="Authentication_Report"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;&lt;span class="mw-headline"&gt;Authentication Report&lt;/span&gt;&lt;/h3&gt;Lists all auth attempts and their result. This also includes logins by other means, eg. imap access&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;aureport -au&lt;br /&gt;&lt;/pre&gt;To list just logins&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;aureport -l&lt;br /&gt;&lt;/pre&gt;To list account modification attempts. This lists only successful attempts. For eg. it won't list an attempt made by an unprivileged user.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;aureport -m&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;Rules for security standards&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/usr/share/doc/audit-&amp;lt;version&amp;gt; has pre-defined rules for different standards&lt;br /&gt;&lt;br /&gt;Controlled Access Protection Profile (CAPP) - &lt;a class="external free" href="http://www.commoncriteriaportal.org/files/ppfiles/capp.pdf" rel="nofollow" title="http://www.commoncriteriaportal.org/files/ppfiles/capp.pdf"&gt;http://www.commoncriteriaportal.org/files/ppfiles/capp.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Labeled Security Protection Profile (LSPP) - &lt;a class="external free" href="http://www.commoncriteriaportal.org/files/ppfiles/lspp.pdf" rel="nofollow" title="http://www.commoncriteriaportal.org/files/ppfiles/lspp.pdf"&gt;http://www.commoncriteriaportal.org/files/ppfiles/lspp.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;National Industrial Security Program Operating Manual (NISPOM) - &lt;a class="external free" href="http://www.fas.org/sgp/library/nispom.htm" rel="nofollow" title="http://www.fas.org/sgp/library/nispom.htm"&gt;http://www.fas.org/sgp/library/nispom.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Security Technical Implementation Guides - &lt;a class="external free" href="http://iase.disa.mil/stigs/stig/index.html" rel="nofollow" title="http://iase.disa.mil/stigs/stig/index.html"&gt;http://iase.disa.mil/stigs/stig/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 24px; font-weight: bold;"&gt;Best Practices&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt; If you want everything audited you should add a boot param of audit=1 to Grub. Otherwise certain processes that start before audit loads will not be monitored.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;/var/log/audit should be on its own partition.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Use Syscall rules with care. They will lead to performance degradation if overused&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-size: 24px; font-weight: bold;"&gt;Commands Listing&lt;/span&gt;&lt;br /&gt;&lt;b&gt;Adding/Modifying Rules&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Watch for files&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -w /etc/yum.conf -p wa  -k yum_watch &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -w /usr/bin/nmap -p x   -k nmap_watch &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -w /etc/shadow   -p rwa -k shadow_watch&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Remove a rule using auditctl&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -W /etc/shadow -p rwa -k shadow_watch&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Watching for ptrace system call&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -a entry,always -F arch=b64 -S ptrace -k info_scan&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Suppress 32bit clock_gettime &amp;amp; fstat64 system calls&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a entry,never -F arch=b32 -S clock_gettime -k clock_gettime &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;-a entry,never -F arch=b32 -S fstat64 -k fstat64&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Audit files opened by a specific user&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a exit,always -S open -F auid=2010 &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a exit,always -F arch=b64 -F auid=2010  -F uid=2010 -F path=/etc/hosts -S open&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt; Audit unsuccessful attempts for multiple system calls where user id is greater than or equal to 500&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EACCES -F auid&amp;gt;=500&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: xx-small;"&gt;auditctl -a always,exit -F arch=b32 -S creat -S open -S openat -S truncate -S ftruncate -F exit=-EPERM -F auid&amp;gt;=500 &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;pre&gt;&lt;/pre&gt;&lt;b&gt;Reporting/Searching&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;List all rules&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -l&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;List status&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;auditctl -s&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Report on watched files.  Date format is local to the server's date format.&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f --start 02/18/10 17:42:00&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f --start 02/18/10 17:00:00 --end 02/18/10 17:10:00&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f -ts this-week &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -f -ts today&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search by system call&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -sc ptrace -i&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search for user id or effective user id&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -ui 2010 &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -ue 2010&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Lists all auth attempts and their result&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -au&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;List just logins&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -l&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;List account modification attempts.&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;aureport -m&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search events where success value is no, User id is 500 and key is nmap_watch&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -sv no -ua 500 -k nmap_watch&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search by executable&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -x /usr/bin/nmap&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search by terminal&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -tm pts/0&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Search by daemon. Stuff like cron log terminal as the daemon name&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;ausearch -tm cron&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=2359589543351279601" id="Audit_data_visualisation" name="Audit_data_visualisation"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt;Audit data visualisation&lt;/span&gt;&lt;/h2&gt;mkgraph &amp;amp; mkgraph are two scripts that make use of gnuplot to plot graphs using the data from aureport and ausearch.&lt;br /&gt;&lt;br /&gt;More of this at &lt;a class="external free" href="http://people.redhat.com/sgrubb/audit/visualize/index.html" rel="nofollow" title="http://people.redhat.com/sgrubb/audit/visualize/index.html"&gt;http://people.redhat.com/sgrubb/audit/visualize/index.html&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2359589543351279601-7638653207334691838?l=loadaverage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loadaverage.blogspot.com/feeds/7638653207334691838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://loadaverage.blogspot.com/2011/01/linux-and-auditd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/7638653207334691838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2359589543351279601/posts/default/7638653207334691838'/><link rel='alternate' type='text/html' href='http://loadaverage.blogspot.com/2011/01/linux-and-auditd.html' title='Linux and Auditd'/><author><name>Sriram Rajan</name><uri>http://www.blogger.com/profile/03240364714315023907</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_lFNiONv6UeM/TSx0ZRU8mKI/AAAAAAAAAAU/Knl_IwDliaI/S220/0e6c6a6.jpg'/></author><thr:total>0</thr:total></entry></feed>
