Mar 222016
 

When you have webmail separated from your pop3/imap4 server things can be complicated if you don’t have direct access to mysql server over the network. using poppassd will not solving the problem if you’re using mysql, pgsql or ldap backend for storing user information. because (AFAIK) it only can access/change user/password on passwd/shadow file.

using courierpassd allows us to access or modify pop3/imap4 user information store in mysql, pgsl or ldap backend. one caveat, courierpassd using courier-authlib API in order to be able accessing those database backend. we have to install or build from source. courierpassd use the same protocol as poppassd does.

i’m using centos and this is how i do it.

first using non priviledged user cccount, create rpm build environment.

$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386

echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

download courier-authlib and courierpassd source

wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.60.2.tar.bz2
wget http://www.arda.homeunix.net/?ddownload=375 -O courierpassd.1.1.2.tar.gz

compile and install courier-authlib

$rpmbuild -ta courier-authlib-0.60.2.tar.bz2
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-0.66.4-1.el6.x86_64.rpm
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-devel-0.66.4-1.el6.x86_64.rpm
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-mysql-0.66.4-1.el6.x86_64.rpm

extract courierpassd, compile and install

#tar xzf courierpassd.1.1.2.tar.gz
#cd courierpassd-1.1.2
#./configure
#make
#make install

you want be able to access this courierpassd from other server on the network. people using xinet.d usually.

#vi /etc/xinetd.d/courierpassd
service courierpassd
{
       disable          = no
       socket_type      = stream
       protocol         = tcp
       port             = 106
       wait             = no
       user             = root
       server           = /usr/sbin/courierpassd
       instances        = 10
       only_from        = 192.168.0.101 127.0.0.1
}

Continue reading »

Mar 222016
 

hardware: ESP8266 (ESP-12), DHT22/AM2302, jumpers
firmware: nodemcu-dev096-21-modules-2015-09-20-05-43-31-float (custome f/w) http://frightanic.com/nodemcu-custom-build/
language: Lua

IDE : ESPlorer

WRITEKEY="thingspeak write key"    -- set your thingspeak.com key
PIN = 2                --  data pin, GPIO2
wifi.setmode(wifi.STATION)
wifi.sta.config("ssid","password")
wifi.sta.setip({ip="192.168.0.115",netmask="255.255.255.0",gateway="192.168.0.1"})
wifi.sta.connect()
tmr.delay(1000000)
humi=0
temp=0
-- LED = 1
-- gpio.mode(LED, gpio.OUTPUT)

RST = 4
gpio.mode(RST, gpio.OUTPUT)
--gpio.write(RST, gpio.LOW)
function init_OLED(sda,scl) --Set up the u8glib lib
     sla = 0x3c
     i2c.setup(0, sda, scl, i2c.SLOW)
     disp = u8g.ssd1306_128x64_i2c(sla)
     disp:setFont(u8g.font_6x10)
     disp:setFontRefHeightExtendedText()
     disp:setDefaultForegroundColor()
     disp:setFontPosTop()
end

init_OLED(5,6) --Run setting up
gpio.write(RST, gpio.HIGH)

function display_OLED(humi, temp)
     disp:firstPage()
       repeat
          -- lines = 25
          lines = 5
          disp:drawFrame(0,0,128,64);
          disp:drawStr( 5, 5, "Temp & Humi")
          disp:drawStr( 5, 20, "Humidity    : "..humi.."%")
          disp:drawStr( 5, 31, "Temperature : "..temp.."C")
       until disp:nextPage() == false
end

--load DHT module and read sensor
function ReadDHT()
    dht=require("dht")
    -- dht.read(PIN)
    status,temp,humi,temp_decimial,humi_decimial = dht.read(PIN)
        if( status == dht.OK ) then
          -- gpio.write(LED, gpio.HIGH)
          -- Integer firmware using this example
          --  print(
          --      string.format(
          --          "\r\nDHT Temperature:%d.%03d\r\nHumidity:%d.%03d\r\n",
          --          temp,
          --          temp_decimial,
          --          humi,
          --          humi_decimial
          --      )
          --  )
            -- Float firmware using this example
            print("Humidity:    "..humi.."%")
            print("Temperature: "..temp.."C")
        elseif( status == dht.ERROR_CHECKSUM ) then
            print( "DHT Checksum error." );
        elseif( status == dht.ERROR_TIMEOUT ) then
            print( "DHT Time out." );
        end
    -- release module
    dht=nil
    package.loaded["dht"]=nil
end
-- send to https://api.thingspeak.com
function sendTS(humi,temp)
conn = nil
conn = net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload)success = true print(payload)end)
conn:on("connection",
   function(conn, payload)
   print("Connected")
   conn:send('GET /update?key='..WRITEKEY..'&field1='..humi..'&field2='..temp..'HTTP/1.1\r\n\
   Host: api.thingspeak.com\r\nAccept: */*\r\nUser-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n\r\n')end)
conn:on("disconnection", function(conn, payload) print('Disconnected') end)
conn:connect(80,'api.thingspeak.com')
-- gpio.write(LED, gpio.LOW)
end
-- ReadDHT()
-- sendTS(humi,temp)
tmr.alarm(1,60000,1,function()ReadDHT()display_OLED(humi, temp)sendTS(humi,temp)end)