August 28, 2020

Using cf-remote to download and install CFEngine nightlies

This is a work related post. Nightly packages are very useful for testing new features of CFEngine. Right now, nightly packages can be used to test out these new features: Compliance Reports. Mission Portal Dark Mode. New host info page with variable pinning and copy buttons. Note that these features are in development, some parts may be unfinished or buggy. Nightly packages are not supported and should not be used in production environments. Read more

April 10, 2019

Running cf-runagent as non-root

I work at Northern.tech, developing CFEngine, a configuration management system. This is a work (CFEngine) related post. cf-runagent is a component for triggering remote agent runs using the CFEngine network protocol. It does not allow for arbitrary commands to be executed, but rather asks the remote host to run the policy it already has. To trigger cf-runagent from other systems or web interfaces, you want to be able to run it as non-root. Read more

March 12, 2019

Fixing your mac keyboard in X11 (RHEL 7)

Alternatively: How xkb works, and how to change keys which are wrong. On OS X, there is no alt+gr. Combinations of shift and alt are used instead. Both alt keys behave the same. You can make your Apple internal or external keyboard behave like this on Linux. This blog post shows how, but please note that it changes the behavior of your alt keys. So keyboard shortcuts which rely on alt might not work any more. Read more

March 11, 2019

Introducing cf-remote: Tooling to deploy CFEngine

I work at Northern.tech, developing CFEngine, a configuration management system. This is a work (CFEngine) related post. About a year ago, I wrote a small python script to automate installing and bootstrapping CFEngine on virtual machines in AWS. It had some hard coded IP addresses that I needed to update when I spawned new hosts, but other than that, it worked well. During manual testing, it saved me a lot of time instead of having to do things manually. Read more

November 11, 2018

Scanning unsigned types in C

printf and scanf are the C standard library functions for printing out and reading in data. They have string counterparts, prefixed with s, which work on strings (sprintf and sscanf). All these functions use a format string to match parts of the string with C variables. As an example, %lu in the format string corresponds to an unsigned long, a positive integer type in C. Scanning unsigned types What happens if you try to sscanf a negative number using %lu? Read more

October 20, 2018

Unknown type name 'u_int'

I ran across the error message (Unknown type name 'u_int', 'u_long', 'u_char' etc.) when trying to incorporate some old C code into a more modern project. It shows up in system headers, like sys/attr.h, and I was confused. After quite some time I figured out what the problem was, so I thought I’d share. Simplified example The source code, when simplified, looked something like this: $ cat test.c #define _XOPEN_SOURCE 500 #include <sys/attr. Read more

October 6, 2018

AddressSanitizer (ASAN) examples

AddressSanitizer is a great tool for finding bugs in C or C++ projects. It consists of some instrumentation added to code at compile time, as well as a dynamically linked runtime. Good test coverage is required, as it detects problems at runtime, while running your test-suite. To use it, supply -fsanitize=address to both the compiler and linker when building for tests (works in newer versions of clang and gcc). There are great resources for understanding how it works, but when I started, I was missing a few simple examples. Read more

July 27, 2018

Using Systemd to ensure unit(s) run on one CPU core

This post is based on an excellent article from Red Hat: https://access.redhat.com/solutions/1445073 I’m a CFEngine developer, so this is a more work related post. CFEngine and Systemd In some performance critical situations, it makes sense to limit management software to a single CPU (core). We can do this using systemd and cgroups. CFEngine already provides systemd units on relevant platforms, we just need to tweak them. Tested using CFEngine 3.12 on CentOS 7. Read more

© Ole Herman Schumacher Elgesem 2021

Powered by Hugo & Kiss.