The symlink problem bit me too. I would think it's actually a fairly
common situation for /var/cache/approx to be a symlink, since it's
easy to use much more space for .debs than any of the other contents
for /var. (Especially if you save the old ones; my /var/cache/approx
is currently 49GB, compared to 3.5GB for the portion of /var that's
stored on the same filesystem as /var.)

I haven't attempted to understand the logic of this code in its full
context. It looks like the main function of approx already chdir()s to
the cache directory, and I didn't see any other calls to chdir, so I'm
not sure under what circumstances this check would ever fail, were it
implemented correctly. I also don't see why it isn't possible to
always just use absolute path names, so there's never a reason to
worry about the current directory. But if the check really is serving
a purpose, I think you can avoid issues with path strings being
non-canonical by comparing the stat() information for the two
directories. Attached is a proof of concept patch that makes my system
work again.

 -- Stephen
--- config.ml.orig      2011-07-26 13:24:04.000000000 -0700
+++ config.ml   2011-07-26 13:24:29.000000000 -0700
@@ -51,7 +51,12 @@
 let check_current_directory () =
   let cwd = Sys.getcwd () in
   if cwd <> cache_dir then
-    failwith (Printf.sprintf "current directory is %s, not %s" cwd cache_dir)
+    (if (Unix.stat cwd) = (Unix.stat cache_dir) then
+       () (* Different name, but otherwise the same, such as because of
+            a symlink; not a problem *)
+     else
+       failwith
+        (Printf.sprintf "current directory is %s, not %s" cwd cache_dir))
 
 let interval = get_int "$interval" ~default: 720
 let params = ("$interval", string_of_int interval) :: params

Reply via email to