]>
Commit | Line | Data |
---|---|---|
d6aaa55d MT |
1 | /* SmoothWall install program. |
2 | * | |
3 | * This program is distributed under the terms of the GNU General Public | |
4 | * Licence. See the file COPYING for details. | |
5 | * | |
6 | * (c) Lawrence Manning, 2001 | |
7 | * Write the config and get password stuff. | |
8 | * | |
10bc6f06 | 9 | * $Id: config.c,v 1.6.2.2 2004/08/23 21:09:44 alanh Exp $ |
d6aaa55d MT |
10 | * |
11 | */ | |
12 | ||
13 | #include "install.h" | |
10bc6f06 MT |
14 | |
15 | extern FILE *flog; | |
16 | extern char *mylog; | |
17 | ||
18 | extern char **ctr; | |
19 | ||
20 | extern int raid_disk; | |
d6aaa55d MT |
21 | |
22 | /* called to write out all config files using the keyvalue interface. */ | |
23 | int write_disk_configs(struct devparams *dp) | |
24 | { | |
25 | char devnode[STRING_SIZE]; | |
10bc6f06 | 26 | |
d6aaa55d | 27 | /* dev node links. */ |
10bc6f06 | 28 | snprintf(devnode, STRING_SIZE, "%s", dp->devnode); |
d6aaa55d MT |
29 | if (symlink(devnode, "/harddisk/dev/harddisk")) |
30 | { | |
31 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK]); | |
32 | return 0; | |
33 | } | |
10bc6f06 MT |
34 | if (raid_disk) |
35 | snprintf(devnode, STRING_SIZE, "%sp1", dp->devnode); | |
36 | else | |
37 | snprintf(devnode, STRING_SIZE, "%s1", dp->devnode); | |
38 | if (symlink(devnode, "/harddisk/dev/harddisk1")) | |
39 | { | |
40 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1]); | |
41 | return 0; | |
42 | } | |
43 | if (raid_disk) | |
44 | snprintf(devnode, STRING_SIZE, "%sp2", dp->devnode); | |
45 | else | |
46 | snprintf(devnode, STRING_SIZE, "%s2", dp->devnode); | |
47 | if (symlink(devnode, "/harddisk/dev/harddisk2")) | |
48 | { | |
49 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2]); | |
50 | return 0; | |
51 | } | |
52 | if (raid_disk) | |
53 | snprintf(devnode, STRING_SIZE, "%sp3", dp->devnode); | |
54 | else | |
55 | snprintf(devnode, STRING_SIZE, "%s3", dp->devnode); | |
56 | if (symlink(devnode, "/harddisk/dev/harddisk3")) | |
57 | { | |
58 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3]); | |
59 | return 0; | |
60 | } | |
61 | if (raid_disk) | |
62 | snprintf(devnode, STRING_SIZE, "%sp4", dp->devnode); | |
63 | else | |
64 | snprintf(devnode, STRING_SIZE, "%s4", dp->devnode); | |
65 | if (symlink(devnode, "/harddisk/dev/harddisk4")) | |
66 | { | |
67 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4]); | |
68 | return 0; | |
d6aaa55d MT |
69 | } |
70 | ||
71 | /* Add /dev/root symlink linking to the root filesystem to | |
72 | * keep updfstab happy */ | |
10bc6f06 MT |
73 | if (raid_disk) |
74 | snprintf(devnode, STRING_SIZE, "%sp4", dp->devnode); | |
75 | else | |
76 | snprintf(devnode, STRING_SIZE, "%s4", dp->devnode); | |
d6aaa55d MT |
77 | if (symlink(devnode, "/harddisk/dev/root")) |
78 | { | |
79 | errorbox(ctr[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT]); | |
80 | return 0; | |
81 | } | |
82 | ||
83 | return 1; | |
84 | } | |
85 | ||
86 | int write_lang_configs( char *lang) | |
87 | { | |
88 | struct keyvalue *kv = initkeyvalues(); | |
89 | ||
90 | /* default stuff for main/settings. */ | |
91 | replacekeyvalue(kv, "LANGUAGE", lang); | |
92 | replacekeyvalue(kv, "HOSTNAME", SNAME); | |
93 | writekeyvalues(kv, "/harddisk" CONFIG_ROOT "/main/settings"); | |
94 | freekeyvalues(kv); | |
95 | ||
96 | return 1; | |
97 | } | |
98 | ||
99 | int write_ethernet_configs(struct keyvalue *ethernetkv) | |
100 | { | |
101 | /* Write out the network settings we got from a few mins ago. */ | |
102 | writekeyvalues(ethernetkv, "/harddisk" CONFIG_ROOT "/ethernet/settings"); | |
103 | return 1; | |
104 | } | |
105 | ||
106 | /* Taken from the cdrom one. */ | |
107 | int getpassword(char *password, char *text) | |
108 | { | |
109 | char *values[] = { NULL, NULL, NULL }; /* pointers for the values. */ | |
110 | struct newtWinEntry entries[] = | |
111 | { | |
112 | { ctr[TR_PASSWORD_PROMPT], &values[0], 2 }, | |
113 | { ctr[TR_AGAIN_PROMPT], &values[1], 2 }, | |
114 | { NULL, NULL, 0 } | |
115 | }; | |
116 | char title[STRING_SIZE]; | |
117 | int rc; | |
118 | int done; | |
119 | ||
120 | do | |
121 | { | |
122 | done = 1; | |
123 | sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN); | |
124 | rc = newtWinEntries(title, text, | |
125 | 50, 5, 5, 20, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL); | |
126 | ||
127 | if (rc != 2) | |
128 | { | |
129 | if (strlen(values[0]) == 0 || strlen(values[1]) == 0) | |
130 | { | |
131 | errorbox(ctr[TR_PASSWORD_CANNOT_BE_BLANK]); | |
132 | done = 0; | |
133 | strcpy(values[0], ""); | |
134 | strcpy(values[1], ""); | |
135 | } | |
136 | else if (strcmp(values[0], values[1]) != 0) | |
137 | { | |
138 | errorbox(ctr[TR_PASSWORDS_DO_NOT_MATCH]); | |
139 | done = 0; | |
140 | strcpy(values[0], ""); | |
141 | strcpy(values[1], ""); | |
142 | } | |
143 | } | |
144 | } | |
145 | while (!done); | |
146 | ||
147 | strncpy(password, values[0], STRING_SIZE); | |
148 | ||
149 | if (values[0]) free(values[0]); | |
150 | if (values[1]) free(values[1]); | |
151 | ||
152 | return rc; | |
153 | } | |
10bc6f06 | 154 |