Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Monday, May 2, 2011

Dammit, read the output...

I keep forgetting to read the output of  commands
$ gdb apache2 /tmp/gdb/core
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
     
warning: The current binary is a PIE (Position Independent Executable), which
GDB does NOT currently support.  Most debugger features will fail if used
in this session.

     
Reading symbols from /usr/sbin/apache2...Reading symbols from /usr/lib/debug/usr/sbin/apache2-mpm-prefork...done.
(no debugging symbols found)...done.
Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f9779b25c4f in ?? ()
(gdb) bt
#0  0x00007f9779b25c4f in ?? ()
#1  0x00007fc05b93c8b0 in ?? ()
#2  0x0000000000000007 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) where
#0  0x00007f9779b25c4f in ?? ()
#1  0x00007fc05b93c8b0 in ?? ()
#2  0x0000000000000007 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) quit
root@acme:~#
root@acme:~# apt-get install apache2-mpm-worker
Turns out that squeeze's gdb doesn't support PIE, pulling in SID's copy works
$ gdb -p 21164
GNU gdb (GDB) 7.2-debian
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
.                                                                                                   Attaching to process 21164
Reading symbols from /usr/lib/apache2/mpm-worker/apache2...Reading symbols from /usr/lib/debug/usr/lib/apache2/mpm-worker/apache2-mpm-worke
r...done.
done.
Reading symbols from /lib/libpcre.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libpcre.so.3
Reading symbols from /usr/lib/libaprutil-1.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libaprutil-1.so.0
Reading symbols from /usr/lib/libapr-1 .....

Monday, March 7, 2011

Debian lenny ipv4 socket bind failing

A certain daemon that had been working elsewhere was refusing to bind to v4 on my box. Strace'ing it showed this
connect(5, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(5, {sa_family=AF_INET, sin_port=htons(10042), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EAFNOSUPPORT (Address family not supported by protocol)
close(5)                                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
connect(5, {sa_family=AF_INET, sin_port=htons(10042), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
getsockname(5, {sa_family=AF_INET, sin_port=htons(60862), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
close(5)                                = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = 5
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(5, {sa_family=AF_INET6, sin6_port=htons(10042), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
listen(5, 5)                            = 0
write(2, "Config port: 10042\n", 19Config port: 10042
Notice the kernel says IPV4 binding is not supported! I am dual stacked! I had IPV4, I could ping the box and other hosts over IPV4. A quick look at my sysctl.d showed

net.ipv6.bindv6only = 1
Switching this off (0) fixed the issue. You can also do it interactively by
echo 0 > /proc/sys/net/ipv6/bindv6only 
Now everything works as expected.
Update:
This is weird. According to the kernel documentation

bindv6only - BOOLEAN
        Default value for IPV6_V6ONLY socket option,
        which restricts use of the IPv6 socket to IPv6 communication
        only.
                TRUE: disable IPv4-mapped address feature
                FALSE: enable IPv4-mapped address feature

        Default: FALSE (as specified in RFC2553bis)
Which as far as I can tell shouldn't touch the IPV4 stack. I expected to find this sysctl check under net/ipv4 but grep can only find the checks in net/ipv6. Any ideas?

Tuesday, December 7, 2010

Installing OpenGrok on Debian squeeze

If you have come across lxr, then you might like openGrok. It's a cross referencer for your code. It also highlights as a bonus :) Have a look at the openoffice instance

Pull in the dependencies
  • sudo aptitude install sun-java6-jdk tomcat6 exuberant-ctags

For debian lenny, there default sysctl setting fraks up java. Fix it by setting the vars in /etc/sysctl.d/bindv6only.conf
  • net.ipv6.bindv6only = 0
  • You may restart procps or
  • echo 0 > /proc/sys/net/ipv6/bindv6only
Download the opengrok binary and unzip it
  • wget http://hub.opensolaris.org/bin/download/Project+opengrok/files/opengrok%2D0.9.tar.gz

Make the opengrok directory tree
  • mkdir /opt/opengrok/ && cd /opt/opengrok && mkdir bin data lib source

Copy over files from the unzipped directory to the installation directory
  • cp ~/opengrok-0.9/bin/* bin/
  • cp ~/opengrok-0.9/lib/ lib/

Fix your app
  • mkdir /opt/opengrok/web && cd /opt/opengrok/web && unzip ../lib/source.war
  • Edit your WEB-INF/web.xml to have:
<!-- My configs -->
<context-param>
<param-name>DATA_ROOT</param-name>
<param-value>/opt/opengrok/data</param-value>
<description>REQUIRED: Full path of the directory where data files generated by OpenGrok are stored</description>
</context-param>

<context-param>
<param-name>SRC_ROOT</param-name>
<param-value>/opt/opengrok/source</param-value>
<description>REQUIRED: Full path to source tree</description>
</context-param>

<context-param>
<param-name>SCAN_REPOS</param-name>
<param-value>false</param-value>
<description>Set this variable to true if you would like the web application to scan for external repositories (Mercurial)</description>
</context-param>


  • Save and recreate the war
  • zip -r ../lib/source.war ./

Deploy your app
  • cd /opt/opengrok/bin && ./OpenGrok deploy
  • You should be able to hit the app: http://a.b.c.d:8080/source

Check out your code
  • cd /opt/opengrok/soure && hg clone https://blah.co.ke/app

Index
  • cd /opt/opengrok/bin && ./OpenGrok index /opt/opengrok/source/

Get to work :)

Pretty brilliant!

Thanks to:

Thursday, July 8, 2010

A simple build script for ejbca on debian. It expects you to pull the appropriate jboss and ejbca archives into $SOURCE
It's based mostly on
  • http://projects.arcs.org.au/trac/systems/wiki/HowTo/InstallSLCSServer2/InstallEJBCA
  • http://www.ejbca.org/installation.html


#!/bin/sh

set -e
SOURCE=/home/lmwangi/
export JBOSS_HOME=/opt/jboss
export PATH=$PATH:$JBOSS_HOME/bin
export APPSRV_HOME=$JBOSS_HOME
export ANT_OPTS=-Xmx512m
export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export JAVA_OPTS="-server -Xms128m -Xmx512m"
export JAVAC_OPTS="-Dno-xdoc"

echonice() {
echo "==================================================="
echo "$1"
echo "==================================================="
echo
}
cd /opt/
rm -rf jboss/ ejbca/
unzip $SOURCE/jboss-4.2.3.GA-jdk6.zip
unzip $SOURCE/ejbca_3_10_3.zip

mv jboss-4.2* jboss/
mv ejbca_3* ejbca/

cd /opt/ejbca/conf &amp;&amp; for file in `ls *.sample`; do cp $file `echo $file|sed -e 's/.sample//'`; done

#sed -i -e 's/httpsserver.hostname=localhost/httpsserver.hostname=some.server.com/' web.properties

echonice "Debian testing has a bug that breaks networking in java \n Refer to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560044"

sleep 5;

cd /opt/ejbca/ &amp;&amp; ant bootstrap

#echo "Please start jboss in another shell using /opt/jboss/bin/run.sh -b 0.0.0.0"
echonice "Attempting to start jboss in another shell"
/opt/jboss/bin/run.sh -b 0.0.0.0 &amp;
sleep 60;

echonice "Attempting install"
ant install
sleep 20;

echonice "Attempting to kill jboss"
kill `ps aux|grep jboss|grep run.sh|awk '{print $2}'`

sleep 20;

echonice "Starting ant deploy"
ant deploy


echonice "Final Jboss Startup"
/opt/jboss/bin/run.sh -b 0.0.0.0


Debug
If you are trying to get ejbca to work and run into this error on debian, have a look at this debian bug 560044

--
[echo] ca init AdminCA1 "CN=AdminCA1,O=EJBCA Sample,C=SE" soft null 2048 RSA 3650 null SHA1WithRSA conf/catoken.properties
[java] Initializing CA
[java] Generating rootCA keystore:
[java] CA name: AdminCA1
[java] DN: CN=AdminCA1,O=EJBCA Sample,C=SE
[java] CA token type: soft
[java] CA token password: null
[java] Keyspec: 2048
[java] Keytype: RSA
[java] Validity (days): 3650
[java] Policy ID: null
[java] Signature alg: SHA1WithRSA
[java] CA token properties: null
[java] Initalizing Temporary Authorization Module.
[java] javax.naming.CommunicationException: Could not obtain connection to any of these urls: 127.0.0.1:1099 and discovery failed with error: javax.naming.CommunicationException: Network is unreachable [Root exception is java.io.IOException: Network is unreachable] [Root exception is javax.naming.CommunicationException: Failed to connect to server 127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 127.0.0.1:1099 [Root exception is java.net.SocketException: Network is unreachable]]]
[java] Java Result: -1

--