Netzwerkscript beinahe vollendet.

Setup bearbeitet. (Geht schon ganz gut.)
Sonstiges wie immer...


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@366 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2006-12-21 18:38:37 +00:00
parent 552b817bee
commit 069680acc1
28 changed files with 2560 additions and 1483 deletions

View File

@@ -1,415 +0,0 @@
/* IPCop install2 program.
*
* This program is distributed under the terms of the GNU General Public
* Licence. See the file COPYING for details.
*
* (c) Lawrence Manning, 2001
* (c) Franck Bourdonnec, 2006
* Contains update/restore code
*
* $Id: install2.c,v 1.1.2.5 2006/02/10 06:53:57 gespinasse Exp $
*
*/
#include "install.h"
FILE *flog = NULL;
char *mylog;
char **ctr;
/*
To include a translated string in the final installer, you must reference
it here with a simplr comment. This save a lot a space in the installer
*/
/* TR_BUILDING_INITRD */
/* TR_HELPLINE */
/* TR_SKIP */
/* TR_RESTORE_CONFIGURATION */
/* TR_RESTORE */
/* TR_OK */
/* TR_CANCEL */
/* TR_ERROR */
/* TR_INSTALLING_FILES */
/* TR_FAILED_TO_FIND */
/* TR_UNABLE_TO_INSTALL_FILES */
/* TR_LOADING_PCMCIA */
//libsmooth
/* TR_INTERFACE */
/* TR_ENTER_THE_IP_ADDRESS_INFORMATION */
/* TR_STATIC */
/* TR_DHCP_HOSTNAME */
/* TR_IP_ADDRESS_PROMPT */
/* TR_NETMASK_PROMPT */
/* TR_INVALID_FIELDS */
/* TR_IP_ADDRESS_CR */
/* TR_NETWORK_MASK_CR */
/* TR_DHCP_HOSTNAME_CR */
/* TR_LOOKING_FOR_NIC */
/* TR_MANUAL */
/* TR_SELECT_NETWORK_DRIVER */
/* TR_SELECT_NETWORK_DRIVER_LONG */
/* TR_UNABLE_TO_LOAD_DRIVER_MODULE */
/* TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED */
/* TR_MODULE_PARAMETERS */
/* TR_LOADING_MODULE */
/* TR_MODULE_NAME_CANNOT_BE_BLANK */
//upgrade 120
/* TR_UNABLE_TO_OPEN_SETTINGS_FILE */
/* TR_DOMAINNAME */
/* TR_ENTER_DOMAINNAME */
/* TR_DOMAINNAME_CANNOT_CONTAIN_SPACES */
/* TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM */
/* TR_UNABLE_TO_WRITE_ETC_FSTAB */
// dir to find files, chrooted or not...
#define TMP_EXTRACT_CH "/tmp/ipcop"
#define TMP_EXTRACT "/harddisk" TMP_EXTRACT_CH
#define MOUNT_BACKUP_CH "/mnt/usb"
#define MOUNT_BACKUP "/harddisk" MOUNT_BACKUP_CH
/*
return 0 when dev contains a backup set
leave dev mounted
*/
int try_mount (char *dev, char *testfile) {
char commandstring[STRING_SIZE];
mysystem("/bin/umount " MOUNT_BACKUP);
sprintf(commandstring, "/bin/mount -t vfat -o ro %s " MOUNT_BACKUP, dev);
mysystem(commandstring);
/*verify it's what we want */
sprintf(commandstring, MOUNT_BACKUP "/%s.dat", testfile);
FILE *handle = fopen(commandstring, "r");
if (handle == NULL) {
return 1; /* bad disk ! */
}
fclose(handle);
handle = fopen(MOUNT_BACKUP "/backup.key", "r");
if (handle == NULL) {
return 1; /* bad disk ! */
}
fclose(handle);
return 0; //success
}
/* try to mount usb device until backup.tgz is found except the
destination device (scsi names are identical with usb key)
check "sda sdb sdc sdd"
*/
int mountbackup (char *testfile, char *destination_device) {
char sourcedev[30];
char i,j;
for (i = 'a'; i < 'e'; i++) {
sprintf (sourcedev,"/dev/sd%c ",i);
if (strcmp (destination_device, sourcedev) != 0) {
if (!try_mount (sourcedev, testfile)) return 0;
}
for (j = '1'; j < '5'; j++) {
sourcedev[8] = j;
if (strcmp (destination_device, sourcedev) != 0) {
if (!try_mount (sourcedev, testfile)) return 0;
}
}
}
return 1;
}
int floppy_locate() {
/* Temporarily mount /proc under /harddisk/proc,
run updfstab to locate the floppy, and unmount /harddisk/proc
again. This should be run each time the user tries to restore
so it can properly detect removable devices */
if (mysystem("/bin/mount -n -t proc /proc /harddisk/proc")) {
errorbox(ctr[TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM]);
return 1;
}
if (mysystem("/bin/chroot /harddisk /usr/sbin/updfstab")) {
errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_FSTAB]);
return 1;
}
mysystem("/bin/umount /harddisk/proc");
return 0;
}
/* Check the SQUID acl file exists, if not use our 1.4 copy */
void fixup_squidacl() {
FILE *aclreadfile;
if ((aclreadfile = fopen ("/harddisk" CONFIG_ROOT "/proxy/acl", "r"))) {
unlink ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4");
fclose(aclreadfile);
} else {
rename ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4",
"/harddisk" CONFIG_ROOT "/proxy/acl");
}
chown ("/harddisk" CONFIG_ROOT "/proxy/acl", 99, 99);
}
/* if we detected SCSI then fixup */
void fixup_initrd() {
FILE *handle;
char line[STRING_SIZE];
char commandstring[STRING_SIZE];
if (!(handle = fopen("/scsidriver", "r")))
return;
char *driver;
fgets(line, STRING_SIZE-1, handle);
fclose(handle);
line[strlen(line) - 1] = 0;
driver = strtok(line, ".");
fprintf(flog, "Detected SCSI driver %s\n", driver);
if (!strlen(driver) > 1)
return;
fprintf(flog, "Fixing up ipfirerd.img\n");
mysystem("/bin/chroot /harddisk /sbin/modprobe loop");
mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);
sprintf(commandstring, "/bin/chroot /harddisk /sbin/mkinitrd"
" --with=scsi_mod --with=%s --with=sd_mod"
" --with=sr_mod --with=libata"
" --with=ataraid /boot/ipfirerd.img "KERNEL_VERSION,
driver );
runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
#ifdef __i386__
sprintf(commandstring, "/bin/chroot /harddisk /sbin/mkinitrd"
" --with=scsi_mod --with=%s --with=sd_mod"
" --with=sr_mod --with=libata"
" --with=ataraid /boot/ipfirerd-smp.img "KERNEL_VERSION"-smp",
driver );
runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
#endif
#ifdef __alpha__
runcommandwithstatus("/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf", ctr[TR_BUILDING_INITRD]);
#endif
}
/* when backup is ready in tmpdir, move files to definitive location */
void do_copy_files() {
mysystem("/bin/chroot /harddisk /bin/cp -af "TMP_EXTRACT_CH"/. /");
/* Upgrade necessary files from v1.2 to v1.3 to v1.4 */
upgrade_v12_v13();
upgrade_v130_v140();
/* Upgrade configuration files starting from 1.4.11 */
mysystem("/bin/chroot /harddisk /usr/local/bin/upgrade");
}
int main(int argc, char *argv[]) {
#define LANG argv[1]
#define DEST_DEV argv[2]
#define WGET argv[3]
#ifdef LANG_EN_ONLY
char **langtrs[] = { en_tr, NULL };
#elifdef LANG_ALL
char **langtrs[] = { bz_tr, cs_tr, da_tr, de_tr, en_tr, es_tr, fr_tr, el_tr, it_tr, la_tr, hu_tr, nl_tr, no_tr, pl_tr, pt_tr, sk_tr, so_tr, fi_tr, sv_tr, tr_tr, vi_tr, NULL };
#else
char **langtrs[] = { de_tr, en_tr, NULL };
#endif
char message[1000];
char title[STRING_SIZE];
char commandstring[STRING_SIZE];
setlocale (LC_ALL, "");
/* Log file/terminal stuff. */
mylog = "/dev/tty2";
ctr = langtrs[ atoi(LANG) ];
if (!(flog = fopen(mylog, "w+")))
{
printf("Couldn't open log terminal\n");
return 0;
}
fprintf(flog, "Install2 program started.\n");
newtInit();
newtCls();
strcpy (title, NAME " v" VERSION " - " SLOGAN);
newtDrawRootText(14, 0, title);
newtPushHelpLine(ctr[TR_HELPLINE]);
/* working dirs... */
mkdir(MOUNT_BACKUP, S_IRWXU|S_IRWXG|S_IRWXO);
//create the GUI screen and objects
newtComponent form, header, labelfile, labelkey, file, key, radio0, radio1, radio2, radio3, radio4, ok;
newtCenteredWindow (55,20,ctr[TR_RESTORE]);
form = newtForm (NULL, NULL,0);
sprintf(message, ctr[TR_RESTORE_CONFIGURATION], NAME);
header = newtTextboxReflowed (2,1,message,51,0,0,0);
newtFormAddComponent(form, header);
// The four method of restauration
int start1=1, start2=0, start3=0, start4=0;
radio1 = newtRadiobutton (17, 5, ctr[TR_SKIP], start1, NULL);
radio2 = newtRadiobutton (17, 6, "Floppy (legacy)", start2, radio1);
radio3 = newtRadiobutton (17, 7, "Usb-storage/CDROM", start3, radio2);
if (strcmp(WGET,"none"))
radio4 = newtRadiobutton (17, 8, "HTTP/FTP", start4, radio3);
else
radio4 = NULL;
newtFormAddComponents(form, radio1, radio2, radio3, radio4, NULL);
// The optionnal filename for 'backup'
labelfile=newtTextbox(12, 10, 35, 1, 0);
newtTextboxSetText (labelfile, "Filename");
newtFormAddComponent(form, labelfile);
char *filevalue;
char fileinit[STRING_SIZE] = "backup";
file = newtEntry (17, 11, fileinit, 20, &filevalue, 0);
newtFormAddComponent(form, file);
// The optionnal password for the key
labelkey=newtTextbox(12, 13, 35, 1, 0);
newtTextboxSetText (labelkey, "Backup key password");
newtFormAddComponent(form, labelkey);
char *keyvalue;
char keyinit[STRING_SIZE] = "";
key = newtEntry (17, 14, keyinit, 20, &keyvalue, 0);
newtFormAddComponent(form, key);
// The OK button
ok=newtButton (23, 16, ctr[TR_OK]);
newtFormAddComponent(form, ok);
/* loop until succeeds or user skips out */
int retcode = -1;
while ( retcode<0 ) {
// run the windows
struct newtExitStruct reponse;
newtFormRun (form, &reponse);
radio0 = newtRadioGetCurrent(radio1);
int radio;
radio = radio0 == radio1 ? 1 : radio0 == radio2 ? 2 : radio0 == radio3 ? 3 : radio0 == radio4 ? 4 : 0;
strcpy(keyinit,keyvalue); //reuse actual value
strcpy(fileinit,filevalue);
if (radio==1) {
retcode = 1; // no restore: nothing special
break; // out of the while loop
}
mkdir(TMP_EXTRACT, S_IRWXU|S_IRWXG|S_IRWXO);
statuswindow(45, 4, title, ctr[TR_INSTALLING_FILES]);
switch (radio) {
case 4: // network
sprintf(commandstring,"/bin/wget -P " TMP_EXTRACT " %s/%s.dat", WGET, filevalue);
mysystem (commandstring);
sprintf(commandstring,"/bin/wget -P " TMP_EXTRACT " %s/%s.key", WGET, filevalue);
if (mysystem (commandstring)) {
errorbox(ctr[TR_FAILED_TO_FIND]);
break;
};
goto COMMON;
case 3: // normal backup
if (mountbackup( filevalue, DEST_DEV )) {
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);//mess=no device with backup found
break;
};
// link files to a COMMON location
sprintf (commandstring, "chroot /harddisk ln -s "MOUNT_BACKUP_CH"/%s.dat " TMP_EXTRACT_CH "/%s.dat", filevalue, filevalue);
mysystem (commandstring);
sprintf (commandstring, "chroot /harddisk ln -s "MOUNT_BACKUP_CH"/%s.key " TMP_EXTRACT_CH "/%s.key", filevalue, filevalue);
mysystem (commandstring);
COMMON: // DECRYPT THE TARBALL
// Copy the key to a new location because we decrypt it!
if (strcmp(keyvalue, "")) { // password provided: decrypt the key
sprintf(commandstring, "/bin/chroot /harddisk /usr/bin/openssl enc"
" -a -d -aes256 -salt"
" -pass pass:%s"
" -in " TMP_EXTRACT_CH "/%s.key"
" -out " TMP_EXTRACT_CH "/__tmp.key",
keyvalue, filevalue);
} else { //just copy to new name
sprintf(commandstring, "/bin/chroot /harddisk cp"
" " TMP_EXTRACT_CH "/%s.key"
" " TMP_EXTRACT_CH "/__tmp.key",
filevalue);
}
mysystem (commandstring);
sprintf(commandstring, "/bin/chroot /harddisk /usr/bin/openssl des3"
" -d -salt"
" -in " TMP_EXTRACT_CH "/%s.dat"
" -out " TMP_EXTRACT_CH "/backup.tgz"
" -kfile " TMP_EXTRACT_CH "/__tmp.key",
filevalue);
if (mysystem (commandstring)) {
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);//mess=decrypt error:invalid key?
break;
}
strcpy(commandstring, "/bin/chroot /harddisk /bin/tar"
" -X " CONFIG_ROOT "/backup/exclude.system"
" -C " TMP_EXTRACT_CH
" -xzf " TMP_EXTRACT_CH "/backup.tgz");
if (mysystem(commandstring)) {
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
break;
}
sprintf(commandstring, TMP_EXTRACT "/%s.dat", filevalue);
unlink(commandstring ); //dont need them anymore
unlink( TMP_EXTRACT "/backup.tgz");
sprintf(commandstring, TMP_EXTRACT "/%s.key", filevalue);
unlink(commandstring );
unlink( TMP_EXTRACT "/__tmp.key");
/* Now copy to correct location */
do_copy_files();
retcode = 0; /* successfully restored */
break;
case 2:
// diskette change
if (floppy_locate()) {
retcode = 2; // this an error!
break;
}
/* Always extract to /tmp/ipcop for temporary extraction
just in case floppy fails.
try a compressed backup first because it's quicker to fail.
In exclude.system, files name must be without leading / or
on extraction, name will never match
*/
sprintf(commandstring,
"/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C "TMP_EXTRACT_CH" -xvzf /dev/floppy > %s 2> /dev/null", mylog);
if (system(commandstring)) {
/* if it's not compressed, try uncompressed first before failing*/
sprintf(commandstring,
"/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C "TMP_EXTRACT_CH" -xvf /dev/floppy > %s 2> /dev/null", mylog);
if (system(commandstring)) {
/* command failed trying to read from floppy */
errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
break;
}
}
/* Now copy to correct location */
do_copy_files();
retcode = 0; /* successfully restored */
}//switch
/* remove possible badly restored files */
mysystem("/bin/chroot /harddisk /bin/rm -rf " TMP_EXTRACT_CH );
newtPopWindow(); // close windows
}//while
newtFormDestroy(form);
/* cleanup */
mysystem("/bin/umount " MOUNT_BACKUP);
mysystem("/bin/chroot /harddisk /bin/rmdir " MOUNT_BACKUP_CH);
/* others operations moved from install to install2 */
fixup_squidacl();
fixup_initrd();
fprintf(flog, "Install2 program ended.\n");
fflush(flog);
fclose(flog);
newtFinished();
return retcode;
}

View File

@@ -823,7 +823,7 @@ EXIT:
{
if (!unattended) {
if (system("/bin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
if (system("/sbin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
printf("Unable to run setup.\n");
}
else {

View File

@@ -1,167 +1,167 @@
/* SmoothWall setup program.
*
* This program is distributed under the terms of the GNU General Public
* Licence. See the file COPYING for details.
*
* (c) Lawrence Manning, 2001
* Stuff for setting the keymap.
*
* $Id: keymap.c,v 1.9.2.1 2004/04/14 22:05:41 gespinasse Exp $
*
*/
#include "setup.h"
extern FILE *flog;
extern char *mylog;
extern char **ctr;
extern int automode;
#define MAX_FILENAMES 5000
#define KEYMAPROOT "/usr/share/kbd/keymaps/i386/"
static int filenamecount;
static char *filenames[MAX_FILENAMES];
static char *displaynames[MAX_FILENAMES];
static int process(char *prefix, char *path);
static int cmp(const void *s1, const void *s2);
int handlekeymap(void)
{
int c;
int choice;
char *temp;
struct keyvalue *kv = initkeyvalues();
int rc;
int result;
char keymap[STRING_SIZE];
char commandstring[STRING_SIZE];
filenamecount = 0;
process(KEYMAPROOT "azerty", "");
process(KEYMAPROOT "dvorak", "");
process(KEYMAPROOT "fgGIod", "");
process(KEYMAPROOT "qwerty", "");
process(KEYMAPROOT "qwertz", "");
filenames[filenamecount] = NULL;
qsort(filenames, filenamecount, sizeof(char *), cmp);
for (c = 0; filenames[c]; c++)
{
displaynames[c] = malloc(STRING_SIZE);
if ((temp = strrchr(filenames[c], '/')))
strcpy(displaynames[c], temp + 1);
else
strcpy(displaynames[c], filenames[c]);
if ((temp = strstr(displaynames[c], ".map.gz")))
*temp = '\0';
}
displaynames[c] = NULL;
if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
{
freekeyvalues(kv);
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
return 0;
}
strcpy(keymap, "/usr/share/kbd/keymaps/i386/qwertz/de.map.gz");
findkey(kv, "KEYMAP", keymap);
choice = 0;
for (c = 0; filenames[c]; c++)
{
if (strcmp(keymap, filenames[c]) == 0)
choice = c;
}
rc = newtWinMenu(ctr[TR_KEYBOARD_MAPPING], ctr[TR_KEYBOARD_MAPPING_LONG], 50, 5, 5, 6, displaynames, &choice,
ctr[TR_OK], ctr[TR_CANCEL], NULL);
strcpy(keymap, filenames[choice]);
if (rc != 2)
{
replacekeyvalue(kv, "KEYMAP", keymap);
writekeyvalues(kv, CONFIG_ROOT "/main/settings");
sprintf(commandstring, "/bin/loadkeys %s", keymap);
mysystem(commandstring);
result = 1;
}
else
result = 0;
for (c = 0; filenames[c]; c++)
{
free(filenames[c]);
free(displaynames[c]);
}
freekeyvalues(kv);
return result;
}
static int process(char *prefix, char *path)
{
DIR *dir;
struct dirent *de;
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s%s", prefix, path);
if (!(dir = opendir(newpath)))
{
if (filenamecount > MAX_FILENAMES)
return 1;
filenames[filenamecount] = (char *) strdup(newpath);
filenamecount++;
return 0;
}
while ((de = readdir(dir)))
{
if (de->d_name[0] == '.') continue;
snprintf(newpath, PATH_MAX, "%s/%s", path, de->d_name);
process(prefix, newpath);
}
closedir(dir);
return 1;
}
/* Small wrapper for use with qsort() to sort filename part. */
static int cmp(const void *s1, const void *s2)
{
/* c1 and c2 are copies. */
char *c1 = strdup(* (char **) s1);
char *c2 = strdup(* (char **) s2);
/* point to somewhere in cN. */
char *f1, *f2;
char *temp;
int res;
if ((temp = strrchr(c1, '/')))
f1 = temp + 1;
else
f1 = c1;
if ((temp = strrchr(c2, '/')))
f2 = temp + 1;
else
f2 = c2;
/* bang off the . */
if ((temp = strchr(f1, '.')))
*temp = '\0';
if ((temp = strchr(f2, '.')))
*temp = '\0';
res = strcmp(f1, f2);
free(c1); free(c2);
return res;
}
/* SmoothWall setup program.
*
* This program is distributed under the terms of the GNU General Public
* Licence. See the file COPYING for details.
*
* (c) Lawrence Manning, 2001
* Stuff for setting the keymap.
*
* $Id: keymap.c,v 1.9.2.1 2004/04/14 22:05:41 gespinasse Exp $
*
*/
#include "setup.h"
extern FILE *flog;
extern char *mylog;
extern char **ctr;
extern int automode;
#define MAX_FILENAMES 5000
#define KEYMAPROOT "/lib/kbd/keymaps/i386/"
static int filenamecount;
static char *filenames[MAX_FILENAMES];
static char *displaynames[MAX_FILENAMES];
static int process(char *prefix, char *path);
static int cmp(const void *s1, const void *s2);
int handlekeymap(void)
{
int c;
int choice;
char *temp;
struct keyvalue *kv = initkeyvalues();
int rc;
int result;
char keymap[STRING_SIZE];
char commandstring[STRING_SIZE];
filenamecount = 0;
process(KEYMAPROOT "azerty", "");
process(KEYMAPROOT "dvorak", "");
process(KEYMAPROOT "fgGIod", "");
process(KEYMAPROOT "qwerty", "");
process(KEYMAPROOT "qwertz", "");
filenames[filenamecount] = NULL;
qsort(filenames, filenamecount, sizeof(char *), cmp);
for (c = 0; filenames[c]; c++)
{
displaynames[c] = malloc(STRING_SIZE);
if ((temp = strrchr(filenames[c], '/')))
strcpy(displaynames[c], temp + 1);
else
strcpy(displaynames[c], filenames[c]);
if ((temp = strstr(displaynames[c], ".map.gz")))
*temp = '\0';
}
displaynames[c] = NULL;
if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
{
freekeyvalues(kv);
errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
return 0;
}
strcpy(keymap, "/lib/kbd/keymaps/i386/qwertz/de.map.gz");
findkey(kv, "KEYMAP", keymap);
choice = 0;
for (c = 0; filenames[c]; c++)
{
if (strcmp(keymap, filenames[c]) == 0)
choice = c;
}
rc = newtWinMenu(ctr[TR_KEYBOARD_MAPPING], ctr[TR_KEYBOARD_MAPPING_LONG], 50, 5, 5, 6, displaynames, &choice,
ctr[TR_OK], ctr[TR_CANCEL], NULL);
strcpy(keymap, filenames[choice]);
if (rc != 2)
{
replacekeyvalue(kv, "KEYMAP", keymap);
writekeyvalues(kv, CONFIG_ROOT "/main/settings");
sprintf(commandstring, "/bin/loadkeys %s", keymap);
mysystem(commandstring);
result = 1;
}
else
result = 0;
for (c = 0; filenames[c]; c++)
{
free(filenames[c]);
free(displaynames[c]);
}
freekeyvalues(kv);
return result;
}
static int process(char *prefix, char *path)
{
DIR *dir;
struct dirent *de;
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s%s", prefix, path);
if (!(dir = opendir(newpath)))
{
if (filenamecount > MAX_FILENAMES)
return 1;
filenames[filenamecount] = (char *) strdup(newpath);
filenamecount++;
return 0;
}
while ((de = readdir(dir)))
{
if (de->d_name[0] == '.') continue;
snprintf(newpath, PATH_MAX, "%s/%s", path, de->d_name);
process(prefix, newpath);
}
closedir(dir);
return 1;
}
/* Small wrapper for use with qsort() to sort filename part. */
static int cmp(const void *s1, const void *s2)
{
/* c1 and c2 are copies. */
char *c1 = strdup(* (char **) s1);
char *c2 = strdup(* (char **) s2);
/* point to somewhere in cN. */
char *f1, *f2;
char *temp;
int res;
if ((temp = strrchr(c1, '/')))
f1 = temp + 1;
else
f1 = c1;
if ((temp = strrchr(c2, '/')))
f2 = temp + 1;
else
f2 = c2;
/* bang off the . */
if ((temp = strchr(f1, '.')))
*temp = '\0';
if ((temp = strchr(f2, '.')))
*temp = '\0';
res = strcmp(f1, f2);
free(c1); free(c2);
return res;
}

View File

@@ -21,36 +21,14 @@ char **ctr = NULL;
int automode = 0;
extern char *bz_tr[];
extern char *cs_tr[];
extern char *da_tr[];
extern char *en_tr[];
extern char *es_tr[];
extern char *fi_tr[];
extern char *fr_tr[];
extern char *hu_tr[];
extern char *la_tr[];
extern char *nl_tr[];
extern char *de_tr[];
extern char *tr_tr[];
extern char *it_tr[];
extern char *el_tr[];
extern char *sk_tr[];
extern char *so_tr[];
extern char *sv_tr[];
extern char *no_tr[];
extern char *pl_tr[];
extern char *pt_tr[];
extern char *vi_tr[];
int main(int argc, char *argv[])
{
#ifdef LANG_EN_ONLY
char *shortlangnames[] = { "en", NULL };
char **langtrs[] = { en_tr, NULL };
#elifdef LANG_ALL
char *shortlangnames[] = { "bz", "cs", "da", "de", "en", "es", "fr", "el", "it", "la", "hu", "nl", "no", "pl", "pt", "sk", "so", "fi", "sv", "tr", "vi", NULL };
char **langtrs[] = { bz_tr, cs_tr, da_tr, de_tr, en_tr, es_tr, fr_tr, el_tr, it_tr, la_tr, hu_tr, nl_tr, no_tr, pl_tr, pt_tr, sk_tr, so_tr, fi_tr, sv_tr, tr_tr, vi_tr, NULL };
#else
char *shortlangnames[] = { "de", "en", NULL };
char **langtrs[] = { de_tr, en_tr, NULL };
@@ -68,7 +46,7 @@ int main(int argc, char *argv[])
if (argc >= 2)
mylog = argv[1];
else
mylog = strdup("/root/setup.log");
mylog = strdup("/var/log/setup.log");
if (!(flog = fopen(mylog, "w+")))
{
@@ -131,7 +109,7 @@ int main(int argc, char *argv[])
title[strlen(title) - 1] = '\0';
fclose (f_title);
} else {
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
}
newtDrawRootText(14, 0, title);
newtPushHelpLine(ctr[TR_HELPLINE]);
@@ -214,17 +192,17 @@ int main(int argc, char *argv[])
EXIT:
if (automode != 0)
{
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
if (autook)
newtWinMessage(title, ctr[TR_OK], ctr[TR_SETUP_FINISHED]);
else
newtWinMessage(ctr[TR_WARNING], ctr[TR_OK], ctr[TR_SETUP_NOT_COMPLETE]);
}
fprintf(flog, "Setup program ended.\n");
fflush(flog);
fclose(flog);
newtFinished();
return 0;

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@ int handlerootpassword(void)
return 0;
snprintf(commandstring, STRING_SIZE,
"/bin/echo 'root:%s' | /usr/sbin/chpasswd", password);
"/bin/echo 'root:%s' | /usr/sbin/chpasswd", password);
if (runhiddencommandwithstatus(commandstring, ctr[TR_SETTING_ROOT_PASSWORD]))
{
errorbox(ctr[TR_PROBLEM_SETTING_ROOT_PASSWORD]);
@@ -83,7 +83,7 @@ int getpassword(char *password, char *text)
do
{
done = 1;
sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
rc = newtWinEntries(title, text,
50, 5, 5, 20, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);