Skip to content

Instantly share code, notes, and snippets.

View WanpengQian's full-sized avatar
👳‍♀️

Wanpeng Qian WanpengQian

👳‍♀️
  • Fukuoka, Japan
View GitHub Profile
#!/usr/bin/env bash
set -e
if [ -z "$iso" ] ; then
printf -- ">>> You must invoke with iso=/path/to/winxp.iso $(basename $0)\n"
exit 1
fi
if [ -z "$url" ] ; then
#!/bin/sh
bold=$(tput bold)
norm=$(tput sgr0)
ENV=""
GUID=""
NAME=""
NEWVOL=""
OLDVOL=""
# vmadm halt <uuid>
# zonecfg -z <uuid>
zonecfg:uuid> add dataset
zonecfg:uuid:dataset> set name=<zfs/path>
zonecfg:uuid:dataset> end
zonecfg:uuid> commit
zonecfg:uuid> exit
# zfs set mountpoint=legacy <zfs/path>
# vmadm boot <uuid>
@WanpengQian
WanpengQian / SambaOnFreeBsd.md
Created February 5, 2016 05:33 — forked from TravisTroyer/SambaOnFreeBsd.md
Samba 4.1 on FreeBSD 10.1

Samba 4.1 Active Directory Domain Controller on FreeBSD 10.1

To simplify home network management, I recently decommissioned my beefy domain controller/file server/Hyper-V host, moving mass file storage to the cloud. I thought I could live without Active Directory, but with 5 PCs and a couple of Windows tablets, I want it back, so my plan is to host a tiny VM instance in hyper-V on 4 of my desktop PCs, creating something like peer-to-peer AD (hopefully with little overhead).

Resources

The following references were incredibly helpful, but neither were perfect for getting up and running quickly, hence this gist.

VBoxManage createvm --name gateway --ostype Debian --register
VBoxManage modifyvm gateway --memory 256 --ioapic on --cpus 1 --chipset ich9 --nic1 bridged --nictype1 82540EM --bridgeadapter1 em1
VBoxManage storagectl gateway --name "SATA Controller" --add sata --controller IntelAhci --portcount 4
VBoxManage createhd --filename gateway.vdi --size 40960
VBoxManage storageattach "gateway" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium gateway.vdi
VBoxManage storagectl gateway --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storageattach gateway --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /home/qianwanpeng/debian-8.3.0-i386-CD-1.iso
iptables -t nat -N REDSOCKS
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
VBoxManage setextradata "VM Name" "VBoxInternal/Devices/acpi/0/Config/CustomTable" "/path/to/SLIC.BIN"
I prefer to use the sysutils/screen port with my USB to Serial adapter like this:
screen /dev/cuaU0 9600
You'll need to know the device name of the serial port you want to use -- if it is a regular old serial port (not USB to Serial adapter) check look for a device like /dev/cuau0.
@WanpengQian
WanpengQian / range2cidr.pl
Created July 19, 2016 06:54
IP range to CIDR format
#!/usr/bin/perl -w
# range2cidr.pl
use Net::CIDR;
use Net::CIDR ':all';
if (@ARGV == 0) {
die "Usage Example: $0 192.168.0.0-192.168.255.255 \n";
}
@WanpengQian
WanpengQian / patch-source3_modules_vfs__shadow__copy2.c
Created May 16, 2017 13:31 — forked from moisseev/patch-source3_modules_vfs__shadow__copy2.c
[partial fix] CVE-2015-5299 denies access to ZFS snapshots due to overly strict condition checking (the patch is against Samba 4.4.13)
--- source3/modules/vfs_shadow_copy2.c.orig 2017-04-02 08:19:24 UTC
+++ source3/modules/vfs_shadow_copy2.c
@@ -1533,7 +1533,7 @@ static bool check_access_snapdir(struct
&smb_fname,
false,
SEC_DIR_LIST);
- if (!NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
DEBUG(0,("user does not have list permission "
"on snapdir %s\n",