Blog

  • killing a process in TCL

    Suppose you had spawned a process in TCL and knew its PID and wanted to kill it? Sounds simple enough thing to do, right? This problem has plagued me for many months because some things you can assume on a normal system do not hold true on strange environments, such as build deaemons.

    Seems simple enough, I started off with:

    exec kill $pid
    

    Except.. not every environment has the kill binary, and with that piece of code exec has to be a binary and not a shell builtin. The funny thing is that /bin/kill is in the procps package, which is the package having the buildd problems.

    So next idea was to use command -v to check for the existence of kill and skip those tests that needed kill if not found. Good idea except, so I found out later, it also finds built-ins. That means we are back to problem #1.

    There is a kill command in tcl, but it requires tclx. That seems excessive for just one little simple command. How can I run a shell out of TCL that runs the kill builtin? On the command line, something like below would do it.

    /bin/sh -c 'kill 1234'
    

    I was closer, but then hit TCL quoting hell. No matter what I (initially) did I’d either get the shell to complain or my variable to not be evaluated. In the end, I had to write it to a separate variable for the command line then apply that to the exec. Not perfect but at least it works now.

    The resulting code (found in testsuite/config/unix.exp) looks like:

    proc kill_process pid {
        set cmdline "kill $pid"
        if { [catch { exec /bin/sh -c $cmdline } msg]} {
            warning "Could not kill process: $msgn"
        }
    }
    

    Perhaps there is a more elegant way, I’m certainly no star TCL programmer, but of all the combinations I saw this was the only that worked.

  • Sneak peek of top graphs

    Jim has been busy as part of the procps-ng team that looks after top. Basically all the changes you find in top from around 2.7 or so are by him. Not satisfied enough with fixing top, making it faster and showing more fields, he has given us CPU and memory graphs.

    He also thinks I don’t have enough colours (or as he would put it colors) on my top output so I’ve posted what the new top looks like for me so you can see the graphs and he can see my colours.

    top, with colours
    top, with colours

     

    I think it is both colourful and useful addition. The colours have been available for a while now and the graphs will appear in the next upstream release of procps-ng.

     

  • WordPress 3.9.1

    The Debian package of WordPress version 3.9.1 was uploaded to the ftp master recently.  While the update was pretty simple, the upload took a lot more doing. I’m not sure why the Debian ftp-master server didn’t like me, but it was so slow. Strangely, even dcut uploads were slow and they are only a few lines of text.

    Apologies for the delay too, I’m not sure why I didn’t notice the update from 3.9 to 3.9.1 but there you go.

    The other change is that the package uses the system CA certificates rather than the ones pre-shipped with wordpress. This is done so that if the administrator makes decisions on what certificates to trust, then the wordpress client http libraries will follow that decision.

  • A python utf gotcha

    This one had me stumped for a while:

    # -*- coding: utf-7 -*-
    import datetime
    from sqlalchemy import ForeignKey, Column
    from sqlalchemy.types import Integer, Unicode, Boolean, DateTime
    
    default_due_date = datetime.datetime.now() + datetime.timedelta(days=30)
    

    Syntax error found on last line.

    Hmm, bring up a python interpreter and type the last line in with the imports. Works fine.

    It’s the first line that is the problem, I typoed it and made it utf-7 not utf-8. I suppose it means that it is case-insenstive. Still, it wasn’t too clear to me at least, what was going on.

    Enhanced by Zemanta
  • mutt ate my i key

    I did a large upgrade tonight and noticed there was a mutt upgrade, no biggie really….Except my I have for years (incorrectly?) used the “i” key when reading a specific email to jump back to the list of emails, or from index to pager in mutt speak.

    Instead of my pager of mails, I got “No news servers defined!” The fix is rather simple, in muttrc put

    bind pager i exit

    and you’re back to using the i key the wrong way again like me.

     

    Enhanced by Zemanta
  • WordPress update needed for stable too

    Yesterday I mentioned that wordpress had an important security update to 3.8.2  The particular security bugs also impact the stable Debian version of wordpress, so those patches have been backported.  I’ve uploaded the changes to the security team so hopefully there will new package soon.

    The version you are looking for will be 3.6.1+dfsg-1~deb7u2 and will be on the Debian security mirrors.

    Enhanced by Zemanta
  • Important WordPress update

    WordPress 3.8.2 was released yesterday which contains some important security fixes. This is an important security release and the Debian packages were uploaded to the ftp-master a few minutes ago.

    Besides fixing Debian Bug #744018, the release fixes the following two vulnerabilities (as mentioned in the bug report):

    • CVE-2014-0165 WordPress privilege escalation: prevent contributors from publishing posts
    • CVE-2014-0166 WordPress potential authentication cookie forgery

    I recommend if you use the Debian package to upgrade as soon as it is available.

     

    Enhanced by Zemanta
  • psmisc 22.21 Released

    Today as it was raining and I couldn’t do much gardening, psmisc version 22.21 was released. The files are located up on sourceforge at https://sourceforge.net/projects/psmisc/files/latest/download or at your favorite distro repository soon.  Once again, thanks to all patch submitters, bug reports and translators for all their help in getting this out. Apologies to the translation teams for having two alpha versions.

    So what does psmisc 22.21 bring you? Amongst a lot of minor bug fixes it has:

    • If you started a process and then spawned some threads and then decided to change the names of the threads, pstree would show the “old” name, it now shows the correct new name
    • pstree has a new flag (-N) for namespace support, thanks Aristeu for the patches
    • Previously fuser -M flag only worked if it was before -m, now it can be either order

    The Debian psmisc package should be out in the next few hours.

    Enhanced by Zemanta
  • Resetting USB devices

    I’m not sure if it is just a bad motherboard, cable, USB device or just bad luck, but when I reboot the computer the UPS doesn’t appear. It’s not even seen in lsusb and of course that makes nut-server fail which makes nut-client complain that it cannot work out the UPS status.The solution was to unplug and plug the cable in then reset nut-server and all was good. But playing with cables seems so last century, surely there was a better way?

    Some Googling showed up a way to Reset USB without a reboot but the directories the entry mentioned didn’t exist on my computer; though there was something very close to it. Perhaps that would work? A few tweaks later and I had a working UPS monitoring cable!

    The changed script is below:

    I’m not sure if it is just a bad motherboard, cable, USB device or just bad luck, but when I reboot the computer the UPS doesn’t appear. It’s not even seen in lsusb and of course that makes nut-server fail which makes nut-client complain that it cannot work out the UPS status.The solution was to unplug and plug the cable in then reset nut-server and all was good. But playing with cables seems so last century, surely there was a better way?

    Some Googling showed up a way to Reset USB without a reboot but the directories the entry mentioned didn’t exist on my computer; though there was something very close to it. Perhaps that would work? A few tweaks later and I had a working UPS monitoring cable!

    The changed script is below:

    #!/bin/sh
    
    SYSXHCI=/sys/bus/pci/drivers/xhci_hcd
    
    if [ "$(id -u)" != 0 ] ; then
     echo This must be run as root!
     exit 1
    fi
    
    if ! cd $SYSXHCI ; then
     echo Weird error. Failed to change directory to $SYSXHCI
     exit 1
    fi
    
    for dev_id in ????:??:??.? ; do
     printf "${dev_id}" > unbind
     printf "${dev_id}" > bind
    done

    Thanks to Eli for the original idea which got me onto the right path.

     

     

     

  • Google doesn't get SPF

    Someone has decided to use my email address for a spam source.  They have even used google to relay it which, given Googles current policies seems like a winning idea.

    I keep getting emails from Google’s servers with header lines like this:

    X-Original-Authentication-Results: mx.google.com; spf=hardfail (google.com: domain of [email protected] does not designate 66.80.26.66 as permitted sender)

    You don’t say? You mean even though my SPF records do not include some dodgy server in California, even though Google knows I don’t include this in my SPF records… well we will let the email go through anyhow.

    SPF records mean that’s where my email comes from. If the record has a -all at the end of it, like mine do, then it means don’t accept it from anywhere else. The hardfail means Google sees the -all and still does nothing about it.

    Enhanced by Zemanta