Wednesday, July 18, 2007

Howto: Install and configure LDAP Server (slapd) with TLS in Gentoo

1.1. Install openldap on gentoo

# emerge openldap pam_ldap nss_ldap
# chown ldap:ldap /var/lib/openldap-ldbm /var/lib/openldap-data /var/lib/openldap-slurp

1.2. /etc/openldap/slapd.conf

include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema

### "#echo rootpw `slappasswd -h {SSHA}` >> /etc/openldap/slapd.conf" to generate a password with SSHA crypt

password-hash {SSHA}

# Define SSL and TLS properties
TLSCertificateFile /etc/ssl/ldap.pem
TLSCertificateKeyFile /etc/openldap/ssl/ldap-key.pem
TLSCACertificateFile /etc/ssl/ldap.pem

database bdb # use bdb as backend database
suffix "dc=example, dc=com"
directory /var/lib/openldap-data
rootdn "cn=Manager, dc=example, dc=com"
rootpw {SSHA}ksjdlfjsdlfjslfkjsdlfjl
checkpoint 1024 5

# index
index cn,sn,uid pres,eq,approx,sub
index objectClass eq

# then setup access rules...:
access to attrs=userPassword
by self write
by anonymous auth
by dn.base="cn=Manager,dc=example, dc=com" write
by * none
access to *
by self write
by dn.base="cn=Manager,dc=example,dc=com" write
by * read

1.3. /etc/openldap/ldap.conf

BASE         dc=example, dc=com
URI ldaps://server_host[change it to server]:636/
TLS_REQCERT allow

1.4. Genertate SSL certificate

# cd /etc/ssl
# openssl req -config /etc/ssl/openssl.cnf -new -x509 -nodes -out ldap.pem -keyout /etc/openldap/ssl/ldap-key.pem -days 999999
# chown ldap:ldap /etc/openldap/ssl/ldap.pem

1.5. Modify /etc/conf.d/slapd

OPTS="-h 'ldaps:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'"

1.6. Start slapd

/etc/init.d/slapd start

If success, with this command to test connection, "-d 5" is for debug:

ldapsearch -D "cn=Manager,dc=example,dc=com" -W -d 5

1.7. Autostart slapd service at Systemstart

rc-update slapd default add

1.8. Some issues

  • command "slaptest" for verify slapd.conf
  • if id3entry.bdb not found, try "slapadd"
  • recover DB: db4.3_recover -h .
  • useful log: /var/log/messages

Monday, July 16, 2007

wmctrl

The wmctrl program is a UNIX/Linux command line tool to interact with an EWMH/NetWM compatible X Window Manager.

http://sweb.cz/tripie/utils/wmctrl/

zenity - display GTK+ dialogs

zenity is a program that will display GTK+ dialogs, and return (either in the return code, or on standard output) the users input. This allows you to present information, and ask for information from the user, from all manner of shell scripts.

For example, zenity --question will return either 0 or 1, depending on whether the user pressed OK or Cancel. zenity --entry will output on standard output what the user typed into the text entry field.

Comprehensive documentation is available in the GNOME Help Browser, under GNOME/Utilities.

EXAMPLES

Display a file selector with the title Select a file to remove. The file selected is returned on standard output.


zenity --title="Select a file to remove" --file-selection

Display a text entry dialog with the title Select Host and the text Select the host you would like to flood-ping. The entered text is returned on standard output.


zenity --title "Select Host" --entry --text "Select the host you would like to flood-ping"

Display a dialog, asking Microsoft Windows has been found! Would you like to remove it?. The return code will be 0 (true in shell) if OK is selected, and 1 (false) if Cancel is selected.


zenity --question --title "Alert" --text "Microsoft Windows has been found! Would you like to remove it?"

Show the search results in a list dialog with the title Search Results and the text Finding all header files....


find . -name '*.h' | zenity --title "Search Results" --text "Finding all header files.." --column "Files"

Display a weekly shopping list in a check list dialog with Apples and Oranges pre selected


zenity --list --checklist --column "Buy" --column "Item" TRUE Apples TRUE Oranges FALSE Pears FALSE Toothpaste

Display a progress dialog while searching for all the postscript files in your home directory find `echo $HOME` '*.ps' | zenity --progress --pulsate

http://www.linuxmanpages.com/man1/zenity.1.php

devilspie

Devil’s Pie can be configured to detect windows as they are created, and match the window to a set of rules. If the window matches the rules, it can perform a series of actions on that window.

configuration files are in .devilspie folder, like firefox.ds. Code example:
(if
(is (application_name) "Firefox")
(set_workspace 2)
)
Detail description and syntax here: http://wiki.foosel.net/linux/devilspie


Tabbed rxvt

URxvt.perl-ext-common: default,tabbed
URxvt.tabbed.tab-fg: 12
URxvt.tabbed.tab-bg: 0
URxvt.tabbed.tabbar-fg: 4

Saturday, July 14, 2007

Bash tricks

bash vi keybind:
set -o vi in .bashrc

chinese locale but english console:
LANG="en_US.UTF-8"
LC_CTYPE="zh_CN.UTF-8"
in /etc/environment

custom bash prompt with color:

export TERM=xterm-color

PS1='${debian_chroot:+($debian_chroot)}\[\033[0;35m\]\d - \u@\h:\w\[\033[0;33m\] :: '

in .bashrc

Wednesday, July 11, 2007