Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, January 27, 2009

Guidance on Ahead of Time Compilation for Mono 2.2?

Does anyone have recommendations on using ahead of time compilation for the system libraries under Mono 2.2? The Mono website has this article with some (outdated?) information about how to carry it out. I tried following the instructions with the following exceptions:
  • I found multiple mscorlib.dll assemblies (at /usr/lib/mono/1.0, 2.0, 2.1) and tried AOT-compiling all of them. Only the 1.0 and 2.0 assemblies succeeded. The 2.1 assembly kept referring to the 2.0 assembly and never produced the .so file for itself.
  • Several assemblies (System.Xml.dll for one) in the GAC failed to precompile. The AOT compilation process for that one complained that it could not load the System assembly.
When I tried executing Mono executables (themselves also AOT-compiled and working prior to my pre-compilation of the system assemblies), they universally failed with Mono framework errors.

Has anyone successfully AOT-compiled the system assemblies under Mono 2.2? Is this even a good idea, assuming there's a way to make it work?

Tuesday, October 28, 2008

Compiling Mono 2.0.1 on Ubuntu Gutsy Server 8.04

I didn't want to use the aging Mono version present in Ubuntu Server 8.04, so I set out to compile Mono 2.0 (and subsequently 2.0.1, via the same process). This turned out not to be too bad.

First, install the requisite packages:
aptitude install build-essential swig autoconf gawk mono-common binfmt-support bison pkg-config libglib2.0-dev
Yes, that's not a typo--you do want one of Ubuntu's Mono packages, mono-common. This will enable shell execution of Mono executables via ./ notation rather than having to execute "mono /path/to/executable."

Once you are done, download and unpack the source for Mono. This will get you 2.0.1:
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.0.1.tar.bz2
tar xf mono-2.0.1.tar.bz2

Now you are ready to build and install Mono (the make step will take a while):
cd mono-2.0.1
./configure --with-libgdiplus=no
make
make install
Lastly, you need one symlink so the binfmt-support package can execute Mono executables directly via the shell:
ln -s /usr/local/bin/mono /usr/bin/cli
That's it. Typing the command "mono -V" should yield the about information for Mono 2.0.1. Follow the instructions under "Testing the Mono installation" and confirm you can not only build and execute the example.exe application, but that you can execute it with ./ notation (e.g. ./example.exe).

Cheers!

Sunday, August 17, 2008

Copying files from Linux to Windows

If you ever have occasion to copy files from Linux to Windows, you may discover that this process is not as simple as it may seem. It's fairly easy to take a USB drive formatted with the FAT or NTFS filesystem and physically transport the files from one environment to the other, but there are other complexities you must manage:

1. File Naming Rules

On ext3 filesystems, one of the most common filesystems in the Linux world, there are many legal filenames that are illegal on Windows:
  • Filenames with double quotes (")
  • Filenames with colons (:)
  • Filenames with backslashes (\)
  • etc.
This script will, when executed from the path you wish to examine, rename the files so that they have legal names for Windows environments.

2. Path Length

While ext3 has no maximum length for paths and a 255-character limit for filenames, Windows' NTFS restricts each each path component (directory or filename) to a maximum of up to 255 characters long (from Wikipedia). You have to examine the source folders to confirm you don't have any path component names that are too long to copy. DO NOT TRUST THE SUCCESS OF THE FILE COPY TO VALIDATE THIS. It seems that the Linux NTFS implementation (at least on Ubuntu 8.04) allows paths that would be legal for ext3, and that work while the Linux machine is using the NTFS-formatted drive, but that are NOT legal when consumed by Windows.

3. Case Sensitivity

Windows filenames are not case-sensitive, but Linux filenames are. This means that if you have two files in one folder on the Linux source system as follows:
  • myDocument.doc
  • MyDocument.doc
Only one of these will copy to the destination, or odd errors will result when you attempt to copy them. To identify these issues, and to confirm you haven't been bitten by any of the above problems...

4. Compare, compare, compare

Always use a file and folder compare tool like WinMerge to make sure that everything did copy over properly. Make sure you investigate any differences it identifies, because those are likely issues with case-sensitivity, path lengths, or other problems. This prevents you from thinking you have a good copy of the file tree when you don't. I recommend editing WinMerge's compare options so that only the file size and time are considered when comparing the results of large copy operations so that the comparison completes in a timely fashion.

5. Text File Handling

Lastly, you must be aware that text files have different end-of-line delimiters on Linux vs. Windows. This means that at a minimum Windows programs that don't understand this (Notepad) will show the text all run together rather than having separate lines as it should be. Cross-platform applications using the files (e.g. the instant messenger application Pidgin) will fail on Windows because they expect Windows text file formats.

To avoid these issues, after getting a successful copy, use a Unix-to-Windows text file converter application. I have had good luck with EOL Converter (as an added bonus, it is also free. :) )

Sunday, April 20, 2008

Infrequent IP address changes and No-IP

I use No-IP to provide dynamic DNS services so I can have remote access to my machine at home. However, the No-IP client doesn't send updates when my IP address doesn't change, and with my provider it tends to not change for quite some time. This causes No-IP to send me warning messages that my host is going to be deactivated from inactivity. In these notices, there is a link you can click to keep your host alive with its current IP. That got me thinking how I could force a periodic update.

I wrote the following script, pagecheck, to allow fetching an arbitrary web page and checking for some simple content in the page output:

#!/bin/bash
#Gets a web page and searches it for the specified text; if not found, or if a wget error results, returns
#an error code and prints error text.
#Arthur Penn - 16 Apr 2008

if [ $# -ne 2 ]; then
echo "pagecheck \"URL to page\" \"Success text to expect\""
exit 1
fi

PAGE=$(wget --no-verbose -O - "$1" 2>&1)
RC=$?
if [ 0 -eq $RC ]; then
SUCCESS=$(echo "$PAGE" | grep "$2")
if [ -n "$SUCCESS" ]; then
exit 0
else
echo "Did not find success message of \"$2\" in $1:"
echo "$PAGE"
exit 1
fi
else
echo "$PAGE"
exit 1
fi



This uses wget to fetch the web page and look for the content, and only prints output when it encounters problems. This makes it suitable for cron jobs. I added this script to /usr/local/bin (save it to a text file, and then: sudo cp pagecheck /usr/local/bin && sudo chmod +x /usr/local/bin/pagecheck). I then added the following script into the /etc/cron.monthly folder so it gets run once per month (don't do this more often to avoid excessive No-IP updates):

#!/bin/bash
# Touches the no-ip.com host dialog to confirm that the URL is still in use
/usr/local/bin/pagecheck "http://www.no-ip.com/hostactive.php?host=myhost&domain=noipdomain.net" "Update Successful"



T0 use this, you need to update the portions in red to match your No-IP domain (e.g. if your No-IP domain is fred.atx.net, the host would be "fred," and the domain would be "atx.net."

Since doing this, I haven't gotten any of the host deactivation messages from No-IP.

Thursday, February 14, 2008

Ubuntu rkhunter configuration

I recently added rkhunter, a rootkit detection utility, to my Ubuntu installation. After doing so, I started picking up warnings from cron during its daily scan:
Warning: Found enabled inetd service: /usr/sbin/vmware-authd
Warning: Hidden directory found: /etc/.java
Warning: Hidden directory found: /dev/.static
Warning: Hidden directory found: /dev/.udev
Warning: Hidden directory found: /dev/.initramfs
Warning: Hidden file found: /dev/.tmp-2-0: block special (2/0)
Research indicates that these particular warnings are spurious--I know I have VMware running, and the others seem to be facets of the way Ubuntu is constructed. To suppress them, I added the following lines to /etc/rkhunter.conf:

ALLOWHIDDENDIR=/etc/.java
ALLOWHIDDENDIR=/dev/.static
ALLOWHIDDENDIR=/dev/.udev
ALLOWHIDDENDIR=/dev/.initramfs
ALLOWHIDDENFILE=/dev/.tmp-2-0
INETD_ALLOWED_SVC=/usr/sbin/vmware-authd