Skip to content

Instantly share code, notes, and snippets.

View dshcherb's full-sized avatar

Dmitrii Shcherbakov dshcherb

View GitHub Profile
# this is an example of how to use aliases to avoid making yaml too large
# just by using language features of yaml and a parser support without
# relying on juju at all
# this was done for charm-helpers, see:
# charmhelpers/fetch/__init__.py
# def configure_sources
# and
# charmhelpers/fetch/ubuntu.py
# def add_source
@dshcherb
dshcherb / maas-squashfs-backdoor.sh
Created October 10, 2017 12:14
A procedure to add a root password to maas-deployed cloud images for last-resort debugging.
https://gnu-linux.org/building-ubuntu-rootfs-for-arm.html
"2) Extract the downloaded image with ‘sudo’ to allow ‘mknod’ commands to work"
# get a cloud image from here
# https://cloud-images.ubuntu.com/daily/server/xenial/
# https://cloud-images.ubuntu.com/daily/server/xenial/current/
# based on https://bazaar.launchpad.net/~maas-images-maintainers/maas-images/maas-ephemerals/view/head:/bin/img2squashfs#L161
# extract a cloud image rootfs to a directory, sudo is needed for `mknod`s to work
# doesn't have to be .tar.gz - could well unsquashfs an existing squashfs
@dshcherb
dshcherb / openstack-template-loaders.txt
Created February 8, 2018 16:36
A brain dump on how OpenStack template loaders work in charm-helpers.
**OpenStack Releases and template loading**
When the object is instantiated, it is associated with a specific OS
release. This dictates how the template loader will be constructed.
The constructed loader attempts to load the template from several places
in the following order:
- from the most recent OS release-specific template dir (if one exists)
- the base templates_dir
- a template directory shipped in the charm with this helper file.
@dshcherb
dshcherb / openssl-ubuntu-locations.txt
Created February 8, 2018 17:48
An investigation into where CA certificates are stored in Ubuntu
For verification, applications that use openssl would create an openssl context with either default or specific directories used for verification. Note that some packages (e.g. openldap) use gnutls instead of openssl and gnutls has a compatibility layer (includes/gnutls/openssl.h) which includes common functions like setting verification paths so you may rely on using a single code base for configuration to some extent.
https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_load_verify_locations.html
SSL_CTX_load_verify_locations - set default locations for trusted CA certificates
int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
const char *CApath)
{ return (X509_STORE_load_locations(ctx->cert_store, CAfile, CApath));
int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
const char *path)
// kubernetes tree: c005b9d0ab6cd963abf66a9a12fb8ad5e48121ad
enforcedNodeAddresses = append(enforcedNodeAddresses, v1.NodeAddress{Type: v1.NodeHostName, Address: kl.GetHostname()})
node.Status.Addresses = enforcedNodeAddresses
return nil
}
@dshcherb
dshcherb / new-proxy-settings-keyserver-handling-env.txt
Created November 24, 2018 21:04
A manual functional test environment setup for testing the new code charm-helpers code to handle new Juju proxy settings and keyserver logic
Manual functional test environment (localhost):
juju model-config cloudinit-userdata
ca-certs:
trusted:
- |
-----BEGIN CERTIFICATE-----
# juju tools mirror certificate here
-----END CERTIFICATE-----
preruncmd:
@dshcherb
dshcherb / sqlite3nulls.py
Created October 15, 2019 10:01
Writing null/zero (\x00, ^@) bytes to an sqlite3 DB
import sqlite3
def init_db():
TEST_DB_FILE = 'testdb.sqlite'
db = sqlite3.connect(TEST_DB_FILE, isolation_level="EXCLUSIVE")
c = db.execute("BEGIN")
c.execute("SELECT count(name) FROM sqlite_master WHERE type='table' AND name='snapshot'")
if c.fetchone()[0] == 0:
# Using TEXT colums is not a good idea because SQL expressions will have undefined result per sqlite3 documentation: