Index: common-src/security-util.c
===================================================================
--- common-src/security-util.c	(revision 1039)
+++ common-src/security-util.c	(working copy)
@@ -2097,6 +2097,7 @@
     struct stat sbuf;
     int hostmatch;
     int usermatch;
+    uid_t amanda_uid;
     char *aservice = NULL;
 #ifdef WORKING_IPV6
     char ipstr[INET6_ADDRSTRLEN];
@@ -2108,15 +2109,22 @@
 		   "remoteuser=%s, service=%s)\n"),
 		   host, pwd, remoteuser, service);
 
+    dbprintf("pw_uid-A: %ld\n", (long)pwd->pw_uid);
+    amanda_uid = pwd->pw_uid;
+
     ptmp = stralloc2(pwd->pw_dir, "/.amandahosts");
     if (debug_auth >= 9) {
+	dbprintf("pw_uid-A1: %ld\n", (long)pwd->pw_uid);
 	show_stat_info(ptmp, "");;
+	dbprintf("pw_uid-A2: %ld\n", (long)pwd->pw_uid);
     }
+    dbprintf("pw_uid-B: %ld\n", (long)pwd->pw_uid);
     if ((fp = fopen(ptmp, "r")) == NULL) {
 	result = vstrallocf(_("cannot open %s: %s"), ptmp, strerror(errno));
 	amfree(ptmp);
 	return result;
     }
+    dbprintf("pw_uid-C: %ld\n", (long)pwd->pw_uid);
 
     /*
      * Make sure the file is owned by the Amanda user and does not
@@ -2126,9 +2134,10 @@
 	result = vstrallocf(_("cannot fstat %s: %s"), ptmp, strerror(errno));
 	goto common_exit;
     }
-    if (sbuf.st_uid != pwd->pw_uid) {
+    dbprintf("pw_uid-D: %ld\n", (long)pwd->pw_uid);
+    if (sbuf.st_uid != amanda_uid) {
 	result = vstrallocf(_("%s: owned by id %ld, should be %ld"),
-			ptmp, (long)sbuf.st_uid, (long)pwd->pw_uid);
+			ptmp, (long)sbuf.st_uid, (long)amanda_uid);
 	goto common_exit;
     }
     if ((sbuf.st_mode & 077) != 0) {
