Skip to content

Instantly share code, notes, and snippets.

View SvenDowideit's full-sized avatar
🤓
Back to reading code, wincing, and wishing it wasn't how it was.

Sven Dowideit SvenDowideit

🤓
Back to reading code, wincing, and wishing it wasn't how it was.
View GitHub Profile
@jerblack
jerblack / Elevate when needed in Go.md
Last active May 19, 2024 09:08
Relaunch Windows Golang program with UAC elevation when admin rights needed.

I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.

To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.

I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes

@bradfa
bradfa / mips64el-debian-qemu-exact-steps.md
Last active June 14, 2023 11:14
mips64el Debian QEMU install

Installing Debian Stretch mips64el Using QEMU

We're going to emulate the mips64el "malta" machine and install Debian Stretch using QEMU on a amd64 Debian Buster host.

Likely you need your user to be in the "libvirt" group and have installed these packages (or a subset of such):

sudo apt install qemu-system-mips virt-manager libguestfs-tools
@tianon
tianon / curl-docker-build.sh
Last active August 29, 2015 13:56
Testing "docker build" Remote API Endpoint Using Curl
{ echo 'FROM debian'; echo 'RUN apt-get update'; } | perl -w -MArchive::Tar -e 'my $tar = Archive::Tar->new; { local $/; $tar->add_data("Dockerfile", <>); } print $tar->write' | curl --data-binary @- --header 'Content-Type: application/x-tar' --dump-header - --no-buffer 'http://localhost:4243/build?rm=1&nocache=1'