windows-winlogon-logon-event-20050414
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 14 Apr 2005 06:46:34 +0000 (06:46 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 14 Apr 2005 06:46:34 +0000 (06:46 +0000)
 Apparently the problem with multi-domain forests with cross-
 realm trusts to non-Windows realms was not entirely solved.
 The authentication to the AFS SMB service failed because
 the wrong name was being used.  Using ASU as an example,
 the authentication was being performed with the name
 "QAAD\user" (an account in the forest root) and not
 "user@ASU.EDU (the MIT Kerberos principal used to login with)

 The solution was to add an additional dependency on KFW
 in order or to be able to easily obtain the client principal
 name stored in the MSLSA ccache TGT.  This information is
 used in two locations:

 - the pioctl() function

 - a new WinLogon Event Handler for the "logon" event.

 The pioctl function will now be able to use the correct
 name when calling WNetAddConnection2() and the "logon"
 event handler will now be able to call WNetAddConnection2().
 The hope is that the "logon" event handler will be called
 before the profile is loaded but I have not guarrantee
 that will happen.

19 files changed:
doc/txt/winnotes/afs-changes-since-1.2.txt
doc/txt/winnotes/afs-install-notes.txt
doc/txt/winnotes/afs-issues.txt
src/WINNT/afsd/NTMakefile
src/WINNT/afsd/afskfw.c
src/WINNT/afsd/afskfw.h
src/WINNT/afsd/afslogon.c
src/WINNT/afsd/afslogon.def
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/smb.h
src/WINNT/afsd/smb3.c
src/WINNT/client_exp/gui2fs.cpp
src/WINNT/install/NSIS/OpenAFS.nsi
src/WINNT/install/wix/feature.wxi
src/WINNT/install/wix/files.wxi
src/WINNT/install/wix/replace_afs.cmd [new file with mode: 0644]
src/libafsauthent/NTMakefile
src/sys/NTMakefile
src/sys/pioctl_nt.c

index af1bf62..7d31514 100644 (file)
@@ -1,3 +1,33 @@
+Since 1.3.81:
+  * Added a script command to the msi installer "afs_replace"
+    which can be used to replace one version of OpenAFS with
+    another without requiring an uninstall and reinstall if
+    the installed msi is no longer in its original location.
+
+  * Apparently the problem with multi-domain forests with cross-
+    realm trusts to non-Windows realms was not entirely solved.
+    The authentication to the AFS SMB service failed because 
+    the wrong name was being used.  Using ASU as an example,
+    the authentication was being performed with the name
+    "QAAD\user" (an account in the forest root) and not 
+    "user@ASU.EDU (the MIT Kerberos principal used to login with)
+
+    The solution was to add an additional dependency on KFW
+    in order or to be able to easily obtain the client principal 
+    name stored in the MSLSA ccache TGT.  This information is 
+    used in two locations:  
+
+    - the pioctl() function 
+
+    - a new WinLogon Event Handler for the "logon" event.  
+
+    The pioctl function will now be able to use the correct
+    name when calling WNetAddConnection2() and the "logon"
+    event handler will now be able to call WNetAddConnection2().
+    The hope is that the "logon" event handler will be called 
+    before the profile is loaded but I have not guarrantee
+    that will happen. 
+
 Since 1.3.80:
   * Fixed a locking error in cm_TryBulkStat() which had the
     potential of deadlocking the system for the length of time
index 75120c5..46cae64 100644 (file)
@@ -555,6 +555,7 @@ values using registry keys.  This is useful for managed machines in a
 Windows domain which are centrally located (e.g., in a computing
 lab.)  See registry.txt for details on the "Server Preferences" keys.
 
+
 39. As of 1.3.81, timestamps on file stored in AFS are reported to 
 Windows in UTC all year round.  Previously, in locales with daylight
 savings time, the time reported by AFS to Windows when DST is active
@@ -574,6 +575,15 @@ used to being able to compare the timestamp in an Unix shell with the
 timestamp from the Windows explorer.  During DST, these two times will
 no longer agree even though they are in fact describing the same time.
 
+
+40. If the installer refuses to install and complains about an RPC
+configuration error, check to ensure that the following registry
+entries are present and that they refer to the dll "rpcrt4.dll":
+
+   HKLM "SOFTWARE\Microsoft\RPC\ClientProtocols" "ncacn_np"
+   HKLM "SOFTWARE\Microsoft\RPC\ClientProtocols" "ncacn_ip_tcp"
+   HKLM "SOFTWARE\Microsoft\RPC\ClientProtocols" "ncadg_ip_udp"
+
 ------------------------------------------------------------------------
 
 Reporting Bugs:
index da7f7b0..0aa4426 100644 (file)
@@ -172,7 +172,7 @@ List of unfunded projects:
   10. Documentation Documentation Documentation
   11. Large File support (> 2GB) in SMB/CIFS client
   12. Integrate KFW installation into the NSIS and MSI installers
-  13. Add support for record locking to AFS (requires changes to the servers)
+  13. Add support for byte range locking to AFS (requires changes to the servers)
   14. Unicode enable the SMB/CIFS server.  OEM Code Pages: 
       1. prevent the use of interoperable file names
       2. force the use of paths no longer than 256 characters
index cbdb89a..7194e87 100644 (file)
@@ -213,15 +213,16 @@ $(AFSKFWLIB): $(AFSKFWLIB_OBJS)
 LOGON_DLLFILE = $(DESTDIR)\root.client\usr\vice\etc\afslogon.dll
 
 LOGON_DLLOBJS =\
-       $(OUT)\afslogon.obj \
+    $(OUT)\afslogon.obj \
     $(OUT)\logon_ad.obj \
-       $(OUT)\afslogon.res
+    $(OUT)\afslogon.res
 
 LOGON_DLLLIBS =\
-       $(DESTDIR)\lib\afsauthent.lib \
-       $(DESTDIR)\lib\libafsconf.lib \
+    $(DESTDIR)\lib\afsauthent.lib \
+    $(DESTDIR)\lib\libafsconf.lib \
     $(DESTDIR)\lib\afsrxkad.lib \
     $(DESTDIR)\lib\afsdes.lib \
+    $(LANAHELPERLIB) \
     $(AFSKFWLIB)
 
 LOGON_DLLSDKLIBS =\
index a1fc846..adc8587 100644 (file)
@@ -3409,3 +3409,49 @@ BOOL KFW_probe_kdc(struct afsconf_cell * cellconfig)
     return serverReachable;
 }
 
+BOOL
+KFW_AFS_get_lsa_principal(char * szUser, DWORD *dwSize)
+{
+    krb5_context   ctx = 0;
+    krb5_error_code code;
+    krb5_ccache mslsa_ccache=0;
+    krb5_principal princ = 0;
+    char * pname = 0;
+    BOOL success = 0;
+
+    if (!KFW_is_available())
+        return FALSE;
+
+    if (code = pkrb5_init_context(&ctx))
+        goto cleanup;
+
+    if (code = pkrb5_cc_resolve(ctx, "MSLSA:", &mslsa_ccache))
+        goto cleanup;
+
+    if (code = pkrb5_cc_get_principal(ctx, mslsa_ccache, &princ))
+        goto cleanup;
+
+    if (code = pkrb5_unparse_name(ctx, princ, &pname))
+        goto cleanup;
+
+    if ( strlen(pname) < *dwSize ) {
+        strncpy(szUser, pname, *dwSize);
+        szUser[*dwSize-1] = '\0';
+        success = 1;
+    }
+    *dwSize = strlen(pname);
+
+  cleanup:
+    if (pname)
+        pkrb5_free_unparsed_name(ctx, pname);
+
+    if (princ)
+        pkrb5_free_principal(ctx, princ);
+
+    if (mslsa_ccache)
+        pkrb5_cc_close(ctx, mslsa_ccache);
+
+    if (ctx)
+        pkrb5_free_context(ctx);
+    return success;
+}
\ No newline at end of file
index 995d038..352e059 100644 (file)
@@ -60,6 +60,7 @@ BOOL KFW_AFS_wait_for_service_start(void);
 BOOL KFW_probe_kdc(struct afsconf_cell *);
 int  KFW_AFS_get_cellconfig(char *, struct afsconf_cell *, char *);
 void KFW_import_windows_lsa(void);
+BOOL KFW_AFS_get_lsa_principal(char *, DWORD *);
 
 /* From afs/krb_prot.h */
 /* values for kerb error codes */
index 0e9788e..34833aa 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <winsock2.h>
 #include <lm.h>
+#include <nb30.h>
 
 #include <afs/param.h>
 #include <afs/stds.h>
@@ -26,6 +27,7 @@
 #include "cm_config.h"
 #include "krb.h"
 #include "afskfw.h"
+#include "lanahelper.h"
 
 #include <WINNT\afsreg.h>
 
@@ -561,8 +563,6 @@ GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOpt
     }
 
     if (hkTemp) {
-        HRESULT hr;
-        size_t len;
         CHAR * thesecells;
 
         /* dwSize still has the size of the required buffer in bytes. */
@@ -988,12 +988,11 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
     DWORD  len = 1024;
     PTOKEN_USER  tokenUser = NULL;
     DWORD  retLen;
-    HANDLE hToken;
 
     /* Make sure the AFS Libraries are initialized */
     AfsLogonInit();
 
-    DebugEvent0("AFS_Logoff_Event - Starting");
+    DebugEvent0("AFS_Logoff_Event - Start");
 
     if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen))
     {
@@ -1002,7 +1001,7 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
 
             if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen))
             {
-                DebugEvent("GetTokenInformation failed: GLE = %lX", GetLastError());
+                DebugEvent("AFS_Logoff_Event - GetTokenInformation failed: GLE = %lX", GetLastError());
             }
         }
     }
@@ -1020,7 +1019,7 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
     }
     
     if (strlen(profileDir)) {
-        DebugEvent("Profile Directory: %s", profileDir);
+        DebugEvent("AFS_Logoff_Event - Profile Directory: %s", profileDir);
         if (!IsPathInAfs(profileDir)) {
             if (code = ktc_ForgetAllTokens())
                 DebugEvent("AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code);
@@ -1035,5 +1034,92 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
 
     if ( tokenUser )
         LocalFree(tokenUser);
+
+    DebugEvent0("AFS_Logoff_Event - End");
 }   
 
+VOID AFS_Logon_Event( PWLX_NOTIFICATION_INFO pInfo )
+{
+    DWORD code;
+    TCHAR profileDir[1024] = TEXT("");
+    DWORD  len = 1024;
+    PTOKEN_USER  tokenUser = NULL;
+    DWORD  retLen;
+    HANDLE hToken;
+
+    WCHAR szUserW[128] = L"";
+    char  szUserA[128] = "";
+    char  szClient[MAX_PATH];
+    char szPath[MAX_PATH] = "";
+    NETRESOURCE nr;
+    DWORD res;
+    DWORD gle;
+    DWORD dwSize;
+
+    /* Make sure the AFS Libraries are initialized */
+    AfsLogonInit();
+
+    DebugEvent0("AFS_Logon_Event - Start");
+
+    if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen))
+    {
+        if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) {
+            tokenUser = (PTOKEN_USER) LocalAlloc(LPTR, retLen);
+
+            if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen))
+            {
+                DebugEvent("AFS_Logon_Event - GetTokenInformation failed: GLE = %lX", GetLastError());
+            }
+        }
+    }
+
+    /* We can't use pInfo->Domain for the domain since in the cross realm case 
+     * this is source domain and not the destination domain.
+     */
+    if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
+        WCHAR Domain[64]=L"";
+        GetLocalShortDomain(Domain, sizeof(Domain));
+        if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
+            if (NetUserGetProfilePath(pInfo->Domain, pInfo->UserName, profileDir, len))
+                GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
+        }
+    }
+    
+    if (strlen(profileDir)) {
+        DebugEvent("AFS_Logon_Event - Profile Directory: %s", profileDir);
+    } else {
+        DebugEvent0("AFS_Logon_Event - Unable to load profile");
+    }
+
+    dwSize = sizeof(szUserA);
+    if (!KFW_AFS_get_lsa_principal(szUserA, &dwSize)) {
+        StringCbPrintfW(szUserW, sizeof(szUserW), L"%s\\%s", pInfo->Domain, pInfo->UserName);
+        WideCharToMultiByte(CP_ACP, 0, szUserW, -1, szUserA, MAX_PATH, NULL, NULL);
+    }
+
+    if (szUserA[0])
+    {
+        lana_GetNetbiosName(szClient, LANA_NETBIOS_NAME_FULL);
+        StringCbPrintf(szPath, sizeof(szPath), "\\\\%s", szClient);
+
+        DebugEvent("AFS_Logon_Event - Logon Name: %s", szUserA);
+
+        memset (&nr, 0x00, sizeof(NETRESOURCE));
+        nr.dwType=RESOURCETYPE_DISK;
+        nr.lpLocalName=0;
+        nr.lpRemoteName=szPath;
+        res = WNetAddConnection2(&nr,NULL,szUserA,0);
+        if (res)
+            DebugEvent("AFS_Logon_Event - WNetAddConnection2(%s,%s) failed: 0x%X",
+                        szPath, szUserA,res);
+        else
+            DebugEvent0("AFS_Logon_Event - WNetAddConnection2() succeeded");
+    } else 
+        DebugEvent("AFS_Logon_Event - User name conversion failed: GLE = 0x%X",GetLastError());
+
+    if ( tokenUser )
+        LocalFree(tokenUser);
+
+    DebugEvent0("AFS_Logon_Event - End");
+}
+
index 28cafc5..fa8dacc 100644 (file)
@@ -10,5 +10,6 @@ EXPORTS
     NPPasswordChangeNotify
     AFS_Startup_Event
     AFS_Logoff_Event
+    AFS_Logon_Event
 
 
index 7cdecdc..20872df 100644 (file)
@@ -2692,7 +2692,7 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
               void **lockpp)
 {
     long code;
-    int Which = ((LockType & 0x1) ? LockRead : LockWrite);
+    int Which = ((LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
     AFSFid tfid;
     AFSVolSync volSync;
     cm_conn_t *connp;
@@ -2706,13 +2706,10 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
      */
     q = scp->fileLocks;
     while (q) {
-        fileLock = (cm_file_lock_t *)
-            ((char *) q - offsetof(cm_file_lock_t, fileq));
-        if ((fileLock->flags &
-              (CM_FILELOCK_FLAG_INVALID | CM_FILELOCK_FLAG_WAITING))
-             == 0) {
-            if ((LockType & 0x1) == 0
-                 || (fileLock->LockType & 0x1) == 0)
+        fileLock = (cm_file_lock_t *)((char *) q - offsetof(cm_file_lock_t, fileq));
+        if ((fileLock->flags & (CM_FILELOCK_FLAG_INVALID | CM_FILELOCK_FLAG_WAITING)) == 0) {
+            if ((LockType & LOCKING_ANDX_SHARED_LOCK) == 0 ||
+                (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0)
                 return CM_ERROR_WOULDBLOCK;
             found = 1;
         }
@@ -2766,7 +2763,7 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
                 cm_user_t *userp, cm_req_t *reqp)
 {
     long code = 0;
-    int Which = ((LockType & 0x1) ? LockRead : LockWrite);
+    int Which = ((LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
     AFSFid tfid;
     AFSVolSync volSync;
     cm_conn_t *connp;
@@ -2795,7 +2792,7 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
             ourLock = fileLock;
             qq = q;
         }
-        else if (fileLock->LockType & 0x1)
+        else if (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK)
             anotherReader = 1;
         q = osi_QNext(q);
     }
@@ -2907,7 +2904,7 @@ void cm_CheckLocks()
 long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
 {
     long code;
-    int Which = ((oldFileLock->LockType & 0x1) ? LockRead : LockWrite);
+    int Which = ((oldFileLock->LockType & LOCKING_ANDX_SHARED_LOCK) ? LockRead : LockWrite);
     cm_scache_t *scp;
     AFSFid tfid;
     AFSVolSync volSync;
@@ -2939,8 +2936,8 @@ long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
         if ((fileLock->flags &
               (CM_FILELOCK_FLAG_INVALID | CM_FILELOCK_FLAG_WAITING))
              == 0) {
-            if ((oldFileLock->LockType & 0x1) == 0
-                 || (fileLock->LockType & 0x1) == 0) {
+            if ((oldFileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0
+                 || (fileLock->LockType & LOCKING_ANDX_SHARED_LOCK) == 0) {
                 cm_ReleaseSCache(scp);
                 return CM_ERROR_WOULDBLOCK;
             }
index 78a145d..4a8e3cc 100644 (file)
@@ -365,6 +365,12 @@ typedef struct smb_fid {
 #define SMB_ATTR_NOT_CONTENT_INDEXED 0x2000
 #define SMB_ATTR_ENCRYPTED      0x4000
 
+#define LOCKING_ANDX_SHARED_LOCK        0x01 /* Read-only lock */
+#define LOCKING_ANDX_OPLOCK_RELEASE     0x02 /* Oplock break notification */
+#define LOCKING_ANDX_CHANGE_LOCKTYPE    0x04 /* Change lock type */
+#define LOCKING_ANDX_CANCEL_LOCK        0x08 /* Cancel outstanding request */
+#define LOCKING_ANDX_LARGE_FILES        0x10 /* Large file locking format */
+
 /* for tracking in-progress directory searches */
 typedef struct smb_dirSearch {
     osi_queue_t q;                     /* queue of all outstanding cookies */
index 13989b4..cbdf54f 100644 (file)
@@ -4832,7 +4832,7 @@ long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
     op = smb_GetSMBData(inp, NULL);
 
     for (i=0; i<NumberOfUnlocks; i++) {
-        if (LockType & 0x10) {
+        if (LockType & LOCKING_ANDX_LARGE_FILES) {
             /* Large Files */
             LOffset.HighPart = *((LONG *)(op + 4));
             LOffset.LowPart = *((DWORD *)(op + 8));
@@ -4857,7 +4857,7 @@ long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
     }       
 
     for (i=0; i<NumberOfLocks; i++) {
-        if (LockType & 0x10) {
+        if (LockType & LOCKING_ANDX_LARGE_FILES) {
             /* Large Files */
             LOffset.HighPart = *((LONG *)(op + 4));
             LOffset.LowPart = *((DWORD *)(op + 8));
index 2c1cb0f..02a920c 100644 (file)
@@ -69,44 +69,44 @@ static char *szLogFileName = "afsguilog.txt";
 
 FILE *OpenFile(char *file, char *rwp)
 {
-       char wdir[256];
-       long code;
-       long tlen;
-       FILE *fp;
+    char wdir[256];
+    long code;
+    long tlen;
+    FILE *fp;
 
-       code = GetWindowsDirectory(wdir, sizeof(wdir));
-       if (code == 0 || code > sizeof(wdir)) 
-               return FALSE;
+    code = GetWindowsDirectory(wdir, sizeof(wdir));
+    if (code == 0 || code > sizeof(wdir)) 
+        return FALSE;
 
-       /* add trailing backslash, if required */
-       tlen = strlen(wdir);
-       if (wdir[tlen - 1] != '\\')
-               strcat(wdir, "\\");
+    /* add trailing backslash, if required */
+    tlen = strlen(wdir);
+    if (wdir[tlen - 1] != '\\')
+        strcat(wdir, "\\");
 
-       strcat(wdir, file);
+    strcat(wdir, file);
 
-       fp = fopen(wdir, rwp);
+    fp = fopen(wdir, rwp);
 
-       return fp;
-}
+    return fp;
+}       
 
 CString StripPath(CString& strPath)
 {
-       int nIndex = strPath.ReverseFind('\\');
+    int nIndex = strPath.ReverseFind('\\');
 
-       CString strFile = strPath.Mid(nIndex + 1);
-       if (strFile.IsEmpty())
-               return strPath;
+    CString strFile = strPath.Mid(nIndex + 1);
+    if (strFile.IsEmpty())
+        return strPath;
 
-       return strFile;
+    return strFile;
 }
 
 CStringArray& StripPath(CStringArray& files)
 {
-       for (int i = 0; i < files.GetSize(); i++)
-               files[i] = StripPath(files[i]);
+    for (int i = 0; i < files.GetSize(); i++)
+        files[i] = StripPath(files[i]);
 
-       return files;
+    return files;
 }
 
 void Flush(const CStringArray& files)
@@ -115,46 +115,46 @@ void Flush(const CStringArray& files)
     struct ViceIoctl blob;
     int error = 0;
 
-       HOURGLASS hourglass;
-
-       for (int i = 0; i < files.GetSize(); i++) {
-               blob.in_size = blob.out_size = 0;
+    HOURGLASS hourglass;
 
-               code = pioctl(PCCHAR(files[i]), VIOCFLUSH, &blob, 0);
-               if (code) {
-                       error = 1;
-                       if (errno == EMFILE)
-                               ShowMessageBox(IDS_FLUSH_FAILED, MB_ICONEXCLAMATION, IDS_FLUSH_FAILED, files[i]);
-                       else 
-                               ShowMessageBox(IDS_FLUSH_ERROR, MB_ICONEXCLAMATION, IDS_FLUSH_ERROR, files[i], strerror(errno));
-               }
-    }
+    for (int i = 0; i < files.GetSize(); i++) {
+        blob.in_size = blob.out_size = 0;
+
+        code = pioctl(PCCHAR(files[i]), VIOCFLUSH, &blob, 0);
+        if (code) {
+            error = 1;
+            if (errno == EMFILE)
+                ShowMessageBox(IDS_FLUSH_FAILED, MB_ICONEXCLAMATION, IDS_FLUSH_FAILED, files[i]);
+            else 
+                ShowMessageBox(IDS_FLUSH_ERROR, MB_ICONEXCLAMATION, IDS_FLUSH_ERROR, files[i], strerror(errno));
+        }
+    }   
 
-       if (!error)
-               ShowMessageBox(IDS_FLUSH_OK, MB_ICONEXCLAMATION, IDS_FLUSH_OK);
-}
+    if (!error)
+        ShowMessageBox(IDS_FLUSH_OK, MB_ICONEXCLAMATION, IDS_FLUSH_OK);
+}       
 
 void FlushVolume(const CStringArray& files)
 {
     register LONG code;
     struct ViceIoctl blob;
-       int error = 0;
+    int error = 0;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       for (int i = 0; i < files.GetSize(); i++) {
-               blob.in_size = blob.out_size = 0;
+    for (int i = 0; i < files.GetSize(); i++) {
+        blob.in_size = blob.out_size = 0;
 
-               code = pioctl(PCCHAR(files[i]), VIOC_FLUSHVOLUME, &blob, 0);
-               if (code) {
-                       error = 1;
-                       ShowMessageBox(IDS_FLUSH_VOLUME_ERROR, MB_ICONEXCLAMATION, IDS_FLUSH_VOLUME_ERROR, files[i], strerror(errno));
-               }
-    }
+        code = pioctl(PCCHAR(files[i]), VIOC_FLUSHVOLUME, &blob, 0);
+        if (code) {
+            error = 1;
+            ShowMessageBox(IDS_FLUSH_VOLUME_ERROR, MB_ICONEXCLAMATION, IDS_FLUSH_VOLUME_ERROR, files[i], strerror(errno));
+        }
+    }   
 
-       if (!code)
-               ShowMessageBox(IDS_FLUSH_VOLUME_OK, MB_ICONEXCLAMATION, IDS_FLUSH_VOLUME_OK);
-}
+    if (!code)
+        ShowMessageBox(IDS_FLUSH_VOLUME_OK, MB_ICONEXCLAMATION, IDS_FLUSH_VOLUME_OK);
+}       
 
 void WhichCell(CStringArray& files)
 {
@@ -164,33 +164,33 @@ void WhichCell(CStringArray& files)
     CString str;
     CString str2;
 
-       CStringArray results;
+    CStringArray results;
 
     error = 0;
 
-       HOURGLASS hourglass;
-
-       for (int i = 0; i < files.GetSize(); i++) {
-               blob.in_size = 0;
-               blob.out_size = MAXSIZE;
-               blob.out = space;
-
-               code = pioctl(PCCHAR(files[i]), VIOC_FILE_CELL_NAME, &blob, 1);
-               if (code) {
-                       if (code == ENOENT) {
-                               LoadString (str, IDS_CANT_GET_CELL);
-                               results.Add(str);
-                       } else
-                               results.Add(GetAfsError(errno));
-               } else
-                       results.Add(space);
-       }
-
-       LoadString (str, IDS_SHOW_CELL);
-       LoadString (str2, IDS_SHOW_CELL_COLUMN);
-       CResultsDlg dlg(SHOW_CELL_HELP_ID);
-       dlg.SetContents(str, str2, StripPath(files), results);
-       dlg.DoModal();
+    HOURGLASS hourglass;
+
+    for (int i = 0; i < files.GetSize(); i++) {
+        blob.in_size = 0;
+        blob.out_size = MAXSIZE;
+        blob.out = space;
+
+        code = pioctl(PCCHAR(files[i]), VIOC_FILE_CELL_NAME, &blob, 1);
+        if (code) {
+            if (code == ENOENT) {
+                LoadString (str, IDS_CANT_GET_CELL);
+                results.Add(str);
+            } else
+                results.Add(GetAfsError(errno));
+        } else
+            results.Add(space);
+    }       
+
+    LoadString (str, IDS_SHOW_CELL);
+    LoadString (str2, IDS_SHOW_CELL_COLUMN);
+    CResultsDlg dlg(SHOW_CELL_HELP_ID);
+    dlg.SetContents(str, str2, StripPath(files), results);
+    dlg.DoModal();
 }
 
 void WSCellCmd()
@@ -198,7 +198,7 @@ void WSCellCmd()
     register LONG code;
     struct ViceIoctl blob;
     
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     blob.in_size = 0;
     blob.in = (char *) 0;
@@ -208,10 +208,10 @@ void WSCellCmd()
     code = pioctl((char *) 0, VIOC_GET_WS_CELL, &blob, 1);
 
     if (code) {
-               //Die(errno, (char *) 0);
+        //Die(errno, (char *) 0);
     }
     //else
-               //printf("This workstation belongs to cell '%s'\n", space);
+    //printf("This workstation belongs to cell '%s'\n", space);
 }
 
 BOOL CheckVolumes()
@@ -223,13 +223,13 @@ BOOL CheckVolumes()
     blob.out_size = 0;
     code = pioctl(0, VIOCCKBACK, &blob, 1);
     if (code) {
-               ShowMessageBox(IDS_CHECK_VOLUMES_ERROR, MB_ICONEXCLAMATION, IDS_CHECK_VOLUMES_ERROR, GetAfsError(errno, CString()));
-               return FALSE;
+        ShowMessageBox(IDS_CHECK_VOLUMES_ERROR, MB_ICONEXCLAMATION, IDS_CHECK_VOLUMES_ERROR, GetAfsError(errno, CString()));
+        return FALSE;
     }
 
     ShowMessageBox(IDS_CHECK_VOLUMES_OK, MB_OK, IDS_CHECK_VOLUMES_OK);
 
-       return TRUE;
+    return TRUE;
 }
 
 void SetCacheSizeCmd(LONG nNewCacheSize)
@@ -237,98 +237,98 @@ void SetCacheSizeCmd(LONG nNewCacheSize)
     register LONG code;
     struct ViceIoctl blob;
     
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       blob.in = (char *) &nNewCacheSize;
+    blob.in = (char *) &nNewCacheSize;
     blob.in_size = sizeof(LONG);
     blob.out_size = 0;
 
     code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
     //if (code)
-       //      Die(errno, (char *) 0);
+    // Die(errno, (char *) 0);
     //else
-       //      printf("New cache size set.\n");
+    // printf("New cache size set.\n");
 }
 
 void WhereIs(CStringArray& files)
 {
     register LONG code;
     struct ViceIoctl blob;
-       CStringArray servers;
-       CStringArray resultFiles;
-       CString str;
-       CString str2;
-
-       HOURGLASS hourglass;
-
-       for (int i = 0; i < files.GetSize(); i++) {
-               blob.out_size = MAXSIZE;
-               blob.in_size = 0;
-               blob.out = space;
-               memset(space, 0, sizeof(space));
-
-               code = pioctl(PCCHAR(files[i]), VIOCWHEREIS, &blob, 1);
-               if (code) {
-                       resultFiles.Add(StripPath(files[i]));
-                       servers.Add(GetAfsError(errno));
-                       continue;
-               }
-               
-               LONG *hosts = (LONG *)space;
-               BOOL bFirst = TRUE;
-               str = "";
-
-               for (int j = 0; j < MAXHOSTS; j++) {
-                       if (hosts[j] == 0)
-                               break;
-                       char *hostName = hostutil_GetNameByINet(hosts[j]);
-                       if (bFirst) {
-                               resultFiles.Add(StripPath(files[i]));
-                               bFirst = FALSE;
-                       } else
-                               resultFiles.Add(" ");
-                       servers.Add(hostName);
-               }
-       }
-
-       LoadString (str, IDS_SHOW_FS);
-       LoadString (str2, IDS_SHOW_FS_COLUMN);
-       CResultsDlg dlg(SHOW_FILE_SERVERS_HELP_ID);
-       dlg.SetContents(str, str2, resultFiles, servers);
-       dlg.DoModal();
-}
+    CStringArray servers;
+    CStringArray resultFiles;
+    CString str;
+    CString str2;
+
+    HOURGLASS hourglass;
+
+    for (int i = 0; i < files.GetSize(); i++) {
+        blob.out_size = MAXSIZE;
+        blob.in_size = 0;
+        blob.out = space;
+        memset(space, 0, sizeof(space));
+
+        code = pioctl(PCCHAR(files[i]), VIOCWHEREIS, &blob, 1);
+        if (code) {
+            resultFiles.Add(StripPath(files[i]));
+            servers.Add(GetAfsError(errno));
+            continue;
+        }
+
+        LONG *hosts = (LONG *)space;
+        BOOL bFirst = TRUE;
+        str = "";
+
+        for (int j = 0; j < MAXHOSTS; j++) {
+            if (hosts[j] == 0)
+                break;
+            char *hostName = hostutil_GetNameByINet(hosts[j]);
+            if (bFirst) {
+                resultFiles.Add(StripPath(files[i]));
+                bFirst = FALSE;
+            } else
+                resultFiles.Add(" ");
+            servers.Add(hostName);
+        }
+    }
+
+    LoadString (str, IDS_SHOW_FS);
+    LoadString (str2, IDS_SHOW_FS_COLUMN);
+    CResultsDlg dlg(SHOW_FILE_SERVERS_HELP_ID);
+    dlg.SetContents(str, str2, resultFiles, servers);
+    dlg.DoModal();
+}       
 
 CString GetAfsError(int code, const char *filename)
 {
     CString strMsg;
 
-       if (code == EINVAL) {
-               if (filename)
-                   strMsg.Format("Invalid argument; it is possible that the file is not in AFS");
-               else 
-                       strMsg.Format("Invalid argument");
+    if (code == EINVAL) {
+        if (filename)
+            strMsg.Format("Invalid argument; it is possible that the file is not in AFS");
+        else 
+            strMsg.Format("Invalid argument");
     } else if (code == ENOENT) {
-               if (filename) 
-                       strMsg.Format("The file does not exist");
-               else 
-                       strMsg.Format("No such file returned");
+        if (filename) 
+            strMsg.Format("The file does not exist");
+        else 
+            strMsg.Format("No such file returned");
     } else if (code == EROFS)  {
-               strMsg.Format("You can not change a backup or readonly volume");
+        strMsg.Format("You can not change a backup or readonly volume");
     } else if (code == EACCES || code == EPERM) {
-               strMsg.Format("You do not have the required rights to do this operation");
+        strMsg.Format("You do not have the required rights to do this operation");
     } else if (code == ENODEV) {
-               strMsg.Format("AFS service may not have started");
+        strMsg.Format("AFS service may not have started");
     } else if (code == ESRCH) {
-               strMsg.Format("Cell name not recognized");
+        strMsg.Format("Cell name not recognized");
     } else if (code == ETIMEDOUT) {
-               strMsg.Format("Connection timed out");
+        strMsg.Format("Connection timed out");
     } else if (code == EPIPE) {
-               strMsg.Format("Volume name or ID not recognized");
+        strMsg.Format("Volume name or ID not recognized");
     } else {
-               strMsg.Format("Error 0x%x occurred", code);
+        strMsg.Format("Error 0x%x occurred", code);
     }
 
-       return strMsg;
+    return strMsg;
 }
 
 
@@ -345,9 +345,9 @@ struct AclEntry {
 };
 
 struct Acl {
-    int dfs;                           //      Originally true if a dfs acl; now also the type
-                                                       //      of the acl (1, 2, or 3, corresponding to object,
-                                                       //      initial dir, or initial object).
+    int dfs;                   //      Originally true if a dfs acl; now also the type
+                                //     of the acl (1, 2, or 3, corresponding to object,
+                               //      initial dir, or initial object).
     sec_rgy_name_t cell;       //      DFS cell name
     int nplus;
     int nminus;
@@ -391,30 +391,30 @@ extern "C" int PruneList (struct AclEntry **ae, int dfs)
     struct AclEntry *te, *ne;
     LONG ctr = 0;
     
-       for (te = *ae; te; te = ne) {
+    for (te = *ae; te; te = ne) {
         if ((!dfs && te->rights == 0) || te->rights == -1) {
             *lp = te->next;
             ne = te->next;
             free(te);
             ctr++;
-               }
+        }
         else {
             ne = te->next;
             lp = &te->next;
-               }
+        }
     }
     
-       return ctr;
+    return ctr;
 }
 
 char *SkipLine (register char *astr)
 {
     while (*astr != '\n') 
-               astr++;
+        astr++;
     
-       astr++;
+    astr++;
     
-       return astr;
+    return astr;
 }
 
 /* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */
@@ -422,10 +422,10 @@ static BadName(register char *aname)
 {
     register int tc;
 
-       /* all must be '-' or digit to be bad */
+    /* all must be '-' or digit to be bad */
     while (tc = *aname++) {
-               if ((tc != '-') && (tc < '0' || tc > '9')) 
-                       return 0;
+        if ((tc != '-') && (tc < '0' || tc > '9')) 
+            return 0;
     }
 
     return 1;
@@ -433,18 +433,18 @@ static BadName(register char *aname)
 
 CString GetRightsString(register LONG arights, int dfs)
 {
-       CString str;
+    CString str;
 
     if (!dfs) {
-               if (arights & PRSFS_READ) str += "r";
-               if (arights & PRSFS_LOOKUP) str += "l";
-               if (arights & PRSFS_INSERT) str += "i";
-               if (arights & PRSFS_DELETE) str += "d";
-               if (arights & PRSFS_WRITE) str += "w";
-               if (arights & PRSFS_LOCK) str += "k";
-               if (arights & PRSFS_ADMINISTER) str += "a";
+        if (arights & PRSFS_READ) str += "r";
+        if (arights & PRSFS_LOOKUP) str += "l";
+        if (arights & PRSFS_INSERT) str += "i";
+        if (arights & PRSFS_DELETE) str += "d";
+        if (arights & PRSFS_WRITE) str += "w";
+        if (arights & PRSFS_LOCK) str += "k";
+        if (arights & PRSFS_ADMINISTER) str += "a";
     } else {
-               ASSERT(FALSE);
+        ASSERT(FALSE);
 /*
                if (arights & DFS_READ) str += "r"; else str += "-";
                if (arights & DFS_WRITE) str += "w"; else printf("-");
@@ -454,9 +454,9 @@ CString GetRightsString(register LONG arights, int dfs)
                if (arights & DFS_DELETE) str += "d"; else printf("-");
                if (arights & (DFS_USRALL)) str += "+";
 */
-       }       
+    }  
 
-       return str;
+    return str;
 }
 
 char *AclToString(struct Acl *acl)
@@ -467,22 +467,22 @@ char *AclToString(struct Acl *acl)
     struct AclEntry *tp;
     
     if (acl->dfs)
-               sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
+        sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
     else
-               dfsstring[0] = '\0';
+        dfsstring[0] = '\0';
     sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
     
-       for(tp = acl->pluslist; tp; tp = tp->next) {
+    for(tp = acl->pluslist; tp; tp = tp->next) {
         sprintf(tstring, "%s %d\n", tp->name, tp->rights);
         strcat(mydata, tstring);
     }
     
-       for(tp = acl->minuslist; tp; tp = tp->next) {
+    for(tp = acl->minuslist; tp; tp = tp->next) {
         sprintf(tstring, "%s %d\n", tp->name, tp->rights);
         strcat(mydata, tstring);
     }
     
-       return mydata;
+    return mydata;
 }
 
 struct Acl *EmptyAcl(const CString& strCellName)
@@ -559,42 +559,42 @@ extern "C" int CleanAcl(struct Acl *aa)
     register struct AclEntry *te, **le, *ne;
     int changes;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     /* Don't correct DFS ACL's for now */
     if (aa->dfs)
-               return 0;
+        return 0;
 
     /* prune out bad entries */
     changes = 0;           /* count deleted entries */
     le = &aa->pluslist;
     for(te = aa->pluslist; te; te = ne) {
-               ne = te->next;
-               if (BadName(te->name)) {
-                       /* zap this dude */
-                       *le = te->next;
-                       aa->nplus--;
-                       free(te);
-                       changes++;
-               }
-               else
-                       le = &te->next;
+        ne = te->next;
+        if (BadName(te->name)) {
+            /* zap this dude */
+            *le = te->next;
+            aa->nplus--;
+            free(te);
+            changes++;
+        }
+        else
+            le = &te->next;
     }
 
     le = &aa->minuslist;
     
-       for(te = aa->minuslist; te; te = ne) {
-               ne = te->next;
-               if (BadName(te->name)) {
-                       /* zap this dude */
-                       *le = te->next;
-                       aa->nminus--;
-                       free(te);
-                       changes++;
-               }
-               else
-                       le = &te->next;
-    }
+    for(te = aa->minuslist; te; te = ne) {
+        ne = te->next;
+        if (BadName(te->name)) {
+            /* zap this dude */
+            *le = te->next;
+            aa->nminus--;
+            free(te);
+            changes++;
+        }
+        else
+            le = &te->next;
+    }   
 
     return changes;
 }
@@ -606,49 +606,49 @@ void CleanACL(CStringArray& names)
     struct ViceIoctl blob;
     int changes;
 
-       ShowMessageBox(IDS_CLEANACL_MSG, MB_OK, IDS_CLEANACL_MSG);
+    ShowMessageBox(IDS_CLEANACL_MSG, MB_OK, IDS_CLEANACL_MSG);
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       for (int i = 0; i < names.GetSize(); i++) {
-               blob.out_size = MAXSIZE;
-               blob.in_size = 0;
-               blob.out = space;
+    for (int i = 0; i < names.GetSize(); i++) {
+        blob.out_size = MAXSIZE;
+        blob.in_size = 0;
+        blob.out = space;
 
-               code = pioctl(PCCHAR(names[i]), VIOCGETAL, &blob, 1);
-               if (code) {
-                       ShowMessageBox(IDS_CLEANACL_ERROR, MB_ICONEXCLAMATION, 0, names[i], GetAfsError(errno));
-                       continue;
-               }
-               
-               ta = ParseAcl(space);
-               if (ta->dfs) {
-                       ShowMessageBox(IDS_CLEANACL_NOT_SUPPORTED, MB_ICONEXCLAMATION, IDS_CLEANACL_NOT_SUPPORTED, names[i]);
-                       continue;
-               }
-
-               changes = CleanAcl(ta);
-               if (!changes)
-                       continue;
-
-               /* now set the acl */
-               blob.in = AclToString(ta);
-               blob.in_size = strlen((char *)blob.in) + 1;
-               blob.out_size = 0;
+        code = pioctl(PCCHAR(names[i]), VIOCGETAL, &blob, 1);
+        if (code) {
+            ShowMessageBox(IDS_CLEANACL_ERROR, MB_ICONEXCLAMATION, 0, names[i], GetAfsError(errno));
+            continue;
+        }
+
+        ta = ParseAcl(space);
+        if (ta->dfs) {
+            ShowMessageBox(IDS_CLEANACL_NOT_SUPPORTED, MB_ICONEXCLAMATION, IDS_CLEANACL_NOT_SUPPORTED, names[i]);
+            continue;
+        }
+
+        changes = CleanAcl(ta);
+        if (!changes)
+            continue;
+
+        /* now set the acl */
+        blob.in = AclToString(ta);
+        blob.in_size = strlen((char *)blob.in) + 1;
+        blob.out_size = 0;
                
-               code = pioctl(PCCHAR(names[i]), VIOCSETAL, &blob, 1);
-               if (code) {
-                       if (errno == EINVAL) {
-                               ShowMessageBox(IDS_CLEANACL_INVALID_ARG, MB_ICONEXCLAMATION, IDS_CLEANACL_INVALID_ARG, names[i]);
-                               continue;
-                       }
-                       else {
-                               ShowMessageBox(IDS_CLEANACL_ERROR, MB_ICONEXCLAMATION, 0, names[i], GetAfsError(errno));
-                               continue;
-                       }
-               }
-       }
-}
+        code = pioctl(PCCHAR(names[i]), VIOCSETAL, &blob, 1);
+        if (code) {
+            if (errno == EINVAL) {
+                ShowMessageBox(IDS_CLEANACL_INVALID_ARG, MB_ICONEXCLAMATION, IDS_CLEANACL_INVALID_ARG, names[i]);
+                continue;
+            }
+            else {
+                ShowMessageBox(IDS_CLEANACL_ERROR, MB_ICONEXCLAMATION, 0, names[i], GetAfsError(errno));
+                continue;
+            }
+        }
+    }
+}       
 
 // Derived from fs.c's ListAclCmd
 BOOL GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& strNegative)
@@ -659,70 +659,70 @@ BOOL GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& str
     struct AclEntry *te;
     int idf = 0; //getidf(as, parm_listacl_id);
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       blob.out_size = MAXSIZE;
-       blob.in_size = idf;
-       blob.in = blob.out = space;
+    blob.out_size = MAXSIZE;
+    blob.in_size = idf;
+    blob.in = blob.out = space;
        
-       code = pioctl(PCCHAR(strDir), VIOCGETAL, &blob, 1);
-       if (code) {
-               ShowMessageBox(IDS_GETRIGHTS_ERROR, MB_ICONEXCLAMATION, IDS_GETRIGHTS_ERROR, strDir, GetAfsError(errno));
-               return FALSE;
-       }
-
-       ta = ParseAcl(space);
-       if (ta->dfs) {
-               ShowMessageBox(IDS_DFSACL_ERROR, MB_ICONEXCLAMATION, IDS_DFSACL_ERROR);
-               return FALSE;
-       }
+    code = pioctl(PCCHAR(strDir), VIOCGETAL, &blob, 1);
+    if (code) {
+        ShowMessageBox(IDS_GETRIGHTS_ERROR, MB_ICONEXCLAMATION, IDS_GETRIGHTS_ERROR, strDir, GetAfsError(errno));
+        return FALSE;
+    }
+
+    ta = ParseAcl(space);
+    if (ta->dfs) {
+        ShowMessageBox(IDS_DFSACL_ERROR, MB_ICONEXCLAMATION, IDS_DFSACL_ERROR);
+        return FALSE;
+    }
 
 //     if (ta->dfs)
 //             printf("  Default cell = %s\n", ta->cell);
 
-       CString strRight;
+    CString strRight;
 
-       if (ta->nplus > 0) {
-               for (te = ta->pluslist; te; te = te->next) {
-                       strNormal.Add(te->name);
-                       strNormal.Add(GetRightsString(te->rights, ta->dfs));
-               }
-       }
+    if (ta->nplus > 0) {
+        for (te = ta->pluslist; te; te = te->next) {
+            strNormal.Add(te->name);
+            strNormal.Add(GetRightsString(te->rights, ta->dfs));
+        }
+    }
 
-       if (ta->nminus > 0) {
-               for (te = ta->minuslist; te; te = te->next) {
-                       strNegative.Add(te->name);
-                       strNegative.Add(GetRightsString(te->rights, ta->dfs));
-               }
-       }
+    if (ta->nminus > 0) {
+        for (te = ta->minuslist; te; te = te->next) {
+            strNegative.Add(te->name);
+            strNegative.Add(GetRightsString(te->rights, ta->dfs));
+        }
+    }
 
-       return TRUE;
+    return TRUE;
 }
 
 struct AclEntry *FindList(register struct AclEntry *pCurEntry, const char *entryName)
 {
     while (pCurEntry) {
         if (!foldcmp(pCurEntry->name, PCCHAR(entryName)))
-                       return pCurEntry;
-               pCurEntry = pCurEntry->next;
+            return pCurEntry;
+        pCurEntry = pCurEntry->next;
     }
     
-       return 0;
+    return 0;
 }
 
 void ChangeList (struct Acl *pAcl, BYTE bNormalRights, const char *entryName, LONG nEntryRights)
 {
-       ASSERT(pAcl);
-       ASSERT(entryName);
+    ASSERT(pAcl);
+    ASSERT(entryName);
     
-       struct AclEntry *pEntry;
+    struct AclEntry *pEntry;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     pEntry = (bNormalRights ? pAcl->pluslist : pAcl->minuslist);
     pEntry = FindList(pEntry, entryName);
 
-       /* Found the item already in the list. */
+    /* Found the item already in the list. */
     if (pEntry) {
         pEntry->rights = nEntryRights;
         if (bNormalRights)
@@ -736,22 +736,22 @@ void ChangeList (struct Acl *pAcl, BYTE bNormalRights, const char *entryName, LO
     pEntry = (struct AclEntry *) malloc(sizeof (struct AclEntry));
     ASSERT(pEntry);
        
-       strcpy(pEntry->name, entryName);
+    strcpy(pEntry->name, entryName);
     pEntry->rights = nEntryRights;
     
-       if (bNormalRights) {
+    if (bNormalRights) {
         pEntry->next = pAcl->pluslist;
         pAcl->pluslist = pEntry;
         pAcl->nplus++;
         if (nEntryRights == 0 || nEntryRights == -1)
-                       pAcl->nplus -= PruneList(&pAcl->pluslist, pAcl->dfs);
+            pAcl->nplus -= PruneList(&pAcl->pluslist, pAcl->dfs);
     }
     else {
         pEntry->next = pAcl->minuslist;
         pAcl->minuslist = pEntry;
         pAcl->nminus++;
         if (nEntryRights == 0)
-                       pAcl->nminus -= PruneList(&pAcl->minuslist, pAcl->dfs);
+            pAcl->nminus -= PruneList(&pAcl->minuslist, pAcl->dfs);
     }
 }
 
@@ -765,18 +765,18 @@ LONG Convert(const register char *arights, int dfs, enum rtype *rtypep)
 
     *rtypep = add;     /* add rights, by default */
 
-       if (!strcmp(arights,"read")) 
-               return PRSFS_READ | PRSFS_LOOKUP;
-       if (!strcmp(arights, "write")) 
-               return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
-       if (!strcmp(arights, "mail")) 
-               return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
-       if (!strcmp(arights, "all")) 
-               return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
+    if (!strcmp(arights,"read")) 
+        return PRSFS_READ | PRSFS_LOOKUP;
+    if (!strcmp(arights, "write")) 
+        return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
+    if (!strcmp(arights, "mail")) 
+        return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
+    if (!strcmp(arights, "all")) 
+        return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
     
-       if (!strcmp(arights, "none")) {
-               *rtypep = destroy; /* Remove entire entry */
-               return 0;
+    if (!strcmp(arights, "none")) {
+        *rtypep = destroy; /* Remove entire entry */
+        return 0;
     }
 
     len = strlen(arights);
@@ -784,18 +784,18 @@ LONG Convert(const register char *arights, int dfs, enum rtype *rtypep)
 
     for (i = 0; i < len; i++) {
         tc = *arights++;
-               if (tc == 'r') mode |= PRSFS_READ;
-               else if (tc == 'l') mode |= PRSFS_LOOKUP;
-               else if (tc == 'i') mode |= PRSFS_INSERT;
-               else if (tc == 'd') mode |= PRSFS_DELETE;
-               else if (tc == 'w') mode |= PRSFS_WRITE;
-               else if (tc == 'k') mode |= PRSFS_LOCK;
-               else if (tc == 'a') mode |= PRSFS_ADMINISTER;
-               else {
-                       fprintf(stderr, "illegal rights character '%c'.\n", tc);
-                       exit(1);
-               }
-    }
+        if (tc == 'r') mode |= PRSFS_READ;
+        else if (tc == 'l') mode |= PRSFS_LOOKUP;
+        else if (tc == 'i') mode |= PRSFS_INSERT;
+        else if (tc == 'd') mode |= PRSFS_DELETE;
+        else if (tc == 'w') mode |= PRSFS_WRITE;
+        else if (tc == 'k') mode |= PRSFS_LOCK;
+        else if (tc == 'a') mode |= PRSFS_ADMINISTER;
+        else {
+            fprintf(stderr, "illegal rights character '%c'.\n", tc);
+            exit(1);
+        }
+    }   
     return mode;
 }
 
@@ -805,39 +805,39 @@ BOOL SaveACL(const CString& strCellName, const CString& strDir, const CStringArr
     struct ViceIoctl blob;
     struct Acl *pAcl;
     LONG rights;
-       enum rtype rtype;
+    enum rtype rtype;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       // Create a new ACL
-       pAcl = EmptyAcl(strCellName);
+    // Create a new ACL
+    pAcl = EmptyAcl(strCellName);
 
-       // Set its normal rights
-       for (int i = 0; i < normal.GetSize(); i += 2) {
-               rights = Convert(normal[i + 1], 0, &rtype);
-               ChangeList(pAcl, TRUE, normal[i], rights);
-       }
+    // Set its normal rights
+    for (int i = 0; i < normal.GetSize(); i += 2) {
+        rights = Convert(normal[i + 1], 0, &rtype);
+        ChangeList(pAcl, TRUE, normal[i], rights);
+    }
 
-       // Set its negative rights
-       for (i = 0; i < negative.GetSize(); i += 2) {
-               rights = Convert(negative[i + 1], 0, &rtype);
-               ChangeList(pAcl, FALSE, negative[i], rights);
-       }
+    // Set its negative rights
+    for (i = 0; i < negative.GetSize(); i += 2) {
+        rights = Convert(negative[i + 1], 0, &rtype);
+        ChangeList(pAcl, FALSE, negative[i], rights);
+    }
 
-       // Write the ACL
-       blob.in = AclToString(pAcl);
-       blob.out_size = 0;
-       blob.in_size = 1 + strlen((const char *)blob.in);
-       
-       code = pioctl(PCCHAR(strDir), VIOCSETAL, &blob, 1);
-       if (code) {
-               if (errno == EINVAL)
-                       ShowMessageBox(IDS_SAVE_ACL_EINVAL_ERROR, MB_ICONEXCLAMATION, IDS_SAVE_ACL_EINVAL_ERROR, strDir);
-               else
-                       ShowMessageBox(IDS_SAVE_ACL_ERROR, MB_ICONEXCLAMATION, IDS_SAVE_ACL_ERROR, strDir, GetAfsError(errno, strDir));
-       }
+    // Write the ACL
+    blob.in = AclToString(pAcl);
+    blob.out_size = 0;
+    blob.in_size = 1 + strlen((const char *)blob.in);
 
-       ZapAcl(pAcl);
+    code = pioctl(PCCHAR(strDir), VIOCSETAL, &blob, 1);
+    if (code) {
+        if (errno == EINVAL)
+            ShowMessageBox(IDS_SAVE_ACL_EINVAL_ERROR, MB_ICONEXCLAMATION, IDS_SAVE_ACL_EINVAL_ERROR, strDir);
+        else
+            ShowMessageBox(IDS_SAVE_ACL_ERROR, MB_ICONEXCLAMATION, IDS_SAVE_ACL_ERROR, strDir, GetAfsError(errno, strDir));
+    }       
+
+    ZapAcl(pAcl);
 
     return (code == 0);
 }
@@ -849,91 +849,91 @@ BOOL CopyACL(const CString& strToDir, const CStringArray& normal, const CStringA
     struct Acl *pToAcl;
     int idf = 0; // getidf(as, parm_copyacl_id);
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       // Get ACL to copy to
-       blob.out_size = MAXSIZE;
-       blob.in_size = idf;
-       blob.in = blob.out = space;
-       
-       code = pioctl(PCCHAR(strToDir), VIOCGETAL, &blob, 1);
-       if (code) {
-               ShowMessageBox(IDS_ACL_READ_ERROR, MB_ICONEXCLAMATION, IDS_ACL_READ_ERROR, strToDir, GetAfsError(errno, strToDir));
-               return FALSE;
-       }
-       
-       if (bClear) 
-               pToAcl = EmptyAcl(space);
-       else 
-               pToAcl = ParseAcl(space);
-       
-       CleanAcl(pToAcl);
+    // Get ACL to copy to
+    blob.out_size = MAXSIZE;
+    blob.in_size = idf;
+    blob.in = blob.out = space;
        
-       if (pToAcl->dfs) {
-               ShowMessageBox(IDS_NO_DFS_COPY_ACL, MB_ICONEXCLAMATION, IDS_NO_DFS_COPY_ACL, strToDir);
-               ZapAcl(pToAcl);
-               return FALSE;
-       }
-
-       enum rtype rtype;
-
-       // Set normal rights
-       for (int i = 0; i < normal.GetSize(); i += 2) {
-               LONG rights = Convert(normal[i + 1], 0, &rtype);
-               ChangeList(pToAcl, TRUE, normal[i], rights);
-       }
-
-       // Set negative rights
-       for (i = 0; i < negative.GetSize(); i += 2) {
-               LONG rights = Convert(negative[i + 1], 0, &rtype);
-               ChangeList(pToAcl, FALSE, normal[i], rights);
-       }
-
-       // Save modified ACL
-       blob.in = AclToString(pToAcl);
-       blob.out_size = 0;
-       blob.in_size = 1 + strlen((char *)blob.in);
+    code = pioctl(PCCHAR(strToDir), VIOCGETAL, &blob, 1);
+    if (code) {
+        ShowMessageBox(IDS_ACL_READ_ERROR, MB_ICONEXCLAMATION, IDS_ACL_READ_ERROR, strToDir, GetAfsError(errno, strToDir));
+        return FALSE;
+    }
        
-       code = pioctl(PCCHAR(strToDir), VIOCSETAL, &blob, 1);
-       if (code) {
-               ZapAcl(pToAcl);
-               if (errno == EINVAL)
-                       ShowMessageBox(IDS_COPY_ACL_EINVAL_ERROR, MB_ICONEXCLAMATION, IDS_COPY_ACL_EINVAL_ERROR, strToDir);
-               else 
-                       ShowMessageBox(IDS_COPY_ACL_ERROR, MB_ICONEXCLAMATION, IDS_COPY_ACL_ERROR, strToDir, GetAfsError(errno, strToDir));
-               return FALSE;
-       }
+    if (bClear) 
+        pToAcl = EmptyAcl(space);
+    else 
+        pToAcl = ParseAcl(space);
+
+    CleanAcl(pToAcl);
+
+    if (pToAcl->dfs) {
+        ShowMessageBox(IDS_NO_DFS_COPY_ACL, MB_ICONEXCLAMATION, IDS_NO_DFS_COPY_ACL, strToDir);
+        ZapAcl(pToAcl);
+        return FALSE;
+    }
+
+    enum rtype rtype;
+
+    // Set normal rights
+    for (int i = 0; i < normal.GetSize(); i += 2) {
+        LONG rights = Convert(normal[i + 1], 0, &rtype);
+        ChangeList(pToAcl, TRUE, normal[i], rights);
+    }
+
+    // Set negative rights
+    for (i = 0; i < negative.GetSize(); i += 2) {
+        LONG rights = Convert(negative[i + 1], 0, &rtype);
+        ChangeList(pToAcl, FALSE, normal[i], rights);
+    }
+
+    // Save modified ACL
+    blob.in = AclToString(pToAcl);
+    blob.out_size = 0;
+    blob.in_size = 1 + strlen((char *)blob.in);
+
+    code = pioctl(PCCHAR(strToDir), VIOCSETAL, &blob, 1);
+    if (code) {
+        ZapAcl(pToAcl);
+        if (errno == EINVAL)
+            ShowMessageBox(IDS_COPY_ACL_EINVAL_ERROR, MB_ICONEXCLAMATION, IDS_COPY_ACL_EINVAL_ERROR, strToDir);
+        else 
+            ShowMessageBox(IDS_COPY_ACL_ERROR, MB_ICONEXCLAMATION, IDS_COPY_ACL_ERROR, strToDir, GetAfsError(errno, strToDir));
+        return FALSE;
+    }
 
-       ZapAcl(pToAcl);
+    ZapAcl(pToAcl);
 
-       ShowMessageBox(IDS_COPY_ACL_OK, MB_OK, IDS_COPY_ACL_OK);
+    ShowMessageBox(IDS_COPY_ACL_OK, MB_OK, IDS_COPY_ACL_OK);
 
     return TRUE;
 }
 
 CString ParseMountPoint(const CString strFile, CString strMountPoint)
 {
-       CString strType;
-       CString strVolume;
-       CString strCell;
-       CString strMountPointInfo;
-
-       if (strMountPoint[0] == '#')
-               strType = "Regular";
-       else if (strMountPoint[0] == '%')
-               strType = "Read/Write";
-
-       int nColon = strMountPoint.Find(':');
-       if (nColon >= 0) {
-               strCell = strMountPoint.Mid(1, nColon - 1);
-               strVolume = strMountPoint.Mid(nColon + 1);
-       } else
-               strVolume = strMountPoint.Mid(1);
-
-       strMountPointInfo = strFile + "\t" + strVolume + "\t" + strCell + "\t" + strType;
-
-       return strMountPointInfo;
-}
+    CString strType;
+    CString strVolume;
+    CString strCell;
+    CString strMountPointInfo;
+
+    if (strMountPoint[0] == '#')
+        strType = "Regular";
+    else if (strMountPoint[0] == '%')
+        strType = "Read/Write";
+
+    int nColon = strMountPoint.Find(':');
+    if (nColon >= 0) {
+        strCell = strMountPoint.Mid(1, nColon - 1);
+        strVolume = strMountPoint.Mid(nColon + 1);
+    } else
+        strVolume = strMountPoint.Mid(1);
+
+    strMountPointInfo = strFile + "\t" + strVolume + "\t" + strCell + "\t" + strType;
+
+    return strMountPointInfo;
+}       
 
 BOOL ListMount(CStringArray& files)
 {
@@ -944,66 +944,66 @@ BOOL ListMount(CStringArray& files)
     char true_name[1024];                      /* ``True'' dirname (e.g., symlink target) */
     char parent_dir[1024];                     /* Parent directory of true name */
     register char *last_component;     /* Last component of true name */
-       CStringArray mountPoints;
+    CStringArray mountPoints;
     
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     error = 0;
 
     for (int i = 0; i < files.GetSize(); i++) {
-               strcpy(orig_name, files[i]);
-               strcpy(true_name, orig_name);
-
-               /*
-                * Find rightmost slash, if any.
-                */
-               last_component = (char *)strrchr(true_name, '\\');
-               if (last_component) {
-                       /*
-                        * Found it.  Designate everything before it as the parent directory,
-                        * everything after it as the final component.
-                        */
-                       strncpy(parent_dir, true_name, last_component - true_name + 1);
-                       parent_dir[last_component - true_name + 1] = 0;
-                       last_component++;   /* Skip the slash */
-               }
-               else {
-                       /*
-                        * No slash appears in the given file name.  Set parent_dir to the current
-                        * directory, and the last component as the given name.
-                        */
-                       fs_ExtractDriveLetter(true_name, parent_dir);
-                       strcat(parent_dir, ".");
-                       last_component = true_name;
-                       fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
-               }
-
-               blob.in = last_component;
-               blob.in_size = strlen(last_component) + 1;
-               blob.out_size = MAXSIZE;
-               blob.out = space;
-               memset(space, 0, MAXSIZE);
-
-               code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
-               if (code == 0) {
-                       int nPos = strlen(space) - 1;
-                       if (space[nPos] == '.')
-                               space[nPos] = 0;
-                       mountPoints.Add(ParseMountPoint(StripPath(files[i]), space));
-               } else {
-                       error = 1;
-                       if (errno == EINVAL)
-                               mountPoints.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
-                       else
-                               mountPoints.Add(GetMessageString(IDS_LIST_MOUNT_POINT_ERROR, GetAfsError(errno, StripPath(files[i]))));
-               }
-       }
-
-       CMountPointsDlg dlg;
-       dlg.SetMountPoints(mountPoints);
-       dlg.DoModal();
-
-       return !error;
+        strcpy(orig_name, files[i]);
+        strcpy(true_name, orig_name);
+
+        /*
+         * Find rightmost slash, if any.
+         */
+        last_component = (char *)strrchr(true_name, '\\');
+        if (last_component) {
+            /*
+             * Found it.  Designate everything before it as the parent directory,
+             * everything after it as the final component.
+             */
+            strncpy(parent_dir, true_name, last_component - true_name + 1);
+            parent_dir[last_component - true_name + 1] = 0;
+            last_component++;   /* Skip the slash */
+        }
+        else {
+            /*
+             * No slash appears in the given file name.  Set parent_dir to the current
+             * directory, and the last component as the given name.
+             */
+            fs_ExtractDriveLetter(true_name, parent_dir);
+            strcat(parent_dir, ".");
+            last_component = true_name;
+            fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
+        }
+
+        blob.in = last_component;
+        blob.in_size = strlen(last_component) + 1;
+        blob.out_size = MAXSIZE;
+        blob.out = space;
+        memset(space, 0, MAXSIZE);
+
+        code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
+        if (code == 0) {
+            int nPos = strlen(space) - 1;
+            if (space[nPos] == '.')
+                space[nPos] = 0;
+            mountPoints.Add(ParseMountPoint(StripPath(files[i]), space));
+        } else {
+            error = 1;
+            if (errno == EINVAL)
+                mountPoints.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
+            else
+                mountPoints.Add(GetMessageString(IDS_LIST_MOUNT_POINT_ERROR, GetAfsError(errno, StripPath(files[i]))));
+        }
+    }
+
+    CMountPointsDlg dlg;
+    dlg.SetMountPoints(mountPoints);
+    dlg.DoModal();
+
+    return !error;
 }
 
 BOOL IsPathInAfs(const CHAR *strPath)
@@ -1031,14 +1031,14 @@ static char *Parent(char *apath)
     strcpy(tspace, apath);
     tp = strrchr(tspace, '\\');
     if (tp) {
-               *(tp+1) = 0;    /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */
+        *(tp+1) = 0;   /* lv trailing slash so Parent("k:\foo") is "k:\" not "k:" */
     }
     else {
-               fs_ExtractDriveLetter(apath, tspace);
+        fs_ExtractDriveLetter(apath, tspace);
        strcat(tspace, ".");
     }
     
-       return tspace;
+    return tspace;
 }
 
 BOOL MakeMount(const CString& strDir, const CString& strVolName, const CString& strCellName, BOOL bRW)
@@ -1048,49 +1048,49 @@ BOOL MakeMount(const CString& strDir, const CString& strVolName, const CString&
     char localCellName[1000];
     struct ViceIoctl blob;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       ASSERT(strVolName.GetLength() < 64);
+    ASSERT(strVolName.GetLength() < 64);
 
-/*
+    /*
 
-defect #3069
+    defect #3069
 
     if (as->parms[5].items && !as->parms[2].items) {
        fprintf(stderr,"fs: must provide cell when creating cellular mount point.\n");
        return FALSE;
     }
-*/
+    */
 
     if (strCellName.GetLength() > 0)   /* cell name specified */
-               cellName = PCCHAR(strCellName);
+        cellName = PCCHAR(strCellName);
     else
-               cellName = (char *) 0;
+        cellName = (char *) 0;
 
     if (!IsPathInAfs(Parent(PCCHAR(strDir)))) {
-               ShowMessageBox(IDS_MAKE_MP_NOT_AFS_ERROR, MB_ICONEXCLAMATION, IDS_MAKE_MP_NOT_AFS_ERROR);
-               return FALSE;
+        ShowMessageBox(IDS_MAKE_MP_NOT_AFS_ERROR, MB_ICONEXCLAMATION, IDS_MAKE_MP_NOT_AFS_ERROR);
+        return FALSE;
     }
 
     if (cellName) {
-               blob.in_size = 0;
-               blob.out_size = MAXSIZE;
-               blob.out = space;
-               code = pioctl(Parent(PCCHAR(strDir)), VIOC_FILE_CELL_NAME, &blob, 1);
-    }
+        blob.in_size = 0;
+        blob.out_size = MAXSIZE;
+        blob.out = space;
+        code = pioctl(Parent(PCCHAR(strDir)), VIOC_FILE_CELL_NAME, &blob, 1);
+    }   
 
     strcpy(localCellName, (cellName? cellName : space));
 
     if (bRW)   /* if -rw specified */
-               strcpy(space, "%");
+        strcpy(space, "%");
     else
-               strcpy(space, "#");
+        strcpy(space, "#");
 
     /* If cellular mount point, prepend cell prefix */
-       if (cellName) {
-               strcat(space, localCellName);
-               strcat(space, ":");
-    }
+    if (cellName) {
+        strcat(space, localCellName);
+        strcat(space, ":");
+    }   
 
     strcat(space, strVolName); /* append volume name */
     strcat(space, ".");                /* stupid convention; these end with a period */
@@ -1105,125 +1105,125 @@ defect #3069
     code = pioctl(PCCHAR(strDir), VIOC_AFS_CREATE_MT_PT, &blob, 0);
 
     if (code) {
-               ShowMessageBox(IDS_MOUNT_POINT_ERROR, MB_ICONEXCLAMATION, IDS_MOUNT_POINT_ERROR, GetAfsError(errno, strDir));
-               return FALSE;
+        ShowMessageBox(IDS_MOUNT_POINT_ERROR, MB_ICONEXCLAMATION, IDS_MOUNT_POINT_ERROR, GetAfsError(errno, strDir));
+        return FALSE;
     }
     
-       return TRUE;
+    return TRUE;
 }
 
 /*
 */
 long fs_ExtractDriveLetter(const char *inPathp, char *outPathp)
 {
-       if (inPathp[0] != 0 && inPathp[1] == ':') {
-               /* there is a drive letter */
-                *outPathp++ = *inPathp++;
-                *outPathp++ = *inPathp++;
-                *outPathp++ = 0;
-        }
-       else *outPathp = 0;
+    if (inPathp[0] != 0 && inPathp[1] == ':') {
+        /* there is a drive letter */
+        *outPathp++ = *inPathp++;
+        *outPathp++ = *inPathp++;
+        *outPathp++ = 0;
+    }
+    else *outPathp = 0;
 
-        return 0;
-}
+    return 0;
+}       
 
 /* strip the drive letter from a component */
 long fs_StripDriveLetter(const char *inPathp, char *outPathp, long outSize)
 {
-       char tempBuffer[1000];
-        strcpy(tempBuffer, inPathp);
-        if (tempBuffer[0] != 0 && tempBuffer[1] == ':') {
-               /* drive letter present */
-                strcpy(outPathp, tempBuffer+2);
-        }
-        else {
-               /* no drive letter present */
-               strcpy(outPathp, tempBuffer);
-       }
-        return 0;
-}
+    char tempBuffer[1000];
+    strcpy(tempBuffer, inPathp);
+    if (tempBuffer[0] != 0 && tempBuffer[1] == ':') {
+        /* drive letter present */
+        strcpy(outPathp, tempBuffer+2);
+    }
+    else {
+        /* no drive letter present */
+        strcpy(outPathp, tempBuffer);
+    }
+    return 0;
+}       
 
 
 BOOL RemoveSymlink(const char * linkName)
 {
-       BOOL error = FALSE;
+    BOOL error = FALSE;
     INT code=0;
     struct ViceIoctl blob;
     char tbuffer[1024];
     char lsbuffer[1024];
-       char tpbuffer[1024];
+    char tpbuffer[1024];
     char *tp;
     
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       tp = (char *) strrchr(linkName, '\\');
-       if (!tp)
-           tp = (char *) strrchr(linkName, '/');
-       if (tp) {
-           strncpy(tbuffer, linkName, code=tp-linkName+1);  /* the dir name */
-            tbuffer[code] = 0;
-           tp++;   /* skip the slash */
-       }
-       else {
-           fs_ExtractDriveLetter(linkName, tbuffer);
-           strcat(tbuffer, ".");
-         fs_StripDriveLetter(tp, tpbuffer, 0);
-                tp=tpbuffer;
-       }
-       blob.in = tp;
-       blob.in_size = strlen(tp)+1;
-       blob.out = lsbuffer;
-       blob.out_size = sizeof(lsbuffer);
-       code = pioctl(tbuffer, VIOC_LISTSYMLINK, &blob, 0);
-       if (code)
-               return FALSE;
-       blob.out_size = 0;
-       blob.in = tp;
-       blob.in_size = strlen(tp)+1;
-       return (pioctl(tbuffer, VIOC_DELSYMLINK, &blob, 0)==0);
-}
+    tp = (char *) strrchr(linkName, '\\');
+    if (!tp)
+        tp = (char *) strrchr(linkName, '/');
+    if (tp) {
+        strncpy(tbuffer, linkName, code=tp-linkName+1);  /* the dir name */
+        tbuffer[code] = 0;
+        tp++;   /* skip the slash */
+    }
+    else {
+        fs_ExtractDriveLetter(linkName, tbuffer);
+        strcat(tbuffer, ".");
+        fs_StripDriveLetter(tp, tpbuffer, 0);
+        tp=tpbuffer;
+    }
+    blob.in = tp;
+    blob.in_size = strlen(tp)+1;
+    blob.out = lsbuffer;
+    blob.out_size = sizeof(lsbuffer);
+    code = pioctl(tbuffer, VIOC_LISTSYMLINK, &blob, 0);
+    if (code)
+        return FALSE;
+    blob.out_size = 0;
+    blob.in = tp;
+    blob.in_size = strlen(tp)+1;
+    return (pioctl(tbuffer, VIOC_DELSYMLINK, &blob, 0)==0);
+}       
 
 BOOL IsSymlink(const char * true_name)
 {
     char parent_dir[MAXSIZE];          /*Parent directory of true name*/
-       char strip_name[MAXSIZE];
+    char strip_name[MAXSIZE];
     struct ViceIoctl blob;
-       char *last_component;
+    char *last_component;
     int code;
 
     HOURGLASS hourglass;
 
-       last_component = (char *) strrchr(true_name, '\\');
-       if (!last_component)
-           last_component = (char *) strrchr(true_name, '/');
-       if (last_component) {
-           /*
-            * Found it.  Designate everything before it as the parent directory,
-            * everything after it as the final component.
-            */
-           strncpy(parent_dir, true_name, last_component - true_name + 1);
-           parent_dir[last_component - true_name + 1] = 0;
-           last_component++;   /*Skip the slash*/
-       }
-       else {
-           /*
-            * No slash appears in the given file name.  Set parent_dir to the current
-            * directory, and the last component as the given name.
-            */
-           fs_ExtractDriveLetter(true_name, parent_dir);
-           strcat(parent_dir, ".");
-           last_component = strip_name;
+    last_component = (char *) strrchr(true_name, '\\');
+    if (!last_component)
+        last_component = (char *) strrchr(true_name, '/');
+    if (last_component) {
+        /*
+         * Found it.  Designate everything before it as the parent directory,
+         * everything after it as the final component.
+         */
+        strncpy(parent_dir, true_name, last_component - true_name + 1);
+        parent_dir[last_component - true_name + 1] = 0;
+        last_component++;   /*Skip the slash*/
+    }
+    else {
+        /*
+         * No slash appears in the given file name.  Set parent_dir to the current
+         * directory, and the last component as the given name.
+         */
+        fs_ExtractDriveLetter(true_name, parent_dir);
+        strcat(parent_dir, ".");
+        last_component = strip_name;
         fs_StripDriveLetter(true_name, strip_name, sizeof(strip_name));
-       }
-
-       blob.in = last_component;
-       blob.in_size = strlen(last_component)+1;
-       blob.out_size = MAXSIZE;
-       blob.out = space;
-       memset(space, 0, MAXSIZE);
-       code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1);
-       return (code==0);
-}
+    }
+
+    blob.in = last_component;
+    blob.in_size = strlen(last_component)+1;
+    blob.out_size = MAXSIZE;
+    blob.out = space;
+    memset(space, 0, MAXSIZE);
+    code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1);
+    return (code==0);
+}       
 
 
 /*
@@ -1239,61 +1239,61 @@ BOOL RemoveMount(CStringArray& files)
     char tbuffer[1024];
     char lsbuffer[1024];
     register char *tp;
-       BOOL error = FALSE;
-       CStringArray results;
-       CString str;
-       CString str2;
+    BOOL error = FALSE;
+    CStringArray results;
+    CString str;
+    CString str2;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     for (int i = 0; i < files.GetSize(); i++) {
-               char szCurItem[1024];
-               strcpy(szCurItem, files[i]);
+        char szCurItem[1024];
+        strcpy(szCurItem, files[i]);
        
-               tp = (char *)strrchr(szCurItem, '\\');
-               if (tp) {
-                       strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1);  /* the dir name */
-                       tbuffer[code] = 0;
-                       tp++;   /* skip the slash */
-               } else {
-                       fs_ExtractDriveLetter(szCurItem, tbuffer);
-                       strcat(tbuffer, ".");
-                       tp = szCurItem;
-                       fs_StripDriveLetter(tp, tp, 0);
-               }
-
-               blob.in = tp;
-               blob.in_size = strlen(tp)+1;
-               blob.out = lsbuffer;
-               blob.out_size = sizeof(lsbuffer);
-
-               code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
-               if (code) {
-                       error = TRUE;
-                       if (errno == EINVAL)
-                               results.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
-                       else
-                               results.Add(GetMessageString(IDS_ERROR, GetAfsError(errno, StripPath(files[i]))));
-                       continue;       // don't bother trying
-               }
-               
-               blob.out_size = 0;
-               blob.in = tp;
-               blob.in_size = strlen(tp)+1;
-               
-               code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
-               if (code) {
-                       error = TRUE;
-                       results.Add(GetMessageString(IDS_ERROR, GetAfsError(errno, StripPath(files[i]))));
-               } else
-                       results.Add(GetMessageString(IDS_DELETED));
-    }
+        tp = (char *)strrchr(szCurItem, '\\');
+        if (tp) {
+            strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1);  /* the dir name */
+            tbuffer[code] = 0;
+            tp++;   /* skip the slash */
+        } else {
+            fs_ExtractDriveLetter(szCurItem, tbuffer);
+            strcat(tbuffer, ".");
+            tp = szCurItem;
+            fs_StripDriveLetter(tp, tp, 0);
+        }
+
+        blob.in = tp;
+        blob.in_size = strlen(tp)+1;
+        blob.out = lsbuffer;
+        blob.out_size = sizeof(lsbuffer);
+
+        code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
+        if (code) {
+            error = TRUE;
+            if (errno == EINVAL)
+                results.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
+            else
+                results.Add(GetMessageString(IDS_ERROR, GetAfsError(errno, StripPath(files[i]))));
+            continue;  // don't bother trying
+        }
+
+        blob.out_size = 0;
+        blob.in = tp;
+        blob.in_size = strlen(tp)+1;
 
-       LoadString (str, IDS_REMOVE_MP);
-       LoadString (str2, IDS_REMOVE_MP_COLUMN);
-       CResultsDlg dlg(REMOVE_MOUNT_POINTS_HELP_ID);
-       dlg.SetContents(str, str2, StripPath(files), results);
-       dlg.DoModal();
+        code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
+        if (code) {
+            error = TRUE;
+            results.Add(GetMessageString(IDS_ERROR, GetAfsError(errno, StripPath(files[i]))));
+        } else
+            results.Add(GetMessageString(IDS_DELETED));
+    }   
+
+    LoadString (str, IDS_REMOVE_MP);
+    LoadString (str2, IDS_REMOVE_MP_COLUMN);
+    CResultsDlg dlg(REMOVE_MOUNT_POINTS_HELP_ID);
+    dlg.SetContents(str, str2, StripPath(files), results);
+    dlg.DoModal();
 
     return !error;
 }
@@ -1305,12 +1305,12 @@ BOOL GetVolumeInfo(CString strFile, CVolInfo& volInfo)
     struct VolumeStatus *status;
     char *name;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       volInfo.m_strFilePath = strFile;
+    volInfo.m_strFilePath = strFile;
     volInfo.m_strFileName = StripPath(strFile);
 
-/*
+    /*
        volInfo.m_strName = "VolumeName";
        volInfo.m_nID = 10;
        volInfo.m_nQuota = 20 * 1024 * 1024;
@@ -1320,29 +1320,29 @@ BOOL GetVolumeInfo(CString strFile, CVolInfo& volInfo)
        volInfo.m_nPartFree = 30 * 1024 * 1024;
        volInfo.m_nDup = -1;
        return TRUE;
-*/
+     */
 
-       blob.out_size = MAXSIZE;
-       blob.in_size = 0;
-       blob.out = space;
-
-       code = pioctl(PCCHAR(strFile), VIOCGETVOLSTAT, &blob, 1);
-       if (code) {
-               volInfo.m_strErrorMsg = GetAfsError(errno, strFile);
-               return FALSE;
-       }
-
-       status = (VolumeStatus *)space;
-       name = (char *)status + sizeof(*status);
-
-       volInfo.m_strName = name;
-       volInfo.m_nID = status->Vid;
-       volInfo.m_nQuota = status->MaxQuota;
-       volInfo.m_nNewQuota = status->MaxQuota;
-       volInfo.m_nUsed = status->BlocksInUse;
-       volInfo.m_nPartSize = status->PartMaxBlocks;
-       volInfo.m_nPartFree = status->PartBlocksAvail;
-       volInfo.m_nDup = -1;
+    blob.out_size = MAXSIZE;
+    blob.in_size = 0;
+    blob.out = space;
+
+    code = pioctl(PCCHAR(strFile), VIOCGETVOLSTAT, &blob, 1);
+    if (code) {
+        volInfo.m_strErrorMsg = GetAfsError(errno, strFile);
+        return FALSE;
+    }
+
+    status = (VolumeStatus *)space;
+    name = (char *)status + sizeof(*status);
+
+    volInfo.m_strName = name;
+    volInfo.m_nID = status->Vid;
+    volInfo.m_nQuota = status->MaxQuota;
+    volInfo.m_nNewQuota = status->MaxQuota;
+    volInfo.m_nUsed = status->BlocksInUse;
+    volInfo.m_nPartSize = status->PartMaxBlocks;
+    volInfo.m_nPartFree = status->PartBlocksAvail;
+    volInfo.m_nDup = -1;
 
     return TRUE;
 }
@@ -1354,49 +1354,49 @@ BOOL SetVolInfo(CVolInfo& volInfo)
     struct VolumeStatus *status;
     char *input;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
-       blob.out_size = MAXSIZE;
-       blob.in_size = sizeof(*status) + 3;     /* for the three terminating nulls */
-       blob.out = space;
-       blob.in = space;
-       
-       status = (VolumeStatus *)space;
-       status->MinQuota = -1;
-       status->MaxQuota = volInfo.m_nNewQuota;
+    blob.out_size = MAXSIZE;
+    blob.in_size = sizeof(*status) + 3;        /* for the three terminating nulls */
+    blob.out = space;
+    blob.in = space;
+
+    status = (VolumeStatus *)space;
+    status->MinQuota = -1;
+    status->MaxQuota = volInfo.m_nNewQuota;
        
-       input = (char *)status + sizeof(*status);
-       *(input++) = '\0';      /* never set name: this call doesn't change vldb */
-       *(input++) = '\0';      // No offmsg
-       *(input++) = '\0';      // No motd
+    input = (char *)status + sizeof(*status);
+    *(input++) = '\0'; /* never set name: this call doesn't change vldb */
+    *(input++) = '\0'; // No offmsg
+    *(input++) = '\0'; // No motd
 
 #ifdef LOGGING_ON
-       FILE *fp = OpenFile(szLogFileName, "a");
-       if (fp) {
-               fprintf(fp, "\nSetVolInfo() pioctl parms:\n");
-               fprintf(fp, "\tpathp = %s\n\topcode = VIOCSETVOLSTAT (%d)\n\tblobp = %ld\n", PCCHAR(volInfo.m_strFilePath), VIOCSETVOLSTAT, &blob);
-               fprintf(fp, "\t\tblobp.in = %ld (VolumeStatus *status)\n\t\tblobp.in_size = %ld\n\t\tblobp.out = %ld ((VolumeStatus *status))\n\t\tblobp.out_size = %ld\n", blob.in, blob.in_size, blob.out, blob.out_size);
-               fprintf(fp, "\t\t\tstatus->MinQuota = %ld\n", status->MinQuota);
-               fprintf(fp, "\t\t\tstatus->MaxQuota = %ld\n", status->MaxQuota);
-               fprintf(fp, "\t\t\tOther status fields aren't set\n");
-               fprintf(fp, "\t\t\t3 nulls follow the VolumeStatus structure.\n");
-               fprintf(fp, "\tfollow = 1\n");
-               fclose(fp);             
-       }
+    FILE *fp = OpenFile(szLogFileName, "a");
+    if (fp) {
+        fprintf(fp, "\nSetVolInfo() pioctl parms:\n");
+        fprintf(fp, "\tpathp = %s\n\topcode = VIOCSETVOLSTAT (%d)\n\tblobp = %ld\n", PCCHAR(volInfo.m_strFilePath), VIOCSETVOLSTAT, &blob);
+        fprintf(fp, "\t\tblobp.in = %ld (VolumeStatus *status)\n\t\tblobp.in_size = %ld\n\t\tblobp.out = %ld ((VolumeStatus *status))\n\t\tblobp.out_size = %ld\n", blob.in, blob.in_size, blob.out, blob.out_size);
+        fprintf(fp, "\t\t\tstatus->MinQuota = %ld\n", status->MinQuota);
+        fprintf(fp, "\t\t\tstatus->MaxQuota = %ld\n", status->MaxQuota);
+        fprintf(fp, "\t\t\tOther status fields aren't set\n");
+        fprintf(fp, "\t\t\t3 nulls follow the VolumeStatus structure.\n");
+        fprintf(fp, "\tfollow = 1\n");
+        fclose(fp);            
+    }
 #endif
 
-       code = pioctl(PCCHAR(volInfo.m_strFilePath), VIOCSETVOLSTAT, &blob, 1);
-       if (code) {
-               ShowMessageBox(IDS_SET_QUOTA_ERROR, MB_ICONEXCLAMATION, IDS_SET_QUOTA_ERROR, GetAfsError(errno, volInfo.m_strName));
-               return FALSE;
-       }
+    code = pioctl(PCCHAR(volInfo.m_strFilePath), VIOCSETVOLSTAT, &blob, 1);
+    if (code) {
+        ShowMessageBox(IDS_SET_QUOTA_ERROR, MB_ICONEXCLAMATION, IDS_SET_QUOTA_ERROR, GetAfsError(errno, volInfo.m_strName));
+        return FALSE;
+    }
 
     return TRUE;
 }
 
 int GetCellName(char *cellNamep, struct afsconf_cell *infop)
 {
-       strcpy(infop->name, cellNamep);
+    strcpy(infop->name, cellNamep);
     return 0;
 }
 
@@ -1409,7 +1409,7 @@ BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bF
     struct afsconf_cell info;
     struct chservinfo checkserv;
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     memset(&checkserv, 0, sizeof(struct chservinfo));
     blob.in_size = sizeof(struct chservinfo);
@@ -1420,227 +1420,227 @@ BOOL CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bF
     memset(space, 0, sizeof(LONG));    /* so we assure zero when nothing is copied back */
 
     /* prepare flags for checkservers command */
-       if (nCellsToCheck == LOCAL_CELL)
-               temp = 2;       /* default to checking local cell only */
+    if (nCellsToCheck == LOCAL_CELL)
+        temp = 2;      /* default to checking local cell only */
     else if (nCellsToCheck == ALL_CELLS)
-               temp &= ~2;     /* turn off local cell check */
+        temp &= ~2;    /* turn off local cell check */
 
-       if (bFast)
-               temp |= 1;      /* set fast flag */
+    if (bFast)
+        temp |= 1;     /* set fast flag */
     
     checkserv.magic = 0x12345678;      /* XXX */
     checkserv.tflags = temp;
 
     /* now copy in optional cell name, if specified */
     if (nCellsToCheck == SPECIFIC_CELL) {
-               GetCellName(PCCHAR(strCellName), &info);
-               strcpy(checkserv.tbuffer,info.name);
-               checkserv.tsize = strlen(info.name) + 1;
+        GetCellName(PCCHAR(strCellName), &info);
+        strcpy(checkserv.tbuffer,info.name);
+        checkserv.tsize = strlen(info.name) + 1;
     } else {
-               strcpy(checkserv.tbuffer, "\0");
-               checkserv.tsize = 0;
-       }
+        strcpy(checkserv.tbuffer, "\0");
+        checkserv.tsize = 0;
+    }
 
-       checkserv.tinterval = -1;       /* don't change current interval */
+    checkserv.tinterval = -1;  /* don't change current interval */
 
     code = pioctl(0, VIOCCKSERV, &blob, 1);
     if (code) {
-               ShowMessageBox(IDS_CHECK_SERVERS_ERROR, MB_ICONEXCLAMATION, IDS_CHECK_SERVERS_ERROR, GetAfsError(errno, CString()));
-               return FALSE;
+        ShowMessageBox(IDS_CHECK_SERVERS_ERROR, MB_ICONEXCLAMATION, IDS_CHECK_SERVERS_ERROR, GetAfsError(errno, CString()));
+        return FALSE;
     }
 
     memcpy(&temp, space, sizeof(LONG));
 
-       if (temp == 0) {
-               ShowMessageBox(IDS_ALL_SERVERS_RUNNING, MB_OK, IDS_ALL_SERVERS_RUNNING);
-               return TRUE;
-       }
+    if (temp == 0) {
+        ShowMessageBox(IDS_ALL_SERVERS_RUNNING, MB_OK, IDS_ALL_SERVERS_RUNNING);
+        return TRUE;
+    }
 
-       CStringArray servers;
-       for (j = 0; j < MAXHOSTS; j++) {
-               memcpy(&temp, space + j * sizeof(LONG), sizeof(LONG));
-               if (temp == 0)
-                       break;
-               
-               char *name = hostutil_GetNameByINet(temp);
-               servers.Add(name);
-       }
+    CStringArray servers;
+    for (j = 0; j < MAXHOSTS; j++) {
+        memcpy(&temp, space + j * sizeof(LONG), sizeof(LONG));
+        if (temp == 0)
+            break;
 
-       CDownServersDlg dlg;
-       dlg.SetServerNames(servers);
-       dlg.DoModal();
+        char *name = hostutil_GetNameByINet(temp);
+        servers.Add(name);
+    }
+
+    CDownServersDlg dlg;
+    dlg.SetServerNames(servers);
+    dlg.DoModal();
 
     return TRUE;
-}
+}       
 
 BOOL GetTokenInfo(CStringArray& tokenInfo)
 {
-       int cellNum;
-       int rc;
-       time_t current_time;
-       time_t tokenExpireTime;
-       char *expireString;
-       char userName[100];
+    int cellNum;
+    int rc;
+    time_t current_time;
+    time_t tokenExpireTime;
+    char *expireString;
+    char userName[100];
 //     char s[100];
-       struct ktc_principal serviceName, clientName;
-       struct ktc_token token;
-       
-       CString strTokenInfo;
-       CString strUserName;
-       CString strCellName;
-       CString strExpir;
+    struct ktc_principal serviceName, clientName;
+    struct ktc_token token;
+
+    CString strTokenInfo;
+    CString strUserName;
+    CString strCellName;
+    CString strExpir;
 
-//     tokenInfo.Add("");
+//      tokenInfo.Add("");
 //     return TRUE;
 
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
 //     printf("\nTokens held by the Cache Manager:\n\n");
-       cellNum = 0;
-       current_time = time(0);
-
-       while (1) {
-               rc = ktc_ListTokens(cellNum, &cellNum, &serviceName);
-               if (rc == KTC_NOENT) {
-                       /* end of list */
-//                     printf("   --End of list --\n");
-                       break;
-               }
-               else if (rc == KTC_NOCM) {
-                       ShowMessageBox(IDS_GET_TOKENS_NO_AFS_SERVICE);
-//                     printf("AFS service may not have started\n");
-                       break;
-               }
-               else if (rc) {
-                       ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR, MB_ICONEXCLAMATION, IDS_GET_TOKENS_UNEXPECTED_ERROR, rc);
-                       return FALSE;
-//                     printf("Unexpected error, code %d\n", rc);
-//                     exit(1);
-               }
-               else {
-                       rc = ktc_GetToken(&serviceName, &token, sizeof(token), &clientName);
-                       if (rc) {
-                               ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR2, MB_ICONEXCLAMATION, IDS_GET_TOKENS_UNEXPECTED_ERROR2, 
-                                       serviceName.name, serviceName.instance, serviceName.cell, rc);
-                               continue;
-                       }
-
-                       tokenExpireTime = token.endTime;
-                       
-                       strcpy(userName, clientName.name);
-                       if (clientName.instance[0] != 0) {
-                               strcat(userName, ".");
-                               strcat(userName, clientName.instance);
-                       }
+    cellNum = 0;
+    current_time = time(0);
 
-                       BOOL bShowName = FALSE;
+    while (1) {
+        rc = ktc_ListTokens(cellNum, &cellNum, &serviceName);
+        if (rc == KTC_NOENT) {
+            /* end of list */
+//         printf("   --End of list --\n");
+            break;
+        }
+        else if (rc == KTC_NOCM) {
+            ShowMessageBox(IDS_GET_TOKENS_NO_AFS_SERVICE);
+//         printf("AFS service may not have started\n");
+            break;
+        }
+        else if (rc) {
+            ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR, MB_ICONEXCLAMATION, IDS_GET_TOKENS_UNEXPECTED_ERROR, rc);
+            return FALSE;
+//         printf("Unexpected error, code %d\n", rc);
+//         exit(1);
+        }
+        else {
+            rc = ktc_GetToken(&serviceName, &token, sizeof(token), &clientName);
+            if (rc) {
+                ShowMessageBox(IDS_GET_TOKENS_UNEXPECTED_ERROR2, MB_ICONEXCLAMATION, IDS_GET_TOKENS_UNEXPECTED_ERROR2, 
+                                serviceName.name, serviceName.instance,        serviceName.cell, rc);
+                continue;
+            }
+
+            tokenExpireTime = token.endTime;
 
-                       if (userName[0] == '\0')
-                               ; //printf("Tokens");
+            strcpy(userName, clientName.name);
+            if (clientName.instance[0] != 0) {
+                strcat(userName, ".");
+                strcat(userName, clientName.instance);
+            }
+
+            BOOL bShowName = FALSE;
+
+            if (userName[0] == '\0')
+                ; //printf("Tokens");
 // AFS ID is not returned at this time.
-//                     else if (strncmp(userName, "AFS ID", 6) == 0)
-//                             printf("User's (%s) tokens", userName);
-//                             sscanf(userName, "(AFS ID %s)", szAfsID);
-                       else if (strncmp(userName, "Unix UID", 8) == 0)
-                               ; //printf("Tokens");
-                       else
-                               strUserName = userName;
-//                             printf("User %s's tokens", userName);
+//         else if (strncmp(userName, "AFS ID", 6) == 0)
+//             printf("User's (%s) tokens", userName);
+//             sscanf(userName, "(AFS ID %s)", szAfsID);
+           else if (strncmp(userName, "Unix UID", 8) == 0)
+                ; //printf("Tokens");
+            else
+                strUserName = userName;
+//             printf("User %s's tokens", userName);
                        
-//                     printf(" for %s%s%s@%s ", serviceName.name, serviceName.instance[0] ? "." : "", serviceName.instance, serviceName.cell);
-                       strCellName = serviceName.cell;
+//             printf(" for %s%s%s@%s ", serviceName.name, serviceName.instance[0] ? "." : "", serviceName.instance, serviceName.cell);
+            strCellName = serviceName.cell;
                        
-                       if (tokenExpireTime <= current_time)
-                               strExpir = "[>> Expired <<]";
-//                             printf("[>> Expired <<]\n");
-                       else {
-                               expireString = ctime(&tokenExpireTime);
-                               expireString += 4;       /* Skip day of week */
-                               expireString[12] = '\0'; /* Omit secs & year */
-//                             printf("[Expires %s]\n", expireString);
-                               strExpir.Format("%s", expireString);
-                       }
-               
-                       strTokenInfo = strUserName + "\t" + strCellName + "\t" + strExpir + "\t" + strCellName;
-                       tokenInfo.Add(strTokenInfo);
-               }
-       }
+            if (tokenExpireTime <= current_time)
+                strExpir = "[>> Expired <<]";
+//             printf("[>> Expired <<]\n");
+            else {
+                expireString = ctime(&tokenExpireTime);
+                expireString += 4;      /* Skip day of week */
+                expireString[12] = '\0'; /* Omit secs & year */
+//             printf("[Expires %s]\n", expireString);
+                strExpir.Format("%s", expireString);
+            }
+
+            strTokenInfo = strUserName + "\t" + strCellName + "\t" + strExpir + "\t" + strCellName;
+            tokenInfo.Add(strTokenInfo);
+        }
+    }
 
 //     printf("Press <Enter> or <Return> when finished: ");
 //     gets(s);
-       return TRUE;
+    return TRUE;
 }
 
 UINT MakeSymbolicLink(const char *strName ,const char *strDir)
 {
     struct ViceIoctl blob;
-       char space[MAXSIZE];
-       UINT code;
+    char space[MAXSIZE];
+    UINT code;
 
     HOURGLASS hourglass;
 
     /*lets confirm its a good symlink*/
-       if (!IsPathInAfs(strDir))
-               return 1;
-       LPTSTR lpsz = new TCHAR[strlen(strDir)+1];
-       _tcscpy(lpsz, strName);
+    if (!IsPathInAfs(strDir))
+        return 1;
+    LPTSTR lpsz = new TCHAR[strlen(strDir)+1];
+    _tcscpy(lpsz, strName);
     strcpy(space, strDir);
     blob.out_size = 0;
     blob.in_size = 1 + strlen(space);
     blob.in = space;
     blob.out = NULL;
     if ((code=pioctl(lpsz, VIOC_SYMLINK, &blob, 0))!=0)
-               return code;
-       return 0;
+        return code;
+    return 0;
 }
 
 void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath)
 {
-       ASSERT(nlenPath<MAX_PATH);
+    ASSERT(nlenPath<MAX_PATH);
     struct ViceIoctl blob;
     char orig_name[MAX_PATH+1];                /*Original name, may be modified*/
     char true_name[MAX_PATH+1];                /*``True'' dirname (e.g., symlink target)*/
     char parent_dir[MAX_PATH+1];               /*Parent directory of true name*/
     char *last_component;      /*Last component of true name*/
-       UINT code;    
+    UINT code;    
 
-       HOURGLASS hourglass;
+    HOURGLASS hourglass;
 
     strcpy(orig_name, strName);
-       strcpy(true_name, orig_name);
+    strcpy(true_name, orig_name);
        /*
         * Find rightmost slash, if any.
         */
-       last_component = (char *) strrchr(true_name, '\\');
-       if (!last_component)
-           last_component = (char *) strrchr(true_name, '/');
-       if (last_component) {
+    last_component = (char *) strrchr(true_name, '\\');
+    if (!last_component)
+        last_component = (char *) strrchr(true_name, '/');
+    if (last_component) {
            /*
             * Found it.  Designate everything before it as the parent directory,
             * everything after it as the final component.
             */
-           strncpy(parent_dir, true_name, last_component - true_name + 1);
-           parent_dir[last_component - true_name + 1] = 0;
-           last_component++;   /*Skip the slash*/
-       }
-       else {
-           /*
-            * No slash appears in the given file name.  Set parent_dir to the current
-            * directory, and the last component as the given name.
-            */
-           fs_ExtractDriveLetter(true_name, parent_dir);
-           strcat(parent_dir, ".");
-           last_component = true_name;
-            fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
-       }
-       blob.in = last_component;
-       blob.in_size = strlen(last_component)+1;
-       blob.out_size = MAXSIZE;
-       blob.out = space;
-       memset(space, 0, MAXSIZE);
-       if ((code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1)))
-               strcpy(space,"???");
-       ASSERT(strlen(space)<MAX_PATH);
-       strncpy(strPath,space,nlenPath);
-}
+        strncpy(parent_dir, true_name, last_component - true_name + 1);
+        parent_dir[last_component - true_name + 1] = 0;
+        last_component++;   /*Skip the slash*/
+    }
+    else {
+        /*
+         * No slash appears in the given file name.  Set parent_dir to the current
+         * directory, and the last component as the given name.
+         */
+        fs_ExtractDriveLetter(true_name, parent_dir);
+        strcat(parent_dir, ".");
+        last_component = true_name;
+        fs_StripDriveLetter(true_name, true_name, sizeof(true_name));
+    }
+    blob.in = last_component;
+    blob.in_size = strlen(last_component)+1;
+    blob.out_size = MAXSIZE;
+    blob.out = space;
+    memset(space, 0, MAXSIZE);
+    if ((code = pioctl(parent_dir, VIOC_LISTSYMLINK, &blob, 1)))
+        strcpy(space,"???");
+    ASSERT(strlen(space)<MAX_PATH);
+    strncpy(strPath,space,nlenPath);
+}       
index 4d18f5f..f979241 100644 (file)
@@ -722,6 +722,7 @@ skipremove:
   WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Asynchronous" 0
   WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Impersonate"  1
   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "DLLName" "afslogon.dll"
+  WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Logon" "AFS_Logon_Event"
   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Logoff" "AFS_Logoff_Event"
   WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Startup" "AFS_Startup_Event"
 
index 5095440..7d647ce 100644 (file)
@@ -4,6 +4,7 @@
             Description="$(loc.StrAFSProdDesc)" Display="expand" InstallDefault="local" Level="30"
             Title="OpenAFS">
            <ComponentRef Id="efl_desktop_INI" />
+           <ComponentRef Id="efl_replace_afs_CMD" />
             <Feature Id="feaClient" AllowAdvertise="no" Description="$(loc.StrAFSClientLongDesc)" Display="expand"
                 InstallDefault="followParent" Level="30" Title="$(loc.StrAFSClientDesc)">
                 
index 5f4a86e..cf18477 100644 (file)
@@ -9,7 +9,8 @@
             <Registry Id="reg_afslogon04" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Impersonate" Type="integer" Value="1" />
             <Registry Id="reg_afslogon05" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="DLLName" Type="string" Value="[#fileafslogon_DLL]" />
             <Registry Id="reg_afslogon06" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Logoff" Type="string" Value="AFS_Logoff_Event" />
-            <Registry Id="reg_afslogon07" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Startup" Type="string" Value="AFS_Startup_Event" />
+            <Registry Id="reg_afslogon07" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Logon" Type="string" Value="AFS_Logon_Event" />
+            <Registry Id="reg_afslogon08" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Name="Startup" Type="string" Value="AFS_Startup_Event" />
         </Component>
     <?ifdef DebugSyms?>
         <Component Id="cmp_ClientSystemDebug" Guid="DD34DA09-D9DA-4A5A-9521-87B7738A7D53">
@@ -22,6 +23,9 @@
            <Component Id="efl_desktop_INI" Guid="0ADB427F-3648-4BE0-983B-C454AA51895C">
                <File Id="fildesktop_INI" Name="desktop.ini" KeyPath="yes" DiskId="1" src="$(var.SrcDir)WINNT\install\wix\afsdesktop.ini" Hidden="yes" System="yes" />
            </Component>
+            <Component Id="efl_replace_afs_CMD" Guid="C9C93F3E-EEBA-4056-9669-5EF78D748D50">
+               <File Id="filreplace_afs_CMD" Name="replafs.cmd" LongName="replace_afs.cmd" KeyPath="yes" DiskId="1" src="$(var.SrcDir)\WINNT\install\wix\replace_afs.cmd" />
+            </Component>
             <Directory Id="dirCommon" Name="Common">
                 <Component Id="cmp_CommonDir" Guid="C86B03A1-AE97-48B1-A77B-1B2395F1E117" KeyPath="yes">
                     <Environment Id="envCommon" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Common" />
diff --git a/src/WINNT/install/wix/replace_afs.cmd b/src/WINNT/install/wix/replace_afs.cmd
new file mode 100644 (file)
index 0000000..1a4f674
--- /dev/null
@@ -0,0 +1,59 @@
+@echo off
+
+if "%1"=="" goto show_usage
+
+rem Instead of running the script from the current location
+rem we copy ourselves over to the TMP directory and run
+rem from there.
+
+if not "%2"=="intemp" goto copy_and_run
+
+rem Do the actual work
+
+setlocal
+echo This will replace the current installation of OpenAFS with
+echo the upgraded version at :
+echo   "%~f1"
+set /p response=Continue? (y/n):
+if "%response%"=="y" goto do_this
+if "%response%"=="Y" goto do_this
+endlocal
+
+echo Cancelling.  No changes were made to your computer.
+
+goto end_script
+
+:do_this
+endlocal
+
+echo Running MSIEXEC:
+echo on
+
+msiexec /fvomus "%~f1"
+
+@echo off
+echo Done.
+
+goto end_script
+
+:copy_and_run
+
+copy "%~f0" "%TMP%\tmp_replace_afs.cmd"
+"%TMP%\tmp_replace_afs.cmd" "%~f1" intemp
+
+goto end_script
+
+:show_usage
+echo %0: Upgrade an existing installation of OpenAFS
+echo.
+echo This command replaces the existing installation with a new
+echo installation.  You need to obtain the new .MSI from openafs.org
+echo and run this command as follows :
+echo.
+echo   %0 [path to new .msi]
+echo.
+echo The latest release can be found at the following URL:
+echo      http://www.openafs.org/release/latest.html
+echo.
+
+:end_script
index 692b2d2..e5e0b5b 100644 (file)
@@ -8,7 +8,7 @@
 # This is a pthread safe library containing ubikclient, auth, kauth.
 
 
-AFSDEV_AUXCDEFINES = -DAFS_PTHREAD_ENV
+AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -DAFS_PTHREAD_ENV -I..\WINNT\kfw\inc\loadfuncs -I..\WINNT\kfw\inc\krb5
 
 RELDIR=libafsauthent
 !include ..\config\NTMakefile.$(SYS_NAME)
index a7dec70..1d8d7bd 100644 (file)
@@ -5,6 +5,7 @@
 # License.  For details, see the LICENSE file in the top-level source
 # directory or online at http://www.openafs.org/dl/license10.html
 
+AFSDEV_AUXCDEFINES = $(AFSDEV_AUXCDEFINES) -I..\WINNT\kfw\inc\loadfuncs -I..\WINNT\kfw\inc\krb5
 RELDIR=sys
 !INCLUDE ..\config\NTMakefile.$(SYS_NAME)
 !INCLUDE ..\config\NTMakefile.version
index 06bdbbb..05c1509 100644 (file)
@@ -43,6 +43,9 @@ RCSID
 #include <WINNT/afsreg.h>
 #include <lanahelper.h>
 
+#include <loadfuncs-krb5.h>
+#include <krb5.h>
+
 static char AFSConfigKeyName[] = AFSREG_CLT_SVC_PARAM_SUBKEY;
 
 #define FS_IOCTLREQUEST_MAXSIZE        8192
@@ -123,6 +126,177 @@ IoctlDebug(void)
     return debug;
 }
 
+
+// krb5 functions
+DECL_FUNC_PTR(krb5_cc_default_name);
+DECL_FUNC_PTR(krb5_cc_set_default_name);
+DECL_FUNC_PTR(krb5_get_default_config_files);
+DECL_FUNC_PTR(krb5_free_config_files);
+DECL_FUNC_PTR(krb5_free_context);
+DECL_FUNC_PTR(krb5_get_default_realm);
+DECL_FUNC_PTR(krb5_free_default_realm);
+DECL_FUNC_PTR(krb5_init_context);
+DECL_FUNC_PTR(krb5_cc_default);
+DECL_FUNC_PTR(krb5_parse_name);
+DECL_FUNC_PTR(krb5_free_principal);
+DECL_FUNC_PTR(krb5_cc_close);
+DECL_FUNC_PTR(krb5_cc_get_principal);
+DECL_FUNC_PTR(krb5_build_principal);
+DECL_FUNC_PTR(krb5_c_random_make_octets);
+DECL_FUNC_PTR(krb5_get_init_creds_password);
+DECL_FUNC_PTR(krb5_free_cred_contents);
+DECL_FUNC_PTR(krb5_cc_resolve);
+DECL_FUNC_PTR(krb5_unparse_name);
+DECL_FUNC_PTR(krb5_free_unparsed_name);
+
+FUNC_INFO krb5_fi[] = {
+    MAKE_FUNC_INFO(krb5_cc_default_name),
+    MAKE_FUNC_INFO(krb5_cc_set_default_name),
+    MAKE_FUNC_INFO(krb5_get_default_config_files),
+    MAKE_FUNC_INFO(krb5_free_config_files),
+    MAKE_FUNC_INFO(krb5_free_context),
+    MAKE_FUNC_INFO(krb5_get_default_realm),
+    MAKE_FUNC_INFO(krb5_free_default_realm),
+    MAKE_FUNC_INFO(krb5_init_context),
+    MAKE_FUNC_INFO(krb5_cc_default),
+    MAKE_FUNC_INFO(krb5_parse_name),
+    MAKE_FUNC_INFO(krb5_free_principal),
+    MAKE_FUNC_INFO(krb5_cc_close),
+    MAKE_FUNC_INFO(krb5_cc_get_principal),
+    MAKE_FUNC_INFO(krb5_build_principal),
+    MAKE_FUNC_INFO(krb5_c_random_make_octets),
+    MAKE_FUNC_INFO(krb5_get_init_creds_password),
+    MAKE_FUNC_INFO(krb5_free_cred_contents),
+    MAKE_FUNC_INFO(krb5_cc_resolve),
+    MAKE_FUNC_INFO(krb5_unparse_name),
+    MAKE_FUNC_INFO(krb5_free_unparsed_name),
+    END_FUNC_INFO
+};
+
+static int
+LoadFuncs(
+    const char* dll_name,
+    FUNC_INFO fi[],
+    HINSTANCE* ph,  // [out, optional] - DLL handle
+    int* pindex,    // [out, optional] - index of last func loaded (-1 if none)
+    int cleanup,    // cleanup function pointers and unload on error
+    int go_on,      // continue loading even if some functions cannot be loaded
+    int silent      // do not pop-up a system dialog if DLL cannot be loaded
+    )
+{
+    HINSTANCE h;
+    int i, n, last_i;
+    int error = 0;
+    UINT em;
+
+    if (ph) *ph = 0;
+    if (pindex) *pindex = -1;
+
+    for (n = 0; fi[n].func_ptr_var; n++)
+        *(fi[n].func_ptr_var) = 0;
+
+    if (silent)
+        em = SetErrorMode(SEM_FAILCRITICALERRORS);
+    h = LoadLibrary(dll_name);
+    if (silent)
+        SetErrorMode(em);
+
+    if (!h)
+        return 0;
+
+    last_i = -1;
+    for (i = 0; (go_on || !error) && (i < n); i++)
+    {
+        void* p = (void*)GetProcAddress(h, fi[i].func_name);
+        if (!p)
+            error = 1;
+        else
+        {
+            last_i = i;
+            *(fi[i].func_ptr_var) = p;
+        }
+    }
+    if (pindex) *pindex = last_i;
+    if (error && cleanup && !go_on) {
+        for (i = 0; i < n; i++) {
+            *(fi[i].func_ptr_var) = 0;
+        }
+        FreeLibrary(h);
+        return 0;
+    }
+    if (ph) *ph = h;
+    if (error) return 0;
+    return 1;
+}
+
+#define KERB5DLL "krb5_32.dll"
+static BOOL
+IsKrb5Available()
+{
+    static HINSTANCE hKrb5DLL = 0;
+
+    if ( hKrb5DLL )
+        return TRUE;
+
+    hKrb5DLL = LoadLibrary(KERB5DLL);
+    if (hKrb5DLL) {
+        if (!LoadFuncs(KERB5DLL, krb5_fi, 0, 0, 1, 0, 0))
+        {
+            FreeLibrary(hKrb5DLL);
+            hKrb5DLL = 0;
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
+
+static BOOL
+GetLSAPrincipalName(char * szUser, DWORD *dwSize)
+{
+    krb5_context   ctx = 0;
+    krb5_error_code code;
+    krb5_ccache mslsa_ccache=0;
+    krb5_principal princ = 0;
+    char * pname = 0;
+    BOOL success = 0;
+
+    if (!IsKrb5Available())
+        return FALSE;
+
+    if (code = pkrb5_init_context(&ctx))
+        goto cleanup;
+
+    if (code = pkrb5_cc_resolve(ctx, "MSLSA:", &mslsa_ccache))
+        goto cleanup;
+
+    if (code = pkrb5_cc_get_principal(ctx, mslsa_ccache, &princ))
+        goto cleanup;
+
+    if (code = pkrb5_unparse_name(ctx, princ, &pname))
+        goto cleanup;
+
+    if ( strlen(pname) < *dwSize ) {
+        strncpy(szUser, pname, *dwSize);
+        szUser[*dwSize-1] = '\0';
+        success = 1;
+    }
+    *dwSize = strlen(pname);
+
+  cleanup:
+    if (pname)
+        pkrb5_free_unparsed_name(ctx, pname);
+
+    if (princ)
+        pkrb5_free_principal(ctx, princ);
+
+    if (mslsa_ccache)
+        pkrb5_cc_close(ctx, mslsa_ccache);
+
+    if (ctx)
+        pkrb5_free_context(ctx);
+    return success;
+}
+
 static long
 GetIoctlHandle(char *fileNamep, HANDLE * handlep)
 {
@@ -213,14 +387,10 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
                                (va_list *) NULL
                                ) )
             {
-                fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
+                fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%X\r\n\t[%s]\r\n",
                         tbuffer,gle,buf);
             }
         }
-#ifdef COMMENT
-        if (gle != ERROR_DOWNGRADE_DETECTED)
-            return -1;                                   
-#endif
 
         lana_GetNetbiosName(szClient, LANA_NETBIOS_NAME_FULL);
 
@@ -234,7 +404,69 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
 
         if ( szUser[0] ) {
             if ( ioctlDebug )
-                fprintf(stderr, "pioctl logon user: [%s]\r\n",szUser);
+                fprintf(stderr, "pioctl Explorer logon user: [%s]\r\n",szUser);
+
+            sprintf(szPath, "\\\\%s", szClient);
+            memset (&nr, 0x00, sizeof(NETRESOURCE));
+            nr.dwType=RESOURCETYPE_DISK;
+            nr.lpLocalName=0;
+            nr.lpRemoteName=szPath;
+            res = WNetAddConnection2(&nr,NULL,szUser,0);
+            if (res) {
+                if ( ioctlDebug ) {
+                    fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
+                             szPath,szUser,res);
+                }
+                gonext = 1;
+            }
+
+            sprintf(szPath, "\\\\%s\\all", szClient);
+            res = WNetAddConnection2(&nr,NULL,szUser,0);
+            if (res) {
+                if ( ioctlDebug ) {
+                    fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
+                             szPath,szUser,res);
+                }
+                gonext = 1;
+            }
+
+            if (gonext)
+                goto try_lsa_principal;
+
+            fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
+                             FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+                             FILE_FLAG_WRITE_THROUGH, NULL);
+            fflush(stdout);
+            if (fh == INVALID_HANDLE_VALUE) {
+                gle = GetLastError();
+                if (gle && ioctlDebug ) {
+                    char buf[4096];
+
+                    if ( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+                                        NULL,
+                                        gle,
+                                        MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
+                                        buf,
+                                        4096,
+                                        (va_list *) NULL
+                                        ) )
+                    {
+                        fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%X\r\n\t[%s]\r\n",
+                                 tbuffer,gle,buf);
+                    }
+                }
+            }
+        }
+    }
+
+  try_lsa_principal:
+    if (fh == INVALID_HANDLE_VALUE) {
+        int  gonext = 0;
+
+        dwSize = sizeof(szUser);
+        if (GetLSAPrincipalName(szUser, &dwSize)) {
+            if ( ioctlDebug )
+                fprintf(stderr, "pioctl LSA Principal logon user: [%s]\r\n",szUser);
 
             sprintf(szPath, "\\\\%s", szClient);
             memset (&nr, 0x00, sizeof(NETRESOURCE));
@@ -261,7 +493,7 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
             }
 
             if (gonext)
-                goto next_attempt;
+                goto try_sam_compat;
 
             fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
                              FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
@@ -281,7 +513,7 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
                                         (va_list *) NULL
                                         ) )
                     {
-                        fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
+                        fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%X\r\n\t[%s]\r\n",
                                  tbuffer,gle,buf);
                     }
                 }
@@ -289,11 +521,12 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
         }
     }
 
-  next_attempt:
+  try_sam_compat:
     if ( fh == INVALID_HANDLE_VALUE ) {
+        dwSize = sizeof(szUser);
         if (GetUserNameEx(NameSamCompatible, szUser, &dwSize)) {
             if ( ioctlDebug )
-                fprintf(stderr, "pioctl logon user: [%s]\r\n",szUser);
+                fprintf(stderr, "pioctl SamCompatible logon user: [%s]\r\n",szUser);
 
             sprintf(szPath, "\\\\%s", szClient);
             memset (&nr, 0x00, sizeof(NETRESOURCE));
@@ -336,13 +569,14 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
                                         (va_list *) NULL
                                         ) )
                     {
-                        fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
+                        fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%X\r\n\t[%s]\r\n",
                                  tbuffer,gle,buf);
                     }
                 }
                 return -1;
             }
         } else {
+            fprintf(stderr, "GetUserNameEx(NameSamCompatible) failed: 0x%X\r\n", GetLastError());
             return -1;
         }
     }