May 30, 2008

try cnetworkmanager 0.3

cnetworkmanager is a command line interface for Network Manager. It is still lacking many features but I decided to announce it now, when it can:

  1. connect to WiFi networks
  2. read the configuration file of KNetworkManager

It is working for me on RC1 of openSUSE-11.0, which has NetworkManager-0.7.0.r3685-3. It is my first project in Python, so the code is somewhat cumbersome. Thanks to Mišo for getting me started (idea.o.o, abclinuxu.cz), and Bille for the API docs.

Regarding related projects, I have seen network-manager-cli, but it is for 0.6 only and the developers were only active last August, so I decided that I should first write some working code for 0.7.

I am interested in comments, bugs, feature requests, patches, any feedback.

Here are some screenshots ;-)

$ cnetworkmanager -h
cnetworkmanager 0.3 - Command Line Interface for NetworkManager
Options:
-d, --dev list devices
-c, --actcon list active connections
-s, --syscon list system connection settings
-u, --usrcon list user connection settings (can CRASH nm-applet)
-a, --ap list found access points
-n, --nets list found wireless networks
-C<net>, --connect=<net> connect to a wireless network (using knetworkmanagerrc)
-m, --monitor loop to show dbus signals

Listing the networks:

$ cnetworkmanager -n
cnetworkmanager 0.3 - Command Line Interface for NetworkManager
Wifi Networks:
49: onenet (54Mb, protected)
46: IT (54Mb, protected)
48: TiborBrunclik (11Mb, protected)
46: linksys (54Mb)
46: IT (54Mb, protected)
46: 23 (54Mb)

Testing Scribefire

Thanks to Duncan for suggesting an editor, Scribefire for Firefox. I have yet to see if it proves better than the one built in.

Let's try a command:
$ zypper moo
\\\\\
\\\\\\\__o
__\\\\\\\'/_

May 26, 2008

Installation without YaST

With 96MB of RAM, Linuxrc will not start on 11.0 (RC1). So I decided to exploit the image based installation, and not to use YaST at all for a change.

The target machine has dual boot and I am logged on the other system via the network, so I could paste this all in. Fasten your hats...

Update: Planet SUSE is eating the dollar variables :-( See the original post at Blogspot for the real thing.

Target partition:
# mkfs.ext3 /dev/hda1
# mount /dev/hda1 /mnt

A flash drive with images and kernel:
# mount /dev/sda1 /media
# cd /media/misc

Note I used unlzma beforehand because the target machine is way slow for that
# du -m *
5 base-i386.tar
12 base-meta-i386.tar
527 common-base-i386.tar
22 kernel-default-2.6.25.4-8.i586.rpm

Unpack!
# for i in *.tar; do dd if=$i bs=1M | tar -C /mnt -xf -; done &

While it is running, watch the progress:
# pkill -USR1 -x dd
...
552202240 bytes (552 MB) copied, 709,291 s, 779 kB/s

# cp kernel-default-*.i586.rpm /mnt/tmp

Before installing the kernel, we must do some setup so that the post-install script works.

# for i in dev proc sys; do mount --bind /$i /mnt/$i; done

# chroot /mnt
Now I use ## to mark that we are chrooted in the target system.

Modify partitions as needed.
Also see ls -l /dev/disk/by-id
## ROOT=/dev/hda1
## SWAP=/dev/hda4
## cat <<EOF > /etc/fstab
$ROOT / ext3 acl,user_xattr 1 1
$SWAP swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
EOF

You probably don't need to set this one and the others starting with FIX_

## FIX_BOOT=acpi=force
## GROOT="(hd0,0)"
## cat <<EOF > /boot/grub/menu.lst
default 0
timeout 60
gfxmenu $GROOT/boot/message

title openSUSE 11.0
root $GROOT
kernel /boot/vmlinuz root=$ROOT resume=$SWAP vga=787 $FIX_BOOT
initrd /boot/initrd

title Failsafe -- openSUSE 11.0
root $GROOT
kernel /boot/vmlinuz root=$ROOT ide=nodma apm=off acpi=off noresume nosmp noapic maxcpus=0 edd=off x11failsafe vga=787
initrd /boot/initrd
EOF

Put GRUB to MBR
## GDEST="(hd0)"
## cat <<EOF > /boot/grub/device.map
$GDEST /dev/hda
EOF

## cat <<EOF > /etc/grub.conf
setup --stage2=/boot/grub/stage2 $GDEST $GROOT
quit
EOF

## sysconfig() { sed -i -s "/^$2=/s/=\"/=\"$3/" /etc/sysconfig/$1; }

I also need this. You probably don't
## FIX_MODS="ide-generic ide-core"
## sysconfig kernel INITRD_MODULES "$FIX_MODS"

I don't know whether these 2 are strictly necessary
## sysconfig bootloader LOADER_TYPE grub
## sysconfig bootloader LOADER_LOCATION boot

## rpm -Uhv /tmp/kernel-default-*.rpm
It will get the resume device wrong (according to *current* swap partition), but it seems harmless.

## grub-install

## passwd
## chkconfig SuSEfirewall2_init on
## chkconfig SuSEfirewall2_setup on

## exit
# reboot

BTW, I am fed up with the Blogger editor. Can I use an offline one so that I don't have to change blog hosting?

May 19, 2008

Easier Bugzilla search

I realized that I dislike beta bug reporting because it is so painful to search for duplicates before I report a problem. The search form is so ****ing painful to use!

So I wrote a replacement. Enjoy, view source, share, improve.

Search a substring in openSUSE 11.0 bugs (even closed ones):

v 0.3

May 6, 2008

YaST from the Command Line

The Automatic Configuration in openSUSE 11.0 installation is good because you don't have to click Next so much, but now I am missing the button for opening SSH in the firewall.
Here's a one-liner to do it using YaST:
# yast2 firewall services add zone=EXT service=service:sshd
Try also:
# yast2 firewall help
# yast2 firewall longhelp
# yast2 firewall summary
# yast2 firewall services list
# yast2 -l
# yast2 FOO help
(Saying "yast" instead of "yast2" should work too, but there is bug 374259.)

May 5, 2008

cnetworkmanager 0.1

Thanks to Mišo for getting me started on this...
$ cnetworkmanager -d -c
cnetworkmanager 0.1 - Command Line Interface for NetworkManager
state: CONNECTED
wifi: 1
wifi hw: 1
/org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93
Udi: /org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93
Interface: eth0
Driver: 8139too
Ip4Address: 268702730
Capabilities: NM_SUPPORTED,CARRIER_DETECT
Dev State: FAILED
Dev Type: 802_3_ETHERNET
HwAddress: 00:02:3F:0D:7D:93
Speed: 100
Carrier: 1
/org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f
Udi: /org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f
Interface: wlan0
Driver: rt2500pci
Ip4Address: 1476989962
Capabilities: NM_SUPPORTED
Dev State: FAILED
Dev Type: 802_11_WIRELESS
Dev Mode: INFRA
Wifi Capabilities: RSN,CIPHER_WEP40,CIPHER_WEP104,CIPHER_TKIP,CIPHER_CCMP,WPA
HwAddress: 00:11:D8:70:00:2F
Bitrate: 1000
ActiveAccessPoint: /org/freedesktop/NetworkManager/AccessPoint/4
Active Connections
/org/freedesktop/NetworkManager/ActiveConnection/8
ServiceName: org.freedesktop.NetworkManagerSystemSettings
Connection: /org/freedesktop/NetworkManagerSettings/0
SpecificObject: /
SharedServiceName:
SharedConnection: /
Devices: dbus.Array([dbus.ObjectPath('/org/freedesktop/Hal/devices/net_00_02_3f_0d_7d_93')], signature=dbus.Signature('o'), variant_level=1)
/org/freedesktop/NetworkManager/ActiveConnection/9
ServiceName: org.freedesktop.NetworkManagerUserSettings
Connection: /org/freedesktop/NetworkManagerSettings/Connection/0
SpecificObject: /org/freedesktop/NetworkManager/AccessPoint/4
SharedServiceName:
SharedConnection: /
Devices: dbus.Array([dbus.ObjectPath('/org/freedesktop/Hal/devices/net_00_11_d8_70_00_2f')], signature=dbus.Signature('o'), variant_level=1)

May 2, 2008

D-Bus Spying

I found how to make dbus-monitor show me more than just signals on the system bus. The documentation in dbus-daemon(1) is very terse about that. This is probably insecure, although I don't know of an interesting exploit.
--- /etc/dbus-1/system.conf.orig        2008-05-02 17:08:03.000000000 +0200
+++ /etc/dbus-1/system.conf 2008-05-02 17:08:30.000000000 +0200
@@ -55,6 +55,9 @@
<allow send_requested_reply="true">
<allow receive_requested_reply="true">
</allow>
+ <policy context="mandatory">
+ <allow receive_interface="*" eavesdrop="true">
+ </policy>

<!-- Config files are placed here that among other things, punch
holes in the above policy for specific services. -->
Then you need to tell the daemon to reread the config:
# pkill -HUP -u messagebus
BTW I still haven't figured out how to monitor method_return. I guess receive_requested_reply="false" should do it but not sure how. Does anyone know?