]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
no-more-ini-files-20040713
authorJeffrey Altman <jaltman@mit.edu>
Wed, 14 Jul 2004 04:28:36 +0000 (04:28 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 14 Jul 2004 04:28:36 +0000 (04:28 +0000)
Get rid of all %WINDIR% INI files

afs_freelance.ini moved to the HKLM hive SOFTWARE\OpenAFS\Client\Freelance

afsdcell.ini moved to the Openafs Client install directory and renamed
to CellServDB to match Unix and the Openafs Server.

afsdsbmt.ini moved to the registry.  Submounts are moved to HKLM hive
SOFTWARE\OpenAFS\Client\Submounts.  Active Maps and Drive Mappings are
moved to the HKCU hive SOFTWARE\OpenAFS\Client\Active Maps and Mappings.
CSCPolicy is moved to HKCU hive.

afsdns.ini is no longer used.

NSIS installer updated to migrate the afsdcell.ini to CellServDB

The cm_freelance.ini module has been modified to migrate the afs_freelance.ini
data to the registry on first execution.

The afsdsbmt.ini file data is not currently being migrated.

12 files changed:
src/WINNT/afs_setup_utils/afs_setup_utils.cpp
src/WINNT/afs_setup_utils/forceremove.c
src/WINNT/afsd/afsshare.c
src/WINNT/afsd/cm_config.c
src/WINNT/afsd/cm_ioctl.c
src/WINNT/afsd/fs.c
src/WINNT/afsd/smb.c
src/WINNT/client_config/drivemap.cpp
src/WINNT/client_exp/submounts_dlg.cpp
src/WINNT/install/NSIS/OpenAFS.nsi
src/util/dirpath.c
src/util/dirpath_nt.h

index 2e6ff61cc46897407b769352e795e320a990d2a1..5ef39ca1f0181ec0087f184639904d74b0540db7 100644 (file)
@@ -234,11 +234,11 @@ struct APPINFO appClient = {
     TARGETDIR"\\Common\\*.gid\0"
     TARGETDIR"\\Common\\*.fts\0"
     WINDIR"\\..\\AFSCache\0"
-    WINDIR"\\afsd.log\0"
-    WINDIR"\\afsd.ini\0"
-    WINDIR"\\afsdsbmt.ini\0"
-    WINDIR"\\afsdcell.ini\0"
-    WINDIR"\\afsd_init.log\0",
+    WINDIR"\\TEMP\\afsd.log\0"
+    TARGETDIR"\\Client\\afsd.ini\0"
+    TARGETDIR"\\Client\\afsdsbmt.ini\0"
+    TARGETDIR"\\Client\\afsdcell.ini\0"
+    WINDIR"\\TEMP\\afsd_init.log\0",
     
     clientRegValues,
     clientWinNTRegValues,
index a849f9203ec596387e08c410529c286f8d48f300..49a93b36aa2dea1e1366dda38f02f9e15a4ca301 100644 (file)
@@ -119,13 +119,13 @@ DWORD Client34Eradicate(BOOL keepConfig)
        }
     }
 
-    sprintf(filePath, "%s\\%s", winPath, "afsd.log");
+    sprintf(filePath, "%s\\%s", winPath, "temp\\afsd.log");
     status = FileForceRemove(filePath);
     if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
        rc = status;
     }
 
-    sprintf(filePath, "%s\\%s", winPath, "afsd_init.log");
+    sprintf(filePath, "%s\\%s", winPath, "temp\\afsd_init.log");
     status = FileForceRemove(filePath);
     if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
        rc = status;
@@ -144,19 +144,19 @@ DWORD Client34Eradicate(BOOL keepConfig)
     }
 
     if (!keepConfig) {
-       sprintf(filePath, "%s\\%s", winPath, "afsdcell.ini");
+       sprintf(filePath, "%s\\%s", installPath, "Client\\afsdcell.ini");
        status = FileForceRemove(filePath);
        if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
            rc = status;
        }
 
-       sprintf(filePath, "%s\\%s", winPath, "afsdsbmt.ini");
+       sprintf(filePath, "%s\\%s", installPath, "Client\\afsdsbmt.ini");
        status = FileForceRemove(filePath);
        if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
            rc = status;
        }
 
-       sprintf(filePath, "%s\\%s", winPath, "afsd.ini");
+       sprintf(filePath, "%s\\%s", installPath, "Client\\afsd.ini");
        status = FileForceRemove(filePath);
        if (status != ERROR_SUCCESS && status != ERROR_FILE_NOT_FOUND) {
            rc = status;
index 6382c52fba4c3329a43ddc283cdc14d4eaf5b431..152ba92686e3fb3abcc9452023c6aea19e477377 100644 (file)
 #include <windows.h>
 #include <stdio.h>
 
+int
 main(int argc, char **argv) {
     BOOL res;
+    HKEY hkSubmounts;
+
     if (argc < 2 || argc > 3) {
-       fprintf(stderr, "Incorrect arguments\n");
-       exit(1);
+        fprintf(stderr, "Incorrect arguments\n");
+        exit(1);
     }
-    res = WritePrivateProfileString("AFS Submounts",
-                                   argv[1],
-                                   (argc == 3) ? argv[2] : NULL,
-                                   "afsdsbmt.ini");
-    if (res == FALSE)
-       fprintf(stderr, "Failed, error code %d\n", GetLastError());
 
+    if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+                        "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                        0,
+                        NULL,
+                        REG_OPTION_NON_VOLATILE,
+                        KEY_READ|KEY_WRITE,
+                        NULL,
+                        &hkSubmounts,
+                        NULL) == ERROR_SUCCESS) 
+    {
+        if ( argc == 2 ) {
+            if (RegDeleteValue(hkSubmounts, argv[1])) {
+                fprintf(stderr,"Submount Deletion failure for [%s]: %lX",
+                         argv[1], GetLastError());
+                return 1;
+            }
+        } else {
+            if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, argv[2], strlen(argv[2]+1))) {
+                fprintf(stderr,"Submount Set failure for [%s]: %lX",
+                         argv[1], GetLastError());
+                return 2;
+            }
+        }
+        RegCloseKey(hkSubmounts);
+    } else {
+        fprintf(stderr,"Submount access denied: %lX", GetLastError());
+        return 3;
+    }
     return 0;
 }
index 1462d04273da243beb7ecde66f46fa033d962098..9c3cc9cf252227bf42f2890d747277205573a918 100644 (file)
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "cm_config.h"
+#include <WINNT\afssw.h>
 #ifdef AFS_AFSDB_ENV
 #include "cm_dns.h"
 #include <afs/afsint.h>
@@ -32,7 +33,9 @@ char AFSConfigKeyName[] =
        "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters";
 
 /* TODO: these should be pulled in from dirpath.h */
+#if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
 #define AFS_THISCELL "ThisCell"
+#endif
 #define AFS_CELLSERVDB_UNIX "CellServDB"
 #define AFS_CELLSERVDB_NT "afsdcell.ini"
 #ifndef AFSDIR_CLIENT_ETC_DIRPATH
@@ -45,7 +48,7 @@ extern char cm_confDir[];
 extern int errno;
 #endif /* DJGPP */
 #else
-#define AFS_CELLSERVDB AFS_CELLSERVDB_NT
+#define AFS_CELLSERVDB AFS_CELLSERVDB_UNIX
 #endif /* DJGPP || WIN95 */
 
 #ifdef DEBUG
@@ -163,50 +166,20 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
 #if defined(DJGPP) || defined(AFS_WIN95_ENV)
     char *afsconf_path;
 #endif
-#if !defined(DJGPP)
-    HKEY hkClient;
-    PBYTE pFilename;
-    DWORD dwType, dwSize;
-#endif
 
 #if !defined(DJGPP)
-    /* First attempt to find the CellServDB file via the registry */
-    if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
-                        "SOFTWARE\\OpenAFS\\Client",
-                        0,
-                        NULL,
-                        REG_OPTION_NON_VOLATILE,
-                        KEY_READ|KEY_WRITE,
-                        NULL,
-                        &hkClient,
-                        NULL) == ERROR_SUCCESS) {
-        if (RegQueryValueEx( hkClient, "CellServDB", 0, &dwType, NULL, &dwSize) == ERROR_SUCCESS) {
-            pFilename = malloc(dwSize);
-            RegQueryValueEx( hkClient, "CellServDB", 0, &dwType, pFilename, &dwSize);
-            tfilep = fopen(pFilename, "r");
-        }
-        RegCloseKey(hkClient);
-    }
-#endif
-
-    /* If not found, fallback to old behavior */
-    if (!tfilep) {
-#if !defined(DJGPP)
-        code = GetWindowsDirectory(wdir, sizeof(wdir));
-        if (code == 0 || code > sizeof(wdir))
-            return -1;
+    strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
 
-        /* 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, "\\");
 #else
-        strcpy(wdir, cm_confDir);
-        strcat(wdir,"/");
+    strcpy(wdir, cm_confDir);
+    strcat(wdir,"/");
 #endif /* !DJGPP */
         
-        strcat(wdir, AFS_CELLSERVDB);
-        tfilep = fopen(wdir, "r");
-    }
+    strcat(wdir, AFS_CELLSERVDB);
+    tfilep = fopen(wdir, "r");
 
 #if defined(DJGPP) || defined(AFS_WIN95_ENV)
     if (!tfilep) {
@@ -220,7 +193,7 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
         else
             strcpy(wdir, afsconf_path);
         strcat(wdir, "/");
-        strcat(wdir, AFS_CELLSERVDB_UNIX);
+        strcat(wdir, AFS_CELLSERVDB);
         /*fprintf(stderr, "opening cellservdb file %s\n", wdir);*/
         tfilep = fopen(wdir, "r");
         if (!tfilep) return -2;
@@ -488,9 +461,7 @@ cm_configFile_t *cm_CommonOpen(char *namep, char *rwp)
     FILE *tfilep;
 
 #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
-       code = GetWindowsDirectory(wdir, sizeof(wdir));
-        if (code == 0 || code > sizeof(wdir)) 
-            return 0;
+    strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
         
        /* add trailing backslash, if required */
         tlen = strlen(wdir);
@@ -660,47 +631,45 @@ long cm_CloseCellFile(cm_configFile_t *filep)
        closeCode = fclose((FILE *)filep);
 
 #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
-       code = GetWindowsDirectory(wdir, sizeof(wdir));
-        if (code == 0 || code > sizeof(wdir)) 
-           return closeCode;
+    strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
         
        /* add trailing backslash, if required */
-        tlen = strlen(wdir);
-        if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
+    tlen = strlen(wdir);
+    if (wdir[tlen-1] != '\\') strcat(wdir, "\\");
 #else
 #ifdef DJGPP
-        strcpy(wdir,cm_confDir);
+    strcpy(wdir,cm_confDir);
 #else
-        afsconf_path = getenv("AFSCONF");
-        if (!afsconf_path)
-          strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
-        else
-          strcpy(wdir, afsconf_path);
+    afsconf_path = getenv("AFSCONF");
+    if (!afsconf_path)
+        strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
+    else
+        strcpy(wdir, afsconf_path);
 #endif /* !DJGPP */
-        strcat(wdir,"/");
+    strcat(wdir,"/");
 #endif /* DJGPP || WIN95 */
 
-        strcpy(sdir, wdir);
+    strcpy(sdir, wdir);
 
        if (closeCode != 0) {
                /* something went wrong, preserve original database */
-                strcat(wdir, "afsdcel2.ini");
-                unlink(wdir);
-                return closeCode;
-        }
+        strcat(wdir, "afsdcel2.ini");
+        unlink(wdir);
+        return closeCode;
+    }
 
-        strcat(wdir, AFS_CELLSERVDB);
-        strcat(sdir, "afsdcel2.ini");  /* new file */
-        
-        unlink(wdir);                  /* delete old file */
-        
-        code = rename(sdir, wdir);     /* do the rename */
-        
-        if (code) 
-         code = errno;
-        
-        return code;
-}
+    strcat(wdir, AFS_CELLSERVDB);
+    strcat(sdir, "afsdcel2.ini");      /* new file */
+
+    unlink(wdir);                      /* delete old file */
+
+    code = rename(sdir, wdir); /* do the rename */
+
+    if (code) 
+        code = errno;
+
+    return code;
+}   
 
 void cm_GetConfigDir(char *dir)
 {
@@ -712,8 +681,7 @@ void cm_GetConfigDir(char *dir)
 #endif
 
 #if !defined(DJGPP) && !defined(AFS_WIN95_ENV)
-       code = GetWindowsDirectory(wdir, sizeof(wdir));
-    if (code == 0 || code > sizeof(wdir)) wdir[0] = 0;
+    strcpy(wdir, AFSDIR_CLIENT_ETC_DIRPATH);
         
        /* add trailing backslash, if required */
     tlen = strlen(wdir);
index 9e6c1aae0dec635695412c9cfec4b274489ba31a..b001ade221b2961f47b9eaae64ff179b179c27ee 100644 (file)
@@ -1982,10 +1982,12 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
        char afspath[MAX_PATH];
        char *submountreqp;
        int iteration;
-       int submountDataSize;
-       char *submountData;
-       char *submountName;
        int nextAutoSubmount;
+    HKEY hkSubmounts;
+    DWORD dwType, dwSize;
+    DWORD status;
+    DWORD dwIndex;
+    DWORD dwSubmounts;
 
        cm_SkipIoctlPath(ioctlp);
 
@@ -2004,33 +2006,45 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
         * that submount name is in use... if so, the submount's path
         * has to match our path.
         */
-       if (submountreqp && *submountreqp) {
+
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    if (submountreqp && *submountreqp) {
                char submountPathNormalized[MAX_PATH];
                char submountPath[MAX_PATH];
                int submountPathLen;
 
-               submountPathLen = GetPrivateProfileString("AFS Submounts",
-                                       submountreqp, "", submountPath,
-                                       sizeof(submountPath), "afsdsbmt.ini");
+        dwSize = sizeof(submountPath);
+        status = RegQueryValueEx( hkSubmounts, submountreqp, 0,
+                         &dwType, submountPath, &dwSize);
 
-               if ((submountPathLen == 0) ||
-                   (submountPathLen == sizeof(submountPath) - 1)) {
+               if (status != ERROR_SUCCESS) {
 
                        /* The suggested submount name isn't in use now--
                         * so we can safely map the requested submount name
                         * to the supplied path. Remember not to write the
                         * leading "/afs" when writing out the submount.
                         */
-                       WritePrivateProfileString("AFS Submounts",
-                                       submountreqp, 
-                                       (strlen(&afspath[strlen(cm_mountRoot)])) ?
-                                                 &afspath[strlen(cm_mountRoot)]:"/",
-                                       "afsdsbmt.ini");
-
+            RegSetValueEx( hkSubmounts, submountreqp, 0,
+                           REG_SZ, 
+                           (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                           &afspath[strlen(cm_mountRoot)]:"/",
+                           (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                           strlen(&afspath[strlen(cm_mountRoot)])+1:2);
+
+            RegCloseKey( hkSubmounts );
                        strcpy(ioctlp->outDatap, submountreqp);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
                }
 
                /* The suggested submount name is already in use--if the
@@ -2041,35 +2055,26 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                if (!strcmp (submountPathNormalized, afspath)) {
                        strcpy(ioctlp->outDatap, submountreqp);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+            RegCloseKey( hkSubmounts );
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
                }
        }
 
-       /* At this point, the user either didn't request a particular
-        * submount name, or that submount name couldn't be used.
-        * Look through afsdsbmt.ini to see if there are any submounts
-        * already associated with the specified path. The first
-        * step in doing that search is to load the AFS Submounts
-        * section of afsdsbmt.ini into memory.
-        */
+    RegQueryInfoKey( hkSubmounts,
+                 NULL,  /* lpClass */
+                 NULL,  /* lpcClass */
+                 NULL,  /* lpReserved */
+                 NULL,  /* lpcSubKeys */
+                 NULL,  /* lpcMaxSubKeyLen */
+                 NULL,  /* lpcMaxClassLen */
+                 &dwSubmounts, /* lpcValues */
+                 NULL,  /* lpcMaxValueNameLen */
+                 NULL,  /* lpcMaxValueLen */
+                 NULL,  /* lpcbSecurityDescriptor */
+                 NULL   /* lpftLastWriteTime */
+                 );
 
-       submountDataSize = 1024;
-       submountData = malloc (submountDataSize);
-
-       for (iteration = 0; iteration < 5; ++iteration) {
-
-               int sectionSize;
-               sectionSize = GetPrivateProfileString("AFS Submounts",
-                                       NULL, "", submountData,
-                                       submountDataSize, "afsdsbmt.ini");
-               if (sectionSize < submountDataSize-2)
-                       break;
-
-               free (submountData);
-               submountDataSize *= 2;
-               submountData = malloc (submountDataSize);
-       }
 
        /* Having obtained a list of all available submounts, start
         * searching that list for a path which matches the requested
@@ -2079,13 +2084,15 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
 
        nextAutoSubmount = 1;
 
-       for (submountName = submountData;
-               submountName && *submountName;
-               submountName += 1+strlen(submountName)) {
-
+    for ( dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
                char submountPathNormalized[MAX_PATH];
                char submountPath[MAX_PATH] = "";
-               int submountPathLen;
+               DWORD submountPathLen = sizeof(submountPath);
+        char submountName[256];
+        DWORD submountNameLen = sizeof(submountName);
+
+        RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
+              &dwType, submountPath, &submountPathLen);
 
                /* If this is an Auto### submount, remember its ### value */
 
@@ -2097,14 +2104,6 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                                                thisAutoSubmount+1);
                }
 
-               /* We have the name of a submount in the AFS Submounts
-                * section; read that entry to find out what path it
-                * maps to.
-                */
-               submountPathLen = GetPrivateProfileString("AFS Submounts",
-                                       submountName, "", submountPath,
-                                       sizeof(submountPath), "afsdsbmt.ini");
-
                if ((submountPathLen == 0) ||
                    (submountPathLen == sizeof(submountPath) - 1)) {
                        continue;
@@ -2116,18 +2115,15 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
                 */
                cm_NormalizeAfsPath (submountPathNormalized, submountPath);
                if (!strcmp (submountPathNormalized, afspath)) {
-
                        strcpy(ioctlp->outDatap, submountName);
                        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
-                       free (submountData);
+            RegCloseKey(hkSubmounts);
                        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
-                       return 0;
+            return 0;
 
                }
        }
 
-       free (submountData);
-
        /* We've been through the entire list of existing submounts, and
         * didn't find any which matched the specified path. So, we'll
         * just have to add one. Remember not to write the leading "/afs"
@@ -2136,12 +2132,17 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
 
        sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount);
 
-       WritePrivateProfileString("AFS Submounts", ioctlp->outDatap,
-                                 (strlen(&afspath[lstrlen(cm_mountRoot)])) ? 
-                                 &afspath[lstrlen(cm_mountRoot)]:"/",
-                                 "afsdsbmt.ini");
+    RegSetValueEx( hkSubmounts, 
+                   ioctlp->outDatap,
+                   0,
+                   REG_SZ, 
+                   (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                   &afspath[strlen(cm_mountRoot)]:"/",
+                   (strlen(&afspath[strlen(cm_mountRoot)])) ?
+                   strlen(&afspath[strlen(cm_mountRoot)])+1:2);
 
        ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
+    RegCloseKey(hkSubmounts);
        lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
        return 0;
 }
index cae83b6648744f71859b8145230b7f8ce8aa62cd..ac32533db397734efd3e65f7b77c58cd1c088d0d 100644 (file)
@@ -3241,9 +3241,8 @@ static CSCPolicyCmd(struct cmd_syndesc *asp)
 {
        struct cmd_item *ti;
        char *share = NULL;
-       char sbmtpath[256];
-       char *policy;
-       
+    HKEY hkCSCPolicy;
+
        for(ti=asp->parms[0].items; ti;ti=ti->next) {
                share = ti->data;
                if (share)
@@ -3251,20 +3250,27 @@ static CSCPolicyCmd(struct cmd_syndesc *asp)
                        break;
                }
        }
-       
+
        if (share)
        {
-#ifdef WIN32
-        if ( !IsAdmin() ) {
+        char *policy;
+
+        RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                        "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
+                        0, 
+                        "AFS", 
+                        REG_OPTION_NON_VOLATILE,
+                        KEY_WRITE,
+                        NULL, 
+                        &hkCSCPolicy,
+                        NULL );
+
+        if ( !IsAdmin() || hkCSCPolicy == NULL ) {
             fprintf (stderr,"Permission denied: requires Administrator access.\n");
+            if ( hkCSCPolicy )
+                RegCloseKey(hkCSCPolicy);
             return EACCES;
         }
-#else /* WIN32 */
-        if (geteuid()) {
-            fprintf (stderr,"Permission denied: requires root access.\n");
-            return EACCES;
-        }
-#endif /* WIN32 */
 
         policy = "manual";
                
@@ -3277,30 +3283,58 @@ static CSCPolicyCmd(struct cmd_syndesc *asp)
                if (asp->parms[4].items)
                        policy = "disable";
                
-               strcpy(sbmtpath, "afsdsbmt.ini");
-               WritePrivateProfileString("CSC Policy", share, policy, sbmtpath);
+        RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, strlen(policy)+1);
                
                printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
                printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
        }
        else
        {
-               char policies[1024];
-               DWORD len = sizeof(policies);
+        DWORD dwIndex, dwPolicies;
+               char policyName[256];
+               DWORD policyNameLen;
+        char policy[256];
+        DWORD policyLen;
+        DWORD dwType;
 
                /* list current csc policies */
-               strcpy(sbmtpath, "afsdsbmt.ini");
-                               
-               GetPrivateProfileSection("CSC Policy", policies, len, sbmtpath);
+               
+        RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                        "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
+                        0, 
+                        "AFS", 
+                        REG_OPTION_NON_VOLATILE,
+                        KEY_READ|KEY_QUERY_VALUE,
+                        NULL, 
+                        &hkCSCPolicy,
+                        NULL );
+
+        RegQueryInfoKey( hkCSCPolicy,
+                         NULL,  /* lpClass */
+                         NULL,  /* lpcClass */
+                         NULL,  /* lpReserved */
+                         NULL,  /* lpcSubKeys */
+                         NULL,  /* lpcMaxSubKeyLen */
+                         NULL,  /* lpcMaxClassLen */
+                         &dwPolicies, /* lpcValues */
+                         NULL,  /* lpcMaxValueNameLen */
+                         NULL,  /* lpcMaxValueLen */
+                         NULL,  /* lpcbSecurityDescriptor */
+                         NULL   /* lpftLastWriteTime */
+                         );
                
                printf("Current CSC policies:\n");
-               policy = policies;
-               while (policy[0])
-               {
-                       printf("  %s\n", policy);
-                       policy += strlen(policy) + 1;
+        for ( dwIndex = 0; dwIndex < dwPolicies; dwIndex ++ ) {
+
+            policyNameLen = sizeof(policyName);
+            policyLen = sizeof(policy);
+            RegEnumValue( hkCSCPolicy, dwIndex, policyName, &policyNameLen, NULL,
+                          &dwType, policy, &policyLen);
+
+                       printf("  %s = %s\n", policyName, policy);
                }
        }
 
+    RegCloseKey(hkCSCPolicy);
        return (0);
 }
index 10e69c5faac9b0e4cbc73eadf22dcecd3eacbe8f..6b04d44e01eb9d95e61458e3248b67f845cb3379 100644 (file)
@@ -1388,36 +1388,40 @@ int smb_FindShareCSCPolicy(char *shareName)
 {
        DWORD len;
        char policy[1024];
-       char sbmtpath[256];
-
-#ifndef DJGPP
-        strcpy(sbmtpath, "afsdsbmt.ini");
-#else /* DJGPP */
-        strcpy(sbmtpath, cm_confDir);
-        strcat(sbmtpath, "/afsdsbmt.ini");
-#endif /* !DJGPP */
-       len = GetPrivateProfileString("CSC Policy", shareName, "",
-                                     policy, sizeof(policy), sbmtpath);
-       if (len == 0 || len == sizeof(policy) - 1) {
-               return CSC_POLICY_MANUAL;
-       }
-       
-       if (stricmp(policy, "documents") == 0)
+    DWORD dwType;
+    HKEY hkCSCPolicy;
+    int  retval = CSC_POLICY_MANUAL;
+
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ,
+                    NULL, 
+                    &hkCSCPolicy,
+                    NULL );
+
+    len = sizeof(policy);
+    if ( RegQueryValueEx( hkCSCPolicy, shareName, 0, &dwType, policy, &len ) ||
+         len == 0) {
+               retval = CSC_POLICY_MANUAL;
+    }
+       else if (stricmp(policy, "documents") == 0)
        {
-               return CSC_POLICY_DOCUMENTS;
+               retval = CSC_POLICY_DOCUMENTS;
        }
-       
-       if (stricmp(policy, "programs") == 0)
+       else if (stricmp(policy, "programs") == 0)
        {
-               return CSC_POLICY_PROGRAMS;
+               retval = CSC_POLICY_PROGRAMS;
        }
-       
-       if (stricmp(policy, "disable") == 0)
+       else if (stricmp(policy, "disable") == 0)
        {
-               return CSC_POLICY_DISABLE;
+               retval = CSC_POLICY_DISABLE;
        }
        
-       return CSC_POLICY_MANUAL;
+    RegCloseKey(hkCSCPolicy);
+       return retval;
 }
 
 /* find a dir search structure by cookie value, and return it held.
index e5afd9ed23fbb10148bd705914a243378088bf4b..8d6fcfb829047527f848ca6020ab4a8873d9c400 100644 (file)
@@ -43,15 +43,82 @@ const TCHAR sAFSConfigKeyName[] = TEXT("SYSTEM\\CurrentControlSet\\Services\\Tra
 
 #define cREALLOC_SUBMOUNTS   4
 
-static TCHAR cszINIFILE[] = TEXT("afsdsbmt.ini");
-static TCHAR cszSECTION_SUBMOUNTS[] = TEXT("AFS Submounts");
-static TCHAR cszSECTION_MAPPINGS[] = TEXT("AFS Mappings");
-static TCHAR cszSECTION_ACTIVE[] = TEXT("AFS Active");
+static TCHAR cszSECTION_SUBMOUNTS[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Submounts");
+static TCHAR cszSECTION_MAPPINGS[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Mappings");
+static TCHAR cszSECTION_ACTIVE[] = TEXT("SOFTWARE\\OpenAFS\\Client\\Active Maps");
 
 static TCHAR cszAUTOSUBMOUNT[] = TEXT("Auto");
 static TCHAR cszLANMANDEVICE[] = TEXT("\\Device\\LanmanRedirector\\");
 
 
+static BOOL 
+WriteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs)
+{
+    HKEY hkSub = NULL;
+    RegCreateKeyEx( key,
+                    subkey,
+                    0,
+                    NULL,
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_WRITE,
+                    NULL,
+                    &hkSub,
+                    NULL);
+
+    DWORD status = RegSetValueEx( hkSub, lhs, 0, REG_SZ, (const BYTE *)rhs, strlen(rhs)+1 );
+
+    if ( hkSub )
+        RegCloseKey( hkSub );
+
+    return (status == ERROR_SUCCESS);
+}
+
+static BOOL 
+ReadRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs, DWORD * size)
+{
+    HKEY hkSub = NULL;
+    RegCreateKeyEx( key,
+                    subkey,
+                    0,
+                    NULL,
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ,
+                    NULL,
+                    &hkSub,
+                    NULL);
+
+    DWORD dwType;
+    DWORD status = RegQueryValueEx( hkSub, lhs, 0, &dwType, (LPBYTE)rhs, size );
+
+    if ( hkSub )
+        RegCloseKey( hkSub );
+
+    return (status == ERROR_SUCCESS);
+}
+
+static BOOL 
+DeleteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs)
+{
+    HKEY hkSub = NULL;
+    RegCreateKeyEx( key,
+                    subkey,
+                    0,
+                    NULL,
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ,
+                    NULL,
+                    &hkSub,
+                    NULL);
+
+    DWORD dwType;
+    DWORD status = RegDeleteValue( hkSub, lhs );
+
+    if ( hkSub )
+        RegCloseKey( hkSub );
+
+    return (status == ERROR_SUCCESS);
+}
+
 /*
  * STRINGS ____________________________________________________________________
  *
@@ -307,92 +374,128 @@ BOOL fCanIssuePIOCTL (void)
 
 void QueryDriveMapList_ReadSubmounts (PDRIVEMAPLIST pList)
 {
-   if (IsWindowsNT())
-      {
-      size_t cchLHS = 1024;
-      LPTSTR mszLHS = AllocateStringMemory (cchLHS);
-
-      for (int iRetry = 0; iRetry < 5; ++iRetry)
-         {
-         DWORD rc = GetPrivateProfileString (cszSECTION_SUBMOUNTS, NULL, TEXT(""), mszLHS, cchLHS, cszINIFILE);
-         if ((rc != cchLHS-1) && (rc != cchLHS-2))
-            break;
-
-         FreeStringMemory (mszLHS);
-         cchLHS *= 2;
-         mszLHS = AllocateStringMemory (cchLHS);
-         }
-
-      for (LPTSTR psz = mszLHS; psz && *psz; psz += 1+lstrlen(psz))
-         {
-         SUBMOUNT Submount;
-         memset (&Submount, 0x00, sizeof(SUBMOUNT));
-         lstrcpy (Submount.szSubmount, psz);
-
-         TCHAR szMapping[ MAX_PATH ] = TEXT("");
-         GetPrivateProfileString (cszSECTION_SUBMOUNTS, Submount.szSubmount, TEXT(""), szMapping, MAX_PATH, cszINIFILE);
-         if (szMapping[0] != TEXT('\0'))
-            {
-            AdjustAfsPath (Submount.szMapping, szMapping, FALSE, TRUE);
-
-            for (size_t ii = 0; ii < pList->cSubmounts; ++ii)
-               {
-               if (!pList->aSubmounts[ii].szSubmount[0])
-                  break;
-               }
-            if (REALLOC (pList->aSubmounts, pList->cSubmounts, 1+ii, cREALLOC_SUBMOUNTS))
-               {
-               memcpy (&pList->aSubmounts[ii], &Submount, sizeof(SUBMOUNT));
-               }
+    if (IsWindowsNT())
+    {
+        HKEY hkSubmounts;
+
+        RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                        "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                        0, 
+                        "AFS", 
+                        REG_OPTION_NON_VOLATILE,
+                        KEY_READ|KEY_QUERY_VALUE,
+                        NULL, 
+                        &hkSubmounts,
+                        NULL );
+
+        DWORD dwSubmounts;
+        RegQueryInfoKey( hkSubmounts,
+                         NULL,  /* lpClass */
+                         NULL,  /* lpcClass */
+                         NULL,  /* lpReserved */
+                         NULL,  /* lpcSubKeys */
+                         NULL,  /* lpcMaxSubKeyLen */
+                         NULL,  /* lpcMaxClassLen */
+                         &dwSubmounts, /* lpcValues */
+                         NULL,  /* lpcMaxValueNameLen */
+                         NULL,  /* lpcMaxValueLen */
+                         NULL,  /* lpcbSecurityDescriptor */
+                         NULL   /* lpftLastWriteTime */
+                         );
+
+        for ( DWORD dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
+            TCHAR submountPath[MAX_PATH] = "";
+            DWORD submountPathLen = MAX_PATH;
+            TCHAR submountName[MAX_PATH];
+            DWORD submountNameLen = MAX_PATH;
+            DWORD dwType;
+
+            RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
+                          &dwType, (LPBYTE)submountPath, &submountPathLen);
+
+            SUBMOUNT Submount;
+            memset (&Submount, 0x00, sizeof(SUBMOUNT));
+            lstrcpy (Submount.szSubmount, submountName);
+
+            if ( submountPath[0] != TEXT('\0') ) {
+                AdjustAfsPath (Submount.szMapping, submountPath, FALSE, TRUE);
+
+                for (size_t ii = 0; ii < pList->cSubmounts; ++ii)
+                {
+                    if (!pList->aSubmounts[ii].szSubmount[0])
+                        break;
+                }
+                if (REALLOC (pList->aSubmounts, pList->cSubmounts, 1+ii, cREALLOC_SUBMOUNTS))
+                {
+                    memcpy (&pList->aSubmounts[ii], &Submount, sizeof(SUBMOUNT));
+                }
             }
-         }
 
-      FreeStringMemory (mszLHS);
-      }
+        }
+        RegCloseKey(hkSubmounts);
+    }
 }
 
 
 void QueryDriveMapList_ReadMappings (PDRIVEMAPLIST pList)
 {
-   size_t cchLHS = 1024;
-   LPTSTR mszLHS = AllocateStringMemory (cchLHS);
-
-   for (int iRetry = 0; iRetry < 5; ++iRetry)
-      {
-      DWORD rc = GetPrivateProfileString (cszSECTION_MAPPINGS, NULL, TEXT(""), mszLHS, cchLHS, cszINIFILE);
-      if ((rc != cchLHS-1) && (rc != cchLHS-2))
-         break;
-
-      FreeStringMemory (mszLHS);
-      cchLHS *= 2;
-      mszLHS = AllocateStringMemory (cchLHS);
-      }
-
-   for (LPTSTR psz = mszLHS; psz && *psz; psz += 1+lstrlen(psz))
-      {
-      DRIVEMAP DriveMap;
-      memset (&DriveMap, 0x00, sizeof(DRIVEMAP));
-      DriveMap.chDrive = toupper(*psz);
-      DriveMap.fPersistent = TRUE;
-      if ((DriveMap.chDrive < chDRIVE_A) || (DriveMap.chDrive > chDRIVE_Z))
-         continue;
-
-      TCHAR szMapping[ MAX_PATH ] = TEXT("");
-      GetPrivateProfileString (cszSECTION_MAPPINGS, psz, TEXT(""), szMapping, MAX_PATH, cszINIFILE);
-      if (szMapping[0] != TEXT('\0'))
-         {
-         AdjustAfsPath (DriveMap.szMapping, szMapping, TRUE, TRUE);
-         if (DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] == TEXT('*'))
-            {
-            DriveMap.fPersistent = FALSE;
-            DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] = TEXT('\0');
-            }
-         size_t iDrive = DriveMap.chDrive - chDRIVE_A;
-         memcpy (&pList->aDriveMap[ iDrive ], &DriveMap, sizeof(DRIVEMAP));
-         }
-      }
+    HKEY hkMappings;
+    RegCreateKeyEx( HKEY_CURRENT_USER,
+                    "SOFTWARE\\OpenAFS\\Client\\Mappings",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ|KEY_QUERY_VALUE,
+                    NULL, 
+                    &hkMappings,
+                    NULL );
+
+    DWORD dwMappings;
+    RegQueryInfoKey( hkMappings,
+                     NULL,  /* lpClass */
+                     NULL,  /* lpcClass */
+                     NULL,  /* lpReserved */
+                     NULL,  /* lpcSubKeys */
+                     NULL,  /* lpcMaxSubKeyLen */
+                     NULL,  /* lpcMaxClassLen */
+                     &dwMappings, /* lpcValues */
+                     NULL,  /* lpcMaxValueNameLen */
+                     NULL,  /* lpcMaxValueLen */
+                     NULL,  /* lpcbSecurityDescriptor */
+                     NULL   /* lpftLastWriteTime */
+                     );
+
+    for ( DWORD dwIndex = 0; dwIndex < dwMappings; dwIndex ++ ) {
+        TCHAR mapping[MAX_PATH] = "";
+        DWORD mappingLen = MAX_PATH;
+        TCHAR drive[MAX_PATH];
+        DWORD driveLen = MAX_PATH;
+        DWORD dwType;
+
+        RegEnumValue( hkMappings, dwIndex, drive, &driveLen, NULL,
+                      &dwType, (LPBYTE)mapping, &mappingLen);
+
+       DRIVEMAP DriveMap;
+       memset (&DriveMap, 0x00, sizeof(DRIVEMAP));
+       DriveMap.chDrive = toupper(*drive);
+       DriveMap.fPersistent = TRUE;
+       if ((DriveMap.chDrive < chDRIVE_A) || (DriveMap.chDrive > chDRIVE_Z))
+           continue;
+
+       if (mapping[0] != TEXT('\0'))
+       {
+           AdjustAfsPath (DriveMap.szMapping, mapping, TRUE, TRUE);
+           if (DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] == TEXT('*'))
+           {
+               DriveMap.fPersistent = FALSE;
+               DriveMap.szMapping[ lstrlen(DriveMap.szMapping)-1 ] = TEXT('\0');
+           }
+           size_t iDrive = DriveMap.chDrive - chDRIVE_A;
+           memcpy (&pList->aDriveMap[ iDrive ], &DriveMap, sizeof(DRIVEMAP));
+       }
+    }
 
-   FreeStringMemory (mszLHS);
+    RegCloseKey(hkMappings);
 }
 
 BOOL ForceMapActive (TCHAR chDrive)
@@ -403,7 +506,8 @@ BOOL ForceMapActive (TCHAR chDrive)
     szDrive[0] = chDrive;
     szDrive[1] = 0;
 
-    GetPrivateProfileString (cszSECTION_ACTIVE, szDrive, TEXT("0"), szActive, sizeof(szActive), cszINIFILE);
+    DWORD len = sizeof(szActive);
+    ReadRegistryString( HKEY_CURRENT_USER, cszSECTION_ACTIVE, szDrive, szActive, &len);
 
     if ( !lstrcmp(szActive,"1") || !lstrcmpi(szActive,"true") || !lstrcmpi(szActive,"on") || !lstrcmpi(szActive,"yes") )
         return TRUE;
@@ -418,34 +522,69 @@ void WriteActiveMap (TCHAR chDrive, BOOL on)
     szDrive[0] = chDrive;
     szDrive[1] = 0;
 
-    WritePrivateProfileString (cszSECTION_ACTIVE, szDrive, on ? "1" : "0", cszINIFILE);
+    WriteRegistryString(HKEY_CURRENT_USER, cszSECTION_ACTIVE, szDrive, on ? "1" : "0");
 }
 
 void QueryDriveMapList_WriteMappings (PDRIVEMAPLIST pList)
 {
-   WriteDriveMappings (pList);
+    WriteDriveMappings (pList);
 }
 
 
 void WriteDriveMappings (PDRIVEMAPLIST pList)
 {
-   WritePrivateProfileString (cszSECTION_MAPPINGS, NULL, NULL, cszINIFILE);
+    HKEY hkMappings;
+    RegCreateKeyEx( HKEY_CURRENT_USER, 
+                    "SOFTWARE\\OpenAFS\\Client\\Mappings",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ|KEY_QUERY_VALUE|KEY_WRITE,
+                    NULL, 
+                    &hkMappings,
+                    NULL );
+
+    DWORD dwMappings;
+    RegQueryInfoKey( hkMappings,
+                     NULL,  /* lpClass */
+                     NULL,  /* lpcClass */
+                     NULL,  /* lpReserved */
+                     NULL,  /* lpcSubKeys */
+                     NULL,  /* lpcMaxSubKeyLen */
+                     NULL,  /* lpcMaxClassLen */
+                     &dwMappings, /* lpcValues */
+                     NULL,  /* lpcMaxValueNameLen */
+                     NULL,  /* lpcMaxValueLen */
+                     NULL,  /* lpcbSecurityDescriptor */
+                     NULL   /* lpftLastWriteTime */
+                     );
+
+    if ( dwMappings > 0 ) {
+        for ( long dwIndex = dwMappings - 1; dwIndex >= 0; dwIndex-- ) {
+            TCHAR drive[MAX_PATH];
+            DWORD driveLen = MAX_PATH;
+
+            RegEnumValue( hkMappings, dwIndex, drive, &driveLen, NULL, NULL, NULL, NULL);
+            RegDeleteValue( hkMappings, drive );
+        }
+    }
 
    for (size_t iDrive = 0; iDrive < 26; ++iDrive)
-      {
-      if (pList->aDriveMap[iDrive].szMapping[0] != TEXT('\0'))
-         {
-         TCHAR szLHS[] = TEXT("*");
-         szLHS[0] = pList->aDriveMap[iDrive].chDrive;
-
-         TCHAR szRHS[MAX_PATH];
-         AdjustAfsPath (szRHS, pList->aDriveMap[iDrive].szMapping, TRUE, TRUE);
-         if (!pList->aDriveMap[iDrive].fPersistent)
-            lstrcat (szRHS, TEXT("*"));
-
-         WritePrivateProfileString (cszSECTION_MAPPINGS, szLHS, szRHS, cszINIFILE);
-         }
-      }
+   {
+       if (pList->aDriveMap[iDrive].szMapping[0] != TEXT('\0'))
+       {
+           TCHAR szLHS[] = TEXT("*");
+           szLHS[0] = pList->aDriveMap[iDrive].chDrive;
+
+           TCHAR szRHS[MAX_PATH];
+           AdjustAfsPath (szRHS, pList->aDriveMap[iDrive].szMapping, TRUE, TRUE);
+           if (!pList->aDriveMap[iDrive].fPersistent)
+               lstrcat (szRHS, TEXT("*"));
+
+           RegSetValueEx( hkMappings, szLHS, 0, REG_SZ, (const BYTE *)szRHS, lstrlen(szRHS) + 1);
+       }
+   }
+   RegCloseKey( hkMappings );
 }
 
 BOOL DriveIsGlobalAfsDrive(TCHAR chDrive)
@@ -636,29 +775,30 @@ BOOL ActivateDriveMap (TCHAR chDrive, LPTSTR pszMapping, LPTSTR pszSubmountReq,
 
 BOOL InactivateDriveMap (TCHAR chDrive, DWORD *pdwStatus)
 {
-   DWORD rc = DisMountDOSDrive(chDrive, FALSE);
-   if (rc == NO_ERROR)
-      return TRUE;
+    DWORD rc = DisMountDOSDrive(chDrive, FALSE);
+    if (rc == NO_ERROR)
+        return TRUE;
 
-   if (pdwStatus)
-      *pdwStatus = rc;
-   return FALSE;
+    if (pdwStatus)
+        *pdwStatus = rc;
+    return FALSE;
 }
 
 
 void AddSubMount (LPTSTR pszSubmount, LPTSTR pszMapping)
 {
-   TCHAR szRHS[ MAX_PATH ];
-   AdjustAfsPath (szRHS, pszMapping, FALSE, TRUE);
-   if (!szRHS[0])
-      lstrcpy (szRHS, TEXT("/"));
-   WritePrivateProfileString (cszSECTION_SUBMOUNTS, pszSubmount, szRHS, cszINIFILE);
+    TCHAR szRHS[ MAX_PATH ];
+    AdjustAfsPath (szRHS, pszMapping, FALSE, TRUE);
+    if (!szRHS[0])
+        lstrcpy (szRHS, TEXT("/"));
+
+    WriteRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount, szRHS);
 }
 
 
 void RemoveSubMount (LPTSTR pszSubmount)
 {
-   WritePrivateProfileString (cszSECTION_SUBMOUNTS, pszSubmount, NULL, cszINIFILE);
+    DeleteRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount);
 }
 
 
@@ -826,7 +966,7 @@ DWORD RWLogonOption(BOOL read,DWORD value)
    if (read)
    {
           rval=0;
-               if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLogonOptionName,0, KEY_QUERY_VALUE, &hk)==ERROR_SUCCESS)
+               if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSLogonOptionName, 0, KEY_QUERY_VALUE, &hk)==ERROR_SUCCESS)
                {
                        LSPsize=sizeof(rval);
                        RegQueryValueEx(hk, "LogonOptions", NULL,
index 5e5302e229c153d884242bdd56e7a29d90dc0d28..022c1a8864a2f94ee567eb7ae276ae076e5eadef 100644 (file)
@@ -44,12 +44,25 @@ static CSubmountInfo *ReadSubmtInfo(const CString& strShareName)
 
        char pathName[1024];
 
-       len = GetPrivateProfileString("AFS Submounts",
-                                     PCCHAR(strShareName),
-                                     "", pathName, sizeof(pathName),
-                                     "afsdsbmt.ini");
-
-       if (len == 0 || len == sizeof(pathName) - 1)
+    HKEY hkSubmounts;
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    DWORD dwType;
+    DWORD status;
+    len = sizeof(pathName);
+    status = RegQueryValueEx( hkSubmounts, (LPCSTR)PCCHAR(strShareName), 0,
+                              &dwType, (LPBYTE)pathName, &len);
+    RegCloseKey( hkSubmounts );
+
+       if (status || len == 0)
                return pInfo;
 
        pInfo = new CSubmountInfo();
@@ -148,32 +161,48 @@ BOOL CSubmountsDlg::FillSubmtList()
 {
        HOURGLASS hourglass;
 
-       DWORD lsize, size = 500;
-       char *buf = NULL, *next;
-
-       /*
-        * We don't know how large a buffer we need.  Keep doubling it until
-        * we're sure we have enough.
-        */
-       do {
-               size *= 2;
-               if (buf != NULL) free(buf);
-               buf = (char *)malloc(size);
-               lsize = GetPrivateProfileSection("AFS Submounts", buf, size,
-                                                "afsdsbmt.ini");
-       }
-       while (lsize >= size - 2);
-
-       if (lsize != 0) {
-               next = buf;
-               do {
-                       m_SubmtList.AddString(next);
-                       next += (strlen(next) + 1);
-               }
-               while (*next);
-       }
-
-       free(buf);
+    HKEY hkSubmounts;
+    DWORD dwType, dwSize;
+    DWORD status;
+    DWORD dwIndex;
+    DWORD dwSubmounts;
+
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    RegQueryInfoKey( hkSubmounts,
+                 NULL,  /* lpClass */
+                 NULL,  /* lpcClass */
+                 NULL,  /* lpReserved */
+                 NULL,  /* lpcSubKeys */
+                 NULL,  /* lpcMaxSubKeyLen */
+                 NULL,  /* lpcMaxClassLen */
+                 &dwSubmounts, /* lpcValues */
+                 NULL,  /* lpcMaxValueNameLen */
+                 NULL,  /* lpcMaxValueLen */
+                 NULL,  /* lpcbSecurityDescriptor */
+                 NULL   /* lpftLastWriteTime */
+                 );
+
+
+    for ( dwIndex = 0; dwIndex < dwSubmounts; dwIndex ++ ) {
+        char submountName[256];
+        DWORD submountNameLen = sizeof(submountName);
+
+        RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
+              &dwType, NULL, NULL);
+
+        m_SubmtList.AddString(submountName);
+    }
+
+    RegCloseKey( hkSubmounts );
 
        return TRUE;
 }
@@ -219,25 +248,43 @@ static BOOL AddSubmt(CSubmountInfo *pInfo)
 {
        HOURGLASS hourglass;
 
-       BOOL written =
-               WritePrivateProfileString("AFS Submounts",
-                                         PCCHAR(pInfo->GetShareName()),
-                                         PCCHAR(pInfo->GetPathName()),
-                                         "afsdsbmt.ini");
-
-       return written;
+    HKEY hkSubmounts;
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_WRITE,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    DWORD status = RegSetValueEx( hkSubmounts, PCCHAR(pInfo->GetShareName()), 0, REG_SZ,
+                   (const BYTE *)PCCHAR(pInfo->GetPathName()), strlen(PCCHAR(pInfo->GetPathName())) + 1);
+
+    RegCloseKey(hkSubmounts);
+       return (status == ERROR_SUCCESS);
 }
 
 static BOOL DeleteSubmt(CSubmountInfo *pInfo)
 {
        HOURGLASS hourglass;
 
-       BOOL written =
-               WritePrivateProfileString("AFS Submounts",
-                                         PCCHAR(pInfo->GetShareName()),
-                                         NULL,
-                                         "afsdsbmt.ini");
-       return written;
+    HKEY hkSubmounts;
+    RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                    "SOFTWARE\\OpenAFS\\Client\\Submounts",
+                    0, 
+                    "AFS", 
+                    REG_OPTION_NON_VOLATILE,
+                    KEY_WRITE,
+                    NULL, 
+                    &hkSubmounts,
+                    NULL );
+
+    DWORD status = RegDeleteValue( hkSubmounts, PCCHAR(pInfo->GetShareName()));
+
+    RegCloseKey(hkSubmounts);
+       return (status == ERROR_SUCCESS);
 }
 
 void CSubmountsDlg::OnAdd() 
index 8da7af4cddb02ab6a3487c432e2306de0fd0e04b..83ba08ef9855a140ba90ffcf190c891e36a966ad 100644 (file)
@@ -1778,18 +1778,16 @@ StartRemove:
 !ENDIF
   
    IfSilent SkipDel
-;  IfFileExists "$WINDIR\afsdcell.ini" CellExists SkipDelAsk
+;  IfFileExists "$INSTDIR\Client\CellServDB" CellExists SkipDelAsk
 ;  CellExists:
   MessageBox MB_YESNO "Would you like to keep your configuration files?" IDYES SkipDel
-  Delete "$WINDIR\afsdcell.ini"
+  Delete "$INSTDIR\Client\CellServDB"
 
-  Delete "$WINDIR\afsdsbmt.ini"
 ; Only remove krb5.ini if KfW was installed
 !IFDEF INSTALL_KFW
   Delete "$WINDIR\krb5.ini"
 !ENDIF
-  Delete "$WINDIR\afsdns.ini"
-  Delete "$WINDIR\afs_freelance.ini"
+  Delete "$INSTDIR\Client\afsdns.ini"
   
   SkipDel:
   Delete "$WINDIR\afsd_init.log"
@@ -2055,21 +2053,21 @@ goto UsePackaged
 
 DoDownload:
    ReadINIStr $R0 $0 "Field 5" "State"
-   NSISdl::download $R0 "$WINDIR\afsdcell.ini"
+   NSISdl::download $R0 "$INSTDIR\Client\CellServDB"
    Pop $R0 ;Get the return value
    StrCmp $R0 "success" +2
       MessageBox MB_OK|MB_ICONSTOP "Download failed: $R0"
    goto done
 
 UsePackaged:
-   SetOutPath "$WINDIR"
-   File "afsdcell.ini"
+   SetOutPath "$INSTDIR\Client"
+   File "CellServDB"
    goto done
    
 CheckOther:
    ReadINIStr $R0 $0 "Field 7" "State"
    StrCmp $R0 "" done
-   CopyFiles $R0 "$WINDIR\afsdcell.ini"
+   CopyFiles $R0 "$INSTDIR\Client\CellServDB"
    
 done:
 
@@ -2220,8 +2218,12 @@ startOver:
   WriteINISTR $0 "Field 4" "State" "0"
   WriteINIStr $0 "Field 6" "State" "0"
   
-  ; If there is an existing afsdcell.ini file, allow the user to choose it and make it default
-  IfFileExists "$WINDIR\afsdcell.ini" +1 notpresent
+  ; If there is an existing afsdcell.ini file, migrate it to CellServDB
+  IfFileExists "$WINDIR\afsdcell.ini" +1 +3
+  CopyFiles /SILENT "$WINDIR\afsdcell.ini" "$INSTDIR\Client\CellServDB"
+  Delete "$WINDIR\afsdcell.ini"
+  ; If there is an existing CellServDB file, allow the user to choose it and make it default
+  IfFileExists "$INSTDIR\Client\CellServDB" +1 notpresent
   WriteINIStr $0 "Field 2" "Flags" "ENABLED"
   WriteINIStr $0 "Field 2" "State" "1"
   WriteINIStr $0 "Field 3" "State" "0"
index 0b7acc1f4a3a65f80f9c312891103c6085ff2bec..188042dbdd9b77cb5ac2ab9e96133ef51bb2c89d 100644 (file)
@@ -135,12 +135,19 @@ initDirPathArray(void)
     FilepathNormalize(ntServerInstallDirShort);
 
     /* get the afs client configuration directory (/usr/vice/etc equivalent) */
-    status = GetWindowsDirectory(ntClientConfigDirLong, AFSDIR_PATH_MAX);
-    if (status == 0 || status > AFSDIR_PATH_MAX) {
-       /* failed to get canonical Windows directory; use temp directory */
-       strcpy(ntClientConfigDirLong, gettmpdir());
+    if (afssw_GetClientInstallDir(&buf)) {
+        /* failed */
+        status = GetWindowsDirectory(ntClientConfigDirLong, AFSDIR_PATH_MAX);
+        if (status == 0 || status > AFSDIR_PATH_MAX) {
+            /* failed to get canonical Windows directory; use temp directory */
+            strcpy(ntClientConfigDirLong, gettmpdir());
+        } else {
+            initStatus |= AFSDIR_CLIENT_PATHS_OK;
+        }
     } else {
-       initStatus |= AFSDIR_CLIENT_PATHS_OK;
+        strcpy(ntClientConfigDirLong, buf);
+        free(buf);
+        initStatus |= AFSDIR_CLIENT_PATHS_OK;
     }
     FilepathNormalize(ntClientConfigDirLong);
 
@@ -187,7 +194,6 @@ initDirPathArray(void)
     /* now initialize various dir and file paths exported by dirpath module */
 
     /* server dir paths */
-
     strcpy(dirPathArray[AFSDIR_SERVER_AFS_DIRPATH_ID], afsSrvDirPath);
 
     pathp = dirPathArray[AFSDIR_SERVER_ETC_DIRPATH_ID];
@@ -218,7 +224,6 @@ initDirPathArray(void)
     AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_BIN_FILE_DIR);
 
     /* client dir path */
-
 #ifdef AFS_NT40_ENV
     strcpy(dirPathArray[AFSDIR_CLIENT_VICE_DIRPATH_ID],
           "/NoUsrViceDirectoryOnWindows");
@@ -237,7 +242,6 @@ initDirPathArray(void)
 #endif /* AFS_NT40_ENV */
 
     /* server file paths */
-
     pathp = dirPathArray[AFSDIR_SERVER_THISCELL_FILEPATH_ID];
     AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR,
                           AFSDIR_THISCELL_FILE);
@@ -363,7 +367,6 @@ initDirPathArray(void)
 
 
     /* client file paths */
-
 #ifdef AFS_NT40_ENV
     strcpy(dirPathArray[AFSDIR_CLIENT_THISCELL_FILEPATH_ID],
           "/NoUsrViceEtcThisCellFileOnWindows");
index b70cf545a3f5c197cf40a468ceb7f4084c65f3ae..230e0629d28a1a7c57f3684dcea5bacf185ab574 100644 (file)
@@ -145,7 +145,11 @@ extern int
 #define AFSDIR_FILELOG_FILE     "FileLog"
 #define AFSDIR_MIGRATE_LOGNAME  "wtlog."
 
+#ifdef COMMENT
 #define AFSDIR_CELLSERVDB_FILE_NTCLIENT  "afsdcell.ini"
+#else
+#define AFSDIR_CELLSERVDB_FILE_NTCLIENT  AFSDIR_CELLSERVDB_FILE
+#endif
 
 #define AFSDIR_NETINFO_FILE     "NetInfo"
 #define AFSDIR_NETRESTRICT_FILE "NetRestrict"