Get out of fail2ban jail

Ever get locked out of your own computer because you tried the password too many times when you were, well, not paying attention? I found it tough to find how to unban myself and was pretty frustrated by the ambiguity of the instructions. Not ambiguous. Comprehensive. I don't really want to know any more about fail2ban than how to remove one particular IP.

First, get a list of the jails
# fail2ban-client status

Status
|- Number of jail: 1
`- Jail list: sshd

Then review the banned things

# fail2ban-client status sshd

Status for the jail: sshd
|- Filter
| |- Currently failed: 2
| |- Total failed: 634
| `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd
`- Actions
|- Currently banned: 2
|- Total banned: 4
`- Banned IP list: 219.137.44.150 229.137.39.8

# fail2ban-client set sshd unbanip 219.137.44.150

I didn't find this recipe written down anywhere, probably it is too obvious for an expert to write it own.

However, this guy writes interesting scripts and I was able to deduce the required actions from reading his code

http://www.iredmail.org/forum/topic7498-iredmail-support-handy-script-for-unbanning-ips.html

Posted in Linux | Tagged | Leave a comment

OpenBUGS-3.2.3 Linux Packages

I'm very sorry I stopped paying attention to the packaging on openbugs for a while. I stopped reading the gmail account because I hated their labeling system, but that account is where I'm registered in the OpenBUGS list.

Oh, well. We are back up to date now

1. RedHat/Centos 6 and 7

https://pj.freefaculty.org/EL/

This is a fully fledged EL repository server, users can add the repo to yum and it will be automatic. Otherwise, can download the old fashioned way...

https://pj.freefaculty.org/EL/7/x86_64/openbugs-3.2.3-1.x86_64.rpm
https://pj.freefaculty.org/EL/6/x86_64/openbugs-3.2.3-1.x86_64.rpm

3. Ubuntu

https://pj.freefaculty.org/Ubuntu/15.04/amd64

That's not a fully fledged repository, that's too baroque for me. But you can download the package file. I left the whole build directory there and everything, so in case you wonder what is in there, be my guest to snoop about

Posted in Linux | Tagged | Leave a comment

Gambit packages updated

Linux packages for Gambit were built yesterday. All of these do install and I'm able to open the Gambit GUI and create a game. I compiled with no special arguments, these may not include all of the features you want. If I got that wrong, email me at pauljohn@ku.edu. I'm willing to do this once again, but only if you ask:).

The RPM for EL7 systems can be found in the repo described here:

https://pj.freefaculty.org/EL

but if you just want the RPM, get them here:

https://pj.freefaculty.org/EL/7/x86_64/gambit-14.1.0-1EL7.x86_64.rpm
https://pj.freefaculty.org/EL/7/x86_64/gambit-debuginfo-14.1.0-1EL7.x86_64.rpm

If you are in different flavor of Linux, maybe you rebuild the SRPM instead:

https://pj.freefaculty.org/EL/7/SRPMS/gambit-14.1.0-1EL7.src.rpm

I also built packages for Ubuntu/Debian systems. I was uncertain at first if the stable version of Gambit is 13.1.2 or 14.1.0, and so I made both. Get the deb files in these directories

https://pj.freefaculty.org/Ubuntu/14.10/amd64/gambit-13.1.2
https://pj.freefaculty.org/Ubuntu/14.10/amd64/gambit-14.1.0

I am struck once again by how incredibly baroque and cumbersome the Debian packaging process has become. Its too bad. I did not build an apt repo, there's no straightforward way to do that. Again, too bad.

This Gambit compile did not produce any shared libraries, which improves the chances that one can run them on similar, but not identical, Linuxes. I'm almost certain these will install & run on Debian or Ubuntu-based Mint. If not, all of the stuff to rebuild is uploaded in the same directory.

This version of Gambit does require the wxWidgets 2.8 or newer. In the end, I used the newest ones I could get more-or-less easily. I used the wx from the EPEL repo on the EL7 system. That provided:

wxGTK-media-2.8.12-13.el7.x86_64
wxGTK-gl-2.8.12-13.el7.x86_64
wxBase-2.8.12-13.el7.x86_64
wxGTK-2.8.12-13.el7.x86_64
wxGTK-devel-2.8.12-13.el7.x86_64

It appears to me I may have been conservative there, I did not intentionally avoid the packages named wxGTK3 on EPEL, I simply took the first set I understood. If you require RPM based on wxGTK3, I think i can do it. Just let me know.

On the Ubuntu system, the wx 3.x is available in the default repositories. However, there is an allegation of an unpatched bug (which I've not experienced). Currently, I'm running with these packages:

libwxgtk3.0-dev_3.0.1-3_amd64.deb
libwxgtk3.0-dev_3.0.2-1.utopic_amd64.deb
wx3.0-headers_3.0.1-3_amd64.deb
wx3.0-headers_3.0.2-1.utopic_amd64.deb
wx-common_3.0.1-3_amd64.deb
libwxgtk3.0-0-unofficial_3.0.2-1.utopic_amd64.deb

Note the last one is the "unofficial" version, that's an update from the non-base repo. In my heart, I don't think you really need that, but I was feeling compulsive and downloaded it from the wx home site. If you want your Ubuntu to work exactly like mine, you can install this repo

deb http://repos.codelite.org/wx3.0.2/ubuntu/ utopic universe

I found that by Mr. Google, same way you would, I expect (https://www.wxwidgets.org leads you to https://www.wxwidgets.org/downloads which leads to http://codelite.org/LiteEditor/WxWidgets30Binaries#toc2).

There is an open question on how to package some working examples and make them easy for users of these packages. I've asked in the gambit email list. In the olden days, I recall packging up the Gambit test programs with this and telling users how to run from the command line to test the calculations. I can't find any evidence of that now, however. It would be nice if we could set this up to install some examples that are supposed to run. Maybe call them templates or whatnot. They may be in the source code now, but I'm too careless to find them. What do you think?

I promised one user I'd demonstrate steps to compile Gambit on EL7.

I did a "manual compile" as a non-root user that installed into /tmp, for exploration. The session was in an Emacs shell, here it is, errors and all:

https://pj.freefaculty.org/scraps/gambit-build-201505.txt

I had to install wxWidgets devel support from the EPEL repository. In case you want to see what the RPM building process does, here is the output

https://pj.freefaculty.org/scraps/gambit-RPM-build.txt

Posted in Linux | Tagged , , , | Leave a comment

Compiz, Multi-Head, Workspace Backgrounds

The approach described in the post earlier this week works well on single-head systems, but not when there are several monitors. Compiz handles these differently than XFCE4 or Gnome, causing some revision in the script.

Since Compiz treats the combined monitors as a single workspace, it is not actually possible to show separate images on the separate monitor backgrounds. There is a workaround, however: Use ImageMagic montage to manufacture a large image and then let compiz display that. I wanted the script to be flexible, so the -w argument now has 4 roles.

If -w -2, then all workspace backgrounds will be reset with randomly drawn images from one directory
If -w -1, then all workspaces are set to the same background
If -w n, for any "n'th" workspace, then that workspace will be replaced
If -w n > existing number of compiz wallpapers, then the new image will be added for the n+1'th workspace.

The -p argument determines whether we are setting for one page (one monitor) or two pages (2 monitors).

WIthout further adieu, here's the script that works. I never wrote anything in Python before, so take mercy


#!/usr/bin/env python3

## Paul E. Johnson 
## 20150102

## A script to randomly reassign compiz background images for viewports.
## Recall compiz after 0.9.2 uses "viewports" to simulate workspaces.

## Will choose an image file randomly from within dir hierarchy. 

## Can replace one viewport's wallpaper.  The w argument will be
## interpreted in one of 3 ways 

## 
## 1. If w is either 0 or -1, this means remove all
## existing wallpapers and replace with one randomly chosen image.
##
## 2. If w is -2, then all workspace backgrounds will be replaced
## with different images from same directory
##
## 3. If 1 < = w <= N (where there are N wallpaper images already
## defined), then the image on viewport w will be replaced. All of the
## other images will remain the same.
##
## 4. If N < w, we interpret this as a request to expand the
## wallpaper array by one.
## 

## I thought it was a little interesting to make types 1 and 3
## work together with compiz. To change the number of wallpapers,
## it is required to correctly change these variables in the
## wallpaper plugin as well:
## "bg-fill-type"
## "bg-image-pos"
## "bg-color1", 
## "bg-color2", s

## I had previously been doing this by dbus-send, but compiz's
## interaction with dbus has become less and less stable, so this version
## uses "gsettings".

## About the schema argument:
## Because I do not use Unity as my desktop environment, I have to point
## SCHEMA at the location where compiz stores wallpapers. If you get
## compiz working with XFCE4, for example, make sure you use the Gsettings
## backend and DO allow Compiz to interact with the desktop environment in
## advanced settings. 

## If you are using Unity, you probably need to change the path, removing
## "Default" with "unity".  You can do from command line or by editing script.

## If you want to know how to get Compiz going without the Unity Desktop, 
## this is not a bad set of advice 
## http://www.webupd8.org/2012/11/how-to-set-up-compiz-in-xubuntu-1210-or.html
## If you have Unity installed, it is necessary to remove it, or else
## launching compiz with the Gsettings back end gets Ubuntu all confused and
## Unity keeps starting at same time. If you have trouble with that, I can help


import argparse
import subprocess
import sys
import os
import random

parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dir",  help = "directory path", 
                    default = "/usr/local/share/Backgrounds")
parser.add_argument("-p", "--pages",  help = "pages", 
                    default = "1", type = int)
parser.add_argument("-w", "--workspace", 
                    help = "workspace number, -1,  0, 1-n, or > n", default = "0", 
                    type = int)
parser.add_argument("-schema", help = "gsettings shema", 
                    metavar = "SCHEMA", default = "org.compiz.wallpaper:/org/compiz/profiles/Default/plugins/wallpaper/")
parser.add_argument("-key", help = "gsettings key", metavar = "KEY", default = "bg-image")
args = parser.parse_args()

array = eval(subprocess.check_output(["gsettings", "get", args.schema, args.key]))

## print(array)
arraylen = len(array)

## python arrays index 0, ... , N-1, so downshift workspace number
ws = args.workspace - 1

def getFn( pages, mydir, myws ):
    if pages > 1:
        dirlist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in dn]
        if (len(dirlist) > 0):
            filelist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(random.choice(dirlist))) for f in fn]
        else:
            filelist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in fn]
        print(filelist)
        filename1 = random.choice(filelist)
        filename2 = random.choice(filelist)
        newfn = '/tmp/dual-%d.jpg' % myws
        if (os.path.isfile(newfn)) == True:
            os.remove(newfn)
            newfn = '/tmp/dual-%d.%s.jpg' % (myws, "2")
        subprocess.call(["montage", filename1, filename2, "-tile",  "2x1", "-geometry", "1600x1200+0+0", "-background", "black", newfn])
        filename = newfn
    else:
        filename = random.choice([os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in fn])
    print("The newly found filename is:")
    print(filename)
    return filename




## print("Array length was")
## print(arraylen)

## If ws 0 or smaller, we are going to reset whole collection back to
## just one image. if ws > N of images, then add a new image.
if ws == -3:
    for num in range(len(array)):
        array[num] =  getFn(args.pages, args.dir, num)

    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
elif ws < 0:
    filename = getFn(args.pages, args.dir, 1)
    array=[str(filename)]
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
    subprocess.call(["gsettings", "set", args.schema, "bg-fill-type", str("[0]")])
    subprocess.call(["gsettings", "set", args.schema, "bg-image-pos", str("[0]")])
    subprocess.call(["gsettings", "set", args.schema, "bg-color1", str("['#000000ff']")])
    subprocess.call(["gsettings", "set", args.schema, "bg-color2", str("['#000000ff']")])
elif ws < arraylen:
    filename = getFn(args.pages, args.dir, ws)
    array[ws]=str(filename)
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
else:
    filename = getFn(args.pages, args.dir, len(array))
    array.append(str(filename))
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
    arraylen = len(array)
    subprocess.call(["gsettings", "set", args.schema, "bg-fill-type", str([0]*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-image-pos", str([0]*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-color1", str(['#000000ff']*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-color2", str(['#000000ff']*arraylen)])



subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])


print("HELLO, corrected image array is:")               
print('\n '.join(array))

Now, if you don't want to use Compiz, but instead any other XFCE4 compatible window manager, such as OpenBox, then you can use XFdesktop to draw separate backgrounds on the monitors. I've done that too.

Posted in Linux | Tagged , , | Leave a comment

Success: compiz wallpapers changed via python script (Ubuntu 14.10 XFCE4)

I started using Linux because it had cool desktop features that made it fun and interesting. The compiz window manager was a highlight, but I stopped using it for a while because I could not make the dbus commands work to change the background after version 0.9 or so. I don't enjoy Unity, but do like XFCE4, and have been using the Openbox window manager.

Openbox is OK, but it lacks flavor. No wobbly windows, not garish animations that we love so much.

Recently, on Ubuntu 14.10, using XFCE4 as the main desktop environment, I had some time and decided to re-investigate ways to run Compiz. Most things are working well now, especially since I have this swell new script
to change wallpapers. There are some verbose comments at the beginning.

A key benefit of this approach is it handles a lot of book keeping, so the script can eliminate the entire wallpaper vector and replace with one image, or it can replace a single image within the wallpaper vector, or it can grow the vector. I'll paste in an example session after the code.

If you want to know how to get Compiz going without the Unity Desktop,
this is not a bad set of advice
http://www.webupd8.org/2012/11/how-to-set-up-compiz-in-xubuntu-1210-or.html

Caution: Do follow the advice to run ccsm before starting Compiz, and DO
enable the plugins. TURN ON wallpapers.

Caution: In the separate ccsm preferences dialogue (bottom left, above "advanced search"), make sure you choose the Gsettings backend and do allow the interaction with the desktop environment.

Caution: If you have Unity installed, it is necessary to remove it, or else
launching compiz with the Gsettings back end gets Ubuntu all confused and
Unity keeps starting at same time. If you have trouble with that, I can help

#!/usr/bin/env python3

## Paul E. Johnson 
## 20150102

## A script to randomly reassign compiz background images for viewports.
## Recall compiz after 0.9.2 uses "viewports" to simulate workspaces.

## Will choose an image file randomly from within dir hierarchy. 

## Can replace one viewport's wallpaper.  The w argument will be
## interpreted in one of 3 ways 
## 
## 1. If w < 1, (either 0 or a negative number), this means remove all
## existing wallpapers and replace with one randomly chosen image.
##
## 2. If 1 <= w <= N (where there are N wallpaper images already
## defined), then the image on viewport w will be replaced. All of the
## other images will remain the same.
##
## 3. If N < w, we interpret this as a request to expand the
## wallpaper array by one.


## I thought it was a little interesting to make types 1 and 3
## work together with compiz. To change the number of wallpapers,
## it is required to correctly change these variables in the
## wallpaper plugin as well:
## "bg-fill-type"
## "bg-image-pos"
## "bg-color1", 
## "bg-color2", s

## I had previously been doing this by dbus-send, but compiz's
## interaction with dbus has become less and less stable, so this version
## uses "gsettings".

## About the schema argument:
## Because I do not use Unity as my desktop environment, I have to point
## SCHEMA at the location where compiz stores wallpapers. If you get
## compiz working with XFCE4, for example, make sure you use the Gsettings
## backend and DO allow Compiz to interact with the desktop environment in
## advanced settings. 

## If you are using Unity, you probably need to change the path, removing
## "Default" with "unity".  You can do from command line or by editing script.



import argparse
import subprocess
import sys
import os
import random

parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dir",  help = "directory path", 
                    default = "/usr/local/share/Backgrounds")
parser.add_argument("-w", "--workspace", 
                    help = "workspace number, 0, 1-n, or > n", default = "-1", 
                    type = int)
parser.add_argument("-schema", help = "gsettings shema", 
                    metavar = "SCHEMA", default = "org.compiz.wallpaper:/org/compiz/profiles/Default/plugins/wallpaper/")
parser.add_argument("-key", help = "gsettings key", metavar = "KEY", default = "bg-image")
args = parser.parse_args()

array = eval(subprocess.check_output(["gsettings", "get", args.schema, args.key]))

## print(array)
arraylen = len(array)

filename = random.choice([os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(args.dir)) for f in fn])
print("The newly found filename is:")
print(filename)

## print("Array length was")
## print(arraylen)

## python arrays index 0, ... , N-1, so downshift workspace number
ws = args.workspace - 1

## If ws 0 or smaller, we are going to reset whole collection back to
## just one image. if ws > N of images, then add a new image.
if ws < 0:
    array=[str(filename)]
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
    subprocess.call(["gsettings", "set", args.schema, "bg-fill-type", str("[0]")])
    subprocess.call(["gsettings", "set", args.schema, "bg-image-pos", str("[0]")])
    subprocess.call(["gsettings", "set", args.schema, "bg-color1", str("['#000000ff']")])
    subprocess.call(["gsettings", "set", args.schema, "bg-color2", str("['#000000ff']")])
elif ws < arraylen:
    array[ws]=str(filename)
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
else:
    array.append(str(filename))
    subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])
    arraylen = len(array)
    subprocess.call(["gsettings", "set", args.schema, "bg-fill-type", str([0]*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-image-pos", str([0]*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-color1", str(['#000000ff']*arraylen)])
    subprocess.call(["gsettings", "set", args.schema, "bg-color2", str(['#000000ff']*arraylen)])



subprocess.call(["gsettings", "set", args.schema, args.key, str(array)])

print("HELLO, corrected image array is:")               
print('\n '.join(array))

I've got a massive background image collection, I think you'll get the idea

First, I'll give a negative value for w, so all existing wallpapers will be replaced by one:

$ ./pjbg.py -w -1 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg

Second, lets grow some more wallpapers

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
 /usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Italy/DOT_Italy_XIII_Venice_086.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
 /usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg
 /usr/local/share/Backgrounds/Italy/DOT_Italy_XIII_Venice_086.jpg

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Scenery/DOT_Colorado_IV_009_Mesa_Verde_National_Park.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
 /usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg
 /usr/local/share/Backgrounds/Italy/DOT_Italy_XIII_Venice_086.jpg
 /usr/local/share/Backgrounds/Scenery/DOT_Colorado_IV_009_Mesa_Verde_National_Park.jpg

After that, I have 5 wallpaper images stored. So when I run the same command again, the
program no longer adds a new element, but it instead replaces workspace 5.

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/Scenery/Sozaijiten_085-Mountains-091_dbg.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
 /usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg
 /usr/local/share/Backgrounds/Italy/DOT_Italy_XIII_Venice_086.jpg
 /usr/local/share/Backgrounds/Scenery/Sozaijiten_085-Mountains-091_dbg.jpg

$ ./pjbg.py -w 5 -d /usr/local/share/Backgrounds
The newly found filename is:
/usr/local/share/Backgrounds/dot_greece_ix_cape_sounion_poseidon_temple_3.jpg
HELLO, corrected image array is:
/usr/local/share/Backgrounds/Water/DOT_Arizona_VII_Grand_Canyon_Clear_Creek_6.jpg
 /usr/local/share/Backgrounds/Scenery/Village_in_Alta_Roca_Region_Corsica_France.jpg
 /usr/local/share/Backgrounds/Scenery/dot_peru_machu_picchu_7.jpg
 /usr/local/share/Backgrounds/Italy/DOT_Italy_XIII_Venice_086.jpg
 /usr/local/share/Backgrounds/dot_greece_ix_cape_sounion_poseidon_temple_3.jpg

You can monitor the effect of this in 2 ways.

1. Run "ccsm", look in the Wallpapers plugin
2. Run "dconf-editor", look under org.... to see the settings change.

After all of that, you end up with a vector of viewports

Posted in Linux | Tagged , , | Leave a comment

ssh: too many authentication failures

Did you follow along with the instructions to make ssh connections "automatic" and "secure" with your favorite servers by transferring your public keys to the authorizedKeys file an then editing your ~/.ssh/config?

The .ssh/config file fills up with entries like this

Host *.fedoraproject.org fedorapeople.org *.fedorahosted.org
IdentityFile ~/.ssh/pjfedora-20111114
IdentitiesOnly yes

Host svn.*gnu.org
IdentityFile ~/.ssh/PaulJohnson-id_rsa-20110510
IdentitiesOnly yes

If you did that for a few servers (and it is, well, required on lots of servers I use), then you will start to get this error when you try to connect to the places that used to work:

$ ssh 129.237.49.83
Kernel 3.10.0-123.13.2.el7.x86_64 on an x86_64
Received disconnect from 129.237.49.83: 2: Too many authentication failures for pauljohn

It used to work, but no more. The ssh system is reading your ~.ssh/config file, finding lots of identities in there, throwing them at the remote server, and the server's patience is exhausted with your and you get rejected.

To work around this, you have to tell the remote system to not try to use your keys. I find both of these work, don't know if one is preferred to the other:

$ ssh -o IdentitiesOnly=yes 129.237.49.83

$ ssh -o PubkeyAuthentication=no 129.237.49.83

Both of those work for me.

To me, the very difficult thing is to remember either one of those because I forget 99% of the time that I need to do that. So I wrote it in the blog, and I can't forget. Can I?

WARNING

Do not follow the advice you see on some Websites that you should insert

IdentitiesOnly yes

at the top of yoru config file. We found that several connections that were otherwise valid would fail after making that change. We had weird problems with SparkleShare after that change, for example.

WARNING

Don't make your server less secure by allowing more failed logins. How silly is that 🙂

Posted in Uncategorized | Leave a comment

R’s drop “gotcha” and the diag “curse”

This title is too dramatic. But it is justified. There really is a "drop gotcha" that has crushed my spirits, and the diag "curse" has caused me to lose sleep on many occasions.

In 2013, I noticed a problem in several of my functions. I call this problem the "drop gotcha." I've been meaning to write it up for the blog, but am lazy and was just sending everybody some emails about it. Now I'm collecting that up.

This one has some general educational value, I think, for R programming. I may put it into the Rchaeology vignette, it is by far the most common flaw in otherwise well written functions. Virtually everybody I know has had the "drop gotcha".

The problem is that R tries to simplify data structures, and sometimes we accidentally wander into the "simplify-able" range, and then ZAP!. We are often working with matrices, and we are going write code that chooses rows or columns. The program, or the user through the program, is supposed to choose pieces from a matrix, and along the way that matrix gets "damaged" an so we get crashes, but only sometimes. Sometimes we get WRONG answers, which is worse.

The first problem: the diag() function can give an unexpected answer, or fails,
when you least expect it. This is due to the fact that diag() is both an
extractor and a creator function. Those 2 purposes make the function appear
"handy" and economical, but it is sometimes a real frustration.

One purpose of diag() is to create a diagonal matrix with p elements, say p = 4

> X <- diag(4) 
> X
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    1    0    0
[3,]    0    0    1    0
[4,]    0    0    0    1

If the argument is a vector, all is well, it puts a vector along the diagonal of the properly sized matrix.

> X <- diag( c(1,2,3,4) ) 
> X
     [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]    0    2    0    0
[3,]    0    0    3    0
[4,]    0    0    0    4

On the other hand, if p happens to be a matrix, then diag will extract the
diagonal, creating a vector.

diag(X) is

> X <- diag( c(1,2,3,4) ) 
> diag(X)
[1] 1 2 3 4

The problem is that diag does something with anything it finds, and so you often don't know you got the wrong thing until something turns out completely
incorrect.

Suppose you want to extract the diagonal of a sub-part from X. All is well if we have more than one element:

> Y <- X[3:4, 3:4] 
> is.matrix(Y)
[1] TRUE
> diag(Y)
[1] 3 4

Suppose there's some calculation that ends up just needing row 2, column 2. We
have many cases like this, if we are taking elements from a covariance matrix,
for example. Try to take the diagonal from that part.

> Y <- X[2,2] 
> Y
[1] 2

Appears correct, yes?

That will fail horribly when we try to get diag from Y. We want just the number
"2", since the diagonal is the same as the whole matrix Y

> Y <- X[2,2] 
> diag(Y)
     [,1] [,2]
[1,]    1    0
[2,]    0    1

This makes the horror more obvious:

> X <- matrix( rnorm(16), nrow=4) 
> X
           [,1]       [,2]        [,3]       [,4]
[1,]  0.1731106  1.3570314 -1.62255241 -1.7614656
[2,] -1.0023882 -0.2765341  0.17372976 -1.2202468
[3,] -1.0521568 -0.4828088 -0.22638791  0.8388842
[4,]  1.4163970  0.9988008  0.04774671 -0.3987813
> Y <- X[2:3, 2:3] 
> diag(Y)
[1] -0.2765341 -0.2263879
> Y <- X[2, 2] 
> diag(Y)
<0 x 0 matrix>

The diag() function does not know how to respond to this:

diag(-0.2765341)

And why does it get -02765341 instead if X[2, 2]?

Answer: the drop curse.

Run it like this instead:

> Y <- X[2, 2, drop = FALSE]
> Y
           [,1]
[1,] -0.2765341
> diag(Y)
[1] -0.2765341

If I were designing R, I wouldn't do this. But R has a common source of feature, which is that it tries to "simplify" and "downgrade" objects where possible.

X[2,2]

is not a matrix with 1 element, it becomes just a vector with 1 element.

Adding the drop = FALSE as a third argument tells it "keep this as a matrix". If you want to choose a single column out of a matrix, but you want the result to still be a matrix with one column, rather than an R vector, which is quite a different thing, run

X[ , 2, drop = FALSE]

In other words, I want column 2, and don't try to simplify this for me by dropping the dimension.

Sometimes you'll see people invent a "little dance", checking each individual calculation to see if R has employed the automatic coercion to a smaller dimension.  Its not necessary, if all transactions with a matrix use the drop = FALSE argument.

I guess I haven't really explained why this comes up, and why it hits the rockchalk package so hard. I have a lot of instances where the flow is like this. A data frame X exists. There might be 20 columns, and some criteria are applied and a few columns are chosen. All is well if the calculation is like this:

Xsub <- X[ , c("A", "B","C")]

to choose 3 columns. However, suppose the column choose variable is created separately, and it is used like this

myMagicChooserVector <- unknownFunction()
Xsub <- X[ , myMagicChooserVector]

If myMagicChooserVector has 2 or more variable names, all is well. But if myMagicChooserVector is c("B"), for example, then the Xsub result here is NOT a matrix.

Xsub <- X[ , myMagicChooserVector]

In the middle of some complicated calculation, you might be thinking that thing is a matrix still, and you ask for row 1, mistakenly

Xsub[1, ]

But you've shot yourself in the foot. Xsub is a vector now, it does not have rows or columns anymore. Run this for yourself, it is easy to see.

> X <- matrix(rnorm(9), ncol = 3)
> Xsub &ly;- X[ ,3]
> Xsub[1, ]
Error in Xsub[1, ] : incorrect number of dimensions

You can stay out of trouble if you remember to add drop = FALSE

> Xsub <- X[ , 3, drop = FALSE]

I would like to have a global option for my programs and packages so that drop
always equals FALSE. I would rather manually shrink things from matrices to
vectors than have to "defensively code" everything to avoid accidental demotion.

pj

Posted in Uncategorized | Leave a comment

Toggle panel below or above

I like to place windows so I only see the bottom half. I like to move windows almost off the screen so I can see something else.

The current trend, to make the window manager in Linux work like a cell phone, tries to block that. One of the things that really bothers me is that they try to keep the panel on top, all the time, you can't get a window over it.

Step one is to make the window manager allow you to move the window frame outside of the desktop. This is different in every window manager. In compiz, there's a setting "constrain Y" that you turn off.

The other problem is to force the panel itself into the background. In 2013, I discovered there is a common desktop standard that offers an avenue to do this. I ran this interactively to test, then scripted it up.

wmctrl -l scans the existing objects, then we find panels, and we tell the panel to go into the bottom layer or the back to the top. This has behaved a little differently over time, with new OS

I think you'll figure it out if you study these two scripts.

$ cat togglePanelAbove.sh
#!/bin/bash

wmctrl -l | grep panel | awk '{print "wmctrl -v -i -r " $1 " -b remove,below"}' | bash

wmctrl -l | grep panel | awk '{print "wmctrl -v -i -r " $1 " -b add,above"}' | bash

$ cat togglePanelBelow.sh
#!/bin/bash

wmctrl -l | grep panel | awk '{print "wmctrl -v -i -r " $1 " -b remove,above"}' | bash

wmctrl -l | grep panel | awk '{print "wmctrl -v -i -r " $1 " -b add,below"}' | bash

I have that associated to keyboard shortcuts. It has worked in compiz and openbox and xfwm4. I lately see trouble in xfce4 that they are blocking my customizations that use the Super (Windows key) as a modifier. That's really frustrating. I gather it is a result of their desire to have whiskermenu, and in order to leave space for that, they are tyranically regulating our use of Super. Too dramatic, I know. They introduced a flaw by accident that will probably get worked out in time 🙂

Leave a comment

Ubuntu 14.04 on Dell Ultrabook 6430u

I inherited a Dell ultrabook 6430u from a departing colleague. I would not have chosen this system because the display is somewhat, well, crappy (terrible viewing angles), but I'm making the best of it.

This is the first PC I've used that does not have nvidia video in a long time. It is nice to not install the special driver,
but the Intel video quality seems not great. I see a lot of tearing in the display.

I created an encrypted LVM with the Ubuntu installer. We'll see how stable that is. It gobbled up the whole disk, put
the /home folder in one giant partition. It was a very tough exercise to make smaller logical volumes so I could segregate /home. That's not a new problem, not different from RedHat based systems. The problem here was that the setting to turn on a encrypted drive switched to LVM and the one giant disk
setup.

1. R CRAN configure:

/etc/apt/sources.list.d

$ cat cran.list
deb http://rweb.quant.ku.edu/cran/bin/linux/ubuntu trusty/

Run the securty key as described in the CRAN instructions.

2. Prevent accidental file erasure. This was default at one time.
For all users, in all shells, I want "rm" to work like "rm -i" so it asks
for permission to destroy files. I tried putting this in /etc/bash.bashrc, but changes there were
ignored in login shells. Then tried /etc/profile. That does only work for login shells. Really? I have to make the
same change in 2 files to make all shells work properly? Silly

/etc/profile
/etc/bash.bashrc

# alert for rm, cp, mv
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

other ones to consider inserting

# color and with classfication
alias ls='ls -F --color=auto'
alias ll='ls -alF'

# grep
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

3. OMG. vi arrow keys don't work. Why do they leave this as default?
It must kill ever new user who tries to be a good Unix person with vi
and it works in none of the virtual terminals that Ubuntu supplies.

In the folder /etc/vim/vimrc.local

# cat vimrc.local
set nocompatible

4. don't erase /tmp upon reboot

edit /etc/default/rcS

TMPTIME=30

5. touchpad too sensitive. jumpy, erratic. I tested this a long
time, found some relief in synclient settings, but also needed
to patch the driver. The patch was released June, 2014,
maybe will find into synaptics upstream. Maybe a person
should try the synclient settings first, then try that.
To customize the synclient settins, put the synclient
defaults in a file in

/etc/X11/xorg.conf.d/90-synclient.conf

Its the only file in there on my system.
In the old OS, there was a template file for that in
/usr/share, but I'm not finding that today.

#
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
MatchDevicePath "/dev/input/event*"
EndSection

Section "InputClass"
Identifier "touchpad ignore duplicates"
MatchIsTouchpad "on"
MatchOS "Linux"
MatchDevicePath "/dev/input/mouse*"
Option "Ignore" "on"
EndSection

# This option enables the bottom right corner to be a right button on
# non-synaptics clickpads.
# This option is only interpreted by clickpads.
Section "InputClass"
Identifier "Default clickpad buttons"
MatchDriver "synaptics"
Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
# To disable the bottom edge area so the buttons only work as buttons,
# not for movement, set the AreaBottomEdge
# Option "AreaBottomEdge" "82%"
EndSection

# This option disables software buttons on Apple touchpads.
# This option is only interpreted by clickpads.
Section "InputClass"
Identifier "Disable clickpad buttons on Apple touchpads"
MatchProduct "Apple|bcm5974"
MatchDriver "synaptics"
Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
EndSection

Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "HorizTwoFingerScroll" "1"
Option "VertTwoFingerScroll" "1"
Option "PalmDetect" "1"
Option "VertEdgeScroll" "1"
Option "CornerCoasting" "1"
Option "RightEdge" "1600"
Option "FingerHigh" "20"
Option "FingerLow" "15"
Option "VertHysteresis" "50"
Option "HorizHysteresis" "50"
Option "PalmMinWidth" "10"
Option "PalmMinZ" "30"
EndSection

6.

Posted in Uncategorized | Leave a comment

Swarm and Ubuntu 14.04: Package uploads

A couple of very pleasant students have been writing to ask for help on running some Swarm apps and yesterday I decided to rebuild some packages to try to smooth out the process. Here are the things I can remember. This process is getting more and more like a stitched together set of my guesses because I have never been comfortable with automake and autoconf languages.

First, some system changes.

1. the dash shell is default, but it doesn't work. It is necessary to replace that with bash. That will be needed for various other research software, so just do it.

Look in /bin, see that sh is a symlink to dash? Replace it

sudo ln -sf /bin/bash /bin/sh

2. It is VITAL that gcc-4.6 and gobjc-4.6 be available. Install those packages, then make the system use them. I did this

sudo ln -sf /usr/bin/gcc-4.6 /usr/bin/gcc

That's not the least intrusive method, you could set the environment.

# export CC=gcc-4.6

I think should suffice. You have to remember to do this all the time.

3. The debian packages for blt and swarm are required.

https://pj.freefaculty.org/Ubuntu/14.04/i386

https://pj.freefaculty.org/Ubuntu/13.10/amd64

Today I did a new Ubuntu 32 bit set. I was mistakenly thinking that was a user's priority need, but after I figured out how to make that work, I knew how to fix the 64 bit things as well.

These are minimally required

https://pj.freefaculty.org/Ubuntu/14.04/i386/blt/blt-dev_2.4z-8pj8.5_i386.deb
https://pj.freefaculty.org/Ubuntu/14.04/i386/blt/blt_2.4z-8pj8.5_i386.deb

https://pj.freefaculty.org/Ubuntu/14.04/i386/swarm/libswarm-dev_2.4.1-5_i386.deb
https://pj.freefaculty.org/Ubuntu/14.04/i386/swarm/libswarm0_2.4.1-5_i386.deb

If you want to try Java Swarm (which I don't use)
https://pj.freefaculty.org/Ubuntu/14.04/i386/swarm/libswarm-java_2.4.1-5_all.deb

I built these in a brand new virtual machine with Ubuntu 14.04, i386. I believe if you are on an U buntu amd64 system, you could install the i386 packages if your system is set up to allow multilib. These i386 will bring in a number of other 32 bit packages. I expect it will draw in 32bit versions of tcl, tk, gcc, blt, and, well, maye lots of others. We are stuck there in i386 land if we want to try Java Swarm. There is a fairly deep, fundamental problem in the foreign language interface that blocks us to only use gcc-4.6 and also prevents 64 bit use of Java.

On a 64 bit system, I did not yet make packges for Ubuntu-14.04, but I think these will work:

https://pj.freefaculty.org/Ubuntu/13.10/amd64/blt/blt-dev_2.4z-8pj8.5_amd64.deb
https://pj.freefaculty.org/Ubuntu/13.10/amd64/blt/blt_2.4z-8pj8.5_amd64.deb

https://pj.freefaculty.org/Ubuntu/13.10/amd64/swarm/libswarm-dev_2.4.1-4_amd64.deb
https://pj.freefaculty.org/Ubuntu/13.10/amd64/swarm/libswarm0_2.4.1-4_amd64.deb

On my own 64 bit laptop, I still have Ubuntu 13.10, and I have built packages for that as well. The BLT package is basically the same as the one I offer for 32 bit systems, except (for reasons I don't entirely understand) the -fPIC compiler flag comes into play. But it works.

The dbg packages are not required to compile and run programs, but they are needed to run them in gdb.

The blt provided with Ubuntu 13.10 or 14.04 won't work because it tries to marry together tcl tk 8.5 and 8.6 in a way that causes programs to crash. The good news is that the Debian team incorporated all the patches I put together for blt and tcl 8.5, so it was a relatively easy thing to take their packaging for blt in 14.04 and re-set it to use only tcl/tk 8.5. I was very glad to see they incorporated those blt packages, it is now a much cleaner set of patches.

Oh, I signed these with my Debian packaging signing key. Its registered on their worldwide network.
You'll find it in the network if you check for:
Paul E. Johnson (Debian Packaging)

You either need to accept that key or you tell you system to ignore keys.

4. To test the installation, work with the objective C Swarm progams. Start with heatbugs and schelling Swarm from here:

https://pj.freefaculty.org/Swarm/swarmapps-2.3.0.tar.gz

When you try to compile, it will be necessary to set SWARMHOME to "/". Not /usr as we have in most of the examples. You can do that in your environment or by editing the program's Makefile.

When you test these, please PLEASE read the README files and try the special compiler arguments to use PNG and HDF5 when available. It turned out yesterday that one person thought Swarm was installed and working because heatbugs ran, but he did not realize he was lacking PNG or HDF5 support because he was not trying any of those features.

5. Some compiles will fail because gcc's linking policy has changed. Libraries that we took for granted now must be named explicitly. This came up when I used a math symbol, the error has something about DSO blah. Here is an example from my 64 bit system:

AVLSet.m: In function ‘compare_object_ids’:
AVLSet.m:21:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
AVLSet.m:22:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
AVLSet.m: At top level:
AVLSet.m:440:1: warning: incomplete implementation of class ‘AVLSet’ [enabled by default]
AVLSet.m:440:1: warning: method definition for ‘-conformsTo:’ not found [enabled by default]
AVLSet.m:440:1: warning: class ‘AVLSet’ does not fully implement the ‘DefinedObject’ protocol [enabled by default]
gcc -c -g -O2 -fgnu-runtime -fno-strict-aliasing -Wall -Wno-import -Wno-protocol -Wno-long-long  -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -DAPPNAME=opinion -DAPPVERSION=2.1.1 -DBUGADDRESS=bug-swarm@swarm.org   -I/usr/include/swarm  SwarmInteger.m
/bin/sh /usr/bin/libtool-swarm --mode link /usr/bin/gcc-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -L/usr/lib/x86_64-linux-gnu/swarm -rpath /usr/lib/x86_64-linux-gnu/swarm    -o opinion main.o Parameters.o ModelSwarm.o ObserverSwarm.o BatchSwarm.o MultiGrid2d.o MultiGridCell.o AppSpecificCell.o MyArguments.o  Attribute.o BatchRaster.o BatchColormap.o CountHeads.o Citizen.o Axelrod.o HJCitizen.o SelectiveCitizen.o Coleman.o MikePM2.o MovingAverage.o Position.o TimeStamp.o AVLSet.o SwarmInteger.o  -lswarm
libtool-swarm: link: /usr/bin/gcc-4.6 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -o opinion main.o Parameters.o ModelSwarm.o ObserverSwarm.o BatchSwarm.o MultiGrid2d.o MultiGridCell.o AppSpecificCell.o MyArguments.o Attribute.o BatchRaster.o BatchColormap.o CountHeads.o Citizen.o Axelrod.o HJCitizen.o SelectiveCitizen.o Coleman.o MikePM2.o MovingAverage.o Position.o TimeStamp.o AVLSet.o SwarmInteger.o  -L/usr/lib/x86_64-linux-gnu/swarm /usr/lib/x86_64-linux-gnu/swarm/libswarm.so -Wl,-rpath -Wl,/usr/lib/x86_64-linux-gnu/swarm -Wl,-rpath -Wl,/usr/lib/x86_64-linux-gnu/swarm
/usr/bin/ld: ModelSwarm.o: undefined reference to symbol 'pow@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
make: *** [opinion] Error 1

Read the error. It is saying a function pow is not defined, meaning its library is not linked. We need it to use the math library, libm, for which the flag is "lm". I found a fix is to insert this in the app's Makefile

APPLIBS=-lm

I put that right before the line that says:
include $(SWARMHOME)/etc/swarm/Makefile.appl

While building the Deb packages, I ran into something that I was unsure about. Now, on this particular Ubuntu i386 system, the libraries are stored in /usr/lib/i386-linux-gnu, not /usr/lib as we had in the old days. In the early multilib days, the libraries were sorted into /usr/lib32 and /usr/lib64. The Swarm build today fails to find library files unless I expliciatly hack the configure statement. Where the current configure has a thing that looks for libraries in /usr/lib /usr/lib32 /usr/lib64, I just edited and replaced the middle one by /usr/lib/i386-linux-gnu. After I realized that would work, it magically solved all of the Swarm troubles I was having. Apps were all of the sudden able to find pixmaps and hdf5.

When I rebuilt the Swarm for 64 bit, I found the same kind of thing had to be done. I had to change /usr/lib64 to /usr/lib/x86_64-linux-gnu

This seems to be a pain in the ass, gratuitious renaming of things for purposes of enhanced navel-gazing. But it all works now. I've verified I have loadable PNG and HDF5 support.

Posted in Linux | Tagged | Leave a comment