<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[iRedMail — lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
		<link>http://www.iredmail.org/forum/topic370-lastlogindate-lastloginipv4-lastloginprotocol.html</link>
		<atom:link href="http://www.iredmail.org/forum/feed-rss-topic370.xml" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in lastlogindate, lastloginipv4, lastloginprotocol ?.]]></description>
		<lastBuildDate>Mon, 09 Nov 2009 08:11:05 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1758.html#p1758</link>
			<description><![CDATA[<p>Thank you, it&#039;s working.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Mon, 09 Nov 2009 08:11:05 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1758.html#p1758</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1725.html#p1725</link>
			<description><![CDATA[<p>Hi, maxie_ro.</p><p>I already updated tracking script, redirect stderr and stdout message to /dev/null, and it works with POP3 &amp; IMAP now. Please refer to this FAQ:<br /><a href="http://www.iredmail.org/forum/topic379-faq-how-to-track-user-last-login-data-ip-date-mail-protocol.html">http://www.iredmail.org/forum/topic379- … tocol.html</a></p><p>Enjoy <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Thu, 05 Nov 2009 07:37:18 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1725.html#p1725</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1641.html#p1641</link>
			<description><![CDATA[<p>Maybe I wasn&#039;t clear enough. Let me explain.</p><p>In dovecot.conf there is, as you said:<br /></p><div class="codebox"><pre><code>mail_executable = /usr/bin/TrackLastLogin.sh imap</code></pre></div><p>where <strong>imap</strong> here is the first command-line argument of the script.</p><p>In &lt;TrackLastLogin.sh&gt; the last line is:<br /></p><div class="codebox"><pre><code>exec /usr/libexec/dovecot/imap $*</code></pre></div><p>,where <strong>$*</strong> means that you are passing to /usr/libexec/dovecot/imap the same arguments as the current script received. One of the arguments it received was &quot;imap&quot;, so you are running:<br /></p><div class="codebox"><pre><code>/usr/libexec/dovecot/imap imap</code></pre></div><p>, but &quot;imap&quot; is an incorrect command line argument for the binary.</p><p>Thus, you need 2 separate scripts, one for POP3, one for IMAP to work.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 13:50:56 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1641.html#p1641</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1640.html#p1640</link>
			<description><![CDATA[<p>That won&#039;t work either, because the first argument of the script is sent to the &quot;imap&quot; and &quot;pop3&quot; binaries. There is no such command line switches for them, so they crash. You need to make 2 separate scripts, one for IMAP and one for POP3, and don&#039;t feed them any arguments.</p><p>And, don&#039;t put them in libexec/dovecot, it won&#039;t work! (maybe because of SELinux?)</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 13:45:30 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1640.html#p1640</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1639.html#p1639</link>
			<description><![CDATA[<p>Change the last line to:<br /></p><div class="codebox"><pre><code>exec /usr/libexec/dovecot/${1} $*</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Tue, 27 Oct 2009 13:31:15 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1639.html#p1639</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1638.html#p1638</link>
			<description><![CDATA[<p>LE: nope, not working. I&#039;m stumped.</p><p>The mysql part is working properly (e.g. the table `mailbox` gets updated) but imap/pop3 isn&#039;t working anymore... Nobody can read mails.</p><p>Maybe because the last line is<br /></p><div class="codebox"><pre><code>exec /usr/libexec/dovecot/imap $*</code></pre></div><p>which will also send &quot;imap&quot; or &quot;pop3&quot; keywords (argument of the script) to imap and pop3 binaries, causing them to return error?</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 13:21:18 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1638.html#p1638</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1637.html#p1637</link>
			<description><![CDATA[<p>Thank you.</p><p>Your script is working, if I modify something: remove the double quotes from the INET_ATON(&#039;$IP&#039;) and NOW(). Otherwise mysql will literally try to write in the field `lastlogindate` the text &quot;NOW()&quot; instead of the actual result of the function NOW() (which is current datetime).</p><p>P.S.<br />If I put my script in /usr/bin it&#039;s working too.... Problem with libexec/dovecot?! Pff.... didn&#039;t cross my mind.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 13:11:56 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1637.html#p1637</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1636.html#p1636</link>
			<description><![CDATA[<div class="codebox"><pre><code>#!/bin/sh

# =========================================================
# Author:   Zhang Huangbin (michaelbibby@gmail.com)
# Date:     2009.07.28
# Purpose:  Track user last login date &amp; ip address.
# =========================================================

# $USER -&gt; login username
# $IP   -&gt; remote ip address
# ${1}  -&gt; mail protocol: imap, pop3

# Debug &amp; Update to plain file.
# Note: user &#039;dovecot&#039; should have write permission on this file.
#echo &quot;$(date +%Y.%m.%d-%H:%M:%S), $USER, $IP, ${1})&quot; &gt;&gt; /tmp/tracking.log

# ----------------------------------------------
# Update to MySQL database.
# ----------------------------------------------
#mysql -uvmailadmin -psecret_passwd vmail &lt;&lt;EOF
#UPDATE mailbox SET \
#   lastloginipv4=&quot;INET_ATON(&#039;$IP&#039;)&quot;, \
#   lastlogindate=&quot;NOW()&quot;, \
#   lastloginprotocol=&quot;${1}&quot; \
#   WHERE username=&#039;$USER&#039;;
#EOF

# ----------------------------------------------
# Update to LDAP (OpenLDAP) directory server.
# ----------------------------------------------
# Convert username to LDAP dn.
# -c         continuous operation mode (do not stop on errors)
# -x            Simple authentication
# -H URI        Uniform Resource Identifier(s)
# -D binddn     Bind dn. Default is &#039;cn=vmailadmin,dc=iredmail,dc=org&#039;
# -w bindpw     Bind password (for simple authentication)
if [ X&quot;${USER}&quot; != X&quot;dump-capability&quot; ]; then
    ldapmodify -c -x \
        -H ldap://127.0.0.1:389 \
        -D &#039;cn=vmailadmin,dc=iredmail,dc=org&#039; \
        -w passwd &lt;&lt;EOF
dn: mail=${USER},ou=Users,domainName=$(echo ${USER} | awk -F&#039;@&#039; &#039;{print $2}&#039;),o=domains,dc=iredmail,dc=org
changetype: modify
replace: lastLoginDate
lastLoginDate: $(date +%Y%m%d%H%M%SZ)
-
replace: lastLoginIP
lastLoginIP: ${IP}
-
replace: lastLoginProtocol
lastLoginProtocol: ${1}
EOF

fi

# Execute IMAP process.
# RHEL/CentOS:
exec /usr/libexec/dovecot/imap $*
# Debian &amp; Ubuntu:
#exec /usr/lib/dovecot/imap $*</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Tue, 27 Oct 2009 12:29:47 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1636.html#p1636</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1635.html#p1635</link>
			<description><![CDATA[<p>OK..... and what is the contents of TrackLastLogin.sh?</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 12:06:01 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1635.html#p1635</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1634.html#p1634</link>
			<description><![CDATA[<p>It works for me:<br /></p><div class="codebox"><pre><code>    protocol imap {
        mail_drop_priv_before_exec=yes
        mail_executable = /usr/bin/TrackLastLogin.sh imap
        ...
    }

    protocol pop3 {
        mail_drop_priv_before_exec=yes
        mail_executable = /usr/bin/TrackLastLogin.sh pop3
        ...
    }</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Tue, 27 Oct 2009 11:42:35 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1634.html#p1634</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1633.html#p1633</link>
			<description><![CDATA[<p>Not missed anything <img src="http://www.iredmail.org/forum/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p><p>Tested with both &quot;mail_drop_priv_before_exec&quot; set to &#039;no&#039; and &#039;yes&#039; already. Not working... Still not finding the file...</p><p>And it shouldn&#039;t have to do anything with it anyway, because default is &#039;no&#039;, and changing it to &#039;yes&#039; should only make things worse...</p><p>Besides, it can find the &quot;imap&quot; executable in the same directory with identical permissions and owner.... ?!</p><p>BTW, I tried replied previously and I think I accidentaly hit the report button, sorry.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 11:36:00 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1633.html#p1633</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1632.html#p1632</link>
			<description><![CDATA[<p>You must miss this in dovecot wiki page:<br /></p><div class="quotebox"><blockquote><p>WARNING: The process still runs as root at this point! The privileges are dropped only after the imap process starts. You can change this by setting mail_drop_priv_before_exec=yes.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Tue, 27 Oct 2009 11:18:24 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1632.html#p1632</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1631.html#p1631</link>
			<description><![CDATA[<p>Of course I did, I said it in the previous post.</p><p>The imaplastlogin shell script is in the same directory as the imap executable, and they have the same permissions and owner. But it can&#039;t find the shell script.</p><p>I triple-checked the path &amp; name, everything is ok.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 11:09:59 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1631.html#p1631</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1630.html#p1630</link>
			<description><![CDATA[<p>It&#039;s clear in the output message:<br /></p><div class="quotebox"><blockquote><p>Starting Dovecot Imap: Fatal: execv(/usr/libexec/dovecot/imaplastlogin) failed: No such file or directory</p></blockquote></div><p>Did you use &#039;chmod&#039; to set correct file permission? such as 0755:<br /></p><div class="codebox"><pre><code># chmod 0755 /usr/libexec/dovecot/imaplastlogin</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ZhangHuangbin)]]></author>
			<pubDate>Tue, 27 Oct 2009 10:39:35 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1630.html#p1630</guid>
		</item>
		<item>
			<title><![CDATA[Re: lastlogindate, lastloginipv4, lastloginprotocol ?]]></title>
			<link>http://www.iredmail.org/forum/post1629.html#p1629</link>
			<description><![CDATA[<p>I don&#039;t know why, but it doesn&#039;t work.</p><p>I created the shell script file, &quot;imaplastlogin&quot;:<br /></p><div class="codebox"><pre><code>#!/bin/sh
mysql --password=...... --user=root --default-character-set=utf8 --database=vmail --execute=&quot;UPDATE vmail.mailbox SET lastlogindate = NOW(), lastloginipv4=INET_ATON(&#039;$IP&#039;), lastloginprotocol=&#039;IMAP&#039; WHERE username = &#039;$USER&#039;;&quot;

exec /usr/local/libexec/dovecot/imap $*</code></pre></div><p>Modified dovecot.conf:<br /></p><div class="codebox"><pre><code># POP3 configuration
protocol imap {
    #mail_plugins = quota imap_quota zlib expire
    mail_plugins = quota imap_quota zlib

    # number of connections per-user per-IP
    #mail_max_userip_connections = 10
    mail_executable = /usr/libexec/dovecot/imaplastlogin
}</code></pre></div><p>When restarting dovecot I get the following error:<br /></p><div class="codebox"><pre><code>Stopping Dovecot Imap:                                     [  OK  ]
Starting Dovecot Imap: Fatal: execv(/usr/libexec/dovecot/imaplastlogin) failed: No such file or directory
Error: imap dump-capability process returned 84
Fatal: Invalid configuration in /etc/dovecot.conf
                                                           [FAILED]</code></pre></div><p>When I run the mysql command directly in the shell it works ok.<br />But why do I get such an error?! The permissions appear to be ok... (0755).</p><p>Also, if I modify to the default:<br /></p><div class="codebox"><pre><code>mail_executable = /usr/libexec/dovecot/imap</code></pre></div><p> everything works ok.</p>]]></description>
			<author><![CDATA[null@example.com (maxie_ro)]]></author>
			<pubDate>Tue, 27 Oct 2009 10:35:00 +0000</pubDate>
			<guid>http://www.iredmail.org/forum/post1629.html#p1629</guid>
		</item>
	</channel>
</rss>
