Jenkins, Kerberos and Python

Trying to talk to Jenkins while authenticating with Kerberos and getting

GSSException: No credential found for: 1.2.840.113554.1.2.2 usage: Accept

Using requests_gssapi and specifying SPNEGO:

import gssapi
import requests
from requests_gssapi import HTTPSPNEGOAuth

login = 'http://jenkins/login'
job = 'http://jenkins/view/.../job/.../'

# GSSException: No credential found for: 1.2.840.113554.1.2.2 usage: Accept
spnego = gssapi.mechs.Mechanism.from_sasl_name("SPNEGO")

s = requests.Session()

rl = s.get( login, auth=HTTPSPNEGOAuth( mech=spnego ) )
rj = s.get( job )

works for me.

ldapsearch, Kerberos and Active Directory

Trying to use -Y GSSAPI when ldapsearching Active Directory and getting:

SASL/GSSAPI authentication started
ldap_sasl_interactive_bind_s: Local error (-2)
        additional info: SASL(-1): generic failure: GSSAPI Error: An invalid name was supplied (Success)

Does the host’s IP address you try to connect to not resolve back to it’s name, for example:

ldapsearch -H ldap://gc.local/

gc.local has address 192.168.0.1
1.0.168.192.in-addr.arpa domain name pointer foo.local.
foo.local has address 192.168.0.1

Try using the other name: ldapsearch -H ldap://foo.local/

Jolokia agent and Artifactory

Is Artifactory not starting when you specify Jolokia as a javaagent? Do you see

error opening zip or jar manifest missing

in your log? Unpacking jolokia.jar, copying ./META-INF/MANIFEST.MF to ./ and repacking helped me.

Icinga Locale

Getting Unable to interpret /usr/bin/free output? Make sure your locale is not set to something weird, e.g. not C.

Icinga Eventstream

Need to debug if data is sent from a satelite to your master? Use an event stream to filter for CheckResults from hosts matching *foo*:

curl -N -k -s -u 'x:y' \
  -H 'Accept: application/json' \
  -X POST \
  'https://localhost:5665/v1/events?queue=more&types=CheckResult&filter=match%28%22*foo*%22,event.host%29'

The parameter for filter is match=("*foo*",event.host) urlencoded.

Stream multipart uploads from a pipe with python requests

With requests-toolbelt you can stream files to a multipart POST, but you can not stream from a pipe, as there is no way to compute the Content-Length HTTP header.

However, if you are in the situation, that you do know the length and data is coming from a pipe, you can wrap it with something like this:

class NotAPipe():
	""" Implement enough of a file like object, that MultipartEncoder can
	use a pipe to stream data """

	def __init__ ( self, pipe, length ):
		self._pipe = pipe
		self._length = length

		self._left = self._length
		self._hash = hashlib.md5()

	def read( self, *args, **kwargs ):
		data = self._pipe.read( *args, **kwargs )
		self._hash.update( data )
		self._left -= len( data )
		return data

	def md5( self ):
		return self._hash.hexdigest()

	def __len__( self ):
		return self._left

The md5 part, is optional, but plays well together with this test server, a Mojolicious::Lite application heaily based on their Streaming Cookbook example. Run it with morbo server.pl. Use it with this complete test client.

Openwrt Firmware

Does your box need a firmware blob to work? Putting it in /lib/firmware will lead to it’s loss on upgrade; /etc on the other hand seems to be kept.

Reptyr to the resuce

Did your XFCE crash during apt-get dist-upgrade and apt-get is now still running and waiting for your input? reptyr to the rescue:

reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don’t want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.

Luckily gcc and make was installed, so I could build it ;).

Eclipse Mars No Marketplace

Gettin a java.lang.NullPointerException when opening the marketplace in Eclipse Mars 4.5.2 under Linux?

org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
	...
Caused by: java.lang.NullPointerException
	at org.eclipse.swt.widgets.TabFolder.gtk_switch_page(TabFolder.java:570)

Try forcing eclipse to no use gtk3:

export SWT_GTK3=0
eclipse

Icinga check_disk Inodes Ignored

Running icinga2 < 2.9.0 and wondering why check_disk ignores your inode thresholds?

Turns out check_disk needs all thresholds specified before passing -A, -R, etc., see #5714

This can be done using the order key (see CheckCommand Documentation):

--- /tmp/command-plugins.conf	2019-05-10 13:15:27.358692552 +0200
+++ /usr/share/icinga2/include/command-plugins.conf	2019-05-10 13:13:03.106517997 +0200
@@ -961,11 +961,13 @@
		"-W" = {
			value = "$disk_inode_wfree$"
			description = "Exit with WARNING status if less than PERCENT of inode space is free"
+			order = -2
		}

		"-K" = {
			value = "$disk_inode_cfree$"
			description = "Exit with CRITICAL status if less than PERCENT of inode space is free"
+			order = -2
		}
 
		"-p" = {