Skip to content

Instantly share code, notes, and snippets.

View KunalSin9h's full-sized avatar

Kunal Singh KunalSin9h

View GitHub Profile
@KunalSin9h
KunalSin9h / setup_containerd.sh
Last active November 11, 2023 09:07
Install and setup containerd on Ubuntu
#! /bin/bash
TMPROOT=$(mktemp -d)
cd /$TMPROOT
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
@dixudx
dixudx / StreamToString.go
Created November 16, 2016 09:34 — forked from tejainece/StreamToString.go
Golang: io.Reader stream to string or byte slice
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)

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.)