<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>VMware Communities: Message List - SOLUTION: How to sync the system clock of non-supported guest OSes</title>
    <link>http://communities.vmware.com/community/vmtn/desktop/fusion?view=discussions</link>
    <description>Most recent forum messages</description>
    <language>en</language>
    <pubDate>Sun, 20 May 2007 01:00:54 GMT</pubDate>
    <generator>Clearspace 1.10.12 (http://jivesoftware.com/products/clearspace/)</generator>
    <dc:date>2007-05-20T01:00:54Z</dc:date>
    <dc:language>en</dc:language>
    <item>
      <title>SOLUTION: How to sync the system clock of non-supported guest OSes</title>
      <link>http://communities.vmware.com/message/649010?tstart=0#649010</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
since Fusion Beta 1, I've been running OPENSTEP on Fusion with big success; although an unsupported guest OS, it runs rock-solid. You'll need special VMware drivers for mouse, network, graphics and sound, but thankfully, all these are available on the net. "Shared folders" are easy to emulate via NFS mounts. So basically all VMware tools can be replaced/emulated, except one:&lt;br /&gt;
&lt;br /&gt;
There's no obvious way to automatically reset the system clock of the guest OS. This is necessary in 2 situations:&lt;br /&gt;
- OPENSTEP resumes from suspension&lt;br /&gt;
&lt;br /&gt;
In both cases, OPENSTEP does not "know" the system clock has gotten out of sync, and will use the trailing time.&lt;br /&gt;
&lt;br /&gt;
In the following, I will describe how I successfully solved this problem. Though I will describe it for OPENSTEP, it should be basically usable for all non-supported guest OSes, at least if they are Unix-like. So I hope this will be useful for other VMware users. Since the VMware Forum does not seem to have a specific style for code, I will use italics to display code. Example values in the code which you'll have to replace by your own values will be bold.&lt;br /&gt;
&lt;br /&gt;
The basic idea is to use the network connection between guest and host instead of VMware's proprietary communication channel for supported guest OSes. This implies you must have a &lt;b&gt;bridged network&lt;/b&gt; configuration, so that Mac OS X can address OPENSTEP via the network. In my example, the OPENSTEP virtual machine has the IP &lt;b&gt;192.168.1.6&lt;/b&gt; and Mac OS X has the IP &lt;b&gt;192.168.1.1&lt;/b&gt;.&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;Files in the OPENSTEP guest OS&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
There are 2 files we need in the OPENSTEP guset OS. First, we need a utility that actually sets the time:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;/usr/local/bin/setTime&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
rdate &lt;b&gt;my.timeserver.org&lt;/b&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
I used rdate since that works most easily on OPENSTEP; but note that not all time servers are rdate compatible.&lt;br /&gt;
&lt;br /&gt;
Since rdate needs root privileges, but root login via rsh/rlogin is disabled on OPENSTEP, we need to make setTime suid root so that we can execute it with normal user privileges:&lt;br /&gt;
&lt;br /&gt;
   % chmod 4755 /usr/local/bin/setTime&lt;br /&gt;
&lt;br /&gt;
Since the virtual machine is only reachable from within my local network, this is fine with me from a security point of view.&lt;br /&gt;
&lt;br /&gt;
The second file we need is in my home directory in OPENSTEP (I use the same user name on OPENSTEP and Mac OS X, and my example will assume this identity):&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;~/.rhosts&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;192.168.1.1 myusername&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This file takes care that I will be able to rsh from Mac OS X without having to provide a password.&lt;br /&gt;
&lt;p /&gt;
&lt;b&gt;Files in Mac OS X&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First, we create a little program that actually sets the time on the OPENSTEP guest OS remotely:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;/usr/local/bin/nswake&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
rsh -t 7 &lt;b&gt;192.168.1.6&lt;/b&gt; /usr/local/bin/setTime 2&amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
sleep 6&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Note that rsh needs no user name (since you log in from an account of the same name) and no password (because of the .rhosts file installed on OPENSTEP). Since the automatic invocation of this program will also happen when OPENSTEP is suspended or shut down (see below), the -t 7 option makes for a relatively short timeout of rsh in case OPENSTEP is unreachable. sleep 6 takes care that launchd (see below) will not invoke this program several times within a short timespan.&lt;br /&gt;
&lt;p /&gt;
Now we need 2 mechanisms to trigger nswake when (a) OPENSTEP resumes from suspension and (b) Mac OS X awakes from sleep.&lt;br /&gt;
&lt;br /&gt;
(a) is taken care of by Mac OS X's launchd system (note you need Mac OS X &amp;gt;= 10.4 for that!). launchd is set up to control the VMware virtual machine directory. When the guest OS is resumed from suspension (but also when it is suspended), VMware will change the number of files within the virtual machine directory. This can be used to trigger launchd. The following config file takes care of that:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;~/Library/LaunchAgents/nswake.plist&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&amp;gt;&lt;br /&gt;
&amp;lt;plist version="1.0"&amp;gt;&lt;br /&gt;
&amp;lt;dict&amp;gt;&lt;br /&gt;
        &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;&lt;br /&gt;
        &amp;lt;string&amp;gt;nswake&amp;lt;/string&amp;gt;&lt;br /&gt;
        &amp;lt;key&amp;gt;Program&amp;lt;/key&amp;gt;&lt;br /&gt;
        &amp;lt;string&amp;gt;/usr/local/bin/nswake&amp;lt;/string&amp;gt;&lt;br /&gt;
        &amp;lt;key&amp;gt;ServiceDescription&amp;lt;/key&amp;gt;&lt;br /&gt;
        &amp;lt;string&amp;gt;Set time in OPENSTEP VMware client after sleep/suspension&amp;lt;/string&amp;gt;&lt;br /&gt;
        &amp;lt;key&amp;gt;WatchPaths&amp;lt;/key&amp;gt;&lt;br /&gt;
        &amp;lt;array&amp;gt;&lt;br /&gt;
                &amp;lt;string&amp;gt;&lt;b&gt;/my/path/to/virtual/machine/directory/&lt;/b&gt;&amp;lt;/string&amp;gt;&lt;br /&gt;
        &amp;lt;/array&amp;gt;&lt;br /&gt;
&amp;lt;/dict&amp;gt;&lt;br /&gt;
&amp;lt;/plist&amp;gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
(b) is a little trickier; you would think that there's some easy (scriptable) way in Mac OS X to trigger a command based on a wake-up event, but I couldn't find any, so I wrote a tiny Cocoa app to do this. Nothing fancy, but still a bit scary for those who don't know Cocoa. Still, here's the source; if anyone's interested, I could offer an archive with the source and the compiled application.&lt;br /&gt;
&lt;br /&gt;
The app is a normal Cocoa app called WakeNotifier. It has just one class, Controller:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Controller.h&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;#import &amp;lt;Cocoa/Cocoa.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
@interface Controller : NSObject&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
- (void) wakeUp:(id)notification;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Controller.m&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;@implementation Controller&lt;br /&gt;
&lt;br /&gt;
- (id) init&lt;br /&gt;
{&lt;br /&gt;
	self = [super init];&lt;br /&gt;
	if (self != nil)&lt;br /&gt;
	{&lt;br /&gt;
		NSNotificationCenter *wakeNotificationCenter = [[NSWorkspace sharedWorkspace] notificationCenter];&lt;br /&gt;
		[wakeNotificationCenter addObserver:self selector:@selector(wakeUp:) name:NSWorkspaceDidWakeNotification object:nil];&lt;br /&gt;
	}&lt;br /&gt;
	return self;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void) wakeUp:(id)notification&lt;br /&gt;
{&lt;br /&gt;
    NSLog(@"Setting time on OPENSTEP virtual machine");&lt;br /&gt;
	[NSTask launchedTaskWithLaunchPath:@"/usr/local/bin/nswake" arguments:[NSArray array]];&lt;br /&gt;
}&lt;br /&gt;
&lt;p /&gt;
@end&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
As usual with Cocoa apps, you must make the Controller instance a delegate of File's Owner in Interface Builder. Also, you must add these lines to &lt;b&gt;Info.plist&lt;/b&gt;:&lt;br /&gt;
&lt;i&gt;	&amp;lt;key&amp;gt;LSBackgroundOnly&amp;lt;/key&amp;gt;&lt;br /&gt;
	&amp;lt;string&amp;gt;1&amp;lt;/string&amp;gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
This makes WakeNotifier run in the background. To make it actually run as soon as you log in, you must add it to your startup items in System Preferences.&lt;br /&gt;
&lt;p /&gt;
That's it. Now the time will be reliably adjusted in OPENSTEP when you wake up your Mac or resume your guest OS from suspension.&lt;br /&gt;
&lt;br /&gt;
I hope that helps people in similar situations as me.&lt;br /&gt;
&lt;p /&gt;
Uli</description>
      <pubDate>Sun, 20 May 2007 01:00:54 GMT</pubDate>
      <author>Uli Zappe</author>
      <guid>http://communities.vmware.com/message/649010?tstart=0#649010</guid>
      <dc:date>2007-05-20T01:00:54Z</dc:date>
      <clearspace:dateToText>2 years, 6 months ago</clearspace:dateToText>
    </item>
  </channel>
</rss>

