Change SUEXEC docroot without changing makefiles under FreeBSD

July 23rd, 2010

make WITH_SUEXEC=yes SUEXEC_DOCROOT=’/foo’

Alternately you can add

WITH_SUEXEC=yes
SUEXEC_DOCROOT=’/foo’

to the /etc/make.conf file

Using awk to add new files to svn

July 17th, 2009
svn add `svn status | grep "^?" | awk '{print $2 }'`

you can also use grep -v to exclude specific files

svn add `svn status | grep "^?" | awk '{print $2 }' | grep -v prefs.inc.php`

Recursively convert all text files in a directory from Windows EOL to Unix with dos2unix

April 10th, 2009
find . -type f -exec dos2unix {} \;

Migrating a RedHat users file to FreeBSD/OpenBSD

April 5th, 2009

http://www.openbsd.org/faq/faq9.html#passwd

First, figure out if your Linux password file is shadowed or not. If it is, install John the Ripper from packages or ports (security/john) and use the unshadow utility that comes with it to merge your passwd and shadow files into one Sixth Edition-style file.

Using your Linux password file, we’ll call it linux_passwd, you need to add in ::0:0 between fields four and seven. awk(1) does this for you.

# cat linux_passwd | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", \
> $1,$2,$3,$4,$5,$6,$7); }' > new_passwd

At this point, you want to edit the new_passwd file and remove the root and other system entries that are already present in your OpenBSD password file or aren’t applicable with OpenBSD (all of them). Also, make sure there are no duplicate usernames or user IDs between new_passwd and your OpenBSD box’s /etc/passwd. The easiest way to do this is to start with a fresh /etc/passwd

.

# cat new_passwd >> /etc/master.passwd
# pwd_mkdb -p /etc/master.passwd

The last step, pwd_mkdb is necessary to rebuild the /etc/spwd.db and /etc/pwd.db files. It also creates a Sixth Edition-style password file (minus encrypted passwords) at /etc/passwd for programs which use it. OpenBSD uses a stronger encryption for passwords, blowfish, which is very unlikely to be found on any system which uses full Sixth Edition-style password files. To switch over to this stronger encryption, simply have the users run ‘passwd’ and change their password. The new password they enter will be encrypted with your default setting (usually blowfish unless you’ve edited /etc/login.conf). Or, as root, you can run passwd username.

Also you will want to copy over the groups file. note again, only copy over groups that do not exist in both.

convert linux passwd to a FreeBSD one

March 31st, 2009
cat linux_passwd | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", $1,$2,$3,$4,$5,$6,$7); }' > new_passwd

Basic pfctl control

March 30th, 2009

# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.

#### General PFCTL Commands ####
# pfctl -d disable packet-filtering
# pfctl -e enable packet-filtering
# pfctl -q run quiet
# pfctl -v -v run even more verbose

#### Loading PF Rules ####
# pfctl -f /etc/pf.conf load /etc/pf.conf
# pfctl -n -f /etc/pf.conf parse /etc/pf.conf, but dont load it
# pfctl -R -f /etc/pf.conf load only the FILTER rules
# pfctl -N -f /etc/pf.conf load only the NAT rules
# pfctl -O -f /etc/pf.conf load only the OPTION rules

#### Clearing PF Rules & Counters ####
# pfctl -F all flush ALL
# pfctl -F rules flush only the RULES
# pfctl -F queue flush only queue’s
# pfctl -F nat flush only NAT
# pfctl -F info flush all stats that are not part of any rule.
# pfctl -z clear all counters
# note: flushing rules do not touch any existing stateful connections

#### Output PF Information ####
# pfctl -s rules show filter information
# pfctl -v -s rules show filter information for what FILTER rules hit..
# pfctl -vvsr show filter information as above and prepend rule numbers
# pfctl -v -s nat show NAT information, for which NAT rules hit..
# pfctl -s nat -i xl1 show NAT information for interface xl1
# pfctl -s queue show QUEUE information
# pfctl -s label show LABEL information
# pfctl -s state show contents of the STATE table
# pfctl -s info show statistics for state tables and packet normalization
# pfctl -s all show everything

#### Maintaining PF Tables ####
# pfctl -t addvhosts -T show show table addvhosts
# pfctl -vvsTables view global information about all tables
# pfctl -t addvhosts -T add 192.168.1.50 add entry to table addvhosts
# pfctl -t addvhosts -T add 192.168.1.0/16 add a network to table addvhosts
# pfctl -t addvhosts -T delete 192.168.1.0/16 delete nework from table addvhosts
# pfctl -t addvhosts -T flush remove all entries from table addvhosts
# pfctl -t addvhosts -T kill delete table addvhosts entirely
# pfctl -t addvhosts -T replace -f /etc/addvhosts reload table addvhosts on the fly
# pfctl -t addvhosts -T test 192.168.1.40 find ip address 192.168.1.40 in table addvhosts
# pfctl -T load -f /etc/pf.conf load a new table definition
# pfctl -t addvhosts -T show -v output stats for each ip address in table addvhosts
# pfctl -t addvhosts -T zero reset all counters for table addvhosts

Installing VMware Server on Ubuntu 8.04 Hardy Heron

June 16th, 2008

I found a great post at MakeTechEasier I changed it a little and posted it.

You will be building kernel specific files so you need to have the proper header files installed for your kernel along with something to compile it.

sudo apt-get install linux-headers-`uname -r` build-essential
sudo apt-get install xinetd gcc-3.4

If you are using 64 bits system, you have to install 32bit compatibility files

sudo apt-get install ia32-libs

Download VMware Server 1.0.6

Download the patch file vmware-any-any-update-116.tgz

Extract the downloaded files

tar zxf vmware-any-any-update-116.tgz
tar xzf VMware-server-1.0.6-91891.tar.gz

Run the VMware Server installer

cd vmware-server-distrib
sudo ./vmware-install.pl

You will be prompted to answer some questions. Press Enter to select the default answer. When it reaches the point that requires you to run vmware-config.pl, type No. The installer will exit. Next, apply the patch

cd vmware-any-any-update116
sudo ./runme.pl

This time, press Enter for all the questions and enter Yes to run the vmware-comfig.pl. Once it has finished compiling, you should now see the VMware console in your Applications->Other. The first time you run vmware use the console by typing vmware in the terminal. If there are any errors it will tell us. If it says it can’t find some files all we need to do is copy them from the /usr/lib directory.

sudo cp /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0/
sudo cp /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1/

For 64 bit users

sudo ln -s /usr/lib32 /usr/l32
sudo sed -i -e ’s/usr\/lib/usr\/l32/g’ /usr/lib32/gtk-2.0/2.10.0/loader-files.d/libgtk2.0-0.loaders
sudo sed -i -e ’s/usr\/lib/usr\/l32/g’ /usr/lib32/libgdk_pixbuf-2.0.so.0.1200.9

That’s it. Your VMware Server should be working now.

Realtek ALC888 and Ubuntu Hardy Heron low audio problem

May 4th, 2008

Last night I installed Ubuntu 8.04 and I’m so impressed. I did the WbUI version. And let me tell you, It was the easiest OS install I have ever done. Everything is great only one problem. My audio was really quiet. I have an Realtek ALC888 chipset. I had to crank my speakers to get a descent volume.

I found a solution.

Even through I have my speakers plugged into the ‘Green’ standard front channel jack Ubuntu thinks it’s plugged into the side channel.

  1.  Open up the ALSA mixer[double click on the speaker at the top by the time]
  2. Click on Edit->Preferences
  3. Check all of the output channels
  4. Turn the volume up on all the devices till you find the right channel(be careful if you have your speakers still cranked or you’ll soil yourself)

Thats it. Easy.

Using OpenSSL to generate a self signed SSL certificate for Apache.

March 15th, 2008

Originally found at How to create a self-signed Certificate

  1. Generate server key
    openssl genrsa -des3 -out server.key 1024
  2. Generate csr
    openssl req -new -key server.key -out server.csr
  3. Remove passphase so apache don’t ask for it on every server start
    cp server.key server.key.org
    openssl rsa -in server.key.org -out server.key
  4. Create self signed certificate
    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  5. Copy certificate to Apache dir
    cp server.crt /usr/local/apache/conf/ssl.crt
    cp server.key /usr/local/apache/conf/ssl.key
  6. Configure Apache to use the certificate
    SSLEngine on
    SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
    SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    CustomLog logs/ssl_request_log
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Make a recursive diff file

November 6th, 2007
diff -exclude="*~" -Naur <old_path> <new_path>