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.3 2005/12/07 20:42:48 franck78 Exp $
14 extern char **ctr
; // text translation table
16 /* called to write out all config files using the keyvalue interface. */
17 int write_disk_configs(struct devparams
*dp
)
19 char devnode
[STRING_SIZE
];
20 char partition
[STRING_SIZE
];
21 char *messages
[5] = { NULL
,
22 ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1
],
23 ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2
],
24 ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3
],
25 ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4
]
28 sprintf(devnode
, "%s", dp
->devnode_disk_run
);
29 if (symlink(devnode
, "/harddisk/dev/harddisk"))
31 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK
]);
37 sprintf(devnode
, "%s%d", dp
->devnode_part_run
,j
);
38 sprintf(partition
,"/harddisk/dev/harddisk%d",j
);
39 if (symlink(devnode
, partition
))
41 errorbox( messages
[j
] );
46 /* Add /dev/root symlink linking to the root filesystem to
47 * keep updfstab happy */
48 sprintf(devnode
, "%s4", dp
->devnode_part_run
);
49 if (symlink(devnode
, "/harddisk/dev/root"))
51 errorbox(ctr
[TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT
]);
58 int write_lang_configs( char *lang
)
60 struct keyvalue
*kv
= initkeyvalues();
62 /* default stuff for main/settings. */
63 replacekeyvalue(kv
, "LANGUAGE", lang
);
64 replacekeyvalue(kv
, "HOSTNAME", SNAME
);
65 writekeyvalues(kv
, "/harddisk" CONFIG_ROOT
"/main/settings");
71 int write_ethernet_configs(struct keyvalue
*ethernetkv
)
73 /* Write out the network settings we got from a few mins ago. */
74 writekeyvalues(ethernetkv
, "/harddisk" CONFIG_ROOT
"/ethernet/settings");
78 /* Taken from the cdrom one. */
79 int getpassword(char *password
, char *text
)
81 char *values
[] = { NULL
, NULL
, NULL
}; /* pointers for the values. */
82 struct newtWinEntry entries
[] =
84 { ctr
[TR_PASSWORD_PROMPT
], &values
[0], 2 },
85 { ctr
[TR_AGAIN_PROMPT
], &values
[1], 2 },
88 char title
[STRING_SIZE
];
95 sprintf (title
, "%s v%s - %s", NAME
, VERSION
, SLOGAN
);
96 rc
= newtWinEntries(title
, text
,
97 50, 5, 5, 20, entries
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
101 if (strlen(values
[0]) == 0 || strlen(values
[1]) == 0)
103 errorbox(ctr
[TR_PASSWORD_CANNOT_BE_BLANK
]);
105 strcpy(values
[0], "");
106 strcpy(values
[1], "");
108 else if (strcmp(values
[0], values
[1]) != 0)
110 errorbox(ctr
[TR_PASSWORDS_DO_NOT_MATCH
]);
112 strcpy(values
[0], "");
113 strcpy(values
[1], "");
119 strncpy(password
, values
[0], STRING_SIZE
);
121 if (values
[0]) free(values
[0]);
122 if (values
[1]) free(values
[1]);