• Welcome to systemBash, a technology and system administration blog by David Drager. If you enjoy this sort of content, can can subscribe to the RSS using the link to the right.

If you wish to run a command which typically uses a lot of CPU (for example, running tar on a large file), then you probably don’t want to bog down your whole system with it. Linux systems provide the nice command to control your process priority at runtime, or renice to change the priority of an already running process. The full manpage has help, but the command if very easy to use:

$ nice -n prioritylevel /command/to/run

The priority level runs from -20 (top priority) to 19 (lowest). For example, to run tar and gzip at a the lowest priority level:

$ nice -n 19 tar -czvf file.tar.gz bigfiletocompress

similarly, if you have a process running, use ps to find the process ID, and then use renice to change it’s priority level:

$ renice -n 19 -p 987 32

This would change processes 987 and 32 to priority level 19.

For many people using hosted Exchange services, password saving problems could plague you. That is mainly because Outlook doesn’t like it if the Exchange server’s domain doesn’t match your domain.

Fortunately there is a way around this, because by the default way it is set up, you would have to enter your password every time you open up Outlook.

First step is to change the registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

Change lmcompatibilitylevel to “2″

Here is the meanings of these numbers (source):

0 - Clients use LM and NTLM authentication, but they never use NTLMv2 session security. Domain controllers accept LM, NTLM, and NTLMv2 authentication.
1 - Clients use LM and NTLM authentication, and they use NTLMv2 session security if the server supports it. Domain controllers accept LM, NTLM, and NTLMv2 authentication.
2 - Clients use only NTLM authentication, and they use NTLMv2 session security if the server supports it. Domain controller accepts LM, NTLM, and NTLMv2 authentication.
3 - Clients use only NTLMv2 authentication, and they use NTLMv2 session security if the server supports it. Domain controllers accept LM, NTLM, and NTLMv2 authentication.
4 - Clients use only NTLMv2 authentication, and they use NTLMv2 session security if the server supports it. Domain controller refuses LM authentication responses, but it accepts NTLM and NTLMv2.
5 - Clients use only NTLMv2 authentication, and they use NTLMv2 session security if the server supports it. Domain controller refuses LM and NTLM authentication responses, but it accepts NTLMv2.

I’ve uploaded a registry file which will automatically make the change here.

You then need to access the advanced user dialog properties (see my previous article on this if you do not see a tab in Control Panel -> Users & Accounts dialog). Click “Manage Passwords” and then add a new entry. This entry should be the Exchange server’s real name - the name that pops up in your password prompt windows. In my example, in is MAILXXX.mail.lan.

Advanced User Dialog Save Passwords

Finally, make sure that the Exchange server’s local name, MAILXXX.mail.lan, is in your hosts file. For most Windows XP folks, this is C:\WINDOWS\system32\drivers\etc\hosts.

The format is:

69.x.x.x MAILXXX.mail.lan

where the real accessible IP address is the first part, and the real Exchange server name is the section part. This allows your PC to locate the “Real” Exchange server name over the internet, even though it is not a real exchange server’s hostname on the internet.

Windows XP and Vista hides the advanced user dialog from the control panel area. This area has been used in Windows 2000 to set saved passwords for login, and also to save passwords for Exchange servers so that you don’t need to type in a password every time you open Outlook.

It can be used to save a password for Outlook if your domain is not the same as your Exchange server. If you don’t set this password, then the proxy server will always ask for a password even if you check off “Save Password”.

Go to Start->Run, then type in:

control userpasswords2

This will launch the advanced user dialog. You can now access the advanced tab. Tested in XP Professional and Vista Business.

Drupal’s administration login area is not secure by default. Usually there is an option in the configuration area of content management systems to set a secure area for logins, otherwise your username and password are sent in plain text over the internet.

Luckily, there is a module which enforces secure login on a Drupal install.

Drupal Module: Securepages

Although it is still in development, the 6.x-1.x-dev version worked great with my Drupal 6.4 installation.

We received this Blu-ray player along with a few Blu-Ray DVDs for an anniversary present. The BDP-S301 is the same as the BDP-S300 except it is only sold at wholesale outlets like Costco and Sam’s Club. The S301 also includes an HDMI cable.

The Pros: The image looks great. Hands down it is a clean, crisp image, and with the latest firmware updates (click here) supports most audio configurations.

The Cons: This thing is the slowest media player I have ever laid my hands on.

The instructions warn that the initial setup could take 90 seconds to start and after that, start up would be quicker. I suppose they didn’t lie - start up on an everyday basis takes around 40 seconds or more! After that, you can finally eject the tray to insert your movie, or make your way to the menu.

Forty seconds, when you have an impatient toddler wanting to watch Finding Nemo for the 50th time, is similar to taking a short detour through Dante’s 3rd circle of hell.

In addition to that, woe to the consumer who might get a relatively new, $30 Blu-ray movie to play in it. We put in Dan In Real Life (Ok movie, but slow paced) - it proceeds to play the previews, fine. Then it seemingly locks up for a few minutes on a screen with a progress bar that says “loading”. We power down, start the process again. Briefly before the “loading” screen pops up again, it mentions that on older players it could take several minutes to load the menu. Seriously, 3 to 4 minutes later, the menu loads up.

Again, we received 10,000BC (don’t waste your time) in the mail from Blockbuster. Started to play it and we wanted to stop and start it over. I pressed the stop button, and I guess I overloaded the system as it was totally frozen. I had to press the power button for 10 seconds and start the whole process over.

Are you kidding me? This is the worst consumer experience I’ve had in a long time. Maybe I am just an impatient American, but spending 5 minutes waiting for a movie to load up, after having spent that much money on top of the line technology, is a disgrace. Sony should be ashamed that they let this product go to market.

What is it doing during this loading time? Is the Java OS loading all of its unnecessary libraries? Who allowed this to pass by QA?

So my recommendation to anyone looking to buy one of these systems is keep looking! There are more and more choices out there. The PS3 is only $50-$100 more and it loads movies much faster and has many more advanced media features (like streaming audio and video right to the PS3 from other media servers), not to mention all the games you can play on it.

Sony used to be top notch in my opinion when it came to hardware of any kind. However after this incident, I will really have to think twice before getting another Sony product!

Names like Comcast, Verizon, SBC, RoadRunner, Cox, Charter - control the vast majority of the ‘last mile’ internet running into many homes. A fact of today’s economy in the United States is that in any particular geographic area, you only have a handful of providers that can provide high-speed access to the internet. For example, in the Philadelphia region there are only 2 serious options - Verizon and Comcast.

The reason for this is that being able to provide a high speed access line to a home involves running a LOT of wire or fiber - and this has an enormous  investment in capital and technology. Only large companies have the resources available to provide these services and keep them stable. They also will buy many smaller companies that pop up - both for their technology or because it also eliminates some of the competition. Comcast has done this in our area and has largely bought many alternatives to their cable service.

Television, on the same hand, has traditionally been controlled by a handful of local companies. Largely due to copyright restrictions and content agreements, smaller non-geographically centered companies have been unable to gain access to popular content. Therefore most television providers are behemoths and there are not many smaller options.

Now in theory, we now have the internet bandwidth to have full streaming, HD television content to come right over your internet connection. There is a great deal of bandwidth involved in such a service - so the technology many companies use to bring video streams to your desktop (or other display) uses Point to Point protocol (P2P). This distributes the bandwidth across many clients so instead of having one source for the video bandwidth, it is more evenly distributed.

The Problem

Perhaps you see where this is going. Many major ISPs now offer television services over their connections. Likewise, many Television companies offer internet service as well. The prospect of a customer going to another company and purchasing a television package, using your ISP/Television Company’s internet bandwidth (that you already pay for), is a frightening prospect for them. Right now, cable programming is a cash cow. I would say the majority of television users watch a handful of channels on a regular basis, however all cable television companies force you to purchase a ‘package’ with hundreds of channels. They have largely resisted a-la-cart programming options.

What it comes down to is choice. The choice to be a smart consumer and not be tied down to a single company for any service - whether that be internet, television or phone. Of course, the companies who provide these services would love for you to have to use their other services, and in my experience many consumers do go for these ‘triple play’ packages. In their minds, getting phone, internet, and TV for $99 (Even though this is a teaser rate, and will likely go up to $140 a month or more after the initial period) is a great deal.

So what can you do?

So how can the consumer fight for this choice? The companies certainly are not going to fight for you.

  1. In the United States, the FCC has some power to regular the big companies that deliver internet to your household. Some people (including myself) do not completely trust in this entity to serve the best interests of consumers.
  2. Ultimately, in today’s free enterprise economic system - your wallet does the talking. If your ISP decides to throttle, delay, or otherwise impede P2P traffic - run for the hills and choose the nearest alternative. Let them know this is the reason you are leaving.
  3. Finally, educate anyone willing to listen about this problem. It goes largely unnoticed by the general population, and the more people who know about this issue, the better.

So what happens when there are no other choices? Well then it may be time for a new breed of ISP to enter the landscape, but I’ll save that article for another day.

For more information or to contact your representative, see http://www.savetheinternet.com/.

I use MediaCoder for most of my encoding/transcoding of video for playback on my PC and other devices. The N800 has a peculiar set of parameters for it’s video - if it doesn’t match up then it either won’t play back or will be very choppy.

I ended up selling the N800 but I thought I would pass this profile along to anyone who might use it.

<?xml version="1.0" encoding="UTF-8"?>
<MediaCoderPrefs>
  <node key="overall">
    <node key="generic">
      <node key="autoRevert">
        <value>Never</value>
      </node>
    </node>
    <node key="ui">
      <node key="optionTab">
        <value>3</value>
      </node>
      <node key="param">
        <value>1069,767,47,50</value>
      </node>
      <node key="noWelcome">
        <value>4068</value>
      </node>
    </node>
    <node key="task"/>
    <node key="output"/>
    <node key="tagging"/>
    <node key="subtitle"/>
    <node key="decoding"/>
    <node key="audio"/>
    <node key="video">
      <node key="format">
        <value>XviD</value>
      </node>
    </node>
    <node key="container">
      <node key="format">
        <value>AVI</value>
      </node>
    </node>
    <node key="mplayer"/>
    <node key="preview"/>
    <node key="plugin"/>
    <node key="presets"/>
    <node key="httpd"/>
    <node key="server"/>
  </node>
  <node key="audiosrc">
    <node key="mplayer"/>
    <node key="winamp"/>
    <node key="lame"/>
    <node key="wavefile"/>
  </node>
  <node key="audioenc">
    <node key="lame"/>
    <node key="vorbis"/>
    <node key="faac"/>
    <node key="aacplus"/>
    <node key="nero"/>
    <node key="helix"/>
    <node key="helixmp3"/>
    <node key="fraunhofer"/>
    <node key="speex"/>
    <node key="musepack"/>
    <node key="ffmpeg"/>
    <node key="aac3gpp"/>
    <node key="amr"/>
    <node key="wavpack"/>
    <node key="flac"/>
    <node key="ape"/>
    <node key="tta"/>
    <node key="als"/>
    <node key="ofr"/>
    <node key="pcm"/>
    <node key="cli"/>
  </node>
  <node key="videosrc">
    <node key="mplayer"/>
    <node key="avisynth"/>
  </node>
  <node key="videoenc">
    <node key="xvid"/>
    <node key="x264"/>
    <node key="mencoder"/>
    <node key="ffmpeg"/>
    <node key="theora"/>
    <node key="dirac"/>
    <node key="amv"/>
    <node key="vfw"/>
    <node key="dumper"/>
    <node key="wm"/>
    <node key="remote"/>
  </node>
  <node key="container">
    <node key="mp4box"/>
    <node key="matroska"/>
    <node key="mencoder"/>
    <node key="mp4creator"/>
    <node key="atom"/>
    <node key="pmp"/>
    <node key="vcd"/>
  </node>
  <node key="audiofilter">
    <node key="resample"/>
    <node key="equalizer"/>
    <node key="channels"/>
    <node key="volume"/>
    <node key="surround"/>
    <node key="compressor"/>
    <node key="delay"/>
    <node key="extraStereo"/>
    <node key="extra"/>
    <node key="shibatch"/>
  </node>
  <node key="videofilter">
    <node key="scale">
      <node key="enabled">
        <value>true</value>
      </node>
      <node key="width">
        <value>352</value>
      </node>
      <node key="height">
        <value>288</value>
      </node>
    </node>
    <node key="crop"/>
    <node key="expand"/>
    <node key="frame"/>
    <node key="eq"/>
    <node key="postproc"/>
    <node key="rotate"/>
    <node key="itf"/>
    <node key="denoise"/>
    <node key="unsharp"/>
    <node key="delogo"/>
    <node key="screenshot"/>
    <node key="thumb"/>
    <node key="extra"/>
  </node>
</MediaCoderPrefs>

You can also download the file here: N800.xml

I created this Bash script as a project for the system administration course I’m taking for the summer. I’m sure there are bugs in it, so let me know if you find any.

It basically uses an XML configuration file, which includes the source, destination, and any excludes from the transfer. You then pass either -u or -d (upload or download) and the options -x (delete if not in source) and -f (force). Destination can be local or remote, but source must be local.

Here is the code:

#!/bin/bash
## Transfer Script
## By David Drager
## CSC586: Summer II 2008
## Requires: xml2, rsync

## Settings
tempdir="/tmp/"
rsynccommand="/usr/bin/rsync"

## Usage command
usage="usage: transfer.sh [options] <config-file>.xmlnoptions:n  -d or -u:t download or upload, resp. one and only one must be presentn  -f:ttforce transfer regardless of 'newness' of filen  -x:ttdelete items in target not present in source"

# Check to make sure temporary directory exists
[ -d $tempdir ] || { echo -e "Error: Could not locate a temporary directory. See file settings."; exit 1; }

# Usage Command
[ $# -eq 0 ] && { echo -e "ERROR: Needs at least the -d or -u flag plus a config file.nn$usage"; exit 1; }

## Get options passed to the program
while getopts "dufx" flag
do
  [ "$flag" = "?" ] && echo -e "ERROR: Flag(s) not valid.nn$usage" && exit 1;
  eval "opt_$flag=1"
done
shift $((OPTIND-1))
configfile="$1"

if [ "$opt_d" = 1 ] && [ "$opt_u" = 1 ]
then
  echo -e "Error: Use either -u Upload or -d Download, but not bothn$usage"; exit 1;
elif  [ "$opt_u" = "" ] && [ "$opt_d" = "" ]
then
    echo -e "Error: Use either -u Upload or -d Download, but not bothn$usage"; exit 1;
fi

if [ "$opt_f" = 1 ]; then
  force=1
fi

if [ "$opt_x" = 1 ]; then
  deltar=1
fi

## Make sure config file is located
if [ "$configfile" != "" ]
then
  [ -f "$configfile" ] || { echo -e "Error: Config file not found.n$usage"; exit 1; }
else
   echo -e "Error: Config file not specified.n$usage"; exit 1;
fi

## End of swich verification

# echo Action: "$action"
# echo Force: "$force"
# echo Delete Target Files: "$deltar"
# echo Config: "$configfile"

## Now read config file

## Set temp file for XML parsing
tempfile="$tempdir"transferscript_$$
tempexcludes="$tempdir"transferscriptexcludes_$$
# echo -e "Temp:$tempfile"

# Run config file through xml2
xml2 < "$configfile" > "$tempfile"

[ -f "$tempfile" ] || { echo -e "There was a problem processing the XML file."; exit 1; }

# Make sure that source and destination are found
excludelist=""
while read line; do
    key=$(echo $line | awk -F '=' '{print $1}')
    value=$(echo $line | awk -F '=' '{print $2}')
    if [ "$key" = "/sync/@src" ]; then
      source="$value";
    elif [ "$key" = "/sync/@dst" ]; then
      destination="$value"
      # Add any exclude options to array
    elif [ "$key" = "/sync/exclude" ]; then
      tempexcl=("$value")
      excludelist=("${excludelist[@]}" "${tempexcl[@]}")
    fi
done < "$tempfile"

[ "$source" ] || { echo "Error: Config file must include a source"; exit 1; }
[ "$destination" ] || { echo "Error: Config file must include a destination"; exit 1; }

source="$source/"
destination="$destination/"

[ -d "$source" ] || { echo "Error: Source must be a local directory"; exit 1; }

excludes=""
excludes=${excludelist[@]}

# echo Excludes: "(${#excludelist[@]}): $excludes"

## Clean up temp file from xml process
rm "$tempfile"

## Build up the command line

[ -f "$rsynccommand" ] || { echo -e "Error: Could not locate rsync command."; exit 1; }

fullcommand="$rsynccommand"
fulltestcommand="$rsynccommand"

if [ "$opt_f" == "1" ]
then
    fulltestcommand="$fulltestcommand -nva"
    fullcommand="$fullcommand -a"
else
    fulltestcommand="$fulltestcommand -nvau"
    fullcommand="$fullcommand -au"
fi

if [ "$opt_u" == "1" ]
then
  fileorder="$source $destination"
  echo "Evaluating transfer from $source ==> $destination"
elif [ "$opt_d" == "1" ]
then
  fileorder="$destination $source"
  echo "Evaluating transfer from $destination ==> $source"
fi

[ "$opt_x" == "1" ] && { fulltestcommand="$fulltestcommand --delete"; fullcommand="$fullcommand --delete"; }

## Move exclude list to a file.
## This duplicates as above but I originally thought we were passing it to rsync as a list and not as a file.

[ "${#excludelist[@]}" -gt 0 ] && {
    tempfile="$tempdir"transferscript_$$
    touch "$tempfile"
    echo "$excludes" | tr " " "n" > "$tempfile"
    fulltestcommand="$fulltestcommand"" --exclude-from=$tempfile"
    fullcommand="$fullcommand"" --exclude-from=$tempfile"
}

fulltestcommand="$fulltestcommand $fileorder"
fullcommand="$fullcommand $fileorder"

# We only want lines minus top line and bottom 3 lines
testresult=`$fulltestcommand | tail --lines=+2 | head --lines=-3`

# If this is empty, then notify that no files would be transferred.
 [ "$testresult" ] || { echo "This command would not transfer any files. Script exiting."; rm "$tempfile"; exit 1; }

# Display changes
echo -e "Changes to be made:n--------------------n$testresultn--------------------"

# Check to see if we really want to run the command.
echo "Do you wish to perform this command? $fullcommand (y/n)[y]"
read confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "" ]
then
    echo "Performing transfer..."
    # Without -v this will not output anything.
    $fullcommand
    echo "Transfer complete."
    rm "$tempfile"
else
    echo "Cancelling transfer..."
    rm "$tempfile"
fi

exit 0

Here is the sample config file:

<sync src="/home/dir/bash-prog/dir1/" dst="login@some.machine:/home/dir/dir2">
        <exclude>
          .test3
          another.*
        </exclude>
</sync>

Visit http://www.google.com/safebrowsing/report_phish/ and report a phishing page this is the response:

Report Sent

Thanks for sending a report to Google. Now that you’ve done your good deed for the day, feel free to:

1. Take a second to rejoice merrily for doing your part in making the web a safer place.

2. Call/email/write to a neighbor/friend/relative and tell them what phishing is and how they can protect themselves.

3. Learn more about malware that can infect your computer on Stopbadware.org.

Jun 17

Real Security

No comment - Post a comment


Real Security is knowing when you’re being bamboozled.

Security Scissors