January 20, 2013

So Cal lakes that allow bow fishing

El Capitan
Sutherland
Otay
San Vicente
Hodges

Lakes Already Approved:

Elsinore
Big Bear
Cachuma
Hemet (with strict regulations)

January 14, 2013

uml and console job control

I started uml with my host debian file system:


./linux rootfstype=hostfs rw init=/home/tzhang/uml/init-uml.sh mem=64M TERM=linux eth0=tuntap,,,192.168.6.88

However the shell I get does not have job control. I tried multiple things found on internet but none did the trick for me. This is what finally solved the problem:

1. get busybox and build it with the "cttyhack" enabled (in shell section of menuconfig)
2. ln -sf busybox cttyhack
3. run that in your init. My init.sh looks like this:


#!/bin/bash
export PS1="[\\u@\\h:\\w] $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml


mount -t tmpfs /dev/ /dev/

/etc/init.d/udev start
/home/tzhang/uml/dropbear -r dropbear_rsa_host_key
exec setsid /home/tzhang/uml/cttyhack bash

This solved the problem beautifully. The last line is what did the trick for job control.
the udev daemon and dropbear made ssh possible.

=============UPDATED 4/10/2017=====================
init.sh:
#!/bin/bash
export PS1="\u@\h:\w $"
export HOME=/home/tzhang
. /home/tzhang/.bashrc
ifconfig eth0 192.168.6.99
hostname -b R1
export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/local/sbin:/usr/sbin
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /var/run -o rw,nosuid,nodev
mount -t tmpfs tmpfs /var/log -o rw,nosuid,nodev
cd $HOME/uml

mount -t tmpfs /dev/ /dev/
ifconfig eth1 192.168.3.2
ifconfig eth0 192.168.2.2

busybox mdev -s
mkdir /dev/pts
mount -t devpts /dev/pts /dev/pts

#dropbear -r dropbear_rsa_host_key -p 2222
exec setsid /home/tzhang/uml/cttyhack bash


run.sh
./linux rootfstype=hostfs rw init=/home/tzhang/uml/init.sh mem=64M TERM=linux \
eth0=tuntap,tap0,,192.168.2.88 \
eth1=tuntap,tap1,,192.168.3.88

Host /etc/network/interfaces
# The primary network interface
auto ens33
iface ens33 inet manual
auto ens38
iface ens38 inet manual
auto tap0
iface tap0 inet manual
    pre-up ip tuntap add tap0 mode tap user tzhang
    up ip link set dev tap0 up
auto tap1
iface tap1 inet manual
    pre-up ip tuntap add tap1 mode tap user tzhang
    up ip link set dev tap1 up
auto br0
iface br0 inet dhcp
        bridge_ports ens33 tap0
auto br0:1
allow-hotplug br0:1
iface br0:1 inet static
        address 192.168.2.1
        broadcast 192.168.2.255
        netmask 255.255.255.0
auto br1
iface br1 inet dhcp
        bridge_ports ens38 tap1
auto br1:1
allow-hotplug br1:1
iface br1:1 inet static
        address 192.168.3.1
        broadcast 192.168.3.255
        netmask 255.255.255.0

January 13, 2013

uml with minimal debian


Build kernel:

1. get kernel
2. make ARCH=um defconfig
3. make ARCH=um menuconfig ; to remove options you don't need
4. make -j 12 ; parallel build


Build rootfs:
dd if=/dev/zero of=my.rootfs bs=1M seek=512 count=0
mkfs.ext2 -F my.rootfs

mkdir rootfs
sudo mount -o loop my.rootfs rootfs
sudo debootstrap --arch=i386 --variant=minbase lucid rootfs

January 8, 2013

SQL Server 2008 can't login with newly created user


SQL Server was not configured to allow mixed authentication.
Here are steps to fix:
  1. Right-click on SQL Server instance at root of Object Explorer, click on Properties
  2. Select Security from the left pane.
  3. Select the SQL Server and Windows Authentication mode radio button, and click OK.

    Right-click on the SQL Server instance, select Restart (alternatively, open up Services and restart the SQL Server service).

    I wish Microsoft has better document.

    Source: http://stackoverflow.com/questions/1719399/sql-server-2008-cant-login-with-newly-created-user

December 27, 2012

putty and gnu screen scroll back with mouse


Summary: add the line to your .screenrc file:
termcapinfo xterm ti@:te@
Reference ( Putty FAQ )
PuTTY's terminal emulator has always had the policy that when the ‘alternate screen’ is in use, nothing is added to the scrollback. This is because the usual sorts of programs which use the alternate screen are things like text editors, which tend to scroll back and forth in the same document a lot; so (a) they would fill up the scrollback with a large amount of unhelpfully disordered text, and (b) they contain their own method for the user to scroll back to the bit they were interested in. We have generally found this policy to do the Right Thing in almost all situations.
Unfortunately, screen is one exception: it uses the alternate screen, but it's still usually helpful to have PuTTY's scrollback continue working. The simplest solution is to go to the Features control panel and tick ‘Disable switching to alternate terminal screen’. (See section 4.6.4 for more details.) Alternatively, you can tell screen itself not to use the alternate screen: the screen FAQ suggests adding the line ‘termcapinfo xterm ti@:te@’ to your .screenrc file.

November 30, 2012

run as user in inittab or init

Sometimes sudo -u USERNAME gives error.

You can try to to use su USERNAME -c "COMMAND" instead.

November 28, 2012

Start screen after sudo su to another user


Sudo'ing to a user then running screen doesn't work out of the box.  Typically you get the following error:
Cannot open your terminal '/dev/pts/1' - please check.
The solution:
sudo su - someuser
script /dev/null
screen

Source: http://dbadump.blogspot.com/2009/04/start-screen-after-sudo-su-to-another.html 

November 26, 2012

Creating a self-signed certificate with ADT


http://help.adobe.com/en_US/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7f74.html

You can use self-signed certificates to produce a valid AIR installation file. However, self-signed certificates only provide limited security assurances to your users. The authenticity of self-signed certificates cannot be verified. When a self-signed AIR file is installed, the publisher information is displayed to the user as Unknown. A certificate generated by ADT is valid for five years.
If you create an update for an AIR application that was signed with a self-generated certificate, you must use the same certificate to sign both the original and update AIR files. The certificates that ADT produces are always unique, even if the same parameters are used. Thus, if you want to self-sign updates with an ADT-generated certificate, preserve the original certificate in a safe location. In addition, you will be unable to produce an updated AIR file after the original ADT-generated certificate expires. (You can publish new applications with a different certificate, but not new versions of the same application.)
Important: Because of the limitations of self-signed certificates, Adobe strongly recommends using a commercial certificate issued by a reputable certification authority for signing publicly released AIR applications.
The certificate and associated private key generated by ADT are stored in a PKCS12-type keystore file. The password specified is set on the key itself, not the keystore.

Certificate generation examples

adt -certificate -cn SelfSign -ou QE -o "Example, Co" -c US 2048-RSA newcert.p12 39#wnetx3tl 
adt -certificate -cn ADigitalID 1024-RSA SigningCert.p12 39#wnetx3tl

To
use these certificates to sign AIR files, you use the following
signing options with the ADT -package or -prepare commands:

-storetype pkcs12 -keystore newcert.p12 -keypass 39#wnetx3tl 
-storetype pkcs12 -keystore SigningCert.p12 -keypass 39#wnetx3tl

Note: Java versions 1.5 and above do not accept high-ASCII characters in passwords used to protect PKCS12 certificate files. Use only regular ASCII characters in the password.


ADT -package command examples

Package specific application files in the current directory for a SWF-based AIR application:

adt –package -storetype pkcs12 -keystore cert.p12 myApp.air myApp.xml myApp.swf components.swc

Download older version of flex SDK

http://blogs.adobe.com/flex/files/2012/05/FlexLicense.swf

November 10, 2012

netcat/ncat server file as a web server

I will use the ncat (part of nmap) tool:

1. first create a bash file with the following contents, and save it as nchttp.sh, and chmod+x on it:
#!/bin/sh
echo "HTTP/1.1 200 OK"
mydate=`date -R`
echo "Date: $mydate"
echo "Server: Apache"
echo "Last-Modified: $mydate"
echo "Accept-Ranges: bytes"
echo "Content-Disposition: inline; filename=\"$1\"";
mysize=`stat $1 |awk '/Size/{print $2}'`
echo "Content-Length: $mysize"
echo "Keep-Alive: timeout=30, max=300"
echo "Connection: Keep-Alive"
echo "Content-Type: application/octet-stream"
echo
cat $1

2. ./nchttp.sh the-file-to-be-downloaded | ncat -l -vv 8001

3. point your brower to your http://YOURSERVERIP:8001, your file will be downloaded

November 9, 2012

Faster ssh X11 Forwarding


I use ssh daily to connect to my servers and laptops around my home office. Most of the time I'm using ssh to login and build software, so it's plain and simple command line activity. However, sometimes I need to run an X11 application on a remote machine, in which case I use X forwarding to display the remote X application on my laptop. However, this can be slow. Today I stumbled on the following incantation to speed up X11 forwarding over ssh:


ssh -c arcfour,blowfish-cbc -X -C user@remotehost

Thanks to Samat Jain for this info.

The choice of cipher is based on some performance benchmarks as noted in LaunchPad bug #54180

Source: http://smackerelofopinion.blogspot.com/2009/07/faster-ssh-x11-forwarding.html

November 7, 2012

php mail() function data flow

php mail() called /usr/sbin/sendmail, which may be a symbolic link to exit4 or sendmail.postfix or whatever sendmail "MTA" installed on your system. If you change that to your own sendmail, you can probably log all outgoing emails for debugging purpose.

November 6, 2012

Build and install python and mercurial from scratch on a system


wget http://www.python.org/ftp/python/2.5.4/Python-2.5.4.tgz
wget http://www.selenic.com/mercurial/release/mercurial-1.2.1.tar.gz
tar zxvf mercurial-1.2.1.tar.gz
tar zxvf Python-2.5.4.tgz

Configure and build Python using /opt - you could use /usr/local or similar but I preferred to keep it out of my $PATH:

cd Python-2.5.4
./configure --prefix=/opt
make
su -c "make install"

Test Python installed properly:

/opt/bin/python
Python 2.5.4 (r254:67916, Mar 25 2009, 12:16:36)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-56)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Build Mercurial, using your Python 2.5:

cd ../mercurial-1.2.1
su -c "make install PYTHON=/opt/bin/python PREFIX=/opt"

Test Mercurial installed properly:

/opt/bin/hg --version
Mercurial Distributed SCM (version 1.2.1)
Copyright (C) 2005-2009 Matt Mackall and others

You may wish to symlink hg from somewhere in your $PATH:
su -c "ln -s /opt/bin/hg /usr/local/bin/hg"

Obviously you'll need a C compiler and associated development tools installed. You may find that the Python configure command complains of missing libraries, such as zlib-devel which can be installed via yum if required

Source: http://blog.friedland.id.au/2009/03/installing-mercurial-on-rhelcentos-3.html

November 2, 2012

When running configure, “.infig.status: error: cannot find input file:” error was generated:


This appears to be caused by by having DOS style line endings in the configure script.
You should be able to use the dos2unix command or alternatively, the tr command:

$ tr -d "\15\32" < configure > configure.new
$ mv configure.new configure
     $ chmod +x configure

 Original Post Here

November 1, 2012

linux console get image size

On linux console, if you need to get an image size, and imagemagick is not installed, you can use the following script (save it as "getimgsize.php", chmod +x, then run it with your image file":


#!/usr/bin/php -f
<?php
if ($argc<2){
        die("Usage: getimagesize IMAGEFILE\n");
}
list($width, $height, $type, $attr) = getimagesize($argv[1]);
echo "Size is $width x $height\n";

October 30, 2012

Windows 8 and Ubuntu 12.10 dual boot issue

I recently bought a HP Envy dv4 laptop for work. It came with Windows 8, and I wanted to install Ubuntu 12.10 Server on it. Here is the problems I ran into and how they were solved:

1. Internal CDROM install did not work correctly. First I thought it was because the CDROM was broken. Later on I found out that legacy BIOS support is not enabled in the UEFI. Once Legacy support is enabled in UEFI, installing from CDROM worked fine.

2. Ubuntu 12.10 64-bit did not detect that the system is using UEFI and installed GRUB-PC(which is for the old BIOS/MBR) instead. So after installation the system booted straight into Windows 8 with no  option to boot into Linux.

3. I downloaded the Boot Repair and ran it. It uninstalled the grub-pc and installed grub-efi but at the end it stated that error occurred and suggested that I move the Linux into the first partition. This was not an easy option for me. So the system still cannot boot into Linux.

4. What saved the day was the tool called "rEFInd" found in  This Post . The actual website is located at HERE. A great piece of software with clear instructions. So I booted into Windows 8 and followed the instruction listed under "

Installing rEFInd Manually Using Windows"


5. It worked great!! Later on I used the "bcdedit" command to set the boot manager to grubx64 directly and it worked as well.

Thanks Rod!


October 23, 2012

How to Tell if Your CPU supports Virtulization Technology on Linux


It’s quite simple: We’ll need to take a peek inside the /proc/cpuinfo file and look at the flags section for one of two values, vmx or svm.
  • vmx – (intel)
  • svm – (amd)
You can use grep to quickly see if either value exists in the file by running the following command:
egrep ‘(vmx|svm)’ /proc/cpuinfo
If your system supports VT, then you’ll see vmx or svm in the list of flags. My system has two processors, so there are two separate sections:

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
VT technology can still be disabled in your computer’s BIOS, however, so you’ll want to check there to make sure that it hasn’t been disabled. The flags in cpuinfo simply mean that your processor supports it.


Source: http://www.howtogeek.com/howto/linux/linux-tip-how-to-tell-if-your-processor-supports-vt/

October 12, 2012

vmware and virtualbox usb device in use not able to attach to VM

If you have a USB device that cannot be detached from the HOST and attach to your VM, one possible reason is because you are using USB 3.0 port the device. Change to a USB 2.0 port should help in that case. This was my case with Windows 7 running on Thinkpad T530.

September 19, 2012

Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Excerpt:

Avoiding IP Fragmentation: What TCP MSS Does and How It Works

The TCP Maximum Segment Size (MSS) defines the maximum amount of data that a host is willing to accept in a single TCP/IP datagram. This TCP/IP datagram may be fragmented at the IP layer. The MSS value is sent as a TCP header option only in TCP SYN segments. Each side of a TCP connection reports its MSS value to the other side. Contrary to popular belief, the MSS value is not negotiated between hosts. The sending host is required to limit the size of data in a single TCP segment to a value less than or equal to the MSS reported by the receiving host.
Originally, MSS meant how big a buffer (greater than or equal to 65496K) was allocated on a receiving station to be able to store the TCP data contained within a single IP datagram. MSS was the maximum segment (chunk) of data that the TCP receiver was willing to accept. This TCP segment could be as large as 64K (the maximum IP datagram size) and it could be fragmented at the IP layer in order to be transmitted across the network to the receiving host. The receiving host would reassemble the IP datagram before it handed the complete TCP segment to the TCP layer.