Skip to content

Instantly share code, notes, and snippets.

View schlomo's full-sized avatar

Schlomo Schapiro schlomo

View GitHub Profile
@schlomo
schlomo / prefs.sh
Created February 7, 2015 19:12
Ubuntu guest session customization. Install as /etc/guest-session/prefs.sh
touch "$HOME"/.skip-guest-warning-dialog
if [[ -r /usr/share/applications/google-chrome.desktop ]] ; then
mkdir -p "$HOME"/.local/share/applications
sed -e '/Exec/s/google[a-z-]\+/& --password-store=basic/' -e '/^Name=/s/=/&Guest /' \
< /usr/share/applications/google-chrome.desktop > "$HOME"/.local/share/applications/google-chrome.desktop
fi
mkdir -p "$HOME"/.config/autostart
for service in blueman.desktop deja-dup-monitor.desktop indicator-bluetooth.desktop indicator-power.desktop light-locker.desktop vino-server.desktop nm-applet.desktop ; do
if [[ -e /etc/xdg/autostart/$service ]] ; then
@schlomo
schlomo / disable-suspend-and-hibernate.pkla
Created February 7, 2015 19:09
PolicyKit Local Authority policy to disable suspend and hibernate for all users. Should be installed into /var/lib/polkit-1/localauthority/90-mandatory.d or /etc/polkit-1/localauthority/90-mandatory.d
[Completely disable suspend and hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend;org.freedesktop.upower.hibernate;org.freedesktop.login1.suspend*;org.freedesktop.login1.hibernate*
ResultAny=no
ResultInactive=no
ResultActive=no
@schlomo
schlomo / guest-lockdown.pkla
Created February 7, 2015 19:04
PolicyKit Local Authority policy to lockdown Ubuntu guest session from modifying the system. Should be installed into /var/lib/polkit-1/localauthority/90-mandatory.d or /etc/polkit-1/localauthority/90-mandatory.d
[Allow harmless stuff]
Identity=unix-user:guest-*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;com.canonical.indicator.sound.AccountsService.ModifyOwnUser;org.freedesktop.accounts.change-own-user-data
ResultActive=yes
[Allow handling removable media]
Identity=unix-user:guest-*
Action=org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.eject-media;org.freedesktop.udisks2.ata-standby;org.freedesktop.udisks2.power-off-drive;org.freedesktop.udisks2.modify-device;org.freedesktop.udisks2.cancel-job;org.freedesktop.udisks2.rescan;org.freedesktop.udisks2.encrypted-unlock;org.freedesktop.udisks2.encrypted-change-passphrase
ResultActive=yes
@schlomo
schlomo / secure-umask.sh
Created February 7, 2015 18:55
Set umask to prevent world readable access
umask 007
@schlomo
schlomo / -glmark2 benchmarks.txt
Last active August 29, 2015 14:13
Some glmark2 benchmarks on my new computer
CPU: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Kernel: 3.16.0-28-generic #38-Ubuntu SMP Fri Dec 12 17:37:40 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
OS: Ubuntu 15.04 vivid (Beta) from December/January 2015
(NVidia GT610 tested on Ubuntu 14.10 utopic on same hardware)
@schlomo
schlomo / aws_mfa.sh
Created September 18, 2014 09:03
Helper Bash function to set up temporary AWS credentials for MFA protected accounts.
function aws_mfa {
if [[ -z "$AWS_ACCESS_KEY_ID" ]] ; then
echo "Please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"
return 1
fi
if [[ -z "$REAL_AWS_ACCESS_KEY_ID" ]] ; then
REAL_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
REAL_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
fi
@schlomo
schlomo / amazon-id.conf
Created September 10, 2014 15:34
Amazon ID plugin for YUM. This will add 2 headers to the HTTP requests. With these headers the YUM repo server can identify the EC2 instance. These files come from the rh-amazon-rhui-client RPM package found on RHEL EC2 instances, probably part of the Red Hat Update Infrastructure (https://access.redhat.com/products/red-hat-update-infrastructure/)…
[main]
enabled=1
@schlomo
schlomo / demo3.ipxe
Last active October 27, 2015 04:51
iPXE Installation menu with several Linux Distributions and Live CDs
#!ipxe
menu Bitte waehlen Sie ein Betriebssystem zur Installation aus
item ubuntu Ubuntu installieren
item fedora Fedora installieren
item --gap
item back Zurueck zum Hauptmenue
choose --timeout 20000 --default back target && goto ${target} || goto menu
:ubuntu
set ubuntu http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/ubuntu-installer/i386
@schlomo
schlomo / login.php
Last active August 29, 2015 14:01
PHP Basic Auth Gateway. Requests basic auth (password is reversed username) and redirects to URL passed as query string
<?php
$username = 1;
$revpwd = 0;
if (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) {
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
$revpwd = strrev($password);
}
if ($username == $revpwd) {
if (isset($_SERVER['QUERY_STRING'])) {