Maxime Chambreuil

Friday April 4, 2008

Tooltips for GIT

Max @ 21:07 | Filed under: Development, Documentation
  • english

GIT

Initialization

$ git config --global user.name “Your Name Comes Here”
$ git config –global user.email  you at yourdomain.example.com

Cloning

$ git clone git+ssh://sflphone_org@sflphone.org/git/sflphone.git

Edit .git/config to have :

[remote "origin"]
        url = git+ssh://sflphone_org@sflphone.org/git/sflphone.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        push = +refs/heads/*:refs/remotes/origin/*

Committing and pushing

$ git-gui

Then “Add Existing”, “Commit” and “Push”.

Branching

Create a new branch toto :

$ git branch toto

List all branches :

$ git branch

Switch to branch toto :

$ git checkout toto

Display branches :

$ gitk

Delete branch toto :

$ git branch -d toto

Saturday January 19, 2008

Fetchmail + Procmail + Cyrus + SASL + LDAP + Roundcube + GetLive

Max @ 12:30 | Filed under: Documentation
  • english

Postfix logoAs many of you, I have a couple years of experience of using Internet and as such I have created different email accounts on different websites : not because I needed it, but mostly because each provider came out with a great benefit compared to the others. Funny thing, the last email account I have is the one from my Internet service provider which doesn’t propose a webmail. Buuuuuuuuuu. You must admit it is not very convenient when you are away from home or work. So here is my need for a solution to retrieve all my emails from Yahoo, Gmail, Free, etc. and serve them with IMAP to either Thunderbird or a Webmail.

Before going into the details of configuring each services, few things to know about my current setup :

Fetchmail

Install fetchmail :

# apt-get install fetchmail

Edit /etc/default/fetchmail to start it as a daemon :

START_DAEMON=yes

Create /etc/fetchmailrc :

poll pop.example.com with proto pop3
  user ‘john.doe’ there with password ‘passwd’ is ‘john’ here
  keep mda ’sudo /usr/bin/procmail -m /etc/procmailrc’
poll pop.gmail.com with proto pop3 port 995
  user ‘john.doe’ there with password ‘password’ is ‘john’ here
  ssl keep mda ’sudo /usr/bin/procmail -m /etc/procmailrc’

The reason I use sudo to execute procmail is that the fetchmail daemon runs as user fetchmail, and as the fetchmail user I wouldn’t be able to deliver the email.

Edit /etc/sudoers to add this line at the end :

fetchmail	ALL=NOPASSWD: /usr/bin/procmail

Start fetchmail :

# invoke-rc.d fetchmail restart

Procmail

Install procmail :

# apt-get install procmail

Create /etc/procmailrc :

SHELL="/bin/sh"
DELIVERMAIL="/usr/sbin/cyrdeliver"
USER="john"
IMAP="$DELIVERMAIL -a $USER -m user/$USER"
LOGFILE="/var/log/mail/$USER.log"
LOGABSTRACT="all"
VERBOSE=YES

:0
|$IMAP

This is a quick and dirty version of /etc/procmailrc. Improvements have to be made to turn it system-wide (for all the users) and add some filtering and anti-spam rules.

Logo CyrusCyrus + SASL

Install Cyrus :

# apt-get install cyrus-imapd-2.2 cyrus-admin-2.2 cyrus-clients-2.2 sasl2-bin

Edit /etc/imapd.conf :

configdirectory: /var/lib/cyrus
partition-default: /var/spool/cyrus
admins: cyrus administrator
sievedir: /var/lib/cyrus/sieve
sendmail: /usr/sbin/sendmail
hashimapspool: true
lmtpsocket: {configdirectory}/socket/lmtp
sasl_pwcheck_method: saslauthd
sasl_mech_list: PLAIN
unixhierarchysep: yes

The user cyrus is a /etc/passwd user. administrator is an LDAP user. lmtpsocket is the same path as the one specified in /etc/cyrus.conf :

lmtpunix	cmd="lmtpd" listen="/var/lib/cyrus/socket/lmtp" prefork=0 maxchild=20

Disable POP3 server :
In /etc/cyrus.conf and the SERVICES section, comment the pop3 line as follows :

# pop3		cmd="pop3d -U 30" listen="pop3" prefork=0 maxchild=50

OpenLDAP logoCreate /etc/saslauthd.conf with :

ldap_servers: ldap://127.0.0.1/
ldap_search_base: dc=example,dc=com

In /etc/default/saslauthd, set the authentication mechanism :

MECHANISMS="ldap"

Start saslauthd :

# invoke-rc.d saslauthd start

Test your ldap connection with :

# testsaslauthd -u john -p password
0: OK "Success."

Start cyrus :

# invoke-rc.d cyrus start

We now have to create mailboxes and give users their rights. We have to log in Cyrus with an LDAP account set as Admins in the cyrus config file (administrator). Once in the cyrus prompt, type help to get the list of command and their arguments :

# su - administrator
$ cyradm localhost
IMAP Password: password
localhost.localdomain> cm user/john
localhost.localdomain> lm
user/john (\HasNoChildren)
localhost.localdomain> sam user/john john all
localhost.localdomain> lam user/john
john lrswipcda
localhost.localdomain> exit
$

I didn’t need it but you can also fix your quota at this step.

Now emails should be ending up in /var/spool/cyrus/j/user/john/ in file named 1. 2. 3. etc.

RoundCube logoRoundCube

Install roundcube :

# apt-get install roundcube

Edit /etc/roundcube/apache.conf to uncomment :

Alias /roundcube /var/lib/roundcube

Reload Apache :

# invoke-rc.d apache2 reload

Point your browser to http://localhost/roundcube to make sure you can access Roundcube login page.

Edit /etc/roundcube/main.inc.php and change this option to connect RoundCube to your IMAP server (authentication and emails) :

$rcmail_config['default_host'] = “imap://localhost:143″;

Edit /etc/roundcube/main.inc.php and change those options to connect RoundCube to your LDAP server (addressbook) :

$rcmail_config['ldap_public']['example.com'] = array(
‘name’          => ‘example.com’,
‘hosts’         => array(’ldap.example.com’),
‘port’          => 389,
‘base_dn’       => ‘ou=addressbook,dc=example,dc=com’,
‘bind_dn’       => ”,
‘bind_pass’     => ”,
‘ldap_version’  => ‘3′,       // using LDAPv3
’search_fields’ => array(’mail’, ‘cn’),  // fields to search in
‘name_field’    => ‘cn’,    // this field represents the contact’s name
‘email_field’   => ‘mail’,  // this field represents the contact’s e-mail
’surname_field’ => ’sn’,    // this field represents the contact’s last name
‘firstname_field’ => ‘givenName’,  // this field represents the contact’s first name
’scope’         => ’sub’,   // search mode: sub|base|list
‘filter’        => ”,      // used for basic listing (if not empty) and will be &’d with search queries. ex: (status=act)
‘fuzzy_search’  => true);   // server allows wildcard search

Now try logging in to RoundCube with john/password and click on Addressbook. “example.com” should appear in the Groups list and with the search box, you should be able to get your LDAP entries.

Hotmail/Live account

When I installed GetLIve, it wasn’t available on Debian repositories, so I have downloaded it from Sourceforge: Download GetLive.

Decompress the archives :

tar zxf GetLive_0_56.tgz

Organize the differents files :

mv GetLive_0_56/*.pl /usr/local/bin/.
mv GetLive_0_56/Manual /usr/local/doc
mv GetLive_0_56.tgz /usr/local/src/.

Create a repository to store the list of downloaded email ID :

mkdir /var/lib/getlive

Create /etc/getliverc :

UserName        = jdoe
Password        = password
Downloaded      = /var/lib/getlive/downloaded.data
Processor       = grep -v 'From ' | /usr/bin/procmail -m /etc/procmailrc
Folder          = INBOX
MarkRead        = YES

The reason of the grep is explained in the Troubleshooting section below.

Add a crontab entry to execute GetLive at 7am, noon and 6pm, for example :

# crontab -e
0 7,12,18 * * * /usr/local/bin/GetLive.pl --config-file /etc/getliverc > /dev/null

Troubleshooting

Most of the problem I had were due to the “From ” (From space, not From:) line, which is the first line in an email. It raised a “Message contains invalid header” error with Cyrus and cyrdeliver. Make sure to keep messages on the server during your tests, because your downloaded emails might end up nowhere on your system.

Logs are your friends :

  • /var/log/mail.log,
  • /var/log/mail/john.log and
  • /var/log/messages.

Check your logs and pay attention to what they say.

Monday July 2, 2007

How do I use GPG ?

Max @ 22:17 | Filed under: Documentation, Security

Here are the basics command after installing gnupg :Generate his public and private key :

$ gpg --gen-key

Publish his public key :

$ gpg --keyserver wwwkeys.pgp.net –send-key [your email]

Retrieve public keys :

$ gpg --keyserver wwwkeys.pgp.net –search-keys [email]
$ gpg –keyserver wwwkeys.pgp.net –recv-keys [hexadecimal code of the key]
$ gpg –sign-key [email]

List all your keys :

$ gpg --list-keys

Update/Modify key :

$ gpg --edit-key [email]

Delete key :

$ gpg --delete-secret-keys [email]
$ gpg –delete-key [email]

Store his public key in a file :

$ gpg --export --armor [email] > publickey.asc

Verify a signature :

$ gpg --verify signature.asc

How can I protect a part of a website ?

Max @ 22:14 | Filed under: Documentation, Security

You have to create an .htaccess file in the directory you want to protect. Here is an example of the syntax :

AuthUserFile /home/*/*/protected/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

Then you just have to use the htpasswd command of the Apache Web Server to create a base of users and encrypted passwords :

# htpasswd -c .htpasswd user

How to use CVS ? What are the basic commands ?

Max @ 22:08 | Filed under: Development, Documentation

Set your CVSROOT variable environment in your .bashrc :

$ export CVSROOT=:ext:@:/path/to/cvs/repository

To import an existing project to the CVS server :

$ cd files/of/your/project
$ cvs import -m " - Initial version."
 init devel

To upload files to the CVS server :

$ cvs commit -m "Comments"

To retrieve files from the CVS server :

$ cvs checkout
 

To update your files from the CVS server :

$ cvs update

To get information of a file :

$ cvs log  

To compare your file from his copy on the CVS :

$ cvs diff

Administration

Max @ 22:04 | Filed under: Documentation

GNU/LinuxHow to add a user to an existing group ?

$ adduser -g group -d /home/group/user user

How to create a block device from a file ?

For a 100M size file:

$ dd if=/dev/zero of=/root/block1 bs=100M count=1
$ losetup /dev/loop0 /root/block1
$ mkfs -j /dev/loop0
$ mount -t ext3 /dev/loop0 /mnt/newfs

How do I do an automatic backup ?

#!/bin/bash

cd /over/the/repository/to/backup
date +%d-%m-%Y > date
tar -zcvf /repository/for/backup/`head date`.tgz /repository/to/backup
rm date

How do I do an automatic dump ?

For PostgreSQL database :

#!/bin/bash

cd /repository/for/dumpfile
date +%d-%m-%Y > date
pg_dump -D database -U username > `head date`.database.sql
rm date

The password will be asked at the prompt, which is a problem I have never solved yet.

For MySQL database :

#!/bin/bash

cd /repository/for/dumpfile
date +%d-%md%Y > date
mysqldump -D database -u username -p passwd > `head date`.database.sql
rm date

You can copy these lines in a file, and move it to /etc/cron.daily/, for example.

How do I rip a DVD ?

Max @ 22:02 | Filed under: Documentation, Multimedia

MS WindowsYou can download the method of Sonic :

  • The pdf documentation only : [ PDF ]
  • The complete Tarball Files containing all installation files of required softwares and the previous pdf file : [ TGZ , 3,56 M ]

Powered by WordPress