User Tools

Site Tools


linux:scribble

Scribble

Autotools

$ libtoolize --force
$ aclocal
$ autoheader
$ automake --force-missing --add-missing
$ autoconf
$ ./configure && make && make install

OR

$ autoreconf -vi

C

How to initialize structures and arrays properly?

I always keep forgetting about this one. Let's hope I won't keep forgetting since I'm going to write it down:

uint8_t data[50];
for (i = 0; i < 50; i++) {
  data[i] = 0;
}
/* memset() works as well */
memset(data, 0, sizeof(data));

struct time_t tm_tmp;
memset(&tm_tmp, 0, sizeof(tm_tmp));

same isn't always the same

Just a bit of example when the same isn't actually the same.

char *string = "foo\0";
char string[] = "foo\0";
char string[4] = "foo\0";

Actually, the first one is a const. Of course, fun begins when you try to modify it in any way 8-) Me fayled miserably today.

Returned pointer, stack and "fun"

Pitfall in 3 … 2 … 1 …

#include <stdlib.h>
#include <stdio.h>

int *
bar(int k)
{
        int l = 20;
        int *m = NULL;
        l = 20 + k;
        m = &l;
        return m;
}

int
main()
{
        int *i;
        int *j;
        i = bar(20);
        printf("i: %i\n", *i);
        j = bar(30);
        printf("i: %i, j: %i\n", *i, *j);
        return 0;
}

Results in printing 'i: 50, j: 50'. This has to do with stack. Just remember, if you don't want to lose it, dereference it(= make a copy). It was a nice pitfall for me, don't let it be yours :-)

printf stdint.h types

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

[...]
uint8_t myvar = 5;
printf("myvar: %" PRIu8 "\n", myvar);
[...]

Some reference at wiki.

shifts

Not exactly as I expected, but remember to shift from N to M as shown below otherwise you'll end up with completely different number. I'm wondering, though, whether this is MS case, because LS case seems to be exactly M to N.

uint16_t number = 305;
uint8_t data[2];

data[0] = number >> 8;
data[1] = number >> 0;

Exercises

Change keyboard layout in console

loadkeys /usr/share/keymaps/i386/qwerty/us.kmap.gz

Don't forget about setfont

Cisco IOS notes

It doesn't belong here at all, but I didn't want to start new page just because of couple lines of text. Just some notes worth to remember; especially if you don't have Cisco certification nor too much experience managing Cisco switches :-)

telnet <switch ip>
switch> enable
switch# configure terminal

Now, you can configure hell out of that switch.

How-to core dump/segfault

I've collected the following information from couple sites, although everything is summarised here.

# sysctl -p fs.suid_dumpable=1 ; 
# sysctl -p kernel.core_uses_pid=1 ;
# ulimit -c unlimited ;

And small code to check whether core dumping works. Calling _assert()_ should work as well.

#include <signal.h>

void
main()
{
  raise(6);
}

And check-out core dump with gdb:

# gdb <program> <core-dump> ;

ffmpeg

Note that these were scraped from various sites and forums and I take no credit.

Fix colour profile/convert to BT709

BT709(and nothing else) is supported by some TVs. Therefore one has to reencode video with BT709 colour profile. Note that this command can be used to extract(unpack) MKV(Matroska video file), although just I/O without reencoding is faster, and re-encodes audio to ACC 44.1kHz 128kbit bit rate!

ffmpeg \
    -i input_file.suffix \
    -color_primaries 1 \
    -color_trc 1 \
    -colorspace 1 \
    -vf scale=out_color_matrix=bt709 \
    -color_primaries bt709 \
    -color_trc bt709 \
    -colorspace bt709 \
    # RE-ENCODE AUDIO TO AAC - unnecessary, can be removed
    -acodec aac \
    -strict -2 \
    -ab 128K \
    -ar 44100 \
    # Remove metadata - unnecessary, can be removed
    -map_metadata -1 \
    output_file.suffix

Convert BT601 to BT709

Just in case …

ffmpeg -i input.mp4 -vf "scale=in_color_matrix=bt601:out_color_matrix=bt709" output.mp4

Git

99.9999% scraped from Intranets.

New branch from tag

git checkout -b newbranch v1.0

Fetch remote branch

git checkout –track origin/daves_branch

Go

Aka golang

JSON

Remember that struct attributes/members must begin with capital letter/character. Otherwise you'll get an empty JSON. It took me very long time to figure this one out :-(

json_test.go
package main
 
import (
  "encoding/json"
  "fmt"
)
 
// Attributes, eg. Name, must begin with capital letter/character, otherwise it won't work.
// Also, JSON mapping is shown.
type Message struct {
    Name string `json:"name"`
    Body string `json:"body"`
    Time int64  `json:"unix_time"`
}
 
func main() {
  m := Message{"Alice", "Hello", 1294706395881547000}
  b, err := json.Marshal(m)
  fmt.Println(err)
  fmt.Println(string(b))
}

iconv

Sharp LC-32FB500E displays properly only subtitles encoded as UNICODE.

iconv --from-code=cp1250 --to-code=UNICODE -o $out_file $in_file

Jenkins

Jenkins.instance.getItemByFullName("JobName").getBuildByNumber(JobNumber).finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
Thread.getAllStackTraces().keySet().each() {
    if (it.name.contains('YOUR JOBNAME')) {  
      println "Stopping $it.name"
      it.stop()
    }
}

libvirt

Priceless

bash-3.1# ./configure
[...]
checking for ebtables... /sbin/ebtables
checking for xdrmem_create in -lportablexdr... no
checking for library containing xdrmem_create... no
configure: error: Cannot find a XDR library
bash-3.1# # OK
bash-3.1# installpkg /tmp/portablexdr-4.9.1-x86_64-1.txz
bash-3.1# ./configure
[...]
checking for ebtables... /sbin/ebtables
checking for xdrmem_create in -lportablexdr... yes
checking for xdr_u_int64_t... no
checking where to find <rpc/rpc.h>... missing
configure: error: Unable to find <rpc/rpc.h>
bash-3.1# # WTF?
bash-3.1# ls -la /usr/include/rpc/rpc.h 
-rw-r--r-- 1 root root 64 Mar  8 06:13 /usr/include/rpc/rpc.h
bash-3.1#
bash-3.1# cat > test.c<< EOF
#include <rpc/rpc.h>
int
main()
{
  ;
  return 0;
}
EOF
bash-3.1# gcc -Wall test.c
In file included from test.c:1:0:
/usr/include/rpc/rpc.h:1:20: fatal error: config.h: No such file or directory
compilation terminated.
bash-3.1# # There you go ...
bash-3.1# cat -n /usr/include/rpc/rpc.h 
     1	#include "config.h"
     2	#include <rpc/types.h>
     3	#include <rpc/xdr.h>
bash-3.1# # And line No.1 is the winner. 

Note: I found out later my system got “corrupted” along(as it happens with compat32 and multilibs from time to time), so that might be the issue behind error above. But libvirt is long gone, replaced and forgotten now.

Move LVM on LUKS to new HDD

Unfortunately, this is like two years later and all I have are two links - first and second. I believe the first one shows how to initialize LUKS at new HDD while the second explains how to move LVM. Shameless copy-paste from the second link. I'm NOT the author of the following:

Ideally, you initialize the new LUKS partition as a LVM PV, add it to your volume group with:
vgextend vg1 /path/to/new/LUKS/device
Then use the LVM pvmove command to migrate your data to it like so:
pvmove /path/to/old/LUKS/device /path/to/new/LUKS/device
When the data migration is done, be sure to remove the old LUKS partition from the volume group with:
vgreduce vg1 /path/to/old/LUKS/device
This can all be done with the system online, although it is marginally safer and probably significantly faster to do it from a LiveCD like SystemRescueCD. Also, if you have a new enough version of LVM, you probably want to use the –atomic option for pvmove, that will ensure that you don't end up with some LV's on the new device and some on the old device if the pvmove command fails.

I wish I've documented all the steps I took to move LUKS between HDDs since it might come handy. Also, it's not the first time I did that. Damn!

loop-AES

Decrypt loopAES encrypted partition

gpg --decrypt private.gpg | \
  cryptsetup loopaesOpen \
  /dev/mapper/xxx \
  newvolumename \
  --key-file=- \
  --key-size 128 \
  --hash sha256

Note that this isn't for /etc/fstab.

Resize encrypted LVM backed partition

root@foo:# umount /encrypted

root@foo:# lvextend -L +1T /dev/mapper/encrypted

root@foo:# losetup -F /dev/loop3
Password: 

root@foo:# fsck -f /dev/loop3
fsck from util-linux 2.22.1
e2fsck 1.42.6 (21-Sep-2012)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure                                           
Pass 3: Checking directory connectivity                                        
Pass 4: Checking reference counts                                              
Pass 5: Checking group summary information                                     
/dev/loop3: 1065215/59539456 files (1.9% non-contiguous), 218308597/238138368 blocks

root@foo:# resize2fs /dev/loop3 
resize2fs 1.42.6 (21-Sep-2012)
Resizing the filesystem on /dev/loop3 to 506573824 (4k) blocks.
The filesystem on /dev/loop3 is now 506573824 blocks long.

root@foo:# mount /encrypted

Funny thing is, it seems much harder to resize encrypted partition via cryptsetup/dm-crypt.

MySQL

Convert database to UTF-8 encoding

Originally found at a2hosting.com

Run mysql and check the encoding:

SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "DBNAME";
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "DBNAME" AND T.table_name = "TABLENAME";

Change encoding of tables:

cat > ~/.my.cnf <<EOF
[client]
user=USER
password=PASSWORD
EOF
mysql --database=DBNAME -B -N -e "SHOW TABLES" | awk '{print "SET foreign_key_checks = 0; ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; SET foreign_key_checks = 1; "}' | mysql --database=DBNAME

Change encoding of DB itself:

ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;

Remove ~/.my.cnf or edit out username and password.

OpenOffice/LibreOffice

Convert documents to PDF from command line

Found at askubuntu.com. Note that LibreOffice didn't like UTF-8 characters in file names, resp. non-ASCI chars(I'm not sure if those actually were in UTF-8 or not). Also, you don't have to specify full path to document you want to convert. On the contrary, actually.

libreoffice --headless --invisible --convert-to pdf --outdir ~/dir  ~/dir/file_to_convert.pptx

Open Sound System (OSS) - license expired

You've updated your OSS for whatever reason, but you get the following notice:

****************************************************************
* NOTE! Your Open Sound System evaluation license has expired  *
****************************************************************

Ok. You've done # soundoff; soundon; and still get the note and your sound still doesn't work. What you might want to try is to:

bash-4.2# soundoff

bash-4.2# echo "Given the changes in GNU/Linux distrubutions, it's possible"
bash-4.2# echo "you'll have to change your path. Also, change kernel version!"
bash-4.2# find /lib/modules/3.4.49/ -name \*oss\*
/lib/modules/3.4.49/kernel/oss
/lib/modules/3.4.49/kernel/oss/oss_cs4281.ko
/lib/modules/3.4.49/kernel/oss/oss_envy24ht.ko
/lib/modules/3.4.49/kernel/oss/oss_trident.ko
/lib/modules/3.4.49/kernel/oss/osscore.ko
/lib/modules/3.4.49/kernel/oss/oss_usb.ko
/lib/modules/3.4.49/kernel/oss/oss_hdaudio.ko
/lib/modules/3.4.49/kernel/oss/oss_emu10k1x.ko
/lib/modules/3.4.49/kernel/oss/oss_ich.ko
/lib/modules/3.4.49/kernel/oss/oss_ymf7xx.ko
/lib/modules/3.4.49/kernel/oss/oss_atiaudio.ko
/lib/modules/3.4.49/kernel/oss/oss_audioloop.ko
/lib/modules/3.4.49/kernel/oss/oss_sbpci.ko
/lib/modules/3.4.49/kernel/oss/oss_madi.ko
/lib/modules/3.4.49/kernel/oss/oss_sbxfi.ko
/lib/modules/3.4.49/kernel/oss/oss_audigyls.ko
/lib/modules/3.4.49/kernel/oss/oss_digi96.ko
/lib/modules/3.4.49/kernel/oss/oss_imux.ko
/lib/modules/3.4.49/kernel/oss/oss_via823x.ko
/lib/modules/3.4.49/kernel/oss/oss_sblive.ko
/lib/modules/3.4.49/kernel/oss/oss_fmedia.ko
/lib/modules/3.4.49/kernel/oss/oss_cmi878x.ko
/lib/modules/3.4.49/kernel/oss/oss_userdev.ko
/lib/modules/3.4.49/kernel/oss/oss_audiopci.ko
/lib/modules/3.4.49/kernel/oss/oss_cs461x.ko
/lib/modules/3.4.49/kernel/oss/oss_ali5455.ko
/lib/modules/3.4.49/kernel/oss/oss_cmpci.ko
/lib/modules/3.4.49/kernel/oss/oss_via97.ko
/lib/modules/3.4.49/kernel/oss/oss_midimix.ko
/lib/modules/3.4.49/kernel/oss/oss_envy24.ko
/lib/modules/3.4.49/kernel/oss/oss_midiloop.ko
/lib/modules/3.4.49/kernel/oss/oss_solo.ko
/lib/modules/3.4.49/kernel/oss/oss_geode.ko
/lib/modules/3.4.49/kernel/oss/oss_hdsp.ko

bash-4.2# echo "Check the list of files above, resp. make sure"
bash-4.2# echo "these are really and only OSS modules!"
bash-4.2# find /lib/modules/3.4.49/ -name \*oss\* -delete

bash-4.2# soundon
Relinking OSS kernel modules for "3.4.49 SMP mod_unload "
This may take few moments - please stand by...
Relinking OSS kernel modules finished
[...]

And you should be all set up and running.

PXE

“Initial menu has no LABEL entries!” - some files are missing on your PXE server. It's not (that) easy to find out which ones though. Just make sure you have everything there. If you have two, or more, PXE servers, then make sure they're synchronized(they have the same set of files).

Puppet

Generate graph/PNG from dot file

/usr/bin/dot /tmp/cycles.dot -Tpng -o cycles.png

List all facts on Node

facter -p

Test puppet on Node

puppet agent --test <ADDITIONAL_PARAMS>

Treatchery and trickery

Let's say you write something like this:

class foo {
  package { 'apache2': }
  service { 'apache2': }
}

Now, if you've thought these are just abstracts and you're going to work with them later, you were wrong and might be unpleasantly surprised later. What it means is: Puppet, be a good chap, and install apache2 for me and make sure it's up and running. Yep, you're reading that right. Obvious, you say? Well, not really, it isn't. If I declare something like this I expect nothing to happen because I didn't say what should've happen. Obvious, now, is there are some defaults that apply and Puppet will act whether you like it or not.

Oh, and btw, it seems like require ⇒ Package['apache2'] won't fix this. You must do in order to have package installed:

Package['apache2'] {
  ensure => 'installed',
}

"no certificate found and waitforcert is disabled"

# On client
puppet cert clean
service puppet stop
rm -rf /var/lib/puppet/ssl/
# and get a new SSL cert - d'oh!

QEMU

Bigger resolutions via VNC, vga std, X11

All you need is to configure your monitor properly. Really. Too bad DDC(?) is not implemented which would make it easier. Anyway, if you're lazy you can use any of monitor definitions below or any other monitor, if you know the specifications. I figured it doesn't matter what you put in since it's VNC/virtual.

One more thing. Prior to correct configuration of Monitor, I've noticed messages in /var/log/Xorg.0.log about insufficient memory for resolutions higher than 800×600. So I've used VideoRAM option(described here), but it seems it is not needed at all and VideoRAM gets increased “on demand” in correlation with resolutions used.

[...]
Section "Device"
    Identifier     "Card0"
    Driver         "vesa"
    VendorName     "Unknown Vendor"
    BoardName      "Unknown Board"
    VideoRAM       8192
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "HP ZR24w"
    HorizSync       24.0 - 80.0
    VertRefresh     59.0 - 61.0
    Option         "dpms" "true"
    Option         "StandbyTime" "10"
    Option         "SuspendTime" "15"
    Option         "Off" "10"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Neovo"
    ModelName      "F-419"
    HorizSync       24.0 - 80.0
    VertRefresh     49.0 - 75.0
    Option         "dpms" "true"
    Option         "StandbyTime" "10"
    Option         "SuspendTime" "15"
    Option         "Off" "10"
EndSection
[...]

Kernel panic when booting off virtio-blk-pci

I've encountered this “strange” kernel panic when installing/updating LILO under kernel 2.6.37.6 and then booting into newer kernel. Now, I don't remember which “newer” kernel exactly, there were a few for sure, but it is 3.0.23 now.

I assume device type of virtio-blk-pci got changed, as shown below using # stat;, with (some) kernel version from fc to fd and LILO doesn't like it.

[... LILO ... boot/kernel messages and such ... ]
[    0.705349] VFS: Cannot open root device "fc01" or unknown-block(252,1)
[    0.705887] Please append a correct "root=" boot option; here are the availab
le partitions:
[    0.706802] fd00         6291456 vda  driver: virtio_blk
[    0.707390]   fd01         2816351 vda1 00000000-0000-0000-0000-000000000000
[    0.707991]   fd02          256032 vda2 00000000-0000-0000-0000-000000000000
[    0.708642] 0b00         1048575 sr0  driver: sr
[    0.709204] Kernel panic - not syncing: VFS: Unable to mount root fs on unkno
wn-block(252,1)
[    0.710315] Pid: 1, comm: swapper Not tainted 3.0.23 #1
[    0.710829] Call Trace:
[    0.711283]  [<ffffffff817640a4>] panic+0x8c/0x197
[    0.711770]  [<ffffffff817641eb>] ? printk+0x3c/0x3e
[    0.712311]  [<ffffffff81cacf95>] mount_block_root+0x149/0x1e9
[    0.712825]  [<ffffffff81cad224>] mount_root+0xe0/0xeb
[    0.713375]  [<ffffffff81179c11>] ? sys_unlink+0x11/0x20
[    0.713871]  [<ffffffff81cad39f>] prepare_namespace+0x170/0x19d
[    0.714437]  [<ffffffff81caccf0>] kernel_init+0x130/0x13c
[    0.714934]  [<ffffffff8176fa24>] kernel_thread_helper+0x4/0x10
[    0.715488]  [<ffffffff81cacbc0>] ? start_kernel+0x36c/0x36c
[    0.715993]  [<ffffffff8176fa20>] ? gs_change+0x13/0x13
/ # uname -a
Linux none 2.6.37.6 #3 SMP Sat Apr 9 22:49:32 CDT 2011 x86_64 GNU/Linux
/ # stat /dev/vda
  File: /dev/vda
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 5h/5d   Inode: 3295        Links: 1     Device type: fc,0
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2012-03-30 06:36:03.000000000
Modify: 2012-03-30 06:36:03.000000000
Change: 2012-03-30 06:36:03.000000000
/ # uname -a
Linux none 3.0.23 #1 SMP Tue Mar 6 16:35:46 CDT 2011 x86_64 GNU/Linux
/ # stat /dev/vda
  File: /dev/vda
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: eh/14d  Inode: 2063        Links: 1     Device type: fd,0
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2012-03-30 06:39:11.000000000
Modify: 2012-03-30 06:39:11.000000000
Change: 2012-03-30 06:39:11.000000000

Mouse pointer problems via VNC

tags: kvm, qemu, mouse, pointer, vnc, problem, imprecision

I have a Debian as a VM and had problems with mouse pointer not aligning properly. It was just way off. At first, I thought it might be a X.org driver issue, but it isn't. I even compared X.org log to some Fedora(in VM as well) which works properly. Nothing. I've tried different VNC client. Still nothing. Then I've set on to search. I found a clue related to non-Linux OS - “Enhance Pointer Position”. Thus I set off to experiment a bit.

Answer is - pointer acceleration is to blame. If you, resp. I did, turn it off, mouse imprecision is gone. The following should take care of it(some bits are courtesy of https://wiki.archlinux.org/

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "ZAxisMapping" "4 5 6 7"
    Option         "AccelerationProfile" "-1"
    Option         "AccelerationScheme" "none"
EndSection

It also is suggested to use “usbdevice='tablet'” in Xen. Perhaps QEMU equivalent is going to work as well, but I haven't tested it.

Segfaulting QEMU 3..2..1..now!

QEMU version 1.0.1 and -current as of now(~ 29.3.2012).

Now, this is probably very stupid thing to do with QEMU. Most likely the stupidest combination of options one could think of and come up with, but I did anyway. And QEMU segfaults and it segfaults hard. Yes, it killed all other QEMU processes as well. Combination of -curses and -vnc seems to be deadly after you try to connect to VNC server. Yes, I've tried to experiment with parameters and leaving out -curses doesn't cause segfault.

Problem seems to be in ./ui/vnc.c at line 670, resp. see below. No, I don't know how to patch it :-\

[...]
static void vnc_write_pixels_generic(VncState *vs, struct PixelFormat *pf,
                                     void *pixels1, int size)
{
[...]
    } else if (pf->bytes_per_pixel == 1) {
        uint8_t *pixels = pixels1;
        int n, i;
        n = size;
        for(i = 0; i < n; i++) {
            vnc_convert_pixel(vs, buf, pixels[i]);
            vnc_write(vs, buf, vs->clientds.pf.bytes_per_pixel);
        }
    } else {
        /* HERE */
        fprintf(stderr, "vnc_write_pixels_generic: VncState color depth not supported\n");
    }
}
[...]

Way to reproduce:

/usr/bin/qemu-system-x86_64 
-name my-vm 
-m 512 
-smp 1 
-netdev vde,id=hostnet0,sock=/var/run/vde2/vde.virswitch0 
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:11:22:33,multifunction=on 
-drive if=none,id=disk1,file=/mnt/qemu/my-vm.img,format=qcow2,media=disk 
-device ide-hd,drive=disk1 
-boot order=c 
-curses 
-monitor unix:/var/run/kvm-wrapper/monitor/my-vm.unix,server,nowait 
-serial unix:/var/run/kvm-wrapper/serial/my-vm.unix,server,nowait 
-pidfile /usr/share/kvm-wrapper/run/local:my-vm-vm.pid 
-balloon virtio-balloon-pci 
-vnc 127.0.0.1:1 
-enable-kvm 
-vga std

Segfault messages:

Mar 24 19:54:25 shodan kernel: [3202733.788054] qemu-system-x86[26012]: segfault at 0 ip 00007f3f7daeed1c sp 00007fff7e9238a0 error 4 in qemu-system-x86_64[7f3f7d97f000+311000]
Mar 24 19:54:43 shodan kernel: [3202750.854077] qemu-system-x86[25291]: segfault at 0 ip 00007fd2f2418d1c sp 00007fff0a1eee40 error 4 in qemu-system-x86_64[7fd2f22a9000+311000]
Mar 24 20:09:09 shodan kernel: [3203617.187186] qemu-system-x86[26857]: segfault at 0 ip 00007fdbc05c0d1c sp 00007ffff37d9fa0 error 4 in qemu-system-x86_64[7fdbc0451000+311000]
Mar 24 20:09:25 shodan kernel: [3203633.099067] qemu-system-x86[26925]: segfault at 0 ip 00007ff06f2b3d1c sp 00007fff45cfe530 error 4 in qemu-system-x86_64[7ff06f144000+311000]
Mar 24 21:10:50 shodan kernel: [3207318.819095] qemu-system-x86[14948]: segfault at 0 ip 00007f5ae9bccd1c sp 00007fff269a9fa0 error 4 in qemu-system-x86_64[7f5ae9a5d000+311000]
Mar 24 21:12:00 shodan kernel: [3207388.062952] qemu-system-x86[15081]: segfault at 4 ip 00007f3495c0f1e5 sp 00007fff51c52af0 error 4 in qemu-system-x86_64[7f3495a93000+311000]
Mar 24 21:12:56 shodan kernel: [3207444.254077] qemu-system-x86[15181]: segfault at 0 ip 00007f3722368d1c sp 00007fff36dc5b60 error 4 in qemu-system-x86_64[7f37221f9000+311000]
Mar 24 21:13:39 shodan kernel: [3207487.761077] qemu-system-x86[15270]: segfault at 0 ip 00007fa81fbbad1c sp 00007fff3550cf50 error 4 in qemu-system-x86_64[7fa81fa4b000+311000]
Mar 24 21:23:11 shodan kernel: [3208059.451072] qemu-system-x86[15610]: segfault at 0 ip 00007fe875b75cbe sp 00007fff6e84ff00 error 4 in qemu-system-x86_64[7fe875a06000+311000]
Mar 24 21:33:31 shodan kernel: [3208679.724095] qemu-system-x86[16130]: segfault at 0 ip 00007fdf670b5cbe sp 00007fff6fe73600 error 4 in qemu-system-x86_64[7fdf66f46000+311000]
Mar 24 21:53:26 shodan kernel: [3209874.497204] qemu-system-x86[22532]: segfault at 0 ip 00007fc5a73ae69e sp 00007fff7dadbee0 error 4 in qemu-system-x86_64[7fc5a7205000+34a000]

PostgreSQL

Convert ASCI encoding to UTF-8

If you need to convert your dumped PgSQL database from ASCII into UTF-8, then you can try to use following command. I found it somewhere and it worked for me:

recode ASCII-BS..u8 <FILE>

SSH

CVS via SSH behind Firewall-Proxy

So it happens. You're in corporate network sitting behind strong firewall and proxy, yet you are in need of CVS tunneled through SSH, because there is no way you're going to send your password in plain text.

SourceForge.net CVS access is used as an example.

Substitutes in examples bellow:

  • DEVNAME - your SF.net login
  • PROJECT - SF.net project name
  • PROXY_SRV - FQDN/IP of proxy server
  • PROXY_PORT - port at which proxy server is listening at

Standard procedure won't work:

export CVS_RSH=ssh

cvs -z3 -d:ext:DEVNAME@PROJECT.cvs.sourceforge.net:/cvsroot/PROJECT co -P modulename

What now? How about this:

% cat > ~/cvs-ssh-sfnet.sh <<EOF
#!/bin/sh
/usr/bin/ssh \
  -o 'ProxyCommand=/usr/bin/proxytunnel -p PROXY_SRV:PROXY_PORT -d PROJECT.cvs.sourceforge.net:22' \
  -p 22 $*
EOF

% chmod u+x,go-rwx ~/cvs-ssh-sfnet.sh
% export CVS_RSH=~/cvs-ssh-sfnet.sh
% cvs -z3 -d:ext:DEVNAME@PROJECT.cvs.sourceforge.net:/cvsroot/PROJECT co -P modulename

SVN

I had to move projectX from REPO1 to REPO2. Well, to make a copy, because I didn't want to remove it from REPO1. I wasn't sure whether % svn copy; retains all history which I think is good idea to keep. So I've written set of scripts to:

  1. get revision numbers
  2. get rX:rY → diffs
  3. get commit messages
  4. generate shell “fire-and-forget” shell script to commit into REPO2
  5. since full commit messages were kept, script to check whether rXXXX is in REPO2 % svn log; - imperfect solution though!

Lessons learned:

  • % svn add; is not recursive
  • files added to repository later in project cycle - this is actually unresolved and (proven to be) serious problem! Check diff file for '(revision 0)' text? FIXME
  • it's best to do fresh checkout of both repositories, remove '.svn' with % find ./ -name \.svn -type -d | xargs rm -vrf;, then do % diff -ur OLD_REPO NEW_REPO;
  • double triple check you have all files and changes in! Look for 'Only in …' in % diff; output

TAR

Create XZ archive

Works the same as if you were creating GZIP/BZIP2. Found on the intranet:

tar -cf out.tar.xz --use-compress-program=xz file-or-dir
linux/scribble.txt · Last modified: 2022/07/06 17:27 by stybla