1 /* SmoothWall install program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Write the config and get password stuff.
9 * $Id: config.c,v 1.6.2.2 2004/08/23 21:09:44 alanh Exp $
22 /* called to write out all config files using the keyvalue interface. */
23 int write_disk_configs(struct devparams
*dp
)
25 char devnode
[STRING_SIZE
];
28 snprintf(devnode
, STRING_SIZE
, "%s", dp
->devnode
);
29 if (symlink(devnode
, "/harddisk/dev/harddisk"))
31 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK
]);
35 snprintf(devnode
, STRING_SIZE
, "%sp1", dp
->devnode
);
37 snprintf(devnode
, STRING_SIZE
, "%s1", dp
->devnode
);
38 if (symlink(devnode
, "/harddisk/dev/harddisk1"))
40 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1
]);
44 snprintf(devnode
, STRING_SIZE
, "%sp2", dp
->devnode
);
46 snprintf(devnode
, STRING_SIZE
, "%s2", dp
->devnode
);
47 if (symlink(devnode
, "/harddisk/dev/harddisk2"))
49 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2
]);
53 snprintf(devnode
, STRING_SIZE
, "%sp3", dp
->devnode
);
55 snprintf(devnode
, STRING_SIZE
, "%s3", dp
->devnode
);
56 if (symlink(devnode
, "/harddisk/dev/harddisk3"))
58 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3
]);
62 snprintf(devnode
, STRING_SIZE
, "%sp4", dp
->devnode
);
64 snprintf(devnode
, STRING_SIZE
, "%s4", dp
->devnode
);
65 if (symlink(devnode
, "/harddisk/dev/harddisk4"))
67 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4
]);
71 /* Add /dev/root symlink linking to the root filesystem to
72 * keep updfstab happy */
74 snprintf(devnode
, STRING_SIZE
, "%sp4", dp
->devnode
);
76 snprintf(devnode
, STRING_SIZE
, "%s4", dp
->devnode
);
77 if (symlink(devnode
, "/harddisk/dev/root"))
79 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT
]);
86 int write_lang_configs( char *lang
)
88 struct keyvalue
*kv
= initkeyvalues();
90 /* default stuff for main/settings. */
91 replacekeyvalue(kv
, "LANGUAGE", lang
);
92 replacekeyvalue(kv
, "HOSTNAME", SNAME
);
93 writekeyvalues(kv
, "/harddisk" CONFIG_ROOT
"/main/settings");
99 int write_ethernet_configs(struct keyvalue
*ethernetkv
)
101 /* Write out the network settings we got from a few mins ago. */
102 writekeyvalues(ethernetkv
, "/harddisk" CONFIG_ROOT
"/ethernet/settings");
106 /* Taken from the cdrom one. */
107 int getpassword(char *password
, char *text
)
109 char *values
[] = { NULL
, NULL
, NULL
}; /* pointers for the values. */
110 struct newtWinEntry entries
[] =
112 { ctr
[TR_PASSWORD_PROMPT
], &values
[0], 2 },
113 { ctr
[TR_AGAIN_PROMPT
], &values
[1], 2 },
116 char title
[STRING_SIZE
];
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
);
129 if (strlen(values
[0]) == 0 || strlen(values
[1]) == 0)
131 errorbox(ctr
[TR_PASSWORD_CANNOT_BE_BLANK
]);
133 strcpy(values
[0], "");
134 strcpy(values
[1], "");
136 else if (strcmp(values
[0], values
[1]) != 0)
138 errorbox(ctr
[TR_PASSWORDS_DO_NOT_MATCH
]);
140 strcpy(values
[0], "");
141 strcpy(values
[1], "");
147 strncpy(password
, values
[0], STRING_SIZE
);
149 if (values
[0]) free(values
[0]);
150 if (values
[1]) free(values
[1]);