Macports without root on Leopard (and Tiger)

Posted by Peter Burkholder Mon, 11 Aug 2008 18:02:00 GMT

I don’t have root on my desktop Mac at $WORK, even though I have root on about 1200 production systems. sigh

So, I asked my Mac administrator to install the XCode development tools. Once that was done, all I needed to was the following.

  • Download the MacPort.tar.bz source distribution: http://svn.macports.org/repository/macports/downloads/MacPorts-1.6.0/MacPorts-1.6.0.tar.bz2
  • Note: For Leopard, one needs to apply the patch from http://trac.macports.org/changeset/32105
  • Run the following:
    
      tar -jxf MacPorts-1.6.0.tar.bz2 && cd MacPorts-1.6.0
    
      PATH=/usr/bin:/usr/sbin:/bin:/sbin ./configure \
      --prefix=$HOME/macports \
      --with-install-user=`id -un` \
      --with-install-group=`id -gn` \
      --x-includes=/usr/X11R6/include \
      --x-libraries=/usr/X11R6/lib \
      --with-tclpackage=$HOME/macports/share/macports/Tcl
    
      make
      make install
    
    
  • Add something like the following to your Mac’s .bashrc>
    
      export PATH=$HOME/macports/bin:$HOME/macports/sbin
      export MANPATH=$HOME/macports/share/man:$MANPATH
      export PERL5LIB=$HOME/macports/lib/perl5/5.8.8:$HOME/macports/lib/perl5/vendor_perl/5.8.8:$PERL5LIB
    
  • Run a selfupdate: port selfupdate
  • Now you do can do cool things like learn Scheme over lunch with: port search scheme; port install mzscheme

I’ve added this to the MacPorts wiki

Oscon 2008 Day One report

Posted by Peter Burkholder Tue, 22 Jul 2008 05:03:00 GMT

Outbound: Spotted at least two OSCON attendees at Dulles Airport. One carrying a dynamic OLED keyboard (Optimus Maximus) that can display different character set imaginable (well, 113 different ones at least), another hard at work on her OLPC XO. I’m sure there were others, but better camouflaged. The flight was late, and cramped, and I was keenly aware of United’s 33-inch seat pitch versus the 33 inches one gets on Frontier Airlines.

The keyboard bearer was one convivial Jacob coming in from http://www.thinkgeek.com, and we together figured out the Max light rail in towards the convention center.

Monday: At breakfast I got an inkling that OSCON attendees are more sociable than their USENIX/SAGE counterparts. At least it wasn’t pulling teeth to engage in a conversation. Joel Noble of Caring Family described his group’s project to bring social networking to the elderly via simple pen & paper interfaces. Fred Meyer of USA Today was from my neck of the woods, and a fellow bike commuter, and we ended up walking Portland in the evening. As for the sessions….

Mastering Perl: brian d foy got down to some essentials of his book of the same name. Takeaways: Profiling can be useful, Benchmarking is less useful than one thinks (unless done correctly). Configuration is good. As is logging and persistence.

I then succumbed to my passions instead of my rational side—and jumped into the Arduino tutorial “Making Things Blink”. What a trip! Michael Dory, Adam Simon, and Scott Varland took us on a whirlwind introduction of the remarkably intuitive Arduino microcontroller system. Their kit included the Arduino Diecimila board, a interface shield, microbreadboard, LEDs, potentiometers, wiring, and force transducers. Oh, and a copy of “Making Things Talk” by Tom Igoe. Soon I was tweaking their circuit and code examples to implement my own riffs on their tutorial project, and by the end I had completed their digital ‘Etch-a-Sketch’ project

I’m excited to do more—and not for any practical reason. It’s just somehow exciting to get back to hardware, real transistors, resistors and diodes, after a generation of computing advances have made hardware less and less accessible at any level beyond swapping out whole components.

Peter out.

RPM building

Posted by Peter Burkholder Thu, 08 May 2008 13:20:00 GMT

It seems that most resources on the Internet about building RPMs are woefully out of date. If you want to unpack and work on RPM source packages in, say your home directory, most documentation points you to settings for your $HOME/.rpmrc file

Then you get errors like this:

error: bad option 'topdir' at /home/burkholp/.rpmrc:1

The use of .rpmrc is obsolete. Instead you’ll want a .rpmmacros file like the following:


%_topdir        %( echo ${HOME}/rpmbuild )
%_tmppath       %{_topdir}/tmp

%packager      Peter Burkholder <pburkholder@pobox.com> 

Apache and "shared memory" issues on Linux 2

Posted by Peter Burkholder Thu, 10 Apr 2008 13:07:00 GMT

This morning I was having trouble getting Apache (2.0.X) to restart. I was getting these error messages:

[Thu Apr 10 08:32:49 2008] [crit] (17)File exists: unable to create scoreboard "/var/private/logs/apache_runtime_status" (name-based shared memory failure)

and I kept deleting the offending file, and making sure that permissions all along the path were correct. No dice.

So I restarted Apache again running strace:

strace /usr/sbin/httpd2-prefork -X -Dprivate '-CPidFile /var/run/apache2.private.pid' -f /etc/apache2/httpd.conf

and saw output like this:

unlink("/var/private/logs/apache_runtime_status") = -1 ENOENT (No such file or directory)
open("/var/private/logs/apache_runtime_status", O_WRONLY|O_CREAT|O_EXCL, 0666) = 9
stat("/var/private/logs/apache_runtime_status", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
shmget(16908303, 40824, IPC_CREAT|IPC_EXCL|0600) = -1 EEXIST (File exists)
write(2, "[Thu Apr 10 08:18:46 2008] [crit"..., 168) = 168

Red Herring

Turns out that worrying about the filesystem was a distraction. The real issue is that the previous Apache had left behind shared memory segments that it couldn’t access anymore. Now I won’t pretend that I understand the ins and outs of shared memory on Linux, but a bit of Googling led me, fortunately to Sven Vermeulen’s blog, where he shared a similar experience on Solaris. I would’ve left nice comments on his blog, but as he doesn’t take comments, I’ll give a shout out to him here.

Anyhow, the ipcs and ipcrm commands come to the rescue:

# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x0102000f 99942402   root      600        40824      0

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00001f58 0          root       600        0            0

Ah-ha—there’s shmid at 99942402. Let’s rm that:

# ipcrm -m 99942402
# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status

------ Semaphore Arrays --------
key        semid      owner      perms      nsems

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x00001f58 0          root       600        0            0

And apache started right up. Yea.

P.S. One find out more about a shared memory segment with something like: ipcs -m -i 99942402, which will report:

Shared memory Segment shmid=99942402
uid=0   gid=0   cuid=0  cgid=0
mode=0600       access_perms=0600
bytes=40824     lpid=6987       cpid=6987       nattch=0
att_time=Thu Apr 10 08:20:48 2008  
det_time=Thu Apr 10 08:21:55 2008  
change_time=Thu Apr 10 08:20:48 2008  

Looking up IPs with mDNS and dns-sd on Mac OS X 10.4 1

Posted by Peter Burkholder Thu, 03 Jan 2008 02:54:00 GMT

I forgot the IP address of my printer on my local area network at home.

And my Mac quite cleverly only had the mdns name in the DeviceURI, but for setting up an older Windows system I really wanted the IP. Here’s how:

  • Browse for printers: dns-sd -B _printers._tcp .. :
    
      Timestamp     A/R Flags if Domain                   Service Type             Instance Name
    21:56:43.972  Add     2  7 local.                   _printer._tcp.           Brother HL-2070N series
  • Lookup the service info for the printer you’ve found: dns-sd -L "Brother HL-2070N series" _printer._tcp:
    
    21:58:30.695  Brother\032HL-2070N\032series._printer._tcp.local. can be reached at BRN-7E6301.local.:515 ...
  • Query on the domain name: dns-sd -Q BRN-7E6301.local.:
    
    Timestamp     A/R Flags if Name                             T   C Rdata
    21:59:52.553  Add     2  7 BRN-7E6301.local.                1   1 192.168.15.103

The reason to bother documenting this? Because the Mac Os X man page for dns-sd doesn’t document the use of the -Q switch.

Grrrrrrrrr.

Processing gzipped files with Perl IO:Uncompress 2

Posted by Peter Burkholder Wed, 02 Jan 2008 19:23:00 GMT

Idiom of the day:


use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;

foreach $host ( "foo", "bar", "dev", "teset") {
  foreach $site ( "public", "private" ) {
   foreach $date ( "20071223", "20071224", "20071225", "20071226", "20071227", "20071228", "20071229", "20071230", "20071231", "20080101" ) {

     $input="/web/$host/$site/logs/access-$date.gz";
     next unless -f $input;
     my $z = new IO::Uncompress::Gunzip $input or die "IO::Uncompress::Gunzip failed: $GunzipError\n";

        while (<$z>) {
          next unless / 200 /;
          @F=split;
          ($URI, $therest) = split(/\?/, $F[6], 2);
          # perl regex operation on the URI

        }
   }
  }
}

Forensic Server Project (FSP) on Unix/Macosx 5

Posted by Peter Burkholder Fri, 26 Oct 2007 15:23:00 GMT

I’ve been working with the security incident response tools on the Helix CD, and been intrigued by Harvey Carlan’s Forensic Server Project

However, the Sourceforge files for the FSP server don’t run on MacOSX or other Unix-style machines because it uses the Win32::GetCwd and Win32::SetCwd modules. The simple patch, below, can be saved as, say, “fspc.patch” in the same directory as the unzipped FSP files. To patch, run:

patch -p0 < fscp.patch

Here’s the patch:

--- fspc.pl.orig    2007-10-24 15:40:22.000000000 -0400
+++ fspc.pl    2007-10-24 16:18:09.000000000 -0400
@@ -18,6 +18,7 @@
 use Digest::MD5;
 use Digest::SHA1;
 use Getopt::Long;
+use Cwd;

 #--------------------------------------------------------------------------
 # Globals
@@ -39,7 +40,7 @@
     exit 1;
 }

-$setup{basedir} = Win32::GetCwd();
+$setup{basedir} = getcwd();
 $setup{casedir} = $config{casedir} || "cases";
 $setup{casename} = $config{casename};
 $setup{port} = $config{port} || 7070;
@@ -296,14 +297,14 @@
 #------------------------------------------
 sub _setup {
 # clean up the directory names
-    $setup{basedir} = $setup{basedir}."\\" unless ($setup{basedir} =~ m/\\$/); 
-    $setup{casedir} = $setup{casedir}."\\" unless ($setup{casedir} =~ m/\\$/);
-    $setup{casename} = $setup{casename}."\\" unless ($setup{casename} =~ m/\\$/);
+    $setup{basedir} = $setup{basedir}."/" unless ($setup{basedir} =~ m/\/$/); 
+    $setup{casedir} = $setup{casedir}."/" unless ($setup{casedir} =~ m/\/$/);
+    $setup{casename} = $setup{casename}."/" unless ($setup{casename} =~ m/\/$/);
     my $casedir = $setup{basedir}.$setup{casedir};
     mkdir $casedir if (! -e $casedir && ! -d $casedir);
     my $curr_case = $casedir.$setup{casename};
-    mkdir $curr_case if (! -e $curr_case && ! -d $curr_case);
-    Win32::SetCwd($curr_case);
+     mkdir $curr_case if (! -e $curr_case && ! -d $curr_case);
+    chdir($curr_case);
     print "Setup complete.\n" if ($config{verbose});
 }

@@ -312,5 +313,5 @@
 # clears setup data so it can be renewed
 #------------------------------------------
 sub _reset {
-    Win32::SetCwd($setup{basedir});
+    chdir($setup{basedir});
 }

Mac Finder and smb:// error -36 -- Help from Samba 2

Posted by Peter Burkholder Tue, 16 Oct 2007 16:39:00 GMT

When trying to connect to a remote CIFS share today using the Mac OS X 10.4.10 Finder, I was getting the very unhelpful error:

The finder cannot complete the operation because some data in “smb://myservername” could not be read or written. (Error code -36)

Googling for this (or GoodSearching, in my case) didn’t turn up much of use. The system logs in /var/log/* weren’t of much help either. Far more useful was the smbclient command, which is part of the Samba installation. E.g.:

$ smbclient //server.addomain.univ.edu/Admin -W ADDOMAIN -U USERNAME
Password: 
session setup failed: NT_STATUS_PASSWORD_MUST_CHANGE

Oh! Excellent! That’s right, I’ve not used that password in eons, and it’s expired. Thank god I didn’t waste my time chasing red herrings. Now, how do I change my password from a Mac?

Being a general Windows nincompoop, I actually called technical support first off, but that wasn’t any help. Fifteen seconds of pondering, and 1 minute of reading the man page, and I came up with this:

$ smbpasswd -r aaddomain.univ.edu -U USERNAME
Old SMB password:
New SMB password:
Retype new SMB password:
Password changed for user USERNAME

All done!

Random MacOSX tidbits 2

Posted by Peter Burkholder Tue, 18 Sep 2007 10:02:00 GMT

Disk cleanup aides

Again, some chatter at work that I wanted to note for

  • Grand Perspective
  • Disk Inventory X
  • OmniSweeper
  • AppZapper: find and destray application that haven’t been used in a long time
  • Monolingual: remove localizations for unused languages
  • Delocalizer: ditto

Setting localhost DNS for development sites (Mac OS X)

There’s been a discussion at work on how to get devlelopment sites, e.g. http://mysite.local, to resolve to 127.0.0.1. My colleague Ethan Winn passed along this:

#!/bin/sh

# usage:  make_vhost_dns.sh my_site.dev.local

sudo niutil -create . /machines/$1
sudo niutil -createprop . /machines/$1 ip_address 127.0.0.1
sudo niutil -createprop . /machines/$1 name $1
sudo niutil -createprop . /machines/$1 serves './local'
exit

That’s all

svndump | svndumpfilter

Posted by Peter Burkholder Fri, 10 Aug 2007 20:51:00 GMT

Just a snippet for latter reference:

sudo -u apache -h nice svnadmin dump -r 18000:48135 //path/to//svnroot 2>fff.svnadmin.err | svndumpfilter—renumber-revs include sites/production/fff.org sites/devel/fff 1>fff.svndump 2>fff.dumpfilter.err &

Older posts: 1 2 3