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