Futile words for your pleasure.

.archiv - Abteilung ‘Downloads and Code’

Große Dateien im aktuellen Verzeichnis finden

Donnerstag, 17. Dezember 2009

Listet nur Dateien auf die >= 10MB sind.
~ # du -hcx | sed -n '/^[0-9]*[MG]/ p' | less

Howto emerge gcc-4.x.x on Hardened Gentoo

Dienstag, 29. September 2009

Normally you only have gcc-3.4.6 on a hardened Gentoo system. (I’m using a 64bit system.)

~ # gcc-config -l
[1] x86_64-pc-linux-gnu-3.4.6 *
[2] x86_64-pc-linux-gnu-3.4.6-hardenednopie
[3] x86_64-pc-linux-gnu-3.4.6-hardenednopiessp
[4] x86_64-pc-linux-gnu-3.4.6-hardenednossp
[5] x86_64-pc-linux-gnu-3.4.6-vanilla

To emerge gcc-4.x.x you have to unmask the ebuild by adding gcc-4.x.x to /etc/portage/package.unmask. Normally it is masked by the hardened profile.

~ # echo “=sys-devel/gcc-4.3*” >> /etc/portage/package.unmask

After that just run

~ # emerge -av sys-devel/gcc

Check if it will install gcc-4.x.x in a new slot (NS) and then press enter to continue.

After emerge finished run gcc-config to see if the new gcc is installed.

~ # gcc-config -l
[1] x86_64-pc-linux-gnu-3.4.6
[2] x86_64-pc-linux-gnu-3.4.6-hardenednopie
[3] x86_64-pc-linux-gnu-3.4.6-hardenednopiessp
[4] x86_64-pc-linux-gnu-3.4.6-hardenednossp
[5] x86_64-pc-linux-gnu-3.4.6-vanilla
[6] x86_64-pc-linux-gnu-4.3.2 *
[7] x86_64-pc-linux-gnu-4.3.2-hardenednopie
[8] x86_64-pc-linux-gnu-4.3.2-vanilla

Done

Rechenaufgabe

Donnerstag, 24. September 2009

Wieviel Leistung (kW) wird benötigt um 1 Kubikmeter Wasser (=1.000 Liter) von 10 °C auf 60 °C zu erwärmen?
Wärmekapazität von Wasser = 418 J/(g K)
Masse = 1.000 Liter = 1.000 Kg = 1.000.000 g
Temperaturdifferenz = 60 °C - 10 °C = 50 °C = 50 K

Energie = Wärmekapazität * Masse * Temperaturdifferenz
Energie = 418 J/(g K) * 1.000.000 g * 50 K
Energie = 20.900.000.000 J
    1 J = 1 Ws
Energie = 20.900.000.000 Ws

          20.900.000.000 Ws
Energie = —————————————————
                   3.600 s/h
Energie = 5.805.555,6 Wh
Energie = 5.805,6 kWh

Ports zu Applikationen finden

Donnerstag, 27. August 2009

Oft ist es so, daß man auf bestimmten (embedded-)Systemen mit Linux eine BusyBox als Shell hat und diese BusyBox weder netstat -anp noch lsof kennt.

Hier also nun ein Quick and Dirty Workaround um dennoch herauszufinden welche Applikation auf welchem Port lauscht.
Gesucht wird eine Applikation die auf Port ”8086” lauscht.

~ # netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
[…]
tcp 0 0 0.0.0.0:8086 0.0.0.0:* LISTEN
[…]

Port ”8086” ist HEX ”1F96”. /proc/net/tcp listet uns alle aktiven TCP Verbindungen auf. (Für udp entsprechend /proc/net/udp.)

~ # cat /proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:022A 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 487 1 c128bcc0 300 0 0 2 -1
1: 00000000:0015 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 263 1 c0ae89a0 300 0 0 2 -1
2: 00000000:1F96 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 403 1 c09819a0 300 0 0 2 -1
3: 00000000:0017 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 264 1 c0ae8cc0 300 0 0 2 -1
4: 2902A8C0:0017 0D02A8C0:0518 01 00000003:00000000 01:00000023 00000000 0 0 614 4 c128b9a0 37 4 9 2 -1

Aha! An Position 2 gefunden! Wichtig ist jetzt der inode-Wert. Hier ist er ”403”.
Wir suchen also nach dem Wert ”403” in ganzen Proc-System:

~ # (find /proc/[0-9]* | xargs ls -ld | grep ‘\[403\]’) 2>/dev/null
lrwx—— 1 root root 64 Jan 10 17:51 /proc/265/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/266/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/268/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/287/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/288/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/293/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/337/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/377/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/378/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/379/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/380/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/381/fd/17 -> socket:[403]
lrwx—— 1 root root 64 Jan 10 17:51 /proc/382/fd/17 -> socket:[403]

Okay, treffer! PID ”265,266,268,…” benutzen diesen inode und lauschen demnach auf Port ”8086”.
ps -ax eröffnet uns dann das Programm zur PID.

~ # ps ax
PID Uid VmSize Stat Command
1 root 344 S init
2 root SW [keventd]
3 root SWN [ksoftirqd_CPU0]
4 root SW [kswapd]
5 root SW [bdflush]
6 root SW [kupdated]
7 root SW [mtdblockd]
29 root SWN [jffs2_gcd_mtd1]
79 root 224 S /sbin/watchdog 60 5
88 root 200 S /usr/sbin/hresetd /dev/gpio4
184 root 324 S /sbin/syslogd -m 0 -o 64000
201 root 336 S /usr/sbin/drmd
203 root 336 S /usr/sbin/drmd
204 root 336 S /usr/sbin/drmd
233 root 308 S /usr/sbin/inetd /etc/inetd.conf
240 root 372 S /usr/sbin/crond -l 0
257 root 260 S /usr/sbin/swatchdog -t 15 -p /var/run/swatchdog.farseer.pid -a /usr/bin/soft-reboot-bg
265 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
266 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
268 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
287 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
288 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
293 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
303 root 272 S /usr/sbin/eventd -p /var/run/eventd.0.pid -c /tmp/farseer.fifo
337 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
377 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
378 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
379 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
380 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
381 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
382 root 2816 S /usr/sbin/farseer.out -d -c /tmp/farseer.fifo
429 root 364 S /sbin/getty -L ttyS0 38400 vt100
446 root 372 S telnetd
447 root 516 S -sh
1043 root 364 R ps ax

Es ist also das Programm farseer.out welches auf dem Port 8086 hört.

Original Beitrag:
http://majordomo.squawk.com/njs/blog/2006/02/interpreting-procprocessfd0-9-entries.html

Howto install Lotus Notes for Linux

Freitag, 18. Juli 2008

#####################################################################################
# Evils Install #
#####################################################################################

  1. add user and group “notes” and create the home dir /home/notes
  2. install as root, run <CD-ROM>/Clients/Linux/setup.sh
  3. chown and chgrp of /ibm/lotus, /etc/lotus and /home/notes/lotus to notes user
  4. install libgnomeprint, libgnomeprintui, libgnomevfs, gnome-vfs and libgnome
  5. “xhost +” to allow all users access to the X-Server
  6. sudo notes
  7. cd /opt/ibm/lotus/notes/framework/rcp
  8. run “./rcplauncher -config notes”
    watch out for errors in the console log. you may have to install more libraries
    if notes is missing them (”libblah.so could not be found”)
  9. cd /opt/ibm/lotus/notes/
  10. run “./notes”
  11. Enjoy.

To run notes as root, you have to do step 5, 9 and 10 every time (or use a script)

####################################################################################
#!/bin/bash
# This is only proof of concept!

xhost +
cd /opt/ibm/lotus/notes
./notes

MS Access via PHP nutzen

Mittwoch, 4. April 2007

require_once("DB.php");
$dsn = array("phptype" => “ado”,”dbsyntax” => “access”,”username” => “”,”password” => “”,”database” => “PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\\Northwind.mdb”);

$conn = DB::connect($dsn);
if (PEAR::isError($conn)) die($conn->getMessage());

$conn->setFetchMode(DB_FETCHMODE_ASSOC);
$res = $conn->query(’SELECT * FROM sometable’);
while ($row = $res->fetchRow()) {
print_r($row);
}
?>

Gaußsche Osterglocke

Donnerstag, 29. März 2007

Jaja, der Gauß. Hier mal seine Berechnung wann Ostern ist:
a = X % 19;
b = X % 4;
c = X % 7;
k = X / 100;
p = (8*k + 13) / 25;
q = k / 4;
M = (15 + k - p - q) % 30;
N = (4 + k - q) % 7;
d = (19*a + M) % 30;
e = (2*b + 4*c + 6*d + N) % 7;

Und das allertollste ist: sie funktioniert sogar :)
Ich hab mal den Compiler angeschmissen und nen Programm erzeugt.
[easterdate.zip] - Windows Code + Binary ~ 4kB
[easterdate.tar.gz] - Linux Code ~ 1kB
Und hier die online Variante zum direkt rechnen:
[ostern.php]


Aktion UBERWACH!