Log in

No account? Create an account
c y l i

Ying Li
Date: 2009-05-08 19:48
Subject: I've moved
Security: Public
I have a new blog.

This happened a while ago, but I never announced it here because I was hoping to migrate my old posts. I suppose I can do that later - also, I know I haven't been answering messages/comments here, which I will hopefully remedy in the next few weeks.
1 Comment | Post A Comment | | Link

Ying Li
Date: 2008-04-11 11:39
Subject: Shelless SSH Server with Twisted
Security: Public
Tags:python, twisted
I needed a shelless SSH server that would not honor shell requests or exec commands, because I wanted to provide SFTP access without allowing shell access. I'm only posting this because this may be useful to people - I don't know Twisted very well, and there may be a better way to do it, but this works:
from zope import interface
from twisted.cred import portal
from twisted.python import log
from twisted.conch.avatar import ConchUser
from twisted.conch.ssh import session

class ShelllessSSHRealm:

    def requestAvatar(self, avatarID, mind, *interfaces):
        user = ShelllessUser()
        return interfaces[0], user, user.logout

class ShelllessUser(ConchUser):
    A shell-less user that does not answer any global requests.
    def __init__(self, root=None):
        self.channelLookup["session"] = ShelllessSession

    def logout(self):
        pass   # nothing to do

class ShelllessSession(session.SSHSession):
    name = 'shellessSession'

    def __init__(self, *args, **kw):
        session.SSHSession.__init__(self, *args, **kw)
    def _noshell(self):
        if not self.closing:
            self.write("This server does not provide shells "
                       "or allow command execution.\n")
        return 0

    def request_shell(self, data):
        log.msg("shell request rejected")
        return self._noshell()

    def request_exec(self, data):
        log.msg("execution request rejected")
        return self._noshell()

    def request_pty_req(self, data):
        log.msg("pty request rejected")
        return self._noshell()

    def request_window_change(self, data):
        log.msg("window change request rejected")
        return 0

I have tests for it and everything - I can post those if someone wants them.
2 Comments | Post A Comment | | Link

Ying Li
Date: 2008-03-06 14:04
Subject: Woots, rotation and navigation keys work on the XO.
Security: Public
Tags:ubuntu olpc x11
Now I can use the XO as an ebook reader (in tablet mode) when using Ubuntu.

I was having problems before because the rotation key on the XO, as well as the directional keypad (see this image, although the rotation key is labeled as "backlight control" for some reason). xev didn't even register anything when I hit the keys (oddly enough it did register the gamepad buttons). I knew that that the kernel recognized the key presses, since od /dev/input/event3 register events when the directional pad keys and rotation button (and any other key on the keyboard) is pressed. However, thanks to waba.be's tutorial, I got it working.
Read more...Collapse )
3 Comments | Post A Comment | | Link

Ying Li
Date: 2008-03-02 12:52
Subject: XrandR on Ubuntu on the XO
Security: Public
Tags:ubuntu x11 olpc
The wiki.laptop.org instructions for installing Ubuntu on the XO tell you to install Holger Levsen's backported Xorg AMD drivers. They gave me dependency errors so googled around and found that the AMD Geode driver project on x.org. Even more convenient is Martin-Éric's PPA for the Gutsy and Hardy drivers. Installing xserver-xorg-video-amd, and using the FreeLikeGnu xorg.conf, meant that xrandr now works flawlessly on the XO. Now to get X to even recognize those rotation keys on the XO.
Post A Comment | | Link

Ying Li
Date: 2008-02-29 02:56
Subject: Ubuntu installed on OLPC XO
Security: Public
Tags:ubuntu olpc
Thanks to several sources (wiki.laptop.org Ubuntu installation, wiki.laptop.org XFce, and OLPC News forums), I managed to get Ubuntu working on my OLPC.

The instructions were pretty straightforward, but the process wasn't entirely painless for me so I thought I'd post a few tips:

  1. 2G is absolutely fine. My Ubuntu installation with XFce takes up about 35% of my 2G disk.

  2. You can use the Ubuntu install image linked to from OLPC News forums (1.5G image), but if you want to make your own:

    • When installing qemu you really do want to install the bochs firmware because if you don't, your disk driver won't be detected while doing the Ubuntu install. I missed that part in the instructions, and it was annoying simply because it took a while for the install to get up to that point.

    • Back up your install images at certain stages so you can easily backtrack. For some reason my disk images got corrupted several times after (and during) the xserver install, and I was quite happy to not have to start all over. The Ubuntu install alone took a not insignificant amount of time.

    • The how-to mentioned ata errors and says to ignore them. I thought it would be some small error during bootup, but no, ata errors were scrolling by every second during bootup. It was pretty scary. But yes, apparently it's harmless.

    • After installing sysvinit, the qemu install wouldn't shut down, so I just closed the qemu window and booted back up. It was fine.

  3. I installed it on a microSD card - I have an SD card adapter and a USB adapter. OpenFirmware recognized the SD card, but didn't recognize the USB disk for some reason. My OLPC would mount the microSD/USB drive, but refused to boot off of it. I eventually figured out that it wasn't my olpc.fth, but rather my microSD/USB adapter. A different adapter worked just fine.

  4. Get the files off your OLPC onto a USB disk once (not the one your disk image is on), and copy it elsewhere. It will be much less painful than pulling the files off your OLPC and onto your bootable USB or SD card multiple times.

  5. You can use either the olpc.fth's on the wiki page or the one in the forums. My problem was that OpenFirmware would load the disk image from either the USB drive or the SD drive, but it would hang after loading ramdisk. I spent a huge amount of time reinstalling because I thought I had done something wrong. Apparently OpenFirmware freezes the display but Ubuntu doesn't know to unfreeze it even after the OS is loaded. The solution is to put the line "unfreeze" in your olpc.fth.

  6. It's easier to install xbindkeys and set up scripts, as well get your WPA PSK on your desktop than on the OLPC. The keyboard on the OLPC is a pain to use even for me.

  7. If you use WEP, the following in /etc/network/interfaces works just fine:
    iface eth1 inet dhcp
       wireless-essid SSID
       wireless-key KEY 

I do have some unresolved issues though - if anyone has any suggestions it would be great, as I haven't found solutions yet.

  1. hal-device does not seem to have a charge_level line in Ubuntu, so I haven't figured out how to display battery charge levels in Ubuntu xfce

  2. xrandr doesn't seem to work correctly in Ubuntu, so I can't rotate my display. I get the following error when executing xrandr -o right:
    X Error of failed request:  BadMatch (invalid parameter attributes)
      Major opcode of failed request:  154 (RANDR)
      Minor opcode of failed request:  2 (RRSetScreenConfig)
      Serial number of failed request:  12
      Current serial number in output stream:  12 
    Oddly enough, I get the same error on my desktop and glyf's desktop as well.

1 Comment | Post A Comment | | Link

Ying Li
Date: 2008-02-15 11:48
Subject: Finally finished uploading all my vacation photos!
Security: Public
Iceland photos are up now
Post A Comment | | Link

Ying Li
Date: 2008-01-26 23:41
Subject: PS3 and Saturday nights in
Security: Public
We've been fairly disappointed with the lack of good Wii games lately (and the low output resolution of the Wii) so we finally cleared out our games cabinet a bit, turned in our games and systems for store credit, and bought a PS3.

It's gorgeous! We also got Assassin's Creed, which got meh reviews but that I'm quite enjoying so far. What's neat is that you can download game demos in the background as you play; Devil May Cry 4 looks pretty awesome. I also really like that Folding@Home and "Install Other OS" are options on the main screen (although we haven't tried to install Linux yet).

I spent enough Friday/Saturday nights out that I'm tired of crowds and waiting in line for an hour for crowded trendy restaurants. Just sat around eating some chicken provencal and polenta (as opposed to my usual lazy pasta/mac-n-cheese and sausage/veggies dinner) and ran around base-jumping, dodging guards, and killing some manz.

Totally beats trying to get into Sonsie or Addis Red Sea.
Post A Comment | | Link

Ying Li
Date: 2007-12-29 15:02
Subject: Icelandic woman detained at customs
Security: Public
I recently came across an article posted in the International Herald Tribune about an Icelandic woman who was detained by the Department of Homeland Security at JFK International Airport. She was kept awake for 72 hours, given only bread and porridge once, and otherwise mistreated and humiliated because she had overstayed her student visa by 3 weeks 10 years ago. When she was finally deported back to Iceland (and banned from entering the US again for 10 years), she wrote about her experience in her blog.

Overstaying your visa means that you have to apply for a special visa the next time you visit. She was not aware of this requirement because she had come back before without trouble. The crime clearly did not fit the punishment here - it was a (unfortunately legal) abuse of power by the DHS. Since a lot of my friends are foreign nationals, I just wanted to warn them to make sure all their paperwork was current and they were careful about visas and such.

And yes, I did email the US embassy in Iceland to check this story before I posted it.
Post A Comment | | Link

Ying Li
Date: 2007-12-27 20:57
Subject: USB flash drive problem
Security: Public
I have a 1GB Petito USB flash drive (and no, it is not bling-ed out nor do I wear it on a diamond necklace, but it is a small and aesthetically pleasing drive). Whenever I plug it in, two disks mount: a ~1GB disk on /dev/sdb, and a 512MB disk on /dev/sdc. All my data is on the ~1GB disk, since I can't seem to do anything with the 512MB one. It's magic, somehow. GPartEd thinks it's 512MB of unallocated space, but mount shows it as vfat file format.

It's not a huge problem, it's just annoying that whenever I plug in my USB disk, my data is randomly in either /media/disk-1 or /media/disk. And the other disk is completely useless - it can't be formatted, and I can't figure out how to get it to not mount automatically.

If anyone has any ideas, please let me know.
Post A Comment | | Link

Ying Li
Date: 2007-12-23 02:49
Subject: Damn you, genetics
Security: Public
Apparently I may have a vitamin D deficiency.
Post A Comment | | Link

my journal
May 2009