Skip to content

Instantly share code, notes, and snippets.

View grawity's full-sized avatar

Mantas Mikulėnas grawity

View GitHub Profile
@grawity
grawity / README.md
Created June 2, 2011 05:39
ADVENT magic mode script for TOPS-10-In-a-Box

This script was written for the TOPS-10-In-a-Box project. It calculates the passwords for Magic Mode in ADVENT, and is based on the one available at Zonadepruebas website.

Description copied from Zonadepruebas:

Don Woods, who deviced this authentication scheme 29 years ago, has given his kind permission to disclose it publically

'Advent' is reputedly the first text adventure game. It was originally created by William Crowthers, and later expanded by Don Woods. It was programmed in Fortran, on a DEC PDP-10 computer, and Woods' version dates from 1977. This first version has a maintenance feature called "Magic Mode". It was intended for administrators only, and involves a bizarre authentication process. After entering "MAGIC MODE" as first command in the game, the program will ask:

  1. "ARE YOU A WIZARD?", (replay "YES")
  2. "PROVE IT! SAY MAGIC WORD", (default is "DWARF")
@grawity
grawity / ars.css
Created April 4, 2024 07:12
Ars Technica userstyle
/*** This most likely *will not* be updated with any further changes I make to my local version, so just copy-paste import it. ***/
/* Hide junk */
.sticky_support .site-header {
position: unset;
}
.inline-playlist {
display: none;
}

These are only examples, for a few very common actions. You are expected to write your own rules for the rest. The syntax is regular JavaScript, but see the polkit(8) manpage for the object structure and available API. These examples are for polkit versions 106 and later, with the JS interpreter. They won't work with Debian's polkit v105.

  • If you don't know the action name, run pkaction:

    pkaction | grep cups
    
  • The possible results are YES, AUTH_SELF(_KEEP), AUTH_ADMIN(_KEEP), NO. Returning a result is final. Returning null will continue checking other rules.

  • Put your rules in /etc/polkit-1/rules.d/*.rules. (You can check everything in one giant addRule, or you can have a separate file and separate addRule for each program; it doesn't matter.)

@grawity
grawity / README.md
Last active November 15, 2023 19:35
systemd Type=notify implementations

The official documentation is in the [sd_notify(3)][1] manual page.

Very short summary:

  1. Change your systemd service to Type=notify.
  2. Your daemon will receive an environment variable NOTIFY_SOCKET, which contains a path to an AF_UNIX socket.
    (If the first path byte is @, this means an "abstract" socket, and you should change the 1st byte to 0x00 before using.)
  3. The protocol consists of sending datagrams containing textual (UTF-8) status messages.
    Each message contains newline-separated KEY=value parameters.
  4. When the daemon is ready, it must send READY=1, and systemd will transition the service from "starting" to "running".
@grawity
grawity / Makefile
Created January 11, 2012 21:33
NTFS volume creation timestamp
CC = i486-mingw32-gcc
LDFLAGS = -lntoskrnl -lntdll
volumeinfo.exe: volumeinfo.c
$(CC) -o $@ $< $(LDFLAGS)
ACTION!="add", GOTO="deauthorize_end"
SUBSYSTEM!="usb", GOTO="deauthorize_end"
TEST!="authorized", GOTO="deauthorize_end"
## make hubs deauthorize all devices by default
TEST=="authorized_default", ATTR{authorized_default}="0", GOTO="deauthorize_end"
## whitelist specific devices
ENV{ID_VENDOR}=="Yubico", ENV{ID_MODEL}=="Yubikey_NEO*", ATTR{authorized}="1", GOTO="deauthorize_end"
ENV{ID_VENDOR}=="Zubico", ENV{ID_MODEL}=="Zubikey_GEO*", ATTR{authorized}="1", GOTO="deauthorize_end"
@grawity
grawity / SASL.md
Last active May 13, 2023 12:06
SASL authentication from the perspective of IRC server-to-server protocols

SASL authentication in IRC

© 2014 Mantas Mikulėnas <grawity@gmail.com>

This documentation is released under Creative Commons 3.0 Attribution license.


This is a description of server-server protocol, intended for ircd and services developers. For the client-server protocol descriptions, intended for client & bot developers, see the IRCv3 [sasl-3.1][] and [sasl-3.2][] specifications.

@grawity
grawity / dhcp_option119.py
Last active April 19, 2023 17:24 — forked from SmartFinn/dhcp_option119.py
a script for converting domain names to DHCP Option 119 (Domain Search Option)
#!/usr/bin/env python3
"""Command generator for setting DHCP Option 119
This script converts the specified domain names to DHCP Option 119
(Domain Search Option) and prints commands for various DHCP servers.
USAGE:
./dhcp_option119.py DOMAIN ...
EXAMPLE:
# NOTE
#
# Eduroam settings are organization-specific.
#
# If something works with *@foobar.edu, that _does_not_mean_ the same
# settings automatically work elsewhere.
#
# Fortunately, *most* sites use very similar settings – password logins via
# PEAP or TTLS. That's what this example covers.
#
@grawity
grawity / aleph_upload_patrons.py
Last active February 3, 2022 09:37
UK – įrankis įkelti Aleph vartotojų duomenims per users.library.lt
#!/usr/bin/env python3
import argparse
import bs4
import os
import requests
import subprocess
import sys
def validate_xml_file(path, schema):
r = subprocess.call(["xmllint", "--noout", "--schema", schema, path])