Errors Linux Misc Networking Software

Gmail automatic “mark (spam) as read”

I hate having unread mail. I hate having spam. And most of all, I hate spam that asks for attention.

When receiving spam in Gmail, you get the annoying bold Spam (12353434) with ‘12353434’ being the number of unread spam messages.

With the introduction of Gmail Labs I’d hope to see an “automaticly mark spam message as seen” feature, which, well, I haven’t found yet.

Being tired of all these increasing spam numbers, and my daily efforts to “select all unread + mark as read”, I ended up writing a small PHP file which connects to the Gmail (using IMAP, so I asume you’ll need IMAP enabled in your settings..) and marks all spam messages as read. Running this script locally with a curl or cron every X time will solve most of your problems, I hope.

Download the file here (phps) or here (txt).

Or just copy paste it!

< ?php
Gmail "spam mark-as-read"
by Tuinslak
v0.01 :: 26/08/2008 . init php codez
// Config starts here
// Gmail user &amp; pass
$user = "YOU";
$pass = "hiddensecretz";
// Debugging - Outputs a list of mailboxes and status on the imap server (1/0)
$listmailbox = 0;
// Advanced config :o
// "Path" of the (spam) mailbox and/or its name.
// default should be ok with Gmail.
$path = "[Google Mail]/Spam";
// End of config
$open = imap_open ("{}$path", $user, $pass, "", 1) or die(imap_last_error() . "
Connection failed.");
// debug
if($listmailbox) {
        echo "<strong>Mailboxes:";
        $folders = imap_listmailbox($open,  "{  Gmail  }", "*");
        if ($folders == false) {
                echo "Call failed\n";
        } else {
                foreach ($folders as $val) {
                        echo $val . "\n";
        echo "</strong><strong>Status</strong>:";
        $status = imap_status($open, "{}$path", SA_ALL);
        if ($status) {
                echo "Messages:   " . $status-&gt;messages    . "\n";
                echo "Recent:     " . $status-&gt;recent      . "\n";
                echo "Unseen:     " . $status-&gt;unseen      . "\n";
                echo "UIDnext:    " . $status-&gt;uidnext     . "\n";
                echo "UIDvalidity:" . $status-&gt;uidvalidity . "\n";
        } else {
                echo "imap_status failed: " . imap_last_error() . "\n";
// Mark as read
$search = imap_search($open, 'UNSEEN');
// print out the array containing $search info
for ($i = 0; $i &lt; sizeof($search); $i++) {
        $read = imap_setflag_full($open, $search[$i], '\\Seen');
// and close it down !
// EOF

If you plan to execute it from shell, don’t forget to add a shebang “#!/usr/bin/php” on line 1 and chmod +x gmail_spamreader.php.

Edit: Please add a comment if you’re using it, just for statistics. 🙂

Apple Linux Software

Rsync backups

My own simple rsync backup ‘script’.

You’ll need a rsync server, something to backup, and ssh-agent running to ease the process (or, fill in your password each time).

Add the following lines (using a terminal text editor) to a text file (“.rsync” for example, hidden files under Unix-like systems), and chmod +x $file.

rsync --archive -uv --exclude-from=/home/you/.rsync_exclude \
--rsh="ssh -p 222" --delete --stats --progress /Users/you/Documents/ \

This will upload any files in /Users/you/Documents to /home/you/remote-backup-directory.

It will use ssh on port 222 to transfer the files.

Just execute ./.rsync (if that’s the name of your file) to run it.

If you make any changes (locally), and run this, the changes will be applied on the remote server (e.g. file changes, renames, deletes, …) — this will delete files on the remote server if you’ve deleted them locally!

The file .rsync_exclude is optional, it includes all files or directories that should NOT be uploaded

This is what I have in my .rsync_exclude:

Nazgul:~ yeri$ cat .rsync_exclude

Simple as hell, and yet so handy!

Errors Linux

Multiple Memory Access Vulnerabilities Linux Kernel

Well, it had to happen…

Yesterday evening two of our linux boxes were exploited.
I had to try it out for myself; and yes, it really does work. 😐
Booted up my Ubuntu in Parallels, installed build-essential & ran that program!

sudo apt-get install build-essential
gcc what-ever-the-file-name-is.c

This is what it looks like:

Kernel exploit

I’m pretty sure this doesn’t require any more explanations 😉

Apple Linux VM

Parallels + Ubuntu

I finally got a reply from the Parallels support team. After using the alternate Parallels installer it finally works again! Even after rebooting Mac! joy

Before trying to run Vista/Bootcamp through Parallels again, I’m waiting till the end of my exams (Thursday). Don’t want to blow up my Windows install again when I’m in desperate need of it. 😉

As usual with Parallels, creating/installing a new OS isn’t easy. Wether it crashes or you get a bunch of errors, you’re always up for a day full of fun!

Ubuntu on Parallels (1)

Here is how I managed to install Ubuntu on Parallels:

  • First of all, make sure you’re running the latest version of Parallels, especially if you’re using Leopard.
  • Step 2, download the alternate Ubuntu installer. If you do not use the alternate installer, you’ll end up with ‘Display server errors’ before being able to install Ubuntu. You can download Ubuntu here. Select the approriate version (probably Desktop, latest version), and check “Check here if you need the alternate desktop CD. This CD does not include the Live CD, instead it uses a text-based installer“.
  • Step 3, create a new virtual machine, with OS Linux/Ubuntu.

Parallels: Create a VMParallels: Create a VM (2)

  • And follow the steps. I’ve added some more screenshots below. You can leave everything by default, that’s as you wish.

Parallels: Create a VM (3)Parallels: Create a VM (4)Parallels: Create a VM (5)Parallels: Create a VM (6)Parallels: Create a VM (7)Parallels: Create a VM (8)

  • As CD-drive, select the Ubuntu (alternate) installer .iso-file.

Parallels: Create a VM (9)

  • Click Finish and Start — the Ubuntu installer will boot.
  • You’ll end up in Ubuntu’s welcome screen. Select your keyboard layout (hit F3) and select (text) install
  • Here too, follow the steps on the screen. It will ask for your language, country, and will propose a manual or automatic disk partition. I’ve selected automatic — it creates a big ext3 root partition, and a swap partition.
    The installer then asks if you agree with the partition table. Select Yes or No. (I’ve selected No – changed my root partition from ext3 to reiserfs, as I’m a big reiserfs fan.) When selecting Yes — the table will be created and Ubuntu will start installing.
  • After it’s installed, Ubuntu will reboot. This is where you’ll get your first error; ACPI: Unable to locate RSDP. This is a known error; you can safey ignore it.
  • Ubuntu will continue to boot, and then pop up this error: The display server has been shut down about 6 times in the last 90 seconds, and will freeze. To fix this error, shut down and restart (or reset) the VM, and hit the ESC-key. Grub’s bootloader menu will pop up if everything is right.
  • Select the 2nd option (recovery). Ubuntu will boot up in text-mode-only and you should be logged in as root (if you’re not, add ‘sudo’ in front of the commands below).
  • In Parallels, click (on top of your screen) “Actions” -> “Install Parallels Tools…” and type in following commands in the shell:
    • mount /media/cdrom
    • cd /media/cdrom
    • ./
    • reboot
  • After Ubuntu has rebooted (in normal mode), you shouldn’t receive any more errors, and you can enjoy Ubuntu on your mac!

Ubuntu on Parallels (2)