Skip to content

Instantly share code, notes, and snippets.

View kadler's full-sized avatar
😎

Kevin Adler kadler

😎
View GitHub Profile
@kadler
kadler / srcpf-to-ifs.sh
Last active October 20, 2021 15:23
Convert SRCPF member to stream file
#!/QOpenSys/pkgs/bin/bash
MBRPATH=/qsys.lib/qsysinc.lib/h.file/stdio.mbr
RCDLEN=80 # default, use whatever was specified on CRTSRCPF
CCSID=037 # needs leading zeros if less than 3 digits
OUTFILE=stdio.h
# What it does:
# 1. Convert the member "stream of bytes" to UTF-8
@kadler
kadler / passwd.py
Created July 28, 2021 15:54
Calling QSYCHGPW via Python with Emoji
from ctypes import c_char, c_int, c_uint, c_int16, c_uint16, \
c_size_t, c_ulonglong, c_void_p, c_char_p, \
addressof, sizeof, create_string_buffer, \
CDLL, DEFAULT_MODE, POINTER, Structure
import unicodedata
RTLD_MEMBER = 0x00040000
@kadler
kadler / README.md
Last active November 27, 2019 22:32
Basic sudo implementation on IBM i

Basic sudo implementation on IBM i

Uses standard Unix setuid to change the current process user id and executes the parameters passed. On other platforms, this usually requires root authority, but on IBM i we just need *USE authority to the user profile. :)

Build

gcc -o sudo sudo.c
@kadler
kadler / instructions.md
Created February 28, 2019 00:48
Retrieve message id from PASE signal handler
gcc -std=c99 -o pase-signal-msgid pase-signal-msgid.c && ./pase-signal-msgid

Example output:

ptr: ffffffffffffba1
----- in handler -----
msgid = MCH0602
@kadler
kadler / db2_connect_bind.md
Created February 19, 2019 01:27
Setting up DB2 Connect packages

If PHP tests fail with

[IBM][CLI Driver][AS] SQL0805N  Package "NULLID.SYSSH000" was not found.  SQLSTATE=51002 SQLCODE=-805

You'll need to set up the DB2 Connect SQL packages by "binding" them.

From the clidriver directory

@kadler
kadler / building_ibm_db2.md
Last active February 18, 2019 22:00
Building ibm_db2 on IBM i 7.2 with Zend PHP

Building ibm_db2 on IBM i

Setup

We need to install various packages in order to build ibm_db2. Most of these can be installed with yum:

yum group install 'Development tools'
yum install git
@kadler
kadler / README.md
Last active February 6, 2020 20:56
Set Up SSL CA Certificates for Various Git Providers on IBM i

README

🚨 This gist is obsolete 🚨

This was a way to easily set up a few certificates for GitHub, BitBucket, etc for use with git. It's largely irrelevant nowadays with the advent of ca-certificates being availabe.

Instead, just yum install ca-certificates-mozilla. This installs the Mozilla CA trust store (the same used by Firefox and many other open source projects), as well as the ca-certificates infrastructure. ca-certificates will generate the format needed by OpenSSL (and Java, too!).

@kadler
kadler / notes.md
Last active January 11, 2018 07:27
Calling QzuiCreateInstance

For some reason I'm getting CPF3C1D when calling the API and I don't know why.

The API is defined here and the structure is defined here.

The last field of the structure is at offset 570 and is 512 bytes, which means the whole structure is 1082, which is what we're passing. It says that we need to pass 1 more byte, but I have no idea why or what it should be.

Also: the lib option to iSrvPgm does not work...

Update: I added a 2 byte dummy field to make it greater than 1083 bytes long and now get: "A value in the instance data at decimal offset 28 is not valid"

@kadler
kadler / pase2rpg_ffi.py
Created March 1, 2017 04:40
Converting PASE structures to RPG structures with padding and alignment using Python CFFI
#
# The MIT License (MIT)
#
# Copyright (c) 2017 IBM Corp.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is