Annotation of embedaddon/ntp/lib/isc/win32/ntpaths.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
3: * Copyright (C) 2001 Internet Software Consortium.
4: *
5: * Permission to use, copy, modify, and/or distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10: * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11: * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14: * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15: * PERFORMANCE OF THIS SOFTWARE.
16: */
17:
18: /* $Id: ntpaths.c,v 1.11 2007/06/18 23:47:49 tbox Exp $ */
19:
20: /*
21: * This module fetches the required path information that is specific
22: * to NT systems which can have its configuration and system files
23: * almost anywhere. It can be used to override whatever the application
24: * had previously assigned to the pointer. Basic information about the
25: * file locations are stored in the registry.
26: */
27:
28: #include <config.h>
29: #include <isc/bind_registry.h>
30: #include <isc/ntpaths.h>
31:
32: /*
33: * Module Variables
34: */
35:
36: static char systemDir[MAX_PATH];
37: static char namedBase[MAX_PATH];
38: static char ns_confFile[MAX_PATH];
39: static char lwresd_confFile[MAX_PATH];
40: static char lwresd_resolvconfFile[MAX_PATH];
41: static char rndc_confFile[MAX_PATH];
42: static char ns_defaultpidfile[MAX_PATH];
43: static char lwresd_defaultpidfile[MAX_PATH];
44: static char local_state_dir[MAX_PATH];
45: static char sys_conf_dir[MAX_PATH];
46: static char rndc_keyFile[MAX_PATH];
47:
48: static DWORD baseLen = MAX_PATH;
49: static BOOL Initialized = FALSE;
50:
51: void
52: isc_ntpaths_init() {
53: HKEY hKey;
54: BOOL keyFound = TRUE;
55:
56: memset(namedBase, 0, MAX_PATH);
57: if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SUBKEY, 0, KEY_READ, &hKey)
58: != ERROR_SUCCESS)
59: keyFound = FALSE;
60:
61: if (keyFound == TRUE) {
62: /* Get the named directory */
63: if (RegQueryValueEx(hKey, "InstallDir", NULL, NULL,
64: (LPBYTE)namedBase, &baseLen) != ERROR_SUCCESS)
65: keyFound = FALSE;
66: RegCloseKey(hKey);
67: }
68:
69: GetSystemDirectory(systemDir, MAX_PATH);
70:
71: if (keyFound == FALSE)
72: /* Use the System Directory as a default */
73: strcpy(namedBase, systemDir);
74:
75: strcpy(ns_confFile, namedBase);
76: strcat(ns_confFile, "\\etc\\named.conf");
77:
78: strcpy(lwresd_confFile, namedBase);
79: strcat(lwresd_confFile, "\\etc\\lwresd.conf");
80:
81: strcpy(lwresd_resolvconfFile, systemDir);
82: strcat(lwresd_resolvconfFile, "\\Drivers\\etc\\resolv.conf");
83:
84: strcpy(rndc_keyFile, namedBase);
85: strcat(rndc_keyFile, "\\etc\\rndc.key");
86:
87: strcpy(rndc_confFile, namedBase);
88: strcat(rndc_confFile, "\\etc\\rndc.conf");
89: strcpy(ns_defaultpidfile, namedBase);
90: strcat(ns_defaultpidfile, "\\etc\\named.pid");
91:
92: strcpy(lwresd_defaultpidfile, namedBase);
93: strcat(lwresd_defaultpidfile, "\\etc\\lwresd.pid");
94:
95: strcpy(local_state_dir, namedBase);
96: strcat(local_state_dir, "\\bin");
97:
98: strcpy(sys_conf_dir, namedBase);
99: strcat(sys_conf_dir, "\\etc");
100:
101: Initialized = TRUE;
102: }
103:
104: char *
105: isc_ntpaths_get(int ind) {
106: if (!Initialized)
107: isc_ntpaths_init();
108:
109: switch (ind) {
110: case NAMED_CONF_PATH:
111: return (ns_confFile);
112: break;
113: case LWRES_CONF_PATH:
114: return (lwresd_confFile);
115: break;
116: case RESOLV_CONF_PATH:
117: return (lwresd_resolvconfFile);
118: break;
119: case RNDC_CONF_PATH:
120: return (rndc_confFile);
121: break;
122: case NAMED_PID_PATH:
123: return (ns_defaultpidfile);
124: break;
125: case LWRESD_PID_PATH:
126: return (lwresd_defaultpidfile);
127: break;
128: case LOCAL_STATE_DIR:
129: return (local_state_dir);
130: break;
131: case SYS_CONF_DIR:
132: return (sys_conf_dir);
133: break;
134: case RNDC_KEY_PATH:
135: return (rndc_keyFile);
136: break;
137: default:
138: return (NULL);
139: }
140: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>