<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>the ultimedia project</title>
	<atom:link href="http://blogicons.de/mniewerth/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blogicons.de/mniewerth</link>
	<description>... Ultimedia GNU/Linux OS - Developers Blog</description>
	<lastBuildDate>Tue, 28 Aug 2012 23:46:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Firewall: delete iptables rule by rule-number</title>
		<link>http://blogicons.de/mniewerth/?p=560</link>
		<comments>http://blogicons.de/mniewerth/?p=560#comments</comments>
		<pubDate>Fri, 24 Aug 2012 09:57:24 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Devel]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://blogicons.de/mniewerth/?p=560</guid>
		<description><![CDATA[Since a long time im maintaining the firewall by hand. If i add rules or am i delete rules, i&#8217;ll do that over the command line. This has some advantages and also some disadvantages. Editing firewall rules by hand has the positive effect that you begin to understood how to maintain this rules. The next [...]]]></description>
			<content:encoded><![CDATA[<p>Since a long time im maintaining the firewall by hand. If i add rules or am i delete rules, i&#8217;ll do that over the command line. This has some advantages and also some disadvantages. Editing firewall rules by hand has the positive effect that you begin to understood how to maintain this rules. The next advantage is, that you not rely on other applications, which would do exatly the same thing that you should do by hand. A negative behaviour is that iptables not numbers it&#8217;s entries, thoug it&#8217;s possible to delete a rule by rule-number. </p>
<h2>Solution</h2>
<p>For exactly this reason i wrote a helper script, in this case it is the list-rules script, which takes over the list of chains and entries that iptables returns and manipulate it to be numbered. This makes it verry easy and handy to delete a rule by rule-number. </p>
<h2>The script: list-rules</h2>
<p>Let&#8217;s have a look to the <a rel="nofollow" href="#sourcecode">list-rules</a> script (sourcode is attached below). The chain parameter is always accepted by the script. Assume that you want to show just the INPUT chain, you should give this parameter to list-rules. </p>
<pre>
list-rules INPUT
</pre>
<p><strong>gives you a list like that</strong>:</p>
<pre>
Chain INPUT (policy ACCEPT)
Num target     prot opt source               destination         
1 fail2ban-ssh  tcp  --  0.0.0.0/0            0.0.0.0/0           multiport dports 22 
...
10 DROP       udp  --  229.229.1.2          0.0.0.0/0  
11 DROP       tcp  --  229.229.1.2          0.0.0.0/0  
</pre>
<p><strong>to delete an entry you could enter the whole iptables rule</strong>: </p>
<pre>
iptables --delete INPUT -d 229.229.1.2/32 -p udp -j DROP
iptables --delete INPUT -d 229.229.1.2/32 -p tcp -j DROP
</pre>
<p><strong>or with the rule-number</strong>:</p>
<pre>
iptables --delete INPUT 10
iptables --delete INPUT 10
</pre>
<p><strong>If you would list the rules again, you&#8217;ll see the rules are no more listed as they where deleted:</strong></p>
<pre>
Chain INPUT (policy ACCEPT)
Num target     prot opt source               destination         
1 fail2ban-ssh  tcp  --  0.0.0.0/0            0.0.0.0/0           multiport dports 22 
</pre>
<h2>Extended chains</h2>
<p>There are more chains supported then the INPUT/OUTPUT chains. Have another look to the script and find the  <strong>$LISTCHAINS</strong> variable. You are able to list the extended chains there and use them as parameter to the list-rules script. Always keep in mind, that the default parameter is ALL, which is an keyword to show a list of all chains and rules.</p>
<p><a name="sourcecode"></a><br />
<h2>Sourcode: list-rules</h2>
<pre>
#!/usr/bin/env sh
# ######################################################
# Category: Firewall
# Related: iptables
# Script-Name:list-rules 
# ######################################################
# This script is intended to users which are working on 
# the console and configuring iptables chains and rules. 
# It lists all chains and prefix the rule number, which 
# makes it more suitable for deletions.
# ######################################################
# Author: Markus Niewerth <mniewerth@ultimediaos.com>
# Date: Thu, 23 Aug 2012 22:16:42 +0200 
# Copyright: 2011-2012 by Markus Niewerth
# License: GPLv3
# ######################################################
# Default chain is ALL which is a macro for all chains; 
# use the $LISTCHAINS param to configure chains.
# FIXME: export $LISTCHAINS to 
#   /etc/default/list-rules-default.conf
# ######################################################

chain=${1:-ALL}
LISTCHAINS="fail2ban-ssh fail2ban-postfix fail2ban-courierauth \
		fail2ban-ssh-ddos fail2ban-couriersmtp"

if [ $chain = ALL ]; then
	# basic chains
	INPUT=`$0 INPUT`
	OUTPUT=`$0 OUTPUT`
	FORWARD=`$0 FORWARD`
	# extended chains $LISTCHAINS
	for LSC in $LISTCHAINS; do
		_LISTCHAINS="$_LISTCHAINS `$0 $LSC` \n"
	done;

	echo -e "$INPUT \n$OUTPUT \n$FORWARD \n$_LISTCHAINS"
	exit 0;
fi;

OIFS=$IFS
IFS=$'\n'

# first lines are trash
i=-2

for line in `/sbin/iptables --list $chain --numeric`; do 
	((i++))
    if [ $i = 0 ]; then
    	echo -n "Num "
    fi
    
    if [ $i -gt 0 ]; then
    	echo -n "$i "
    fi
    
    echo "$line"
done

# reset to old IFS
IFS=$OIFS

# exit script with the last exit value (just useful for 
#  single chains)
exit $?
</pre>
<h2>Alternatives</h2>
<p>Another alternative is to use the iptables-save output, to become the corresponding rules copied or deleted. You should try this out by typing:</p>
<pre>
iptables-save
</pre>
<h2>Download Script</h2>
<p><strong>Size</strong>: 985 bytes<br />
<strong>Info</strong>: bzip2 compressed data, block size = 900k<br />
<strong>md5sum</strong>: 293e45e091f4fc54a5454fd2fbc39a7d<br />
<strong>File</strong>: <a rel="nofollow" href='http://www.blogicons.de/mniewerth/downloads/list-rules.tar.bz2'>list-rules.tar.bz2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=560</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using make to backup a webserver</title>
		<link>http://blogicons.de/mniewerth/?p=513</link>
		<comments>http://blogicons.de/mniewerth/?p=513#comments</comments>
		<pubDate>Sat, 18 Aug 2012 11:43:59 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Devel]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://blogicons.de/mniewerth/?p=513</guid>
		<description><![CDATA[Sometimes im learning new stuff or i try other ways of doing the same job that i&#8217;ve done before. Today i thought i could use make for creating some backup routines instead off an old way where i&#8217;m actually just used a bunch of shell scripts. Cause make will give me more flexibility to define [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes im learning new stuff or i try other ways of doing the same job that i&#8217;ve done before. Today i thought i could use make for creating some backup routines instead off an old way where i&#8217;m actually just used a bunch of shell scripts. Cause make will give me more flexibility to define backup targets and also it is easy to work with it.</p>
<p>Anyways let&#8217;s have a look what the Makefile  is able  to do:</p>
<pre>
- clean (cleans everything but archive)
- create-structure (create archive structure)
- backup-all (Performs every of target below)
  - backup-svn
  - backup-ldap
  - backup-mysql
  - backup-www (Performs everything of targets below)
    - www-structure 
    - www-config 
    - www-data 
    - www-archive
  - backup-ldap
- archive (Create the main archive)
- clean-svn (Clean backup files)
- clean-ldap (Clean backup files)
- clean-mysql (Clean backup files)
- clean-www (Clean backup files)
- clean-etc (Clean backup files)
- clean-archive-ldap (Clean archive files)
- clean-archive-mysql (Clean archive files)
- clean-archive-www (Clean archive files)
- clean-archive-etc (Clean archive files)
- disk-usage (Shows disk usage)
- list-archive (Lists and totals archive)
- get-archive (Client sided download target)
</pre>
<p>While each target is server sided, there is one target for the client side. The target is <em><strong>get-archive</strong></em> and will download the latest created backup archive. While each of the backup targets ldap,mysql,svn,etc are mostly identical on GNU Linux systems, the www backup task is not. So let&#8217;s have an eye on the Makefile and the configuration part:</p>
<pre>
export PATH:=$(CURDIR)/bin:$(PATH)

ifndef TARGETS
TARGETS=clean create-structure backup-all archive
endif

ifndef DATETIME
# an identifier - i assumed to create backups once a day
DATETIME=$(shell date +%Y%m%d)
endif

# just store it, mabye we need the macro later...
OLDCURDIR=$(CURDIR)

# configuration parameters
BACKUPDIR=/backups
SVNADMIN=/usr/bin/svnadmin
SVNREPODIR=/srv/vcs/svn
BACKUPNAME=example.com
REMOTE_SERVER=root@example.com
REMOTE_BACKUP_DIR=/var/backups/example.com
DOMAINS=example.com www2.example.com
WWWDATADOMAINS=example.com
VHOSTSDIR=/var/www
VERBOSE=v
</pre>
<h2>Macro Description</h2>
<p>The macro TARGETS and DATETIME are configurable before the make command. </p>
<p><strong>TARGETS</strong>: <code>clean create-structure backup-all archive</code><br />
<strong>DATETIME</strong>: <code>$(shell date +%Y%m%d)</code></p>
<p>For instance:<br />
<code>$ TARGETS="clean backup-all" DATETIME=20121010 make</code></p>
<h3>Configuration Macros</h3>
<p><strong>BACKUPDIR</strong>: /backups<br />
This describes the working directory on the remote server where backups are stored.</p>
<p><strong>SVNADMIN</strong>: /usr/bin/svnadmin<br />
This defines the svnadmin command.</p>
<p><strong>SVNREPODIR</strong>: /srv/vcs/svn<br />
Basic repository path. This is the path where svn stores all repositories.</p>
<p><strong>BACKUPNAME</strong>: example.com<br />
A static identifier name to be used as the backup archive name, prefixed by <strong>DATETIME</strong>.</p>
<p><strong>REMOTE_SERVER</strong>: root@example.com<br />
The user/server on the server side should be root, while the user that downloads (scp) the archive could also be someone else.</p>
<p><strong>REMOTE_BACKUP_DIR</strong>: /var/backups/example.com<br />
If a remote backup is stored on the local client machine, use this folder for downloads (scp).</p>
<p><strong>DOMAINS</strong>: example.com www2.example.com<br />
This domains are needed to store configurations for.</p>
<p><strong>WWWDATADOMAINS</strong>: example.com<br />
While this domains are used to backup just the www data. This could differ and often the webcontents are already backuped on local machines.</p>
<p><strong>VHOSTSDIR</strong>: /var/www<br />
This is the path where all vhosts are stored. The DOMAINS macro describes the folders inside this path.</p>
<p><strong>VERBOSE</strong>: v<br />
Should we verbose output everything. This should be enabled.</p>
<h2>The Makefile Targets</h2>
<p>Now let&#8217;s have an eye on the targets i have defined for backup purposes. The targets backup-all is having subtargets which also could called manually. In general it is always possible to call targets manual and recreate backups manually on the same day (see DATETIME macro). </p>
<pre>
.PHONY: clean

all: $(TARGETS) 

create-structure:
	mkdir -p$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/{svn,ldap,mysql,www,etc}

backup-all: backup-svn backup-ldap backup-mysql backup-www backup-etc 
	
backup-svn: 
	if [ ! -d $(SVNREPODIR) ]; then \
		exit 10; \
	fi; \
    for repo in $(shell ls -1 $(SVNREPODIR)); do \
    	if [ ! -f $(SVNREPODIR)/$$repo/format ]; then \
            continue; \
        fi; \
        $(SVNADMIN) dump $(SVNREPODIR)/$$repo | gzip -c -9 > $(BACKUPDIR)/$(DATETIME)/svn/$$repo.gz; \
	done;
	
backup-ldap: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/ldap/var/lib/ldap ]; then \
	 	rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap/* ; \
	fi; \
	mkdir -p$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap/{var/lib,usr/share/phpldapadmin}; \
	/etc/init.d/ldap stop;  \
	sleep 2; \
	cp -pR$(VERBOSE) /var/lib/ldap  $(BACKUPDIR)/$(DATETIME)/ldap/var/lib/ ; \
	/etc/init.d/ldap start; \
	cp -pR$(VERBOSE) /usr/share/phpldapadmin  $(BACKUPDIR)/$(DATETIME)/ldap/usr/share/ ; \
	tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap.tar.bz2  $(BACKUPDIR)/$(DATETIME)/ldap; \
	[ -d $(BACKUPDIR)/$(DATETIME)/ldap ] &#038;&#038; rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap;

backup-mysql:
	if [ -d $(BACKUPDIR)/$(DATETIME)/mysql/var/lib/mysql ]; then \
	 	rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql/* ; \
	fi; \
	mkdir -p$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql/{var/lib,usr/share}; \
	/etc/init.d/mysql stop;  \
	cp -pR$(VERBOSE) /var/lib/mysql  $(BACKUPDIR)/$(DATETIME)/mysql/var/lib/ ; \
	/etc/init.d/mysql start;  \
	cp -pR$(VERBOSE) /usr/share/mysql  $(BACKUPDIR)/$(DATETIME)/mysql/usr/share/ ;
	tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql.tar.bz2  $(BACKUPDIR)/$(DATETIME)/mysql; \
	[ -d $(BACKUPDIR)/$(DATETIME)/mysql ] &#038;&#038; rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql;
	
backup-www: www-structure www-config www-data www-archive

www-structure:
	for d in $(DOMAINS); do \
		mkdir -p$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www/$$d; \
    done;

www-config:
	for d in $(DOMAINS); do \
		cp -pR$(VERBOSE) $(VHOSTSDIR)/$$d/{conf,pd} $(BACKUPDIR)/$(DATETIME)/www/$$d/ ; \
	done; 

www-data:
	for d in $(WWWDATADOMAINS); do \
		tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www/$$d/httpdocs.tar.bz2 $(VHOSTSDIR)/$$d/httpdocs; \
		if [ -d $(VHOSTSDIR)/$$d/usr ]; then \
			tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www/$$d/usr.tar.bz2 $(VHOSTSDIR)/$$d/usr; \
		fi; \
	done; 	
	
www-archive:
	tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www.tar.bz2  $(BACKUPDIR)/$(DATETIME)/www; \
	[ -d $(BACKUPDIR)/$(DATETIME)/www ] &#038;&#038; rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www;

backup-etc:
	cp -pR$(VERBOSE) /etc/*  $(BACKUPDIR)/$(DATETIME)/etc/ ; \
	tar cjf$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/etc.tar.bz2  $(BACKUPDIR)/$(DATETIME)/etc; \
	[ -d $(BACKUPDIR)/$(DATETIME)/etc ] &#038;&#038; rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/etc;

archive:
	if [ -L $(BACKUPDIR)/latest-backup ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/latest-backup; \
	fi; \
	if [ -f $(BACKUPDIR)/$(DATETIME)-$(BACKUPNAME).tar.bz2 ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)-$(BACKUPNAME).tar.bz2; \
	fi; \
	if [ -d $(BACKUPDIR)/$(DATETIME) ]; then \
		tar cjf$(VERBOSE)  $(BACKUPDIR)/$(DATETIME)-$(BACKUPNAME).tar.bz2 $(BACKUPDIR)/$(DATETIME); \
		ln -s$(VERBOSE) $(BACKUPDIR)/$(DATETIME)-$(BACKUPNAME).tar.bz2 $(BACKUPDIR)/latest-backup; \
	fi;

clean-svn: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/svn ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/svn/*.gz; \ 
	fi;

clean-ldap: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/ldap ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap/*.*; \
	fi;
	
clean-mysql: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/mysql ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql/*.*; \
	fi;
	
clean-www: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/www ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www/*.*; \
	fi;	
	
clean-etc: 
	if [ -d $(BACKUPDIR)/$(DATETIME)/etc ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/etc/*.*; \
	fi;

clean-archive-ldap: 
	if [ -f $(BACKUPDIR)/$(DATETIME)/ldap.tar.bz2 ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/ldap.tar.bz2; \
	fi;
	
clean-archive-mysql: 
	if [ -f $(BACKUPDIR)/$(DATETIME)/mysql.tar.bz2 ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/mysql.tar.bz2; \
	fi;
	
clean-archive-www: 
	if [ -f $(BACKUPDIR)/$(DATETIME)/www.tar.bz2 ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/www.tar.bz2; \
	fi;
	
clean-archive-etc: 
	if [ -f $(BACKUPDIR)/$(DATETIME)/etc.tar.bz2 ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME)/etc.tar.bz2; \
	fi;
		
clean-latest:
	if [ -f `readlink $(BACKUPDIR)/latest-backup` ]; then \
		rm -r$(VERBOSE) `readlink $(BACKUPDIR)/latest-backup`; \
	fi; \
	if [ -L $(BACKUPDIR)/latest-backup ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/latest-backup; \
	fi;
	
clean:
	if [ -d $(BACKUPDIR)/$(DATETIME) ]; then \
		rm -r$(VERBOSE) $(BACKUPDIR)/$(DATETIME); \
	fi;

disk-usage:
	du -sh $(BACKUPDIR)/$(DATETIME)/{*.bz2,svn/,../*-$(BACKUPNAME).tar.bz2}
	
list-archive:
	tar tjfv --totals `readlink $(BACKUPDIR)/latest-backup` --totals
	
get-archive:
	if [ ! -d $(REMOTE_BACKUP_DIR) ]; then \
		mkdir $(REMOTE_BACKUP_DIR); \
	fi; \
	scp $(REMOTE_SERVER):$(BACKUPDIR)/latest-backup $(REMOTE_BACKUP_DIR)/$(DATETIME)-$(BACKUPNAME).tar.gz;
</pre>
<p>The above code needs some explanations. When calling make the macro <strong>TARGET</strong> will be used to define the tasks. If starting a backup keep in mind that the backup directory is cleaned completely. You could modify this for instance with rsync. If you would use rsync for synchronizing instead of doublicating the files, it would be possible to remove the clean target from the <strong>TARGET</strong> macro.</p>
<p>The <strong><em>create-structure</em></strong> target is intended to create or recreate the folders where files are backuped to and later archived. The backup targets mostly working in the same way, they stop a running service (apache, mysql or ldap) and copy over library and share pathes. In the case of the ldap task it backups the phpldapadmin too, if you&#8217;re not using the ldapadmin you have to remove the line.</p>
<p>The  apache server backup task works more complicated and is executed in serveral steps. First of all it creates the backup structure for each vhost. The <strong><em>www-config</em></strong> target is just in case you have Plesk runnning or a configuration folder for each vhost. In the next step the htdocs data is backuped (see macro description <strong>WWWDATADOMAINS</strong>), the routines may differ if you are using other configurations, rewrite this from scratch if you want.</p>
<p>Each backup task is using tar and bzip2 in the end to compress the backup data. The files are called <em>ldap.tar.bz2</em>, <em>mysql.tar.bz2</em>, <em>svn.tar.bz2</em>, <em>www.tar.bz2</em>, <em>etc.tar.bz2</em> and are later again archived to become a single file.</p>
<h2>Download Makefile</h2>
<p>The whole file could be downloaded <a rel="nofollow" href="/mniewerth/downloads/make-backup.tar.bz2" title="make-backup.tar.bz2">here</a>. Extract the Makefile to a folder of your choice. It is not necesarry to use the current path (/usr/share). To start the whole backup perform just <strong><em>make</em></strong>. </p>
<p>Do the same on the client machine. Extract the Makefile and download the archive with: </p>
<p><code>$ make get-archive</code></p>
<p>If you have any suggestions or quetsions feel free to ask. </p>
<h2>Additional Documents</h2>
<p>* <strong>GNU Make</strong>: <a rel="nofollow" href="http://doc.ultimedia-linux.org/reader/index.php?doc=/gnu/make.html" title="make.html">gnu/make.html</a><br />
* <strong>GNU Automake</strong>: <a rel="nofollow" href="http://doc.ultimedia-linux.org/reader/index.php?doc=/gnu/automake.html" title="automake.html">gnu/automake.html</a></p>
<p><strong>&#8211;</strong> <strong>Last updated</strong>: Sat, 22 Aug 2012 16:58:46 +0200 (<em>mniewerth</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=513</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto: setting up a PGP keyserver with OpenLDAP</title>
		<link>http://blogicons.de/mniewerth/?p=323</link>
		<comments>http://blogicons.de/mniewerth/?p=323#comments</comments>
		<pubDate>Tue, 03 Jul 2012 00:42:29 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Devel]]></category>
		<category><![CDATA[ldap]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=323</guid>
		<description><![CDATA[I&#8217;m glad to post this howto about setting up a PGP keyserver with OpenLDAP. The inital thread that finally leads to here starts at: http://marc.theaimsgroup.com/?l=gnupg-users&#038;m=114028686432264&#038;w=2 Many thanks to Peter Palfrader for providing the LDAP schema and especially to David Shaw for providing invaluable help and adding LDAP basic authentication to GnuPG. Used software: OpenLDAP 2.2.27, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m glad to post this howto about setting up a PGP keyserver with OpenLDAP. The inital thread that finally leads to here starts at: <a rel="nofollow" href="http://marc.theaimsgroup.com/?l=gnupg-users&#038;m=114028686432264&#038;w=2" target="_blank">http://marc.theaimsgroup.com/?l=gnupg-users&#038;m=114028686432264&#038;w=2</a></p>
<p>Many thanks to Peter Palfrader for providing the LDAP schema and especially to David Shaw for providing invaluable help and adding LDAP basic authentication to GnuPG.</p>
<p>Used software: OpenLDAP 2.2.27, run under SuSE 10.0 GnuPG 1.4.3rc1 (subversion revision 4020).</p>
<p>If you don&#8217;t want to wait until 1.4.3 is officially released, grab yourself a copy from svn:<br />
<code><br />
> svn co svn://cvs.gnupg.org/gnupg/trunk<br />
</code></p>
<p>Attached is tarball with the files for OpenLDAP configuration, to which will be refered to below. I hope this doesn&#8217;t violate  the rules of this list but the attachment is very small anyways.</p>
<p>You should have a basic understanding about LDAP first. If not, I&#8217;d recommend to read the OpenLDAP Admin Guide on <a rel="nofollow" href="http://www.openldap.org" title="openLDAP" target="_blank">http://www.openldap.org</a>, which provides excellent documentation.</p>
<p>Also, as an LDAP client and excellent server management tool, I&#8217;d recommend phpLDAPadmin: <a rel="nofollow" href="http://phpldapadmin.sourceforge.net" title="PHP  LDAP  Admin" target="_blank">http://phpldapadmin.sourceforge.net</a></p>
<p>The LDAP tree created in this example setup looks like:</p>
<pre>
  dc=EXAMPLE,dc=COM
  |
  +----cn=Manager
  +----cn=PGPServerInfo
  +----ou=PGP Keys
  |    +---pgpCertID=...
  |    +---pgpCertID=...
  +----ou=PGP Users
       +---uid=...
       +---uid=...
</pre>
<p>where dc=EXAMPLE,dc=COM is obviously the base DN.</p>
<p>First, install pgp-keyserver.schema from the tarball into to your schema directory. There are two more files which are not used here, but have been part of the schema I got from Peter, so I kept them for completeness.</p>
<p>Next, install slapd.conf and edit to suit your needs. That is, select either anonymous or user authentication.</p>
<p>In the provided file, anonymous writes are enabled. However, access is restricted to writes from localhost only. You may lift this restriction by modifying the peername.ip statement. See slapd.access(5) for details and examples.</p>
<p>Think twice before opening up anonymous writes, as _any_ user who can connect to your LDAP server can not only upload but also delete keys.</p>
<p>For user authentication, comment out update_anon and the access rule for anonymous writes. Users are stored as DN &#8220;uid=<username>,ou=PGP Users,dc=EXAMPLE,dc=COM&#8221;.</p>
<p>You need to create users to bind to LDAP. One sample user is provided in ldif/pgpusers.ldif. Just copy the entry and modify it to create more and read the file to learn the used password.</p>
<p>Also, the password for the OpenLDAP manager is stored as a hash. It is &#8216;gpg&#8217;. Run slappasswd(8) to create a stronger password and replace the hash in slapd.conf.</p>
<p>Try to start your OpenLDAP server now. Under SuSE, I run &#8220;/etc/init.d/ldap start&#8221;.</p>
<p>Next, populate the directory with the basic layout by importing the example.ldif file (enter on a single line):</p>
<pre>
> cat example.ldif | ldapadd -x -W -h localhost
      -D "cn=Manager,dc=EXAMPLE,dc=COM"
</pre>
<p>When prompted for a password, enter the one you&#8217;ve created above or &#8216;gpg&#8217; if you did not.</p>
<p>If you selected anonymous writes, you&#8217;re done configuring your OpenLDAP PGP keyserver.</p>
<p>If you selected user authentication, you need to add users now:</p>
<pre>
> cat pgpusers.ldif | ldapadd -x -W -h localhost
      -D "cn=Manager,dc=EXAMPLE,dc=COM"
</pre>
<p>Finally, you can use GnuPG to add keys (always on a single line):</p>
<p>For anonymous write:<br />
<code><br />
> gpg --keyserver ldap://localhost --send-key 12345678<br />
</code></p>
<p>For user authentication (insecure on command-line, see below):</p>
<pre>
> gpg --keyserver ldap://localhost --keyserver-options
   "binddn=\"uid=user1,ou=PGPUsers,dc=EXAMPLE,dc=COM\""
   --keyserver-options bindpw=user1 --send-keys 12345678
</pre>
<p>To receive keys, simply do:<br />
<code><br />
> gpg --keyserver ldap://localhost --recv-keys 12345678<br />
</code></p>
<p><strong>Further notes:</strong></p>
<pre>
* GnuPG looks for PGPServerInfo under the base DN.
  If you decide to put it somewhere else, use keyserver-option
  basedn to specify the new location, e.g.:
  keyserver-options "basedn=\"cn=PGPServerInfo,ou=PGP Info,dc=MYDOM\""

* Beware of shell quoting, like above which is the correct format
  if you  have spaces in your DN and specify the keyserver option
  on the command line.

* GnuPG can use TLS/SSL. For SSL, use ldaps:// and for tls the
  keyserver-options tls. It takes 'no','try','warn' or 'require'
  as an argument, e.g.:
  keyserver-options tls=require

* Put other keyserver options into ~/.gnupg/gpg.conf, e.g.:

  keyserver ldap://localhost
  keyserver-options binddn="uid=test1,ou=PGP Keys,dc=EXAMPLE,dc=COM"
  keyserver-options bindpw=verysecret
  keyserver-options tls=try
  keyserver-options verbose

  Then the following will just work:
  > gpg --send-keys 12345678
  or
  > gpg --recv-keys 12345678

* As it is INSECURE to specify your bind password on the command
  line, you should put it to your ~/.gnupg/gpg.conf and protect
  this file with 0600 permissions.
</pre>
<p>Well, that&#8217;s it for now. I hope this howto is helpful and somewhat complete! Good luck setting up your PGP keyserver with OpenLDAP.</p>
<p>I&#8217;d be glad if someone could verify the steps so that there are no glitches. Comments, notes, questions or else are appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=323</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade to Ultimedia GNU/Linux from Debian 6.x</title>
		<link>http://blogicons.de/mniewerth/?p=276</link>
		<comments>http://blogicons.de/mniewerth/?p=276#comments</comments>
		<pubDate>Fri, 29 Jun 2012 16:16:58 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Debian GNU/Linux]]></category>
		<category><![CDATA[Ultimedia GNU/Linux]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=276</guid>
		<description><![CDATA[Source: http://ultimediaos.com/install.html This is the verry shortguide how to upgrade to Ultimedia GNU/Linux with X11 and Gnome-2 with a Debian netinstall CD or image. Ultimedia GNU/Linux OS is currently only x86 compatible, so there will be no 64Bit build available (if your CPU supports 64 Bit but you just have max 4 GB of RAM, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Source:</strong> <a rel="nofollow" href="http://ultimediaos.com/install.html" title="Install Ultimedia Linux">http://ultimediaos.com/install.html</a><br />
This is the verry shortguide how to upgrade to Ultimedia GNU/Linux with X11 and Gnome-2 with a Debian netinstall CD or image. Ultimedia GNU/Linux OS is currently only x86 compatible, so there will be no 64Bit build available (if your CPU supports 64 Bit but you just have max 4 GB of RAM, this should be no issue).</p>
<h2>Related files</h2>
<p>List of <a href="http://ultimedia-linux.org/related/files/" target="new">related files</a> and downloads</p>
<ul>
<li> <a href="http://ultimedia-linux.org/related/files/debian_version" target="new">/etc/debian_version</a></li>
<li> <a href="http://ultimedia-linux.org/related/files/lsb-release" target="new">/etc/lsb-release</a></li>
<li><a href="http://ultimedia-linux.org/related/files/sources.list.prod" target="new">/etc/apt/sources.list     Productive</a></li>
<li><a href="http://ultimedia-linux.org/related/files/sources.list.devel" target="new">/etc/apt/sources.list     Devel/Mixed</a></li>
<li><a rel="nofollow" href="http://cdimage.debian.org/debian-cd/6.0.5/i386/iso-cd/debian-6.0.5-i386-netinst.iso" target="new">/debian-cd/6.0.5/i386/iso-cd/debian-6.0.5-i386-netinst.iso</a></li>
</ul>
<h2>Debian Installation</h2>
<p>Download the <a rel="nofollow" href="http://cdimage.debian.org/debian-cd/6.0.5/i386/iso-cd/debian-6.0.5-i386-netinst.iso" title="Debian Squeeze i386 netinstall ISO">Debian Squeeze 6.x netinstall ISO</a>.<br />
If the version not exists, have a look at the <a rel="nofollow" href="http://www.debian.org/distrib/netinst" title="Deb Netinstall">netinstall</a> website and choose the <strong>i386</strong> from the &#8220;Small CDs&#8221; Menu.</p>
<p>Now boot with the ISO, click on the Install or Graphical Install menuoption and do the necesarry steps to prepare your partitions (recommended fs: ext3) and install the Debian Squeeze 6.x netinstall ISO base system. If you can choose from the list of available package compilations, just let the option base-system checked. After installing and rebooting to your new installation, you should have internet access and root access on the console, this is everything you need to perform the next steps.</p>
<p>Login as root (or &#8220;user&#8221;, but you will have sudo configured, which makes it more complicated).</p>
<h2>1.0 Dist Upgrade</h2>
<p>Now you&#8217;ll have to configure some basic conf files and to import the Ultimedia keyring which is needed for the signature checks that apt will perform. </p>
<pre>
  /etc/debian_version       (Update)
  /etc/lsb-release          (New file)
  /etc/apt/sources.list     (Move and recreate)
</pre>
<p>The following steps will upgrade the distribution and release on Debian systems:</p>
<h3>1.1 /etc/debian_version</h3>
<pre>
  $ echo "blade/unstable" > /etc/debian_version
</pre>
<h3>1.2 /etc/lsb-release</h3>
<p><code><br />
  $ echo "DISTRIB_ID=Ultimedia" > /etc/lsb-release<br />
  $ echo "DISTRIB_RELEASE=1.0.1" >> /etc/lsb-release<br />
  $ echo "DISTRIB_CODENAME=blade" >> /etc/lsb-release<br />
  $ echo "DISTRIB_DESCRIPTION=\"Ultimedia OS 1.0.1 (Blade)\"" >> /etc/lsb-release<br />
</code></p>
<h3>1.3 /etc/apt/sources.list</h3>
<p><code><br />
  $ mv /etc/apt/sources.list /etc/apt/~sources.list<br />
  $ echo "deb http://ftp.ultimediaos.com/ultimedia blade main contrib non-free" > /etc/apt/sources.list<br />
  $ echo "deb-src http://ftp.ultimediaos.com/ultimedia blade main contrib non-free" >> /etc/apt/sources.list<br />
</code>      </p>
<h3>1.4 Keyring import and `apt dist-upgrade`</h3>
<p>Download the keyring from our HTTP keyserver: <a rel="nofollow" href="http://ks.ultimedia-linux.org/keyring/ultimedia-keyring.gpg" title="ultimedia-keyring">server</a>.</p>
<p>The simple way of doing this is reading the key into the <strong>STDIN</strong> stream and pipe it to <strong>apt-key</strong> that will read from <strong>STDIN</strong> or you could wget (<em>download</em>) it and add it manual.</p>
<pre>
  $ wget http://ks.ultimedia-linux.org/keyring/ultimedia-keyring.gpg \
    -O- | apt-key add -
</pre>
<p>Or in two steps:</p>
<pre>
  $ wget http://ks.ultimedia-linux.org/keyring/ultimedia-keyring.gpg
</pre>
<p>Import keyring to apt.</p>
<pre>
  $ apt-key add ultimedia-keyring.gpg
</pre>
<p>Update available packages, delete the old packages and perform the dist-upgrade.</p>
<pre>
  $ apt-get clean
  $ apt-get update
  $ apt-get dist-upgrade
</pre>
<p>During the upgrade it could be that the base-files package is replaced, this means that the before manual created files need to be upgraded. If debconf asks you how you&#8217;ll decide on the old configuration files, it is necesarry to press &#8220;Y&#8221;. It will upgrade the /etc/lsb-release and /etc/debian_version configuration again. </p>
<h2>Install X11/Gnome2</h2>
<p>The following steps will install X11 with gnome2 and GDM as display manager. You could also install Compiz Fusion but note that there is currently only the NVidia kernel driver builded, which will support only NVida graphic cards. The Xorg drivers mostly support all grafic cards but are not everytime able to use all features and modes (special with modern graphic cards), which makes it impossible to enable the compiz features. But feel free to experiment.</p>
<pre>
  $ apt-get install gnome
  $ reboot
</pre>
<p>Now your new bootloader will be grub2 and your new system is Ultimedia GNU/Linux OS. </p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=276</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set up SSH keys</title>
		<link>http://blogicons.de/mniewerth/?p=241</link>
		<comments>http://blogicons.de/mniewerth/?p=241#comments</comments>
		<pubDate>Wed, 27 Jun 2012 01:52:50 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Devel]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=241</guid>
		<description><![CDATA[HOWTO: set up ssh keys Paul Keck, 2001 Getting Started First, install OpenSSH on two UNIX machines, hurly and burly. This works best using DSA keys and SSH2 by default as far as I can tell. All the other HOWTOs I&#8217;ve seen seem to deal with RSA keys and SSH1, and the instructions not surprisingly [...]]]></description>
			<content:encoded><![CDATA[<p>HOWTO: set up ssh keys<br />
Paul Keck, 2001</p>
<h3>Getting Started</h3>
<p>First, install OpenSSH on two UNIX machines, hurly and burly. This works best using DSA keys and SSH2 by default as far as I can tell. All the other HOWTOs I&#8217;ve seen seem to deal with RSA keys and SSH1, and the instructions not surprisingly fail to work with SSH2.<br />
On each machine type ssh somemachine.example.com and make a connection with your regular password. This will create a .ssh dir in your home directory with the proper perms.<br />
On your primary machine where you want your secret keys to live (let&#8217;s say hurly), type</p>
<p><code><br />
ssh-keygen -t dsa<br />
</code></p>
<p>This will prompt you for a secret passphrase. If this is your primary identity key, make sure to use a good passphrase. If this works right you will get two files called id_dsa and id_dsa.pub in your .ssh dir. Note: it is possible to just press the enter key when prompted for a passphrase, which will make a key with no passphrase. This is a Bad Idea ™ for an identity key, so don&#8217;t do it! See below for uses of keys without passphrases.</p>
<p><code>scp ~/.ssh/id_dsa.pub burly:.ssh/authorized_keys2</code></p>
<p>Copy the id_dsa.pub file to the other host&#8217;s .ssh dir with the name authorized_keys2.</p>
<p>Now burly is ready to accept your ssh key. How to tell it which keys to use? The ssh-add command will do it. For a test, type</p>
<p><code>ssh-agent sh -c 'ssh-add &lt; /dev/null &amp;&amp; bash'</code></p>
<p>This will start the ssh-agent, add your default identity(prompting you for your passphrase), and spawn a bash shell. From this new shell you should be able to:</p>
<p><code>ssh burly</code></p>
<p>This should let you in without typing a password or passphrase. Hooray! You can ssh and scp all you want from this bash shell and not have to type any password or passphrase.</p>
<h2>Using X Windows</h2>
<p>Now this is all well and good, but who wants to run their whole life from a single bash instance? If you use an X window system, you can type your passphrase once when you fire up X and all subprocesses will have your keys stored.</p>
<p>In the ~/.xinitrc file, modify your line which spawns windowmaker to read:</p>
<p><code>exec ssh-agent sh -c 'ssh-add &lt; /dev/null &amp;&amp; exec /usr/local/bin/wmaker </code></p>
<p>This will prompt you for your passphrase when you start up X, and then not again. All shells you spawn from X will have your keys stored.</p>
<p>This brings up a security issue- if someone comes upon your X session, they can spawn ssh sessions to burly and other hosts where you have put your id_dsa.pub information into the authorized_keys2 file. A locking screensaver like xlock is vital.</p>
<h3>Different usernames</h3>
<p>By default ssh assumes the same username on the remote machine. If you have a different username on the other machine, follow the normal ssh procedure:</p>
<p><code>[pkeck@hurly /]$ ssh -l paulkeck burly</code></p>
<h2>More keys!</h2>
<p>You are not limited to one public key in your authorized_keys2 file. Append as many as you like! If you, say, generated a unique private key on every machine you log into, and then appended the id_dsa.pub files to each of the other machines&#8217; authorized_keys2 file, you&#8217;d have the equivalent of a .rhosts file with two added benefits:</p>
<p>Someone would need to know your passphrase to use it, so a cracker gaining access to an account on one machine will not jeopardize the other accounts. (If you foolishly use the same passphrase or, heaven forbid, id_dsa file on all the hosts, it would make it easier to exploit, so don&#8217;t do that.) Traffic is encrypted.</p>
<p>This command will do it without requiring an scp and vi session:</p>
<p><code>cat foo.pub |ssh burly 'sh -c "cat - &gt;&gt;~/.ssh/authorized_keys2"'</code></p>
<h3>Single-purpose keys</h3>
<p>So now you&#8217;re sshing and scping your brains out. Sooner or later you&#8217;ll come across one or both of these situations:</p>
<p>You want to automate some ssh/scp process to be done after hours, but can&#8217;t because no one will be around to type the passphrase. You want to allow an account to do some sort of ssh/scp operation on another machine, but are hesitant to append a key to your authorized_keys2 file because that essentially &#8220;opens the barn door&#8221; to anything that other account wants to do, not just the one operation you want to let it do. (This is the situation if you use a .shosts file.)</p>
<p>Single-purpose keys to the rescue!</p>
<p>Make yourself another key:</p>
<p><code>ssh-keygen -t dsa -f ~/.ssh/whoisit</code></p>
<p>ust press return when it asks you to assign it a passphrase- this will make a key with no passphrase required. If this works right you will get two files called whoisit and whoisit.pub in your .ssh dir.</p>
<p><code>cp ~/.ssh/whoisit.pub tempfile</code></p>
<p>We want to work on it a little. tempfile should consist of one really long line that looks kind of like this:</p>
<p><code>ssh-dss AAAAB3NzaC1k[...]9qE9BTfw== pkeck@hurly.example.com</code></p>
<p>Edit tempfile and prepend some things to that line so that it looks like this:</p>
<p><code>command="echo I\'m `/usr/ucb/whoami` on `/usr/bin/hostname`",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss AAAAB3NzaC1k[...]9qE9BTfw== whoisitnow</code></p>
<p>That will do what we want on Solaris; to try this example on Linux use this:</p>
<p><code>command="echo I\'m `/usr/bin/whoami` on `/bin/hostname`",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss AAAAB3NzaC1k[...]9qE9BTfw== whoisitnow</code></p>
<p>The stuff to prepend is your command that will be run when this key is activated, and some options to keep it from being abused (hopefully). The last thing on the line is just a comment, but you probably want to set it to something meaningful.</p>
<p>Also, most examples I see use no-pty as an additional option, but this messes up the carriage-return/linefeediness of the output of the above example. (Try it.) I haven&#8217;t looked into it enough to see why you would want it, but there you go.</p>
<p><code>cat tempfile |ssh burly 'sh -c "cat - &gt;&gt;~/.ssh/authorized_keys2"'</code></p>
<p>Append tempfile to your authorized_keys2 file on burly.</p>
<p>To &#8220;activate&#8221; (or perhaps &#8220;detonate&#8221;) the key from hurly (or anywhere that has the secret key), do this (maybe there is a better way?):</p>
<p><code>ssh -i ~/.ssh/whoisit burly</code></p>
<p>The following also works but is cumbersome:</p>
<p><code>ssh-agent sh -c 'ssh-add ~/.ssh/whoisit &lt; /dev/null &amp;&amp; ssh burly'</code></p>
<p>You can also append this &#8220;command key&#8221; to a different account&#8217;s authorized_keys2 file and trigger it from a different username. You just need the secret key. Like so:</p>
<p><code>ssh -i ~/.ssh/whoisit -l paulkeck burly'</code></p>
<p>The next leap in the pattern is something like this:</p>
<p><code>ssh -i /home/pkeck/.ssh/whoisit -l paulkeck burly'</code></p>
<p>This could be run by any user on the box if they could read your secret key, so always keep your .ssh dir and all your keys chmodded to 700 and 600 respectively.</p>
<p>You could make single-purpose keys with commands to (haven&#8217;t tested all these):</p>
<p><code>mt -f /dev/nst0 rewind</code></p>
<p>Rewind a tape on a remote machine</p>
<p><code>nice -n 19 dd of=/dev/nst0</code><br />
Send STDIN to that tape drive. Maybe STDIN is a tar stream from tar -cf -.</p>
<p><code>nice -n 19 dd if=/dev/nst0</code><br />
Read stuff from there to my STDIN</p>
<p><code>cat claxon.au &gt; /dev/audio</code><br />
Play an alarm noise on a remote machine</p>
<p><code>cat - &gt; /dev/audio</code><br />
Play any sound you send on STDIN</p>
<p><code>cat - &gt; /etc/dhcpd.conf</code><br />
Replace /etc/dhcpd.conf with some stuff from STDIN on the triggering machine (sounds like a temp file would be better)</p>
<p>You can send the stuff on STDIN with something like this on the triggering machine:</p>
<p><code>ssh-agent sh -c 'ssh-add ~/.ssh/whoisit &lt; /dev/null &amp;&amp; cat alarm.au | ssh burly'</code></p>
<p>or</p>
<p><code>ssh-agent sh -c 'ssh-add ~/.ssh/whoisit &lt; /dev/null &amp;&amp; tar cf - /home/pkeck | ssh burly'</code></p>
<p>Maybe for that one the corresponding command to &#8220;catch&#8221; that stream would be:</p>
<p><code>cat - &gt; ~/backups/pkeck.tar.`date +%Y%m%d.%H-%M-%S`</code></p>
<p>You get the idea! Go crazy!</p>
<p>Tape examples from Ed Cashin&#8217;s Gettin&#8217; Fancy with SSH Keys, my inspiration for getting into this whole thing!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=241</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian GNU/Linux Derivatives/Guidelines</title>
		<link>http://blogicons.de/mniewerth/?p=174</link>
		<comments>http://blogicons.de/mniewerth/?p=174#comments</comments>
		<pubDate>Sun, 24 Jun 2012 22:48:41 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Debian GNU/Linux]]></category>
		<category><![CDATA[Debian Packages]]></category>
		<category><![CDATA[Ultimedia GNU/Linux]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=174</guid>
		<description><![CDATA[This page outlines aspects to take care while creating a derivative Debian distribution. For now it is just an outline to collect relevant information which could be formalized later on in the form of Specification. Intro Derivative Debian distributions vary in the domains of their specialization, user base, and the scale of modifications/extension they bring [...]]]></description>
			<content:encoded><![CDATA[<p>This page outlines aspects to take care while creating a derivative Debian distribution. For now it is just an outline to collect relevant information which could be formalized later on in the form of Specification.</p>
<h2>Intro</h2>
<p>Derivative Debian distributions vary in the domains of their specialization, user base, and the scale of modifications/extension they bring on top of vanilla Debian distribution.  Therefore, there might not be a strict deterministic set of rules, and rather a set of guidelines could help to decide which actions should be taken by the developers of the derivative distribution to not inflict Debian, and, moreover, benefit from the Debian infrastructure/resources/frameworks where applicable.</p>
<h2>Infrastructure</h2>
<p>We encourage derivative distributions to mention and define their relationship with Debian on the web page that gives information about the derivative distro (usually the about page).<br />
We encourage derivative distributions to use Debian infrastructure and the software that powers Debian infrastructure where possible.</p>
<h2>Repositories</h2>
<p>For those derivatives that re-use Debian binary packages, add some source packages and modify some source packages, where possible we encourage them to use standard Debian mirrors and add a second repository containing only the source and binary packages that have been added or modified.</p>
<p>For those derivatives that rebuild Debian source packages, add some source packages and modify some source packages, where possible we encourage them to use standard Debian mirrors for the source packages and add a second repository containing only the source and binary packages that have been added or modified. This recommendation may be hard to do and therefore regular source package syncing is an alternative recommendation.</p>
<p>Of course in both cases it is a good idea to run a Debian mirror to ensure source and binary availability. Any exact mirrors of Debian source and or binary packages should be registered with the Debian mirrors list.</p>
<p>If you are copying Debian source packages to your repositories without modifying them, please leave the signatures in place in the .dsc files, do not re-sign them with your own keys.</p>
<h2>Keyrings</h2>
<p>Please create your own keyring packages instead of patching the Debian keyring packages.</p>
<h2>Releases</h2>
<p>If your derivative is based on Debian stable releases, please start your release testing process at least when the Debian freeze happens or do regular release testing during the whole Debian release cycle.</p>
<h2>Trademark</h2>
<p> * Derivative distributions must not be named &#8221;Debian&#8221; <img src='http://blogicons.de/mniewerth/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> * [[http://www.debian.org/trademark|Current Debian trademark policy]] states: To be fair to all businesses, we insist that no business use the name &#8220;Debian&#8221; in the name of the business, or a domain name of the business.<br />
   * ongoing work on the [[http://wiki.mako.cc/TrademarkFreedom|Draft of the new Debian trademark policy]] aims to clarify/relax above restriction. Consult the [[DebianProjectLeader]] meanwhile on a case-by-case basis</p>
<h2>De-/Re-branding</h2>
<p>Depending on the degree of divergence from the vanilla Debian, it might be necessary to introduce non-functional modifications in the deployed system to eliminate user confusion of the derivative distribution with vanilla &#8221;Debian&#8221;</p>
<h2>Entry points</h2>
<p>Following packages along with corresponding files present users with &#8221;Debian&#8221; name upon interaction with the system</p>
<p><code><br />
 * <strong>base-files</strong><br />
   * /etc/issue<br />
   * /etc/issue.net<br />
   * /etc/dpkg/origins/default (symlink to distribution information file)<br />
   * /usr/share/base-files/motd<br />
 * <strong>grub-pc</strong><br />
   * /etc/grub.d/05_debian_theme<br />
 * <strong>debian-installer</strong><br />
   * package root/build/boot/x86/ (branding, references to 'Debian on all the fnumber screens')<br />
   * package root/build/config/local (override various strings)<br />
 * <strong>debian-cd</strong><br />
   * will probably need customisation for the install images.<br />
 * <strong>synaptic</strong><br />
   * uses the debian logo for indicating packages<br />
 * <strong>software-properties-gtk</strong><br />
   * talks about dfsg and debian release (eg, squeeze). don't know if this counts <img src='http://blogicons.de/mniewerth/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</code></p>
<h3>Artwork</h3>
<p> * Any default background images carrying Debian official use logo?</p>
<p> * &#8220;Debian official use logo&#8221; with &#8220;Debian&#8221; word has usage restrictions: &#8220;This logo or a modified version may be used by anyone to refer to the Debian project, but does not indicate endorsement by the project. &#8221;</p>
<h2>Packages</h2>
<p>Rebuilt Debian packages should carry distribution specific version suffix to avoid confusion with possibly API/ABI-incompatible original packages provided from Debian archives.</p>
<p>When modifying source packages, rename the Maintainer field to XSBC-Original-Maintainer and add a new Maintainer field.</p>
<h2>Bug reports</h2>
<p>Since Debian bug tracking system should not be used directly to report bugs in the derivative distributions, submitted bugreports should not be sent directly against Debian packages.  &#8220;reportbug&#8220; could either be switched (see /usr/share/doc/reportbug/README.developers.gz) or patched (please do not forget to make patch generic and submit it to Debian) to use some other bug tracking system/server; alternatively different address to submit reports could be specified per each source package in the Bugs field of source portion in &#8220;debian/control&#8220; file. </p>
<p>Specific choice among above scenarios depends on the degree to which derivative distribution is changing/extending vanilla Debian system.  For example, if the derivative does not introduce heavy reconfiguration of the stock Debian system, nor provides custom builds of non-leaf packages &#8212; it should be sufficient to provide custom Bugs: header fields only in rebuilt/new packages.  If some base Debian libraries get customized/rebuilt and/or heavy re-configuration of the default Debian system in place, it is advised that all bugreports get submitted to the maintainers of the derivative distribution first for the analysis either the bug is pertinent to stock Debian, where it should be forwarded by the maintainers in such cases.</p>
<h2>Popularity Contest</h2>
<p>If you want to become the collector of popcon submissions,  please do not simply divert popcon submissions  from the default &#8220;popcon.debian.org&#8220; to your server.  Multiple target popcon servers could be listed in &#8220;SUBMITURLS&#8220;.  </p>
<h3>Benefits</h3>
<p> * Debian would benefit from more adequate status on the usage of the work of Debian community<br />
 * If &#8220;apt&#8220; package in the derivative carries custom suffix (since per se no other distribution-specific information is included in the popcon submissions) it could allow Debian to discover the most popular derivatives and provide some nice statistics of the usage beyond stock Debian<br />
 * Niche packages, which might not be very popular in stock Debian, could be more actively used in a specialized derivative distribution.  Having adequate popcon statistic  in Debian would guarantee that the package would not be removed from stock Debian, thus offloading maintenance burden on the interested derivative<br />
 * Debian&#8217;s popcon, unlike some other deployed popcon servers, might provide additional information (e.g. historical data) which might not be exposed on the derivative&#8217;s popcon website for some reason.</p>
<h2>See also</h2>
<p> * http://www.debian.org/logos<br />
 * http://wiki.mako.cc/TrademarkFreedom<br />
 * http://www.emdebian.org/emdebian/customisation.html</p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=174</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache2 and the trouble with BaiduSpider</title>
		<link>http://blogicons.de/mniewerth/?p=120</link>
		<comments>http://blogicons.de/mniewerth/?p=120#comments</comments>
		<pubDate>Fri, 22 Jun 2012 13:41:57 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[BadBots]]></category>
		<category><![CDATA[Bots]]></category>
		<category><![CDATA[Cracker]]></category>
		<category><![CDATA[Spider]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=120</guid>
		<description><![CDATA[Some time ago as the Ultimiedia linux project started, i realized that the web has changed. More and more attackers and bots are out there to bug websites and find security holes to breach them or just block them by unwanted requests and queries. Another issue is, that the robots.txt is not respected by such, [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago as the Ultimiedia linux project started, i realized that the web has changed. More and more attackers and bots are out there to bug websites and find security holes to breach them or just block them by unwanted requests and queries. Another issue is, that the robots.txt is not respected by such, i call &#8216;em bad bots, so the site is under constant fire all arround the clock. Such a spider is the chinese searchengine Baidu and it&#8217;s BaiduSpider system. A main issue in blocking is, you block a range that they&#8217;re constant using but they&#8217;ll come back from other ranges, which makes it verry hard to handle (see my list of IP ranges below). </p>
<p>Language related it makes absolutly no sense to get listed on chinese searchspiders in my opinion, also it is another leaking point of security to get listed by unwanted searchengines. Crackers using they own searchalgorithms to scan for emails and services &#8211; and some providers makes it verry easy for them. Often those crackers occupy network ranges and bomb your servers, by sending emails over your smtp relay or they testing security breaches. Sometimes even the owners of the attacking machines did not know that they working on an occupied server and that they are member of a botnet.</p>
<p>This security issue could be solved by blocking the occupied ranges preemptively. To do so, you could configure the apache by checking the apache environment variables. Note that, if you have a vserver it would be recommended to block the ip ranges in routing levels. This could be done with ipables or route. See the linux manpages for more informations about the route command. </p>
<h2>Apache 2 configuration (indirect blocking)</h2>
<p>First of all, if you have full access to the webserver, build a global configuration file (i called it /etc/apache2/mod_security.conf) and put it to your conf.d path or load this file via the apache config Include directive, or you should build a .htaccess file if not (requires AllowOverride all). </p>
<p><code><br />
# File: /etc/apache2/mod_security.conf</p>
<p># this is not required but some say it helps against script kids<br />
ServerSignature Off<br />
ServerTokens Prod </p>
<p># lets create some SetEnvIfNoCase environment cases<br />
&lt;IfModule mod_setenvif.c&gt;</p>
<p>    # Block Bad Bots by User-Agent, doublecheck what you want to be allowed<br />
    SetEnvIfNoCase User-Agent "http://www.baidu.com/search/spider.html" badbotlist</p>
<p>    # dont enable this, or users which have removed the browser string will not be able to access your website<br />
      # SetEnvIfNoCase User-Agent "^$" badbotlist<br />
      # SetEnvIfNoCase User-Agent "^-$" badbotlist</p>
<p>    SetEnvIfNoCase User-Agent "^AESOP_com_SpiderMan" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Alexibot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^asterias" badbotlist<br />
    SetEnvIfNoCase User-Agent "^attach" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BackDoorBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BackWeb" badbotlist<br />
    SetEnvIfNoCase User-Agent "Bandit" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Baiduspider" badbotlist<br />
    SetEnvIfNoCase user-Agent "^Baiduspider/2.0" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BatchFTP" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Bigfoot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Black.Hole" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BlackWidow" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BlowFish" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Bot\ mailto:craftbot@yahoo.com" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BotALot" badbotlist<br />
    SetEnvIfNoCase User-Agent "Buddy" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BuiltBotTough" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Bullseye" badbotlist<br />
    SetEnvIfNoCase User-Agent "^BunnySlippers" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Cegbfeieh" badbotlist<br />
    SetEnvIfNoCase User-Agent "^CheeseBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^CherryPicker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ChinaClaw" badbotlist<br />
    SetEnvIfNoCase User-Agent "Collector" badbotlist<br />
    SetEnvIfNoCase User-Agent "Copier" badbotlist<br />
    SetEnvIfNoCase User-Agent "^CopyRightCheck" badbotlist<br />
    SetEnvIfNoCase User-Agent "^cosmos" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Crescent" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Curl" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Custo" badbotlist<br />
    SetEnvIfNoCase User-Agent "^DA" badbotlist<br />
    SetEnvIfNoCase User-Agent "^DISCo" badbotlist<br />
    SetEnvIfNoCase User-Agent "^DIIbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^DittoSpyder" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Download" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Download\ Demon" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Download\ Devil" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Download\ Wonder" badbotlist<br />
    SetEnvIfNoCase User-Agent "Downloader" badbotlist<br />
    SetEnvIfNoCase User-Agent "^dragonfly" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Drip" badbotlist<br />
    SetEnvIfNoCase User-Agent "^eCatch" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EasyDL" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ebingbong" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EirGrabber" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EmailCollector" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EmailSiphon" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EmailWolf" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EroCrawler" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Exabot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Express\ WebPictures" badbotlist<br />
    SetEnvIfNoCase User-Agent "Extractor" badbotlist<br />
    SetEnvIfNoCase User-Agent "^EyeNetIE" badbotlist<br />
    SetEnvIfNoCase user-Agent "^Ezooms/1.0" badbotlist<br />
    SetEnvIfNoCase User-Agent "^FileHound" badbotlist<br />
    SetEnvIfNoCase User-Agent "^FlashGet" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Foobot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^flunky" badbotlist<br />
    SetEnvIfNoCase User-Agent "^FrontPage" badbotlist<br />
    SetEnvIfNoCase User-Agent "^GetRight" badbotlist<br />
    SetEnvIfNoCase User-Agent "^GetSmart" badbotlist<br />
    SetEnvIfNoCase User-Agent "^GetWeb!" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Go!Zilla" badbotlist<br />
    SetEnvIfNoCase User-Agent "Google\ Wireless\ Transcoder" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Go-Ahead-Got-It" badbotlist<br />
    SetEnvIfNoCase User-Agent "^gotit" badbotlist<br />
    SetEnvIfNoCase User-Agent "Grabber" badbotlist<br />
    SetEnvIfNoCase User-Agent "^GrabNet" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Grafula" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Harvest" badbotlist<br />
    SetEnvIfNoCase User-Agent "^hloader" badbotlist<br />
    SetEnvIfNoCase User-Agent "^HMView" badbotlist<br />
    SetEnvIfNoCase User-Agent "^httplib" badbotlist</p>
<p>    # dont block httrack if you share documentations<br />
    # SetEnvIfNoCase User-Agent "^HTTrack" badbotlist</p>
<p>    SetEnvIfNoCase User-Agent "^humanlinks" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ia_archiver" badbotlist<br />
    SetEnvIfNoCase User-Agent "^IlseBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Image\ Stripper" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Image\ Sucker" badbotlist<br />
    SetEnvIfNoCase User-Agent "Indy\ Library" badbotlist<br />
    SetEnvIfNoCase User-Agent "^InfoNaviRobot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^InfoTekies" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Intelliseek" badbotlist<br />
    SetEnvIfNoCase User-Agent "^InterGET" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Internet\ Ninja" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Iria" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Jakarta" badbotlist<br />
    SetEnvIfNoCase User-Agent "^JennyBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^JetCar" badbotlist<br />
    SetEnvIfNoCase User-Agent "^JOC" badbotlist<br />
    SetEnvIfNoCase User-Agent "^JustView" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Jyxobot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Kenjin.Spider" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Keyword.Density" badbotlist<br />
    SetEnvIfNoCase User-Agent "^larbin" badbotlist<br />
    SetEnvIfNoCase User-Agent "^LexiBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^lftp" badbotlist<br />
    SetEnvIfNoCase User-Agent "^libWeb/clsHTTP" badbotlist<br />
    SetEnvIfNoCase User-Agent "^likse" badbotlist<br />
    SetEnvIfNoCase User-Agent "^LinkextractorPro" badbotlist<br />
    SetEnvIfNoCase User-Agent "^LinkScan/8.1a.Unix" bad_bo<br />
    SetEnvIfNoCase User-Agent "^LNSpiderguy" badbotlistt<br />
    SetEnvIfNoCase User-Agent "^LinkWalker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^lwp-trivial" badbotlist<br />
    SetEnvIfNoCase User-Agent "^LWP::Simple" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Magnet" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Mag-Net" badbotlist<br />
    SetEnvIfNoCase User-Agent "^MarkWatch" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Mass\ Downloader" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Mata.Hari" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Memo" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Microsoft.URL" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Microsoft\ URL\ Control" badbotlist<br />
    SetEnvIfNoCase User-Agent "^MIDown\ tool" badbotlist<br />
    SetEnvIfNoCase User-Agent "^MIIxpc" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Mirror" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Missigua\ Locator" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Mister\ PiX" badbotlist<br />
    SetEnvIfNoCase User-Agent "^moget" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NAMEPROTECT" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Navroad" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NearSite" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NetAnts" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NetMechanic" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NetSpider" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Net\ Vampire" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NetZIP" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NextGenSearchBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NG" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NICErsPRO" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NimbleCrawler" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Ninja" badbotlist<br />
    SetEnvIfNoCase User-Agent "^NPbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Octopus" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Offline\ Explorer" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Offline\ Navigator" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Openfind" badbotlist<br />
    SetEnvIfNoCase User-Agent "^OutfoxBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^PageGrabber" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Papa\ Foto" badbotlist<br />
    SetEnvIfNoCase User-Agent "^pavuk" badbotlist<br />
    SetEnvIfNoCase User-Agent "^pcBrowser" badbotlist<br />
    SetEnvIfNoCase User-Agent "^PHP\ version\ tracker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Pockey" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ProPowerBot/2.14" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ProWebWalker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^psbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Pump" badbotlist<br />
    SetEnvIfNoCase User-Agent "^QueryN.Metasearch" badbotlist<br />
    SetEnvIfNoCase User-Agent "^RealDownload" badbotlist<br />
    SetEnvIfNoCase User-Agent "Reaper" badbotlist<br />
    SetEnvIfNoCase User-Agent "Recorder" badbotlist<br />
    SetEnvIfNoCase User-Agent "^ReGet" badbotlist<br />
    SetEnvIfNoCase User-Agent "^RepoMonkey" badbotlist<br />
    SetEnvIfNoCase User-Agent "^RMA" badbotlist<br />
    SetEnvIfNoCase User-Agent "Siphon" badbotlist<br />
    SetEnvIfNoCase User-Agent "sitecheck.internetseer.com" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SiteSnagger" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SlySearch" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SmartDownload" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Snake" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Snapbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Snoopy" badbotlist<br />
    SetEnvIfNoCase User-Agent "^sogou" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SpaceBison" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SpankBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^spanner" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Sqworm" badbotlist<br />
    SetEnvIfNoCase User-Agent "Stripper" badbotlist<br />
    SetEnvIfNoCase User-Agent "Sucker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SuperBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^SuperHTTP" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Surfbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^suzuran" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Szukacz/1.4" badbotlist<br />
    SetEnvIfNoCase User-Agent "^tAkeOut" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Teleport" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Telesoft" badbotlist<br />
    SetEnvIfNoCase User-Agent "^TurnitinBot/1.5" badbotlist<br />
    SetEnvIfNoCase User-Agent "^The.Intraformant" badbotlist<br />
    SetEnvIfNoCase User-Agent "^TheNomad" badbotlist<br />
    SetEnvIfNoCase User-Agent "^TightTwatBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Titan" badbotlist<br />
    SetEnvIfNoCase User-Agent "^toCrawl/UrlDispatcher" badbotlist<br />
    SetEnvIfNoCase User-Agent "^True_Robot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^turingos" badbotlist<br />
    SetEnvIfNoCase User-Agent "^TurnitinBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^URLy.Warning" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Vacuum" badbotlist<br />
    SetEnvIfNoCase User-Agent "^VCI" badbotlist<br />
    SetEnvIfNoCase User-Agent "^VoidEYE" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Web\ Image\ Collector" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Web\ Sucker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebAuto" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebBandit" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Webclipping.com" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebCopier" badbotlist<br />
    SetEnvIfNoCase User-Agent "^webcollage" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebEMailExtrac.*" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebEnhancer" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebFetch" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebGo\ IS" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Web.Image.Collector" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebLeacher" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebmasterWorldForumBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebReaper" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebSauger" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebSite" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Website\ eXtractor" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Website\ Quester" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Webster" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebStripper" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebWhacker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WebZIP" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Wget" badbotlist<br />
    SetEnvIfNoCase User-Agent "Whacker" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Widow" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WISENutbot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WWWOFFLE" badbotlist<br />
    SetEnvIfNoCase User-Agent "^WWW-Collector-E" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Xaldon" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Xenu" badbotlist<br />
    SetEnvIfNoCase user-Agent "YandexBot" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Zeus" badbotlist<br />
    SetEnvIfNoCase User-Agent "^Zyborg" badbotlist<br />
    SetEnvIfNoCase User-Agent "ZmEu" badbotlist<br />
&lt;IfModule mod_setenvif.c&gt;<br />
</code></p>
<p>To load this file from the main httpd.conf, open it and put this line into the configuration file. Note that the file is autoloaded if apache was configured to use a conf.d path.</p>
<p><code><br />
# XXX: Implemented mod_security<br />
Include /etc/apache2/mod_security.conf<br />
</code></p>
<p>Now open your vhost configuration of the website you want to protect against the botlist. The lines look like this:</p>
<p><code><br />
&lt;Directory /www/vhosts/example.com/httpdocs&gt;<br />
    &lt;Files *&gt;<br />
        Order allow,deny<br />
        Allow from all<br />
        Deny from env=badbotlist<br />
    &lt;/Files&gt;<br />
&lt;/Directory&gt;<br />
</code></p>
<p>and restart the webserver: <em>apache2ctl graceful</em> (on Debian based systems). On openSuSE you could use: <em>rcapache2 graceful</em>. Or simply use /etc/init.d/apache2 restart|reload.</p>
<h2>Explicit blocking in the Kernel routing tables</h2>
<p>During the fight against the bots, i was so frustrated that i blocked the ip ranges for a short time. The list below shows verry disturbing networks. Decide by yourself which of them to block. Note that this could be only the last solution if really nothing of the bad bot blocks will work. But after some weeks, the bots are gone.</p>
<p><code><br />
 61.51.16.0 - 61.51.31.255         61.51.16.0/20     # (Baidu China - Beijing)<br />
 14.136.0.0 - 14.136.255.255       14.136.0.0/16     # (Baidu China - H.K.)<br />
 123.125.71.0 - 123.125.71.255     123.125.71.0/24   # (Baidu China)<br />
 14.208.0.0 - 14.223.255.255       14.208.0.0/12     # (Baidu China)<br />
 95.108.241.0 - 95.108.241.255     95.108.241.0      # (YandexBot Russian Federation)<br />
 95.108.151.0 - 95.108.151.255     95.108.151.0      # (YandexBot Russian Federation)<br />
 119.63.192.0 - 119.63.199.255     119.63.192.0/21   # (Baidu Japan Inc.)<br />
 119.63.192.0 - 119.63.199.255     119.63.196.0/24   # (Baidu Japan Inc.)<br />
 180.76.0.0 - 180.76.255.255       180.76.0.0/16     # (Baidu China, Baidu Plaza, Beijing)<br />
 220.181.0.0 - 220.181.255.255     220.181.108.0/24  # (CHINANET Beijing Province Network)<br />
 123.125.71.0 - 123.125.71.255     123.125.71.0/24   # (Baidu China)<br />
 202.46.32.0 - 202.46.63.255       202.46.32.0/19    # (Baidu China)<br />
 39.112.0.0 - 39.127.255.255       39.112.0.0/12     # KOREAN<br />
 211.148.192.0 - 211.148.223.255   211.148.192.0/19  # China ShenZhen Topway Video Communication Co. Ltd.<br />
 58.208.0.0 - 58.223.255.255       58.208.0.0/12     # CHINANET jiangsu province network<br />
 117.79.128.0 - 117.79.191.255     117.79.128.0/18   # Beijing Sanxin Shidai Co.Ltd (denial of time protocol)<br />
 122.225.11.0 - 122.225.11.255     122.225.11.0      # CHINANET<br />
</code></p>
<p>Lets say you want to block an address from above. Issue the following command:</p>
<p><code><br />
/usr/sbin/iptables -A INPUT -p udp -s 61.51.16.0/20 -j DROP<br />
/usr/sbin/iptables -A INPUT -p tcp -s 61.51.16.0/20 -j DROP<br />
</code></p>
<p>That&#8217;s it for the first time. Maybe if i have the time, i will extend this section with a tutorial about ip6tables. Also a verry good solution im using is fail2ban which i&#8217;ll introduce during my next posts.</p>
<p>&#8211; Fight the freedom but keep the peace.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=120</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working on the Bash</title>
		<link>http://blogicons.de/mniewerth/?p=92</link>
		<comments>http://blogicons.de/mniewerth/?p=92#comments</comments>
		<pubDate>Mon, 18 Jun 2012 18:33:49 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Devel]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=92</guid>
		<description><![CDATA[This blog will show you the administrative usage of a linux shell and some tips and tricks. In the first round i’ll talk about some tricks and gimmicks the bash provides and also some experienced users are not knowing. After this i&#8217;m presenting some use case situations and some alias definitions for you .bashrc or [...]]]></description>
			<content:encoded><![CDATA[<p>This blog will show you the administrative usage of a linux shell and some tips and tricks. In the first round i’ll talk about some tricks and gimmicks the bash provides and also some experienced users are not knowing. After this i&#8217;m presenting some use case situations and some alias definitions for you .bashrc or alias config file. Then in the last section im extending this article with some random examples. </p>
<p>If you are reading this article keep in mind that content marked by * was written two years ago and pasted into this blog. This means that some applications may have changed in its usage or the way of doing is not always common.</p>
<h2>Shell magics and internals</h2>
<p>A reverse search to often used commands could be verry useful. Bash provides it and it is called <em>reverse-i-search</em>. You could initialize that mode by pressing the following combination:</p>
<p><code>ctrl + R</code></p>
<p>This will change into the reverse search mode and will pop up:</p>
<pre>
   (reverse-i-search)`': 
</pre>
<p>Now if you type the string: <em>apt-g</em>, you&#8217;ll see the last typed command that is matching. Note that everything depends on the commands you have used before: </p>
<pre>
   (reverse-i-search)`apt-g': apt-get remove gdm
</pre>
<p>If you press the <em><strong>ctrl &#8211; R</strong></em> again you&#8217;ll be able to walk thru all results the bash will find for that string.</p>
<h2>The argument trick</h2>
<p>Maybe you have pressed it allready, but you did not know what it is good for, it is the arg editing mode. I call it this way, please correct me if this is not the right name. </p>
<p>On the console type:<br />
<code>$ echo he</code> </p>
<p>Now you type the double <strong>&#8220;ll&#8221;</strong> and <strong>&#8220;o&#8221;</strong>, <strong>OR</strong> you could perform the following trick:</p>
<p>Press:<br />
<code>alt + 2 + l</code></p>
<pre>
  (arg: 2) l
</pre>
<p>this will give back a double <strong>&#8220;ll&#8221;</strong> to the prompt. In this case it looks like this:</p>
<p><code>$ echo hell</code> </p>
<p>But, this is not useful if you have short strings like that and maybe only useful if you want to type a high ammount of arguments (test data) in a short time.</p>
<h2>Process handling</h2>
<p>Sometimes it is useful to send a process in the background to start another or because it is unnecesarry to se the whole output. To actually send a process to the background press:</p>
<p><code>ctrl + Z</code><br />
[1]+  Stopped                 top</p>
<p>Now the process is running in the background and you could type:</p>
<p><code>fg</code></p>
<p>to bring the process back to foreground. Now lets assume you try to start a second process and you&#8217;ve got to select between them. To do so type:</p>
<p><code>jobs</code><br />
[1]-  Stopped                 top<br />
[2]+  Stopped                 watch -n2 ps auxf</p>
<p>Now bring the process <strong>1</strong> which is the <strong>top</strong> command to the forgeround.<br />
<code>fg 1</code></p>
<p>This will bring back the top process to the forground and you will see the output is going back to stdout.</p>
<h2>Buffer stdout stream</h2>
<p>If you want to buffer the whole stdout stream, this is also possible. Often this is pressed by beginners and will end in frustrating ending of the whole terminal session. </p>
<p>Start an application which actually sends content into the background, for instance:</p>
<p><code>$ sleep 10; df;</code></p>
<p>After executing this command interruppt the stdout stream by pressing the combination <code>alt +s</code>. Ok, now you have interupted the stdout stream and after drinking a cup of coffe and maybe going for a walk you could press <code>alt +q</code> which will release the whole buffered stdout stream. </p>
<h2>Find Files by Extensions and do something with it *</h2>
<p>In some cases you&#8217;ll want to search the harddrives for files by extension and do some actions with them. In this example i&#8217;ll show the usage of the find command. Lets assume i want to md5sum some files by extension but only img iso files and zip archives.</p>
<pre>
   for item in `find . -regex ".*\.\(img\|zip\)"`; do 
      md5sum $item; 
   done;
</pre>
<h2>Convert PDF to image JPEG *</h2>
<p>To convert from PDF format to JPEG format you can use the convert command <strong>[CONVERT(1)]</strong>. The convert command is a powerfull ImageMagick command. Better have a look into the manual <strong><em>man convert</em></strong><strong>[CONVERT(1)]</strong> before you go ahead.</p>
<p>This command will convert an entire PDF document. </p>
<pre>
 /usr/bin/convert file.pdf -geometry 120 -quality 70 jpg:file.jpg
</pre>
<p>If you&#8217;ll need a small preview image from an entire PDF document, you should consider using another approach to get a faster and better result. In this case the approach ist GhostScript. For the optimizing features you&#8217;ll have to look inside the manual for the GhostScript (gs) command. <strong><em>man gs</em></strong> <strong>[GS(1)]</strong></p>
<pre>
  /usr/bin/gs -q 
  -dBATCH                  \ 
  -dMaxBitmap=300000000    \ 
  -dNOPAUSE                \ 
  -dSAFER                  \ 
  -sDEVICE=jpeg            \ 
  -dTextAlphaBits=4        \  
  -dGraphicsAlphaBits=4    \ 
  -dFirstPage=1            \
  -dLastPage=1             \ 
  -sOutputFile=./test.jpg  \
  ./test.pdf -c quit
</pre>
<h2>Find any text phrase in Files by Directory *</h2>
<p>Sometimes you just want to search in directories for a sepcific text phrase. In this case there are some usefull console commands. The first approach is very simple and gives back only the found text phrase.</p>
<pre> 
  cat * | grep -H -n -i searchphrase
</pre>
<p>This command is suboptimal in case that <strong><em>cat *</em></strong> will give back all files as a string, so grep could not return the right line and filename. In case about that it is better to call only the grep command like this:</p>
<pre> 
  grep -H -n -i searchphrase ./*
</pre>
<p>For recursive search requests add the -R option. </p>
<pre>
  grep -R -H -n -i searchphrase ./*
</pre>
<p>The third and much better approach for advanced scripting purposes is a for loop. This gives you more possibilties for defining own actions that you want to execute in case you found a text phrase. In my sample the script returns back the filename where i found the text phrase. This action could been extended and combined with other scripts.</p>
<pre>
 for FILE in *; do
    if [ "$(cat ${FILE} | grep -i searchphrase)" != "" ]; then
      echo ${FILE}
    fi
 done
</pre>
<h2>Search for files by extension and create a filelist *</h2>
<p>Following command will create a filelist by using a for loop and the find command.</p>
<pre>
 for filename in `find your/path/  -name '*.js' `; \ 
     do echo -e "file:${filename}" >> file.lst; done; \
 for filename in `find my/path/  -name '*.txt' `; \ 
     do echo -e "file:${filename}" >> file.lst; done;
</pre>
<h2>Using AWK to replace a Unix Timestamp in multiline messages</h2>
<p>If an application uses the unix-timestamp prefixed in logfiles, it is verry hard to read at which time the event was loged. So for this example im using the awk functions to replace the timestamp and calculate it to a readable Date/Time format. Lets see the script:</p>
<p>If $msg holds the complete logfile content, i assume this solution. Have a look at the comments, they describe what we are able to use for replacements.</p>
<pre>
    msg="`echo -e -n "${msg}" | awk NF`" # strip out empty lines
    msg="`echo -e -n "${msg}"| awk -F"\n" '
        # Returns a string in the format of output of date(1)
        # Populates the array argument time with individual values:
        #    time["second"]       -- seconds (0 - 59)
        #    time["minute"]       -- minutes (0 - 59)
        #    time["hour"]         -- hours (0 - 23)
        #    time["althour"]      -- hours (0 - 12)
        #    time["monthday"]     -- day of month (1 - 31)
        #    time["month"]        -- month of year (1 - 12)
        #    time["monthname"]    -- name of the month
        #    time["shortmonth"]   -- short name of the month
        #    time["year"]         -- year modulo 100 (0 - 99)
        #    time["fullyear"]     -- full year
        #    time["weekday"]      -- day of week (Sunday = 0)
        #    time["altweekday"]   -- day of week (Monday = 0)
        #    time["dayname"]      -- name of weekday
        #    time["shortdayname"] -- short name of weekday
        #    time["yearday"]      -- day of year (0 - 365)
        #    time["timezone"]     -- abbreviation of timezone name
        #    time["ampm"]         -- AM or PM designation
        #    time["weeknum"]      -- week number, Sunday first day
        #    time["altweeknum"]   -- week number, Monday first day

        function gettimeofday(time, ret, now, i) {
         # get time once, avoids unnecessary system calls
         now = systime()

         # return date(1)-style output
         ret = strftime("%a %b %d %H:%M:%S %Z %Y", now)

         # clear out target array
         delete time

         # fill in values, force numeric values to be
         # numeric by adding 0
         time["second"]       = strftime("%S", now) + 0
         time["minute"]       = strftime("%M", now) + 0
         time["hour"]         = strftime("%H", now) + 0
         time["althour"]      = strftime("%I", now) + 0
         time["monthday"]     = strftime("%d", now) + 0
         time["month"]        = strftime("%m", now) + 0
         time["monthname"]    = strftime("%B", now)
         time["shortmonth"]   = strftime("%b", now)
         time["year"]         = strftime("%y", now) + 0
         time["fullyear"]     = strftime("%Y", now) + 0
         time["weekday"]      = strftime("%w", now) + 0
         time["altweekday"]   = strftime("%u", now) + 0
         time["dayname"]      = strftime("%A", now)
         time["shortdayname"] = strftime("%a", now)
         time["yearday"]      = strftime("%j", now) + 0
         time["timezone"]     = strftime("%Z", now)
         time["ampm"]         = strftime("%p", now)
         time["weeknum"]      = strftime("%U", now) + 0
         time["altweeknum"]   = strftime("%W", now) + 0
         time["isodate"]      = strftime("%F", now)
         time["isotime"]      = strftime("%T", now)

         return ret
        }
        BEGIN { 
            FS="[\n]" 
            gettimeofday(now)
            datestring=now["isodate"]"-"now["isotime"]
        }
        { 
            for (i=1; i<=NF; i++) {
                printf "%s: %s\n", datestring,tolower($i)
            } 
        }
    '`"
</pre>
<h2>Useful alias definitions</h2>
<p>For network admins this alias definitions may be useful? Try them.</p>
<pre>
alias ns="netstat -oNplWna"  # netstat
alias nse="netstat -a | grep ESTABLISHED" #netstat established
alias nsw="watch -n2 'netstat -a | grep ESTABLISHED'" # netstat watch
alias nsi="netstat -iW" # netstat interfaces
alias nsr="netstat -rW" # netstat routing
alias nsg="netstat -gW" # netstat ipv4/ipv6 group membership

# watch logs
alias wl="watch -n 2 '/usr/bin/tail /var/log/apache2/access_log &#038;&#038; /usr/bin/tail \
          /var/log/apache2/error.log &#038;&#038; /usr/bin/tail /var/log/messages &#038;&#038; /usr/bin/tail \
          /var/log/syslog &#038;&#038; /usr/bin/tail /var/log/auth.log'"

# or as shorter example + sudo  (keep an eye what logfiles are present!)
alias wl='sudo /usr/bin/tail -f -n 4 /var/log/{auth.log,daemon.log,debug,messages,mysql,syslog,user.log}'

</pre>
<h3>Listen on serial lines via uucp</h3>
<p>A common gotcha is the following scenario. You try to open the serial line and you can't remember the line settings and/or application usage. Sometimes it's possible that the device is not readable by root and only by tty (add yourself to this group or change the mode). This is the ideal time to create some alias definitions for us. Requirements to communicate with the tty is cu (uucp). </p>
<pre>
Alias  Description
---------------------------------
s0     Listen to /dev/ttyS0
s1     Listen to /dev/ttyS1
u0     Listen to /dev/ttyUSB0
</pre>
<p>In the example source im using sudo to obtain a shell with root permissions. In this root shell the chown command will apply the correct user and group for the current serial tty. If this succeed the command cu will be executed with the default settings. Note that you could use the same code also as root. </p>
<pre>

# The values could also be defined by hand in the alias definitions below, 
#   just replace the $TTYLS variable with the required line speed.
export TTYLS=115200 # tty line speed

# Alias s0 for serial port 1
if [ -c /dev/ttyS0 ]; then
    alias s0="/usr/bin/sudo /bin/sh -c '/bin/chown root:root /dev/ttyS1 &#038;&#038; /usr/bin/cu -s $TTYLS -l ttyS1'"
fi;

# Alias s1 for serial port 1
if [ -c /dev/ttyS1 ]; then
    alias s1="/usr/bin/sudo /bin/sh -c '/bin/chown root:root /dev/ttyS1 &#038;&#038; /usr/bin/cu -s $TTYLS -l ttyS1'"
fi;

# Alias u0 for USB/Serial port 1
if [ -c /dev/ttyUSB0 ]; then
    alias u0="/usr/bin/sudo /bin/sh -c '/bin/chown root:root /dev/ttyUSB0 &#038;&#038; /usr/bin/cu -s $TTYLS -l ttyUSB0'"
fi;
</pre>
<h2>Random Examples</h2>
<p>1. Obtain a root shell, switch back to your current $USER and perform the make - and as superuser shutdown machine after all.</p>
<p><code>sudo sh -c "su -c 'make' $USER &#038;&#038; init 0"</code></p>
<p>2. Show a detailed netstat with Proto, Local Address, Foreign Address and PID/Program name.</p>
<p><code>netstat -tanp</code></p>
<p>3. Send a directory via scp protocol to a remote/local location.</p>
<p><code>scp -r source@local:/directory_to_copy   dest@remote.or.local:/pathwhereto/</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=92</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto merge and build a Debian package for Ultimedia GNU/Linux (outdated)</title>
		<link>http://blogicons.de/mniewerth/?p=53</link>
		<comments>http://blogicons.de/mniewerth/?p=53#comments</comments>
		<pubDate>Mon, 18 Jun 2012 05:44:41 +0000</pubDate>
		<dc:creator>mniewerth</dc:creator>
				<category><![CDATA[Debian GNU/Linux]]></category>
		<category><![CDATA[Debian Packages]]></category>
		<category><![CDATA[Devel]]></category>
		<category><![CDATA[Ultimedia GNU/Linux]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[dpkg]]></category>
		<category><![CDATA[reprepro]]></category>

		<guid isPermaLink="false">https://blogicons.de/mniewerth/?p=53</guid>
		<description><![CDATA[To merge and build packages from Debian you&#8217;ll need the Ultimedia dpkg-extension which provides some bare written functions: Note: Ultimedia dpkg-extension was not intended to use in the community, it is a verry speacial script working on ultimedia/blade build systems. Defines a maintainer profile and includes verry related developer settings Defines a default dist profile [...]]]></description>
			<content:encoded><![CDATA[<p>To merge and build packages from Debian you&#8217;ll need the Ultimedia dpkg-extension which provides some bare written functions:</p>
<blockquote><p><strong>Note</strong>: Ultimedia dpkg-extension was not intended to use in the community, it is a verry speacial script working on ultimedia/blade build systems.</p></blockquote>
<ul>
<li>Defines a maintainer profile and includes verry related developer settings</li>
<li>Defines a default dist profile and archive related settings to sync and upload and re/backup</li>
<li>Search thru the Ultimedia archive and package apt-cache</li>
<li>Parse debian/watch files (udeh)</li>
<li>Close bugs with dpkg_close</li>
<li>Sign *.changes files</li>
<li>Cleanup buildsources</li>
<li>Obtain build-deps inside the build folder with dpkg_deb</li>
<li>Execute debchange with whiptail powered gui</li>
<li>Download sources, resolve dependencies, extract source, build and sign with dpkg_apt_source</li>
<li>Maintain the Ultimedia archive</li>
</ul>
<ol style="list-style: none;">
<li><a rel="nofollow" href="#LoginProcess">Login and Build Process</a></li>
<li><a rel="nofollow" href="#LittleHelpercommands">Little Helper commands</a></li>
</ol>
<ul>
<li>Package Development Server: 10.1.2.254</li>
<li>Package Development Path: /debian/source/[username]</li>
<li>Scripts: /etc/profile.d/</li>
</ul>
<ol>
<li><strong>Note</strong>: Since using sudo it is no more needed to obtain root rights by su, just login as user.</li>
<li>Note: As user it is possible you are not able to access the lockfile database and you will get this message:</li>
</ol>
<p><code>Error 13 creating lock file '/srv/www/apt/repodata/ultimedia/db/lockfile': Permission denied!<br />
There have been errors!<br />
If performing "dpkg_search" or "dpkg_apt_source" you can save ignore this message!<br />
</code></p>
<p>This Example converts/includes autogen-5.10 into the Ultimedia<br />
GNU/Linux package repository and shows the usage of<br />
/etc/profile.d/dpkg-extension.sh. For further informations about the<br />
commands you can type “man dpkg-extension.sh”.</p>
<h2 id="LoginProcess">Login Process</h2>
<ul>
<li>Login as root on “Console A” and login as [user]<br />
on “Console B”.</li>
<li>Update APT Package Database (if updates required in the core<br />
packages, perform them first).</li>
<li>Core Packages always need to be builded before you<br />
build/synchronize a Debian Squeeze Package.</li>
</ul>
<p><em>On Console A:</em></p>
<p><code>$ apt-get update<br />
</code></p>
<ul>
<li>Search for the Source Package name (inside the Ultimedia and<br />
Debian Package Database)</li>
</ul>
<p><em>On Console A:</em></p>
<p><code>$ dpkg_search libopts25<br />
</code><br />
<code> I: no packages found<br />
I: source package is autogen<br />
</code></p>
<p>The output message means, that the Package is not available inside the Ultimedia Package Database and the Source Package name is autogen.</p>
<ul>
<li>Download Source Package from Debian Package Server</li>
</ul>
<p><em>On Console B:</em></p>
<p><code>$ dpkg_apt_source autogen no<br />
</code><br />
<code> Error 13 creating lock file '/srv/www/apt/repodata/ultimedia/db/lockfile': Permission denied!<br />
There have been errors!<br />
mkdir: created directory `/debian/source/markus/autogen'<br />
Reading package lists... Done<br />
Building dependency tree<br />
Reading state information... Done<br />
NOTICE: 'autogen' packaging is maintained in the 'Git' version control system at:</p>
<p>http://git.brad-smith.co.uk/git/debian/pkg-autogen.git</p>
<p>Need to get 1400 kB of source archives.<br />
Get:1 http://ftp.de.debian.org/debian/ squeeze/main autogen 1:5.10-1.1 (dsc) [1884 B]<br />
Get:2 http://ftp.de.debian.org/debian/ squeeze/main autogen 1:5.10-1.1 (tar) [1385 kB]<br />
Get:3 http://ftp.de.debian.org/debian/ squeeze/main autogen 1:5.10-1.1 (diff) [12.9 kB]<br />
Fetched 1400 kB in 1s (1115 kB/s)<br />
Download complete and in download only mode<br />
gpgv: keyblock resource `/home/markus/.gnupg/trustedkeys.gpg': file open error<br />
gpgv: Signature made Sun Jan 31 00:26:53 2010 CET using RSA key ID 8313B5F0<br />
gpgv: Can't check signature: public key not found<br />
dpkg-source: warning: failed to verify signature on ./autogen_5.10-1.1.dsc<br />
dpkg-source: info: extracting autogen in autogen-5.10<br />
dpkg-source: info: unpacking autogen_5.10.orig.tar.gz<br />
dpkg-source: info: applying autogen_5.10-1.1.diff.gz<br />
dpkg-source: info: upstream files that have been modified:<br />
autogen-5.10/autoopts/autoopts-config.in<br />
</code><br />
<code> Source: autogen<br />
Version: 1:5.10-1.1<br />
Distribution: unstable<br />
Urgency: low<br />
Maintainer: Kurt Roeckx &lt;kurt@roeckx.be&gt;<br />
Date: Sat, 30 Jan 2010 20:13:56 +0100<br />
Closes: 562607 562791<br />
Changes:<br />
autogen (1:5.10-1.1) unstable; urgency=low<br />
.<br />
* Non-maintainer upload.<br />
* Set shlibs so that other packages get proper Depends (Closes: #562791)<br />
* Don't let autoopts-config return an rpath. This is not useful on any<br />
Debian system. (Closes: #562607)<br />
</code></p>
<p>The above command will create the directory “autogen” (if not exists) chdir inside autogen, downloads the Source Package from the Debian Servers, extracts it and chdir inside the extracted folder. The no switch at the end will disable the direct start of the build process as you not have incremented the Version number. The gpg error (gpgv: keyblock resource `/home/markus/.gnupg/trustedkeys.gpg&#8217;: file open error) indicates that there are public keys missing on the build system, note to install the debian-maintainers keyring or you&#8217;re unable to verrify the source package, which is not allowed in the Debian Policy.</p>
<p><code>Note: There exists an alias for dpkg-parsechangelog: cl.</code></p>
<ul>
<li>Update, increment or add Ultimedia/blade version suffix to<br />
current version.</li>
</ul>
<p><em>On Console B:</em></p>
<p><code>$ dch --newversion=1:5.10-1.1ultimedia1 Synchronized with Debian Source<br />
</code></p>
<p>Check the new version with:</p>
<p><code>$ cl<br />
</code></p>
<p>or</p>
<p><code>$ dpkg-parsechangelog<br />
</code><br />
<code> Source: autogen<br />
Version: 1:5.10-1.1ultimedia1<br />
Distribution: unstable<br />
Urgency: low<br />
Maintainer: Markus Niewerth &lt;mniewerth@ultimediaos.com&gt;<br />
Date: Fri, 30 Mar 2012 01:18:31 +0200<br />
Changes:<br />
autogen (1:5.10-1.1ultimedia1) unstable; urgency=low<br />
.<br />
* Synchronized with Debian Source<br />
</code></p>
<p>Notes to dfsg versions:<br />
<code>(dch warning: no orig tarball found for the new version.)</code></p>
<p>If we have a version like this: ntp_4.2.6.p2+dfsg-1, we won’t increment the Debian Free Software Guidelines TAG, so we remove this TAG from the Ultimedia release.</p>
<p><em>On Console B:</em></p>
<p><code>$ dch --newversion=1:4.2.6.p2+ultimedia-1 Synchronized with Debian source<br />
dch warning: your current directory has been renamed to:<br />
../ntp-4.2.6.p2+ultimedia<br />
dch warning: no orig tarball found for the new version.<br />
</code></p>
<p>This warning appears because the original Tarball matches not our current version. A directory listing shows the issue we currently dealing with.</p>
<p><code>$ l<br />
total 4125<br />
drwxr-xr-x 24 markus markus 1840 Mar 29 16:17 ntp-4.2.6.p2+ultimedia<br />
-rw-r--r-- 1 markus markus 3793444 Jul 13 2010 ntp_4.2.6.p2+dfsg.orig.tar.gz<br />
-rw-r--r-- 1 markus markus 415786 Jul 13 2010 ntp_4.2.6.p2+dfsg-1.debian.tar.gz<br />
</code></p>
<p>The easy way to create the original Tarball with the Ultimedia version TAG, is to rename the current<br />
<code>ntp_4.2.6.p2+dfsg.orig.tar.gz</code><br />
to<br />
<code>ntp_4.2.6.p2+ultimedia.orig.tar.gz</code><br />
.</p>
<p><code>$ mv ntp_4.2.6.p2+dfsg.orig.tar.gz ntp_4.2.6.p2+ultimedia.orig.tar.gz<br />
$ cd ntp-4.2.6.p2+ultimedia/<br />
...<br />
($ dpkg_build)<br />
</code></p>
<ul>
<li>The Control Files in folder: debian/.
<ul>
<li>Open the file debian/control with gedit as a user not as<br />
root and edit the following lines.</li>
</ul>
</li>
</ul>
<p><code> Source: autogen<br />
Section: devel<br />
Priority: optional<br />
Maintainer: Bradley Smith &lt;bradsmith@debian.org&gt;<br />
Build-Depends: debhelper (&gt;= 7), autotools-dev, gperf, guile-1.8-dev, libxml2-dev, texinfo, texlive, texi2html, quilt<br />
Standards-Version: 3.8.3<br />
Homepage: http://www.gnu.org/software/autogen/<br />
Vcs-Git: http://git.brad-smith.co.uk/git/debian/pkg-autogen.git<br />
Vcs-Browser: http://git.brad-smith.co.uk/?p=debian/pkg-autogen.git<br />
</code></p>
<p>In this control file the developers used a Git repository. Remove the field Vcs-Git and replace with Vcs-Svn as we now only using SubVersion as VCS system. Change the field Maintainer and if used the Uploaders field. Move on with the next step: Create a subversion repository.</p>
<p>This fields should be updated:</p>
<ol>
<li>Maintainer</li>
<li>Uploaders</li>
<li>Vcs-Browser</li>
<li>Vcs-Svn</li>
</ol>
<p>Don’t forget to rename the Maintainer field respectivly into XSBC-Original-Maintainer according the Debian Derivate Guidlines (Census).</p>
<p>In the autogen example i’ve changed the following fields:</p>
<ol>
<li>Maintainer: Markus Niewerth &lt;mniewerth@ultimediaos.com&gt;</li>
<li>XSBC-Original-Maintainer: Bradley Smith &lt;bradsmith@debian.org&gt;</li>
<li>Vcs-Svn: http://svn.ultimediaos.com/svn/pkg-autogen/trunk/</li>
<li>Vcs-Browser:
<p>http://svn.ultimediaos.com/wsvn/pkg-autogen/trunk/</li>
</ol>
<p>See the Debian Developer Documentation for more infos about the<br />
control files.</p>
<ul>
<li>Create a logentry inside the debian/changelog file with:</li>
</ul>
<p><code>$ dpkg_edit_cl<br />
</code></p>
<ul>
<li>Create a close logentry inside debian/changelog file with:</li>
</ul>
<p><code>$ dpkg_close [BUGID]<br />
</code></p>
<ul>
<li>Create a Subversion Repository.</li>
</ul>
<p>This step requires root access on the production server, if you are not an Admin of the Ultimedia Version Control Systems, you might request the creation of a repository and move on with: Create a Subversion Project.</p>
<ol>
<li>Login as root and do the following steps to create the source<br />
storage.</li>
</ol>
<p><code>$ cd /srv/vcs/source/<br />
$ mkdir pkg-autogen<br />
$ cd pkg-autogen<br />
</code></p>
<ol>
<li>Create the SubVersion Repository with UltimediaSVN usvn.</li>
</ol>
<p><code>$ usvn -c pkg-autogen<br />
</code><br />
<code> DBG: #981 svnadmin returns: 1<br />
DBG: #867 ShellCMD: /usr/bin/svn import /tmp/vcs-tmp file:///srv/vcs/svn/pkg-autogen --message "Initial structure import."<br />
DBG: #871 Current Working Directory: /srv/vcs/source/pkg-autogen<br />
Adding /tmp/vcs-tmp/trunk<br />
Adding /tmp/vcs-tmp/branches<br />
Adding /tmp/vcs-tmp/tags<br />
</code><br />
<code>Committed revision 1.<br />
</code><br />
<code>$ usvn -ac pkg-autogen<br />
</code><br />
<code> I: Restarting webserver...<br />
Syntax OK<br />
</code></p>
<p>Now you created the SubVersion repository and you are able to administer the repository structure. Im personally using Eclipse with Subversive SVN connectors, which makes an administration and working verry easy.</p>
<p>The URL to the new repository should be:<br />
<code>http://svn.ultimediaos.com/svn/pkg-autogen</code></p>
<p>You will need a Developer account to have access to the subversion project. Remove the old TTB structure inside the repository, (only if you have a MULTI PROJECT) with the following log message:</p>
<p><code>Deleting old obsolete project layout.<br />
</code></p>
<p>Create a new Project Structure inside the repository, for<br />
instance autogen. (In our example it is not needed!) Use this log<br />
message if you create a new project inside an existing subversion<br />
repository.</p>
<p><code>Creating new project layout: pkg-autogen/my-project<br />
</code></p>
<p>Go back to edit the control files in Step: The Control Files in folder: debian/, and edit the following fields. This URLS may be used for Vcs-Browser and Vcs-Svn control fields:</p>
<p><code>Vcs-Svn: http://svn.ultimediaos.com/svn/pkg-autogen/trunk/<br />
Vcs-Browser: http://svn.ultimediaos.com/wsvn/pkg-autogen/trunk/<br />
</code></p>
<ul>
<li>Start the build process.</li>
</ul>
<p>Now you could try a first build as user by using the following<br />
command:</p>
<p><em>On Console A:</em></p>
<p><code>$ apt-get build-dep autogen<br />
</code></p>
<p><em>On Console B:</em></p>
<p><code>$ dpkg_build<br />
</code></p>
<p>Sign the package with your username/password and your certificate which was obtained from the Ultimedia Key Server. See the GPG2 section for more informations about the keyservers.</p>
<p><code> signfile autogen_5.10-1.1ultimedia1.dsc<br />
</code><br />
<code> You need a passphrase to unlock the secret key for<br />
user: "Markus Niewerth &lt;mniewerth@ultimediaos.com&gt;"<br />
1024-bit DSA key, ID C27C484F, created 2011-07-22<br />
</code><br />
<code> dpkg-genchanges &gt;../autogen_5.10-1.1ultimedia1_i386.changes<br />
dpkg-genchanges: not including original source code in upload<br />
signfile autogen_5.10-1.1ultimedia1_i386.changes<br />
</code><br />
<code> You need a passphrase to unlock the secret key for<br />
user: "Markus Niewerth &lt;mniewerth@ultimediaos.com&gt;"<br />
1024-bit DSA key, ID C27C484F, created 2011-07-22<br />
</code><br />
<code> dpkg-source --after-build autogen-5.10<br />
dpkg-buildpackage: binary and diff upload (original source NOT included)<br />
</code></p>
<p>Now the package was builded and you can cleanup the package and<br />
build a TARBALL for the Subversion Repository.</p>
<p><em>On Console A:</em></p>
<p><code>$ dpkg_clean_source<br />
</code><br />
<code></code><br />
$ cd .. $ tar cjf autogen-5.10.tar.bz2 autogen-5.10 $ scp<br />
autogen-5.10.tar.bz2 root@ultimediaos.com:/srv/vcs/source/pkg-autogen/</p>
<p>Now extract the source on the package server and import the<br />
source into the subversion repository.</p>
<p><code> $ cd /srv/vcs/source/pkg-autogen<br />
$ tar xf autogen-5.10.tar.bz2<br />
$ cd<br />
</code></p>
<p><em>On Console B:</em></p>
<p><code>$ svn import . http://svn.example.com/svn/pkg-autogen/trunk --message "Initial source import"<br />
</code><br />
Adding &#8230;.</p>
<ul>
<li>Maintainer Upload.</li>
</ul>
<p>Now it is needed to publish the source and debian packages to<br />
the Ultimedia package server.</p>
<p><em>On Console B:</em></p>
<p><code>$ mkdir build<br />
$ mv autogen_*.{gz,dsc,changes} build<br />
$ mv *.deb build<br />
$ cd build<br />
$ l<br />
</code><br />
<code> total 2542<br />
-rw-r--r-- 1 markus markus 1385329 Nov 17 2009 autogen_5.10.orig.tar.gz<br />
-rw-r--r-- 1 markus markus 13227 Mar 30 23:07 autogen_5.10-1.1ultimedia1.diff.gz<br />
-rw-r--r-- 1 markus markus 1283 Mar 30 23:13 autogen_5.10-1.1ultimedia1.dsc<br />
-rw-r--r-- 1 markus markus 2328 Mar 30 23:13 autogen_5.10-1.1ultimedia1_i386.changes<br />
-rw-r--r-- 1 markus markus 1018232 Mar 30 23:11 autogen_5.10-1.1ultimedia1_i386.deb<br />
-rw-r--r-- 1 markus markus 101348 Mar 30 23:11 libopts25-dev_5.10-1.1ultimedia1_i386.deb<br />
-rw-r--r-- 1 markus markus 62718 Mar 30 23:11 libopts25_5.10-1.1ultimedia1_i386.deb<br />
</code><br />
<code>$ dpkg_include<br />
</code><br />
<code> autogen_5.10-1.1ultimedia1.dsc: component guessed as 'main'<br />
I: changelog upload...<br />
I: changelog uploaded to: /srv/www/apt/repodata/changelogs/pool/main/a/autogen/autogen_1:5.10-1.1ultimedia1/<br />
Created directory "/srv/www/apt/repodata/ultimedia/pool/main/a/autogen"<br />
Exporting indices...<br />
Successfully created '/srv/www/apt/repodata/ultimedia/dists/blade/Release.gpg.new'<br />
Successfully created '/srv/www/apt/repodata/ultimedia/dists/blade/InRelease.new'<br />
Skipping inclusion of 'autogen' '1:5.10-1.1ultimedia1' in 'blade|main|source', as it has already '1:5.10-1.1ultimedia1'.<br />
Exporting indices...<br />
Successfully created '/srv/www/apt/repodata/ultimedia/dists/blade/Release.gpg.new'<br />
Successfully created '/srv/www/apt/repodata/ultimedia/dists/blade/InRelease.new'<br />
</code></p>
<p>Now sync the local package and changelog repository with the<br />
online repository. (root password required)</p>
<p><code>$ dpkg_sync<br />
</code><br />
<code> dpkg_sync: Variable setup ...<br />
dpkg_sync: source_dir=/srv/www/apt/repodata/ultimedia/<br />
dpkg_sync: destin_dir=upackage@10.1.2.254:/srv/www/vhosts/packages.ultimedia-box.de/httpdocs/ultimedia/<br />
dpkg_sync: excludes=<br />
dpkg_sync: rsync_params=-azv --progress --delete<br />
dpkg_sync: Full command-line ...<br />
/usr/bin/rsync -azv --progress --delete \<br />
/srv/www/apt/repodata/ultimedia/ \<br />
upackage@10.1.2.254:/srv/www/vhosts/packages.ultimedia-box.de/httpdocs/ultimedia/ \<br />
</code><br />
<code> Password:<br />
</code></p>
<p>Now the package is uploaded and the servers are in sync. You should now do a apt-get update on the Ultimedia system.</p>
<h2 id="LittleHelpercommands">Little Helper commands:</h2>
<ul>
<li>SVN import (inconsistent newlines)</li>
</ul>
<p>If you are troubled with a message on “svn import” like this:</p>
<p><code> svn: File 'html/drivers/driver44.html' has inconsistent newlines<br />
svn: Inconsistent line ending style<br />
</code></p>
<p>The solution to this issue is dos2unix and the conversion of inconsitent files.</p>
<p><code>$ ultimedia # find my-project-folder -name "*" -type f | xargs dos2unix<br />
</code></p>
<ul>
<li>Create a new <em>debian/changelog</em> file</li>
</ul>
<p>The following command should be used to create a new debian/changelog file for an initial release. Note: the package example is <em>uucp-1.07-20blade1</em></p>
<p><code> $ ultimedia:/src/uucp/uucp-1.07 # mv debian/changelog ../../~debian.changelog<br />
$ ultimedia:/src/uucp/uucp-1.07 # dch --create --package=uucp --newversion=1.07-20blade1 --distribution=unstable Initial release.<br />
</code></p>
<h2>Update a Non-Maintainer-Upload package</h2>
<p>A Non-Maintainer-Upload version should be raised/updated this way: </p>
<blockquote><p>Note: the package example is po-debconf (1.0.16+nmu1)</p></blockquote>
<pre>
$ ultimedia:/src/po-debconf/po-debconf-1.0.16+nmu1] # mv debian/changelog ../../~debian.changelog
$ ultimedia:/src/po-debconf/po-debconf-1.0.16+nmu1] # dch --newversion=1.0.16+nmu2ultimedia1 \
                                                      --distribution=unstable Merged with Debian squeeze.

dch warning: your current directory has been renamed to:
../po-debconf-1.0.16+nmu2ultimedia1
dch warning: no orig tarball found for the new version.

$ ultimedia:/src/po-debconf/po-debconf-1.0.16+nmu2ultimedia1] # mv ../po-debconf_1.0.16+nmu1.tar.gz \
                                                                ../po-debconf_1.0.16+nmu2ultimedia1.tar.gz

</pre>
]]></content:encoded>
			<wfw:commentRss>http://blogicons.de/mniewerth/?feed=rss2&#038;p=53</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
