Merge "veyron/services/mgmt/binary: ignore whitespace when checking binary repository version"
diff --git a/runtimes/google/vsync/vsyncd.go b/runtimes/google/vsync/vsyncd.go
index fdd25b8..c6e84dd 100644
--- a/runtimes/google/vsync/vsyncd.go
+++ b/runtimes/google/vsync/vsyncd.go
@@ -9,6 +9,7 @@
 // log records to get in sync with the sender.
 import (
 	"fmt"
+	"strings"
 	"sync"
 	"time"
 
@@ -16,6 +17,7 @@
 
 	"veyron2/ipc"
 	"veyron2/naming"
+	"veyron2/security"
 	"veyron2/storage"
 	"veyron2/vlog"
 	"veyron2/vom"
@@ -49,6 +51,23 @@
 	hdlInitiator *syncInitiator
 }
 
+type syncDispatcher struct {
+	server ipc.Invoker
+	auth   security.Authorizer
+}
+
+// NewSyncDispatcher returns an object dispatcher.
+func NewSyncDispatcher(s interface{}, auth security.Authorizer) ipc.Dispatcher {
+	return &syncDispatcher{ipc.ReflectInvoker(s), auth}
+}
+
+func (d *syncDispatcher) Lookup(suffix string) (ipc.Invoker, security.Authorizer, error) {
+	if strings.HasSuffix(suffix, "sync") {
+		return d.server, d.auth, nil
+	}
+	return nil, nil, fmt.Errorf("Lookup:: failed on suffix: %s", suffix)
+}
+
 // NewSyncd creates a new syncd instance.
 //
 // Syncd concurrency: syncd initializes three goroutines at
diff --git a/runtimes/google/vsync/vsyncd/main.go b/runtimes/google/vsync/vsyncd/main.go
index c49de82..66c8633 100644
--- a/runtimes/google/vsync/vsyncd/main.go
+++ b/runtimes/google/vsync/vsyncd/main.go
@@ -6,7 +6,8 @@
 	"os"
 
 	"veyron/runtimes/google/vsync"
-	"veyron2/ipc"
+	vflag "veyron/security/flag"
+
 	"veyron2/rt"
 	"veyron2/vlog"
 )
@@ -38,10 +39,15 @@
 		vlog.Fatalf("syncd:: failure creating server: err %v", err)
 	}
 
-	// Register the "sync" prefix with the sync dispatcher.
+	// Create a new SyncService.
 	syncd := vsync.NewSyncd(*peerEndpoints, *peerDeviceIDs, *devid, *storePath, *vstoreEndpoint, *syncTick)
-	serverSync := vsync.NewServerSync(syncd)
-	dispatcher := ipc.SoloDispatcher(serverSync, nil)
+	syncService := vsync.NewServerSync(syncd)
+
+	// Create the authorizer.
+	auth := vflag.NewAuthorizerOrDie()
+
+	// Register the service.
+	syncDisp := vsync.NewSyncDispatcher(syncService, auth)
 
 	// Create an endpoint and begin listening.
 	if endpoint, err := s.Listen("tcp", *address); err == nil {
@@ -50,9 +56,9 @@
 		vlog.Fatalf("syncd:: error listening to service: err %v", err)
 	}
 
-	// Publish the vsync service. This will register it in the mount table and maintain the
-	// registration while the program runs.
-	if err := s.Serve("sync", dispatcher); err != nil {
+	// Publish the vsync service.
+	name := "global/vsync/" + *devid
+	if err := s.Serve(name, syncDisp); err != nil {
 		vlog.Fatalf("syncd: error publishing service: err %v", err)
 	}