Update of /cvsroot/morphix/morphixinstaller/src In directory sc8-pr-cvs1:/tmp/cvs-serv16615 Modified Files: Makefile.am cmdline.c installer.h instlib.c instlib.h main.c Added Files: args.c args.h genlilo.c maincl.c Log Message: adapted installer to build the commandline version seperatly beginnings of including genlilo into the installer --- NEW FILE: args.c --- /* Copyright (C) 2003 Alex de Landgraaf <ale...@xs...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <glib.h> #include <stdio.h> #include <stdarg.h> #include "args.h" #include "installer.h" void print_help() { printf("Usage:\n morphixinstaller --debug | -d\n\t\tPrint debug messages\n\ morphixinstaller --root <path_to_rootpartitiondevice>\n\t\tUse the specified rootpartition\n\ morphixinstaller --swap <part_to_swappartitiondevice>\n\t\tUse the specified swappartition\n\ morphixinstaller --hdd <3-letter-harddiskdevice>\n\t\tUse the specified harddisk\n\ morphixinstaller --nopart\n\t\tDon't partition, go straight to rootpartition selector\n\ morphixinstaller --noswap\n\t\tDon't use swap at all, skip section\n\ morphixinstaller --part-with <path_to_application>\n\t\tWill execute the specified program instead of the default\n\ morphixinstaller --fstype <ext2|ext3|reiserfs|xfs>\n\t\tWill skip filesystemselection\n\ morphixinstaller --hostname <alfanumeric string>\n\t\tUse the specified hostname for installing\n\ morphixinstaller --rootpass <string>\n\t\tUse the specified string as password for the root user\n\ morphixinstaller --user <alfanumeric string> <string>\n\t\tUse the specified string as the username for the user being created, and the string after that for the user's password\n\ morphixinstaller --lilo-mbr\n\t\tUse the selected harddisk for installing lilo on\n\ morphixinstaller --lilo-root\n\t\tUse the selected rootpartition for installing lilo on\n\ morphixinstaller --nolilo\n\t\tDon't install lilo\n\ morphixinstaller --lilo-boot\n\t\tUse the selected bootpartition for installing lilo on\n\ morphixinstaller --ui [cmdline|gtk|auto]\n\t\tUse the selected installer UI. Auto works only with one harddisk, one Linux partition and one Swap partition. Defaults are ext3 for the fs, Morphix for the hostname, morphix for the root password and morph/morph for the username/password. Lilo will be installed to the mbr. You can specify different values by using one of the above arguments. If you don't: MAKE SURE TO CHANGE THE PASSWORDS AFTER INSTALLING! I won't answer any email from people being hacked because they havn't changed their passwords, it is at your own risk!\n\ \n\ You may use any combination of these arguments, note that the lilo-options override eachother, the last one counts\n\ \n\ morphixinstaller --help | -h\n\t\tPrints commandline arguments and exits\n\ \n\ For questions, bugs, feedback or lynching please contact me via www.morphix.org\n\ This program is licensed under the GNU GPL v2, copyright Alex de Landgraaf, 2003\n\n"); } gboolean check_args(int *argcp, char ***argvp) { gint i; gint argc; argc = *argcp; gchar **argv; argv = *argvp; cmdlineargs.no_partitioning = FALSE; cmdlineargs.no_swap_partition = FALSE; cmdlineargs.swappart_set = FALSE; cmdlineargs.rootpart_set = FALSE; cmdlineargs.harddisk_set = FALSE; cmdlineargs.partitioner_set = FALSE; cmdlineargs.fs_set = FALSE; cmdlineargs.hostname_set = FALSE; cmdlineargs.rootpass_set = FALSE; cmdlineargs.user_set = FALSE; cmdlineargs.lilo_set = FALSE; cmdlineargs.ui_set = FALSE; cmdlineargs.ui_type = UI_GTK_TYPE; if (argc == 1) return TRUE; /* a dirty forloop-continue-return construction. couldn't be bothered doing it proper, sorry :) */ for (i = 1; i < argc; i++) { if (strcmp(argv[i],"--debug") == 0 || strcmp(argv[i],"-d") == 0) { debug_switch = 1; continue; } if (strcmp(argv[i],"--help") == 0 || strcmp(argv[i],"-h") == 0) { return FALSE; } if (strcmp(argv[i],"--root") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) >= 15 || !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { printf("Root argument too long or invalid\n"); return FALSE; } strcpy(cmdlineargs.rootpart,argv[i]); cmdlineargs.rootpart_set = TRUE; continue; } if (strcmp(argv[i],"--swap") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) >= 15 || !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { printf("Swap argument too long or invalid\n"); return FALSE; } strcpy(cmdlineargs.swappart,argv[i]); cmdlineargs.swappart_set = TRUE; continue; } if (strcmp(argv[i],"--hdd") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) != 3) { printf("Hdd argument too long or invalid, needs to be 3 letters in length\n"); return FALSE; } strcpy(cmdlineargs.harddisk,argv[i]); cmdlineargs.harddisk_set = TRUE; continue; } if (strcmp(argv[i],"--nopart") == 0) { cmdlineargs.no_partitioning = TRUE; continue; } if (strcmp(argv[i],"--noswap") == 0) { cmdlineargs.no_swap_partition = TRUE; continue; } if (strcmp(argv[i],"--part-with") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) >= 63 || !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { printf("Partitioner argument too long or invalid\n"); return FALSE; } strcpy(cmdlineargs.partitioner,argv[i]); cmdlineargs.partitioner_set = TRUE; continue; } if (strcmp(argv[i],"--fs") == 0) { if (++i >= argc) return FALSE; if ((strcmp(argv[i],"ext2") == 0) || (strcmp(argv[i],"ext3") == 0) || (strcmp(argv[i],"reiserfs") == 0) || (strcmp(argv[i],"xfs") == 0)) { strcpy(cmdlineargs.fs,argv[i]); } else { printf("fs argument invalid\n"); return FALSE; } cmdlineargs.fs_set = TRUE; continue; } if (strcmp(argv[i],"--hostname") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) >= 63) { printf("hostname argument too long or invalid\n"); return FALSE; } gint j; for (j = 0; j < strlen(argv[i]); j++) { if (!g_ascii_isalnum(argv[i][j])) { printf("hostname argument contains invalid char\n"); return FALSE; } } strcpy(cmdlineargs.hostname,argv[i]); cmdlineargs.hostname_set = TRUE; continue; } if (strcmp(argv[i],"--rootpass") == 0) { if (++i >= argc) return FALSE; if (strlen(argv[i]) >= 63) { printf("rootpass argument too long or invalid\n"); return FALSE; } gint j; for (j = 0; j < strlen(argv[i]); j++) { if (!g_ascii_isalnum(argv[i][j])) { printf("rootpass argument contains invalid char\n"); return FALSE; } } strcpy(cmdlineargs.rootpass,argv[i]); cmdlineargs.rootpass_set = TRUE; continue; } if (strcmp(argv[i],"--user") == 0) { if (++i >= argc) { printf("Need username and password\n"); return FALSE; } if (strlen(argv[i]) >= 63) { printf("username argument too long or invalid\n"); return FALSE; } gint j; for (j = 0; j < strlen(argv[i]); j++) { if (!g_ascii_isalnum(argv[i][j])) { printf("username argument contains invalid char\n"); return FALSE; } } strcpy(cmdlineargs.username,argv[i]); if (++i >= argc) { printf("Need username and password\n"); return FALSE; } if (strlen(argv[i]) >= 63) { printf("password argument too long or invalid\n"); return FALSE; } for (j = 0; j < strlen(argv[i]); j++) { if (!g_ascii_isalnum(argv[i][j])) { printf("password argument contains invalid char\n"); return FALSE; } } strcpy(cmdlineargs.userpass,argv[i]); cmdlineargs.user_set = TRUE; continue; } if (strcmp(argv[i],"--lilo-mbr") == 0) { /* lilo_mode: 1 - use selected_harddisk MBR 2 - use selected rootpartition 3 - don't use lilo 4 - use selected bootpartition */ cmdlineargs.lilo_type = 1; cmdlineargs.lilo_set = TRUE; continue; } if (strcmp(argv[i],"--lilo-root") == 0) { cmdlineargs.lilo_type = 2; cmdlineargs.lilo_set = TRUE; continue; } if (strcmp(argv[i],"--nolilo") == 0) { cmdlineargs.lilo_type = 3; cmdlineargs.lilo_set = TRUE; continue; } if (strcmp(argv[i],"--lilo-boot") == 0) { cmdlineargs.lilo_type = 4; cmdlineargs.lilo_set = TRUE; continue; } if (strcmp(argv[i],"--ui") == 0) { if (++i >= argc) return FALSE; if (strcmp(argv[i],"cmdline") == 0) { cmdlineargs.ui_type = UI_CMDLINE_TYPE; cmdlineargs.ui_set = TRUE; continue; } if (strcmp(argv[i],"gtk") == 0) { cmdlineargs.ui_type = UI_GTK_TYPE; cmdlineargs.ui_set = TRUE; continue; } if (strcmp(argv[i],"auto") == 0) { cmdlineargs.ui_type = UI_AUTO_TYPE; cmdlineargs.ui_set = TRUE; continue; } } return FALSE; } } --- NEW FILE: args.h --- #ifndef ARGS_H #define ARGS_H void print_help(); gboolean check_args(int *argcp, char ***argvp); #endif // ARGS_H --- NEW FILE: genlilo.c --- /* copied from genliloconf in Knoppix for integration into the morphix installer could use this to easily generate grub stuff too. Hope to clean this up a bit, maybe make a seperate library for inclusion into the installer, for now it'll stay a standalone application */ #define BC_LILO_CONF "lilo.conf.template" #define BC_RUN_LILO "echo pretend running lilo..." #define APPEND_OPTS "vga=extended" #include <stdio.h> #include <assert.h> #include <ctype.h> #include <string.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mount.h> //#include <linux/fdreg.h> //#include <linux/fd.h> #include "../libfdisk/fdisk.h" #include <stdlib.h> #include <dirent.h> #include <syscall.h> #define DEV_HDA "/dev/hda" #define DEV_I2O_HDA "/dev/i2o/hda" #define DEV_SDA "/dev/sda" #define DEV_RD_C0D0 "/dev/rd/c0d0" #define DEV_IDA_C0D0 "/dev/ida/c0d0" #define DEV_CCISS_C0D0 "/dev/cciss/c0d0" #define DEV_ATARAID_D0 "/dev/ataraid/d0" struct d_choices { char* tag; char* string; int state; }; struct fdisk_partition *Boot; #define PRTBUFSIZE 3364 /* (ceil(log2(80*43)))^2 */ char prtbuf[PRTBUFSIZE]; char *first_ide_disk(void); char *append_opts, *image, *root; struct fdisk_partition *test; char *initrd=NULL; inline int is_filesystem_supported(const char *fstype) { return (syscall(__NR_sysfs, 1, fstype) < 0); } #define BC_LILOTEMPLATE1 \ "# /etc/lilo.conf - See: `lilo(8)' and `lilo.conf(5)',\n" \ "# --------------- `install-mbr(8)', `/usr/share/doc/lilo/',\n" \ "# and `/usr/share/doc/mbr/'.\n" \ "\n" \ "# +---------------------------------------------------------------+\n" \ "# | !! Reminder !! |\n" \ "# | |\n" \ "# | Don't forget to run `lilo' after you make changes to this |\n" \ "# | conffile, `/boot/bootmess.txt', or install a new kernel. The |\n" \ "# | computer will most likely fail to boot if a kernel-image |\n" \ "# | post-install script or you don't remember to run `lilo'. |\n" \ "# | |\n" \ "# +---------------------------------------------------------------+\n" \ "\n" \ "# Support LBA for large hard disks.\n" \ "#\n" \ "lba32\n" \ "\n" \ "# Overrides the default mapping between harddisk names and the BIOS'\n" \ "# harddisk order. Use with caution.\n" \ "%s\n%s\n" \ "# Specifies the boot device. This is where Lilo installs its boot\n" \ "# block. It can be either a partition, or the raw device, in which\n" \ "# case it installs in the MBR, and will overwrite the current MBR.\n" \ "#\n" \ "boot=%s\n" \ "\n" \ "# Specifies the device that should be mounted as root. (`/')\n" \ "#\n" \ "root=%s\n" \ "\n" \ "# Enable map compaction:\n" \ "# Tries to merge read requests for adjacent sectors into a single\n" \ "# read request. This drastically reduces load time and keeps the\n" \ "# map smaller. Using `compact' is especially recommended when\n" \ "# booting from a floppy disk. It is disabled here by default\n" \ "# because it doesn't always work.\n" \ "#\n" \ "# compact\n" \ "\n" \ "# Installs the specified file as the new boot sector\n" \ "# You have the choice between: bmp, compat, menu and text\n" \ "# Look in /boot/ and in lilo.conf(5) manpage for details\n" \ "#\n" \ "install=/boot/boot-menu.b\n" \ "\n" \ "# Specifies the location of the map file\n" \ "#\n" \ "map=/boot/map\n" \ "\n" \ "# You can set a password here, and uncomment the `restricted' lines\n" \ "# in the image definitions below to make it so that a password must\n" \ "# be typed to boot anything but a default configuration. If a\n" \ "# command line is given, other than one specified by an `append'\n" \ "# statement in `lilo.conf', the password will be required, but a\n" \ "# standard default boot will not require one.\n" \ "#\n" \ "# This will, for instance, prevent anyone with access to the\n" \ "# console from booting with something like `Linux init=/bin/sh',\n" \ "# and thus becoming `root' without proper authorization.\n" \ "#\n" \ "# Note that if you really need this type of security, you will\n" \ "# likely also want to use `install-mbr' to reconfigure the MBR\n" \ "# program, as well as set up your BIOS to disallow booting from\n" \ "# removable disk or CD-ROM, then put a password on getting into the\n" \ "# BIOS configuration as well. Please RTFM `install-mbr(8)'.\n" \ "#\n" \ "# password=tatercounter2000\n" \ "\n" \ "# Specifies the number of deciseconds (0.1 seconds) LILO should\n" \ "# wait before booting the first image.\n" \ "#\n" \ "delay=20\n" \ "\n" \ "# You can put a customized boot message up if you like. If you use\n" \ "# `prompt', and this computer may need to reboot unattended, you\n" \ "# must specify a `timeout', or it will sit there forever waiting\n" \ "# for a keypress. `single-key' goes with the `alias' lines in the\n" \ "# `image' configurations below. eg: You can press `1' to boot\n" \ "# `Linux', `2' to boot `LinuxOLD', if you uncomment the `alias'.\n" \ "#\n" \ "# message=/boot/bootmess.txt\n" \ "%s" \ "# prompt\n" \ "# single-key\n" \ "# delay=100\n" \ "# timeout=100\n" \ "\n" \ "# Kernel command line options that apply to all installed images go\n" \ "# here. See: The `boot-prompt-HOWO' and `kernel-parameters.txt' in\n" \ "# the Linux kernel `Documentation' directory.\n" \ "#\n" \ "# append=\"\"\n" \ "%s\n" \ "# Boot up Linux by default.\n" \ "#\n" \ "default=Linux\n" \ "\n" \ "image=%s\n" \ " label=Linux\n" \ " %s\n" #define BC_LILOTEMPLATE3 \ " read-only\n" \ "# restricted\n" \ "# alias=1\n" \ "\n" \ "image=/vmlinuz.old\n" \ " label=LinuxOLD\n" \ " read-only\n" \ " optional\n" \ "# restricted\n" \ "# alias=2\n" \ "\n" \ "# If you have another OS on this machine to boot, you can uncomment the\n" \ "# following lines, changing the device name on the `other' line to\n" \ "# where your other OS' partition is.\n" \ "#\n" \ "# other=/dev/hda4\n" \ "# label=HURD\n" \ "# restricted\n" \ "# alias=3\n" static int run_lilo(char *boot, int fixmap, struct d_choices *others, int o_number) { FILE* filep; int status = 0, i=0; #ifndef _TESTING_ struct stat statbuf; char * size; /* files that we need */ char *files[]={ "/sbin/insmod", "/bin/sh", "/bin/mount", "/bin/umount", "/lib/ld-linux.so.2", "/lib/libc.so.6", "" /* we use the NULL string to find the end */ }; #endif char *append, *prompt=""; char * bootpart_map; char * boot_map; /* if ((filep = fopen(BC_LILO_CONF, "w")) == NULL) { #ifdef _TESTING_ fprintf(stderr, "Cannot open %s: %s\n", BC_LILO_CONF, strerror(errno)); sleep(2); #endif return 1; } */ filep = stdout; /* shouldn't be possible for name to be blank, but would explain Bug #53807 */ // assert(Root->name && Root->name[0]); // assert(boot && boot[0]); boot_map = calloc(1, 32); bootpart_map = calloc(1, 32); if(fixmap==1) { /* harddisk with Boot's location */ char * bootpart_dev = (char *) strndup(Boot->name, 8); /* okay, setting real int13 values for the root and boot devices */ sprintf(boot_map,"disk=%s\nbios=0x80\n", first_ide_disk()); /* if /boot is elsewhere, map it too */ /* if(strcmp(bootpart_dev, first_ide_disk()) != 0) sprintf(bootpart_map,"disk=%s\nbios=0x%i\n", bootpart_dev, *(bootpart_dev+7) - *(boot+7) + 80); */ } else { bootpart_map = "#disk=/dev/sda\n# bios=0x80\n"; boot_map = "#disk=/dev/hde\n# bios=0x81\n"; } INFOMSG("writing lilo.conf with boot of '%s' and root of '%s'%s", boot, root, fixmap ? " and device mapping" : ""); if(o_number > 0) prompt = "prompt\ntimeout=150\n"; else prompt = ""; if (append_opts && strlen (append_opts)) { append = (char *)malloc (strlen (append_opts) + 1 + 10); /* "append=\"" + "\"\n"*/ sprintf (append, "append=\"%s\"\n", append_opts); fprintf(filep, BC_LILOTEMPLATE1, boot_map, bootpart_map, boot, root, prompt, append, image, initrd ? initrd : ""); free (append); } else { fprintf(filep, BC_LILOTEMPLATE1, boot_map, bootpart_map, boot, root, prompt, "", image, initrd ? initrd : "" ); } fprintf(filep, BC_LILOTEMPLATE3); for(i=0; i < o_number; i++) { fprintf(filep, "other=%s\n label=\"%s(%s)\"\n\n", others[i].tag, others[i].string, strrchr(others[i].tag, '/')+1); } fclose(filep); chmod(BC_LILO_CONF, 0640); /*#if !defined _TESTING_ status = execlog(BC_RUN_LILO, LOG_INFO); #endif*/ return status; } /* part_disk_name: return name of partition's disk device, if available */ char *part_disk_name(struct fdisk_partition *part) { return (part->disk ? part->disk->name : NULL); } /* is_first_scsi: return true if partition is on the first SCSI disk */ int is_first_scsi(struct fdisk_partition *part) { char *dname = part_disk_name(part); return dname && (strcmp(dname, DEV_SDA) == 0 || strcmp(dname, DEV_RD_C0D0) == 0 || strcmp(dname, DEV_CCISS_C0D0) == 0 || strcmp(dname, DEV_IDA_C0D0) == 0 || strcmp(dname, DEV_I2O_HDA) == 0 || strcmp(dname, DEV_ATARAID_D0) == 0); } /* is_first_ide: return true if partition is on the first IDE disk */ int is_first_ide(struct fdisk_partition *part) { char *dname = part_disk_name(part); //FIXME - check how ide vs. scsi is handled return dname && strcmp(dname, DEV_HDA) == 0; } /* is_logical_part: return true if partition is an MS-DOS logical partition */ int is_logical_part(struct fdisk_partition *part) { if (part->disk && strcmp(part->disk->partition_format, "msdos") == 0) { char *s, *t; assert(*part->name); /* find the first digit in the part->name, set t to the rest of the string */ for (s = part->name, t = NULL; *s; s++) { if (isdigit(*s)) { t = s; break; } } if (t) { assert(strlen(t) <= 5); return(atoi(t) > 4); } } return 0; } /* !!!! strlen and sizeof are not the same thing. Please don't change this * again !!!!!! -randolph */ /* is_ide: returns true if partition is on an IDE disk */ int is_ide(char *name) { // printf("%s\n",name); return strncmp(name, DEV_HDA, strlen(DEV_HDA) - 1) == 0; // printf("%s, %s, %d, hm...", name, DEV_HDA, strlen(DEV_HDA)); } /* is_scsi: returns true if partition is on a SCSI disk */ int is_scsi(char *name) { return strncmp(name, DEV_SDA, strlen(DEV_SDA) - 1) == 0; } /* is_i2o_scsi: returns true if partition is on a i2o-SCSI disk */ int is_scsii2o(char *name) { return strncmp(name, DEV_I2O_HDA, strlen(DEV_I2O_HDA) - 1) == 0; } /* is_scsird: returns true if partition is on a SCSI disk (/dev/rd/c*) */ int is_scsird(char *name) { return strncmp(name, DEV_RD_C0D0, strlen(DEV_RD_C0D0) - 3) == 0; } /* is_scsiida: returns true if partition is on a SCSI disk (/dev/rd/c*) */ int is_scsiida(char *name) { return strncmp(name, DEV_IDA_C0D0, strlen(DEV_IDA_C0D0) - 3) == 0; } /* is_scsicciss: returns true if partition is on a CCISS disk (/dev/cciss/c*) */ int is_scsicciss(char *name) { return strncmp(name, DEV_CCISS_C0D0, strlen(DEV_CCISS_C0D0) - 3) == 0; } /* is_ataraid: returns true if partition is on a SCSI disk (/dev/ataraid/d*) */ int is_ataraid(char *name) { return strncmp(name, DEV_ATARAID_D0, strlen(DEV_ATARAID_D0) - 3) == 0; } /* Return a string containing the name of the first existing IDE disk. */ char *first_ide_disk(void) { static char disk[] = "/dev/hda"; for (; disk[strlen(disk) - 1] < 'l'; (disk[strlen(disk) - 1])++) if (fdisk_find_disk(disk) != NULL) return disk; return NULL; } /* Return a string containing the name of the first existing SCSI disk. */ char *first_scsi_disk(void) { static char disk[] = "/dev/sda"; for (; disk[strlen(disk) - 1] < 'l'; (disk[strlen(disk) - 1])++) if (fdisk_find_disk(disk) != NULL) return disk; return NULL; } int is_fstype (const char *mount, const char *fs) { FILE *proc; int match=0; char dev[80], dir[80], type[80]; proc = fopen ("/proc/mounts", "r"); if ( proc == NULL ) { // perrorBox(_("Can't read /proc/mounts")); return -1; } while ( EOF != fscanf (proc, "%s %s %s %*s %*i %*i\n", dev, dir, type)) { if (!strncmp (mount, dev, 79)) { match = strncmp (fs, type, 79) ? 0 : 1; break; } if (!strncmp (mount, dir, 79)) { match = strncmp (fs, type, 79) ? 0 : 1; break; } } fclose (proc); return match; } int main(int argc, char *argv[]) { #define ARGMAX 6 int installed_mbr = 0, fix_mapping = 0; char *device = ""; struct d_choices opt[2]; struct stat statbuf; int res; struct d_choices *bootable = NULL; int boot_number=0; char *boot=""; boot = argv[1]; if(argc<ARGMAX-1) { fprintf(stderr, "Usage: genliloconf BootDeviceOrMBR RootDevice AppendOpts KernelImage [miscOptions] \n" "Purpose: generate a lilo.conf.template file scanning all partitions\n" "and putting the bootable into the lilo menu.\n" "miscOptions are added to the primary boot image profile, eg.:\n" "initrd=/path/to/the/initrd-image\n"); return 255; } fdisk_reread(); root = argv[2]; append_opts=argv[3]; image = argv[4]; if(argc=(ARGMAX)) initrd = argv[ARGMAX-1]; /* set device to what we think is the boot disk */ if (is_ide(boot)) device = first_ide_disk (); else if (is_scsi(boot)) device = DEV_SDA; else if (is_scsird(boot)) device = DEV_RD_C0D0; else if (is_scsiida(boot)) device = DEV_IDA_C0D0; else if (is_scsii2o(boot)) device = DEV_I2O_HDA; else if (is_scsicciss(boot)) device = DEV_CCISS_C0D0; else if (is_ataraid(boot)) device = DEV_ATARAID_D0; else { /*device = inputBox(_("The attempt to deduce what your boot disk is failed. " "Please enter the name of your boot disk, for instance, " "'/dev/hda' or '/dev/sda'."), _("Choose Boot Disk"), DEV_HDA); if (! NAME_ISBLK(device, &statbuf) ) { vaproblemBox(_("Invalid Boot Disk"), _("There is no block device '%s'."), device);*/ return 1; // } } //printf("fuck, was ist hier los: %s\n", boot); //return 1; /* XFS stores the superblock in the very first block of the filesystem. This means that installing LILO on a partition containing an XFS superblock will destroy the filesystem. So we can only install onto the MBR on ia32 systems when we're using XFS. */ /* if (is_xfs) { boot = device; installed_mbr = 1; };* else { opt[0].tag = device; opt[0].string = _("Install LILO in the MBR (use this if unsure)."); opt[1].tag = Boot->name; opt[1].string = _("Install LILO in the boot partition's boot sector."); if (Boot == Root) opt[1].string = _("Install LILO in the root partition's boot sector."); snprintf(prtbuf, sizeof(prtbuf), _("LILO can be installed either into the master boot record (MBR), or into the %s boot block. If installed into the MBR, LILO will take control of the boot process. If you choose not to install LILO into the MBR, you will have the opportunity later on to install an alternative MBR program (for bootstrapping LILO).\n"), Boot->name); if ((res = menuBox(prtbuf, _("Where should the LILO boot loader be installed?"), opt, 2, 1)) == -1) return 0; //boot = opt[res].tag; installed_mbr = (res == 0); }*/ if (! NAME_ISBLK(boot, &statbuf) ) { fprintf(stderr,_("Invalid Boot Disk"), _("There is no block device '%s'. You need to try this step again " "with different choices, or perhaps make the device by hand."), boot); return 1; } /* if there is no SCSI hd, no /dev/hda disk, but another IDE harddisks, * this looks like the typical bios-mapping situation. Workaround... */ /* But do not do this on ATARAID, there we should trust lilo */ sprintf(prtbuf, _("Your first IDE harddisk is not connected as the primary master device (/dev/hda). To get around this, most BIOS setups enable emulation so that the first disk is seen as IDE-0 in the boot environment. This emulation cannot be detected by Linux or LILO. However, we can define %s as the first hard disk in the lilo configuration to allow LILO to take advantage of the emulation. If you think your BIOS works this way or if you installed boot management software to enable this emulation, you probably want to say yes. Would you like to enable this mapping?\n\n"), first_ide_disk()); if( (first_scsi_disk() == NULL) && (first_ide_disk() != NULL) && (strcmp(first_ide_disk(), DEV_HDA) != 0) && (!is_ataraid(boot)) /*&& ( yesNoBox(prtbuf, _("Virtual IDE device mapping")) ) */ ) { fix_mapping=1; goto idemapped; } fix_mapping=0; idemapped: /* check for booting from SCSI but we also have /dev/hda if ( is_first_scsi(Boot) && fdisk_find_disk(DEV_HDA) && ! yesNoBox(_("With your current configuration, LILO will try to boot " "from your first SCSI disk, but your system also has a " "master IDE disk at the primary IDE controller. " "It's possible that your BIOS doesn't support that.\n\n" "Do you want to install the MBR anyway?"), _("Problem")) ) { return 1; } */ /* screen is sometimes not cleared, forcing */ // newtCls(); /* begin other-detection */ if(fdisk_partitions != NULL) { struct fdisk_partition *testpart = fdisk_partitions; char bootmagic[2]; FILE *fd; bootable = (struct d_choices *) malloc(20*sizeof(struct d_choices)); boot_number=0; while(testpart) { // printf("teste: %s\n", testpart->name); bzero(bootmagic, 2); if( (!strcmp(testpart->name, root)) || testpart->type == 0x05 ||testpart->type == 0x0f) goto nextone; // skip Root, skip extended partitions fd = fopen(testpart->name, "r"); if (!fd) goto nextone; fseek (fd, 510, SEEK_SET); fread (bootmagic, 1, 2, fd); if(!strncmp(bootmagic, "U\252", 2)) { /* we have one */ char *type; fprintf(stderr, "part: %s, typ: %i\n", testpart->name, testpart->type); switch (testpart->type) { case 0x83: type = "Linux"; break; case 0x41: case 0x81: type = "Minix"; break; case 0x07: type = "WinNT"; break; case 0x0c: case 0x0b: type = "Windows"; break; case 0x06: case 0x04: type = "Win/DOS"; break; case 0x01: type = "DOS"; break; default: type = "Other"; } bootable[boot_number].tag = testpart->name; bootable[boot_number].state = 0; bootable[boot_number++].string = type; //FIXME } fclose(fd); nextone: testpart = testpart->next; } /* if(boot_number) { int status; struct d_choices options[3]; options[0].tag = _("Include"); options[0].state = 0; options[0].string = _("Put all into the menu"); options[1].tag = _("View"); options[1].state = 0; options[1].string = _("Show the list of bootable partitions"); options[2].tag = _("Ignore"); options[2].state = 0; options[2].string = _("Do not include any other partition"); redisplay_options: status = menuBox(_("LILO setup discovered boot signatures on other partitions in your system. If you installed other operating systems on this machine, you may want to include them in the boot menu. Please choose how to handle them: "), _("Other bootable partitions"), options, 3, 0); switch (status) { case 0: break; case 1: { char * buf; int i; buf = (char *) calloc (boot_number, 50); for(i=0; i< boot_number; i++) { strcat(buf, "\t"); strcat(buf, bootable[i].tag); strcat(buf, "("); strcat(buf, bootable[i].string); strcat(buf, ")\n"); } sprintf(prtbuf, _("The following partitions seem to be bootable and would be added to the boot menu:\n\n%s"), buf); problemBox(prtbuf, _("Other bootable partitions")); free(buf); } goto redisplay_options; case 2: boot_number=0; break; default: boot_number=0; return 1; /* Cancelled, failed, whatever } }*/ } return run_lilo(boot, fix_mapping, bootable, boot_number); } --- NEW FILE: maincl.c --- /* Copyright (C) 2003 Alex de Landgraaf <ale...@xs...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <glib.h> #include <stdio.h> #include <stdarg.h> #include "installer.h" #include "instlib.h" #include "cmdline.h" #include "args.h" int debug(const char *fmt, ...) { int d; va_list args; va_start(args, fmt); if (debug_switch == 1) { d = vfprintf(stdout,fmt,args); va_end(args); return d; } va_end(args); return 0; } int main (int argc, char *argv[]) { int cmdline = 0; debug_switch = 0; if (!check_args(&argc, &argv)) { print_help(); return 1; } if (cmdlineargs.ui_set == TRUE && cmdlineargs.ui_type == UI_AUTO_TYPE) { /* Auto works only when root, swap, hdd, nopart, fstype, hostname, rootpass, user, and a lilo option are set. If not, you will need to supply input (for now) */ if (cmdlineargs.harddisk_set == FALSE || cmdlineargs.no_partitioning == FALSE || cmdlineargs.hostname_set == FALSE || cmdlineargs.rootpass_set == FALSE || cmdlineargs.user_set == FALSE || cmdlineargs.lilo_set == FALSE) { printf("Auto install doesn't have the necessary commandline arguments\n"); print_help(); return 1; } } StoreKernelVersion(); start_cmdline_iface(); return 0; } Index: Makefile.am =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 19 Sep 2003 14:34:25 -0000 1.5 --- Makefile.am 7 Jan 2004 23:12:46 -0000 1.6 *************** *** 6,10 **** @PACKAGE_CFLAGS@ ! bin_PROGRAMS = morphixinstaller morphixinstaller_SOURCES = \ --- 6,20 ---- @PACKAGE_CFLAGS@ ! bin_PROGRAMS = morphixinstaller morphixinstallercl genliloconf ! ! genliloconf_SOURCES = \ ! genlilo.c ! ! morphixinstallercl_SOURCES = \ ! maincl.c \ ! cmdline.c cmdline.h \ ! installer.h \ ! args.c args.h \ ! instlib.h instlib.c morphixinstaller_SOURCES = \ *************** *** 13,18 **** interface.c interface.h \ callbacks.c callbacks.h \ installer.h instlib.c instlib.h \ ! cmdline.h cmdline.c morphixinstaller_LDFLAGS = -pthread --- 23,36 ---- interface.c interface.h \ callbacks.c callbacks.h \ + args.c args.h \ installer.h instlib.c instlib.h \ ! cmdline.h cmdline.c ! ! genliloconf_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) ! ! morphixinstallercl_LDFLAGS = -pthread ! ! morphixinstallercl_LDADD = @PACKAGE_LIBS@ -lcrypt -lgthread-2.0 -lglib-2.0 $(INTLLIBS) ! morphixinstaller_LDFLAGS = -pthread Index: cmdline.c =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/cmdline.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cmdline.c 26 Oct 2003 22:56:18 -0000 1.2 --- cmdline.c 7 Jan 2004 23:12:46 -0000 1.3 *************** *** 7,11 **** #endif ! #include <gtk/gtk.h> gchar *ask_harddisk() { --- 7,11 ---- #endif ! #include <glib.h> gchar *ask_harddisk() { Index: installer.h =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/installer.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** installer.h 26 Oct 2003 22:56:18 -0000 1.7 --- installer.h 7 Jan 2004 23:12:46 -0000 1.8 *************** *** 15,27 **** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #ifndef MORPHIX_INSTALLER_H ! #define MORPHIX_INSTALLER_H ! #define INSTALLER_VERSION 0.01 ! #define FS_MINIMUM 350 ! #define SWAP_MINIMUM 32 - #define TEMPLATE_FILENAME "knx-templates-0.37.tgz" #define ROOT_MOUNTPOINT "/mnt/target" #define LOOP_MOUNTPOINT_1 "/tmp/l1" --- 15,28 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! #ifndef INSTALLER_H ! #define INSTALLER_H ! // #define INSTALLER_VERSION 0.1 ! // #define FS_MINIMUM 350 ! // #define SWAP_MINIMUM 32 ! ! // #define TEMPLATE_FILENAME "knx-templates-0.37.tgz" #define ROOT_MOUNTPOINT "/mnt/target" #define LOOP_MOUNTPOINT_1 "/tmp/l1" *************** *** 32,41 **** #define TMP_FILENAME "/tmp/hdinst.tmp" ! #include <gtk/gtk.h> gint debug_switch; #define UI_CMDLINE_TYPE 0 #define UI_GTK_TYPE 1 #define UI_AUTO_TYPE 2 struct cmdlineargs_struct { gchar rootpart[16]; --- 33,46 ---- #define TMP_FILENAME "/tmp/hdinst.tmp" ! #include <glib.h> gint debug_switch; + + /* Ability for cli/gui switching disabled */ #define UI_CMDLINE_TYPE 0 #define UI_GTK_TYPE 1 #define UI_AUTO_TYPE 2 + + /* Save all options given on the commandline */ struct cmdlineargs_struct { gchar rootpart[16]; *************** *** 65,74 **** gint lilo_type; } cmdlineargs; - - ! void StoreKernelVersion(); ! gboolean CheckRoot(); ! void ShowError(); int debug(const char *fmt, ...); #endif --- 70,76 ---- gint lilo_type; } cmdlineargs; ! /* simple printf-replacement */ int debug(const char *fmt, ...); + #endif Index: instlib.c =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/instlib.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** instlib.c 26 Oct 2003 22:56:18 -0000 1.9 --- instlib.c 7 Jan 2004 23:12:46 -0000 1.10 *************** *** 795,799 **** */ ! void SetupLilo(gint lilo_mode) { // lilo.conf shouldn't be hardcoded to executable gchar lilo_conf[4092]; --- 795,799 ---- */ ! gboolean SetupLilo(gint lilo_mode) { // lilo.conf shouldn't be hardcoded to executable gchar lilo_conf[4092]; *************** *** 806,810 **** if (lilo_mode == 3) { /* lilo won't be used, return */ ! return; } /* Install LILO --- 806,810 ---- if (lilo_mode == 3) { /* lilo won't be used, return */ ! return TRUE; } /* Install LILO *************** *** 864,869 **** debug("Exec: %s\n",cmdline); if (g_spawn_command_line_sync(cmdline,&outbuffer,NULL,&exitstatus,NULL) == FALSE) { ! debug("Error occured executing command\n"); ! ShowError(outbuffer); } sprintf(cmdline,"%s/etc/lilo.conf",ROOT_MOUNTPOINT); --- 864,870 ---- debug("Exec: %s\n",cmdline); if (g_spawn_command_line_sync(cmdline,&outbuffer,NULL,&exitstatus,NULL) == FALSE) { ! debug("Error occured executing command:\n"); ! debug(outbuffer); ! debug("\n"); } sprintf(cmdline,"%s/etc/lilo.conf",ROOT_MOUNTPOINT); *************** *** 1030,1033 **** --- 1031,1035 ---- sprintf(cmdline,"lilo -r %s",ROOT_MOUNTPOINT); ExecuteCommand(cmdline); + return TRUE; } *************** *** 1040,1044 **** /* sprintf(cmdline,"%s/etc/inittab",ROOT_MOUNTPOINT); file =fopen(cmdline,"a"); ! // standart Debian inittab already contains this stuff // add getty's so each console has it's login prompt fprintf(file,"2:2345:respawn:/sbin/getty 38400 tty2\n"); --- 1042,1046 ---- /* sprintf(cmdline,"%s/etc/inittab",ROOT_MOUNTPOINT); file =fopen(cmdline,"a"); ! // standard Debian inittab already contains this stuff // add getty's so each console has it's login prompt fprintf(file,"2:2345:respawn:/sbin/getty 38400 tty2\n"); *************** *** 1125,1130 **** } if (g_spawn_command_line_sync(cmdline,&outbuffer,NULL,&exitstatus,NULL) == FALSE) { ! debug("Error occured executing command\n"); ! ShowError(outbuffer); } sprintf(cmdline,"%s/etc/lilo.conf",ROOT_MOUNTPOINT); --- 1127,1133 ---- } if (g_spawn_command_line_sync(cmdline,&outbuffer,NULL,&exitstatus,NULL) == FALSE) { ! debug("Error occured executing command:\n"); ! debug(outbuffer); ! debug("\n"); } sprintf(cmdline,"%s/etc/lilo.conf",ROOT_MOUNTPOINT); *************** *** 1144,1148 **** sprintf(cmdline,"cp /tmp/lilo.conf %s/etc/lilo.conf",ROOT_MOUNTPOINT); ExecuteCommand(cmdline); ! } --- 1147,1151 ---- sprintf(cmdline,"cp /tmp/lilo.conf %s/etc/lilo.conf",ROOT_MOUNTPOINT); ExecuteCommand(cmdline); ! return TRUE; } Index: instlib.h =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/instlib.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** instlib.h 24 Sep 2003 23:23:03 -0000 1.4 --- instlib.h 7 Jan 2004 23:12:46 -0000 1.5 *************** *** 1,6 **** ! #ifndef INSTALLER_INSTLIB_H ! #define INSTALLER_INSTLIB_H ! #include <gtk/gtk.h> #define REAL_INSTALL --- 1,6 ---- ! #ifndef INSTLIB_H ! #define INSTLIB_H ! #include <glib.h> #define REAL_INSTALL *************** *** 173,177 **** */ ! void SetupLilo(gint lilo_mode); /* --- 173,177 ---- */ ! gboolean SetupLilo(gint lilo_mode); /* Index: main.c =================================================================== RCS file: /cvsroot/morphix/morphixinstaller/src/main.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.c 22 Aug 2003 22:25:23 -0000 1.7 --- main.c 7 Jan 2004 23:12:46 -0000 1.8 *************** *** 22,25 **** --- 22,26 ---- #include <stdio.h> #include <stdarg.h> + #include "args.h" #include "interface.h" #include "support.h" *************** *** 47,303 **** GtkWidget *HelpDialog; GtkWidget *SelectPartExpert; - - void print_help() { - printf("Usage:\n morphixinstaller --debug | -d\n\t\tPrint debug messages\n\ - morphixinstaller --root <path_to_rootpartitiondevice>\n\t\tUse the specified rootpartition\n\ - morphixinstaller --swap <part_to_swappartitiondevice>\n\t\tUse the specified swappartition\n\ - morphixinstaller --hdd <3-letter-harddiskdevice>\n\t\tUse the specified harddisk\n\ - morphixinstaller --nopart\n\t\tDon't partition, go straight to rootpartition selector\n\ - morphixinstaller --noswap\n\t\tDon't use swap at all, skip section\n\ - morphixinstaller --part-with <path_to_application>\n\t\tWill execute the specified program instead of the default\n\ - morphixinstaller --fstype <ext2|ext3|reiserfs|xfs>\n\t\tWill skip filesystemselection\n\ - morphixinstaller --hostname <alfanumeric string>\n\t\tUse the specified hostname for installing\n\ - morphixinstaller --rootpass <string>\n\t\tUse the specified string as password for the root user\n\ - morphixinstaller --user <alfanumeric string> <string>\n\t\tUse the specified string as the username for the user being created, and the string after that for the user's password\n\ - morphixinstaller --lilo-mbr\n\t\tUse the selected harddisk for installing lilo on\n\ - morphixinstaller --lilo-root\n\t\tUse the selected rootpartition for installing lilo on\n\ - morphixinstaller --nolilo\n\t\tDon't install lilo\n\ - morphixinstaller --lilo-boot\n\t\tUse the selected bootpartition for installing lilo on\n\ - morphixinstaller --ui [cmdline|gtk|auto]\n\t\tUse the selected installer UI. Auto works only with one harddisk, one Linux partition and one Swap partition. Defaults are ext3 for the fs, Morphix for the hostname, morphix for the root password and morph/morph for the username/password. Lilo will be installed to the mbr. You can specify different values by using one of the above arguments. If you don't: MAKE SURE TO CHANGE THE PASSWORDS AFTER INSTALLING! I won't answer any email from people being hacked because they havn't changed their passwords, it is at your own risk!\n\ - \n\ - You may use any combination of these arguments, note that the lilo-options override eachother, the last one counts\n\ - \n\ - morphixinstaller --help | -h\n\t\tPrints commandline arguments and exits\n\ - \n\ - For questions, bugs, feedback or lynching please contact me via www.morphix.org\n\ - This program is licensed under the GNU GPL v2, copyright Alex de Landgraaf, 2003\n\n"); - } - - gboolean check_args(int *argcp, char ***argvp) { - gint i; - gint argc; - argc = *argcp; - gchar **argv; - argv = *argvp; - cmdlineargs.no_partitioning = FALSE; - cmdlineargs.no_swap_partition = FALSE; - cmdlineargs.swappart_set = FALSE; - cmdlineargs.rootpart_set = FALSE; - cmdlineargs.harddisk_set = FALSE; - cmdlineargs.partitioner_set = FALSE; - cmdlineargs.fs_set = FALSE; - cmdlineargs.hostname_set = FALSE; - cmdlineargs.rootpass_set = FALSE; - cmdlineargs.user_set = FALSE; - cmdlineargs.lilo_set = FALSE; - cmdlineargs.ui_set = FALSE; - cmdlineargs.ui_type = UI_GTK_TYPE; - if (argc == 1) - return; - - /* - a dirty forloop-continue-return construction. - couldn't be bothered doing it proper, sorry :) - */ - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i],"--debug") == 0 || - strcmp(argv[i],"-d") == 0) { - debug_switch = 1; - continue; - } - if (strcmp(argv[i],"--help") == 0 || - strcmp(argv[i],"-h") == 0) { - return FALSE; - } - if (strcmp(argv[i],"--root") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) >= 15 || - !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { - printf("Root argument too long or invalid\n"); - return FALSE; - } - strcpy(cmdlineargs.rootpart,argv[i]); - cmdlineargs.rootpart_set = TRUE; - continue; - } - if (strcmp(argv[i],"--swap") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) >= 15 || - !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { - printf("Swap argument too long or invalid\n"); - return FALSE; - } - strcpy(cmdlineargs.swappart,argv[i]); - cmdlineargs.swappart_set = TRUE; - continue; - } - if (strcmp(argv[i],"--hdd") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) != 3) { - printf("Hdd argument too long or invalid, needs to be 3 letters in length\n"); - return FALSE; - } - strcpy(cmdlineargs.harddisk,argv[i]); - cmdlineargs.harddisk_set = TRUE; - continue; - } - if (strcmp(argv[i],"--nopart") == 0) { - cmdlineargs.no_partitioning = TRUE; - continue; - } - if (strcmp(argv[i],"--noswap") == 0) { - cmdlineargs.no_swap_partition = TRUE; - continue; - } - if (strcmp(argv[i],"--part-with") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) >= 63 || - !g_file_test(argv[i],G_FILE_TEST_EXISTS)) { - printf("Partitioner argument too long or invalid\n"); - return FALSE; - } - strcpy(cmdlineargs.partitioner,argv[i]); - cmdlineargs.partitioner_set = TRUE; - continue; - } - if (strcmp(argv[i],"--fs") == 0) { - if (++i >= argc) - return FALSE; - if ((strcmp(argv[i],"ext2") == 0) || (strcmp(argv[i],"ext3") == 0) || (strcmp(argv[i],"reiserfs") == 0) || (strcmp(argv[i],"xfs") == 0)) { - strcpy(cmdlineargs.fs,argv[i]); - } else { - printf("fs argument invalid\n"); - return FALSE; - } - cmdlineargs.fs_set = TRUE; - continue; - } - if (strcmp(argv[i],"--hostname") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) >= 63) { - printf("hostname argument too long or invalid\n"); - return FALSE; - } - gint j; - for (j = 0; j < strlen(argv[i]); j++) { - if (!g_ascii_isalnum(argv[i][j])) { - printf("hostname argument contains invalid char\n"); - return FALSE; - } - } - strcpy(cmdlineargs.hostname,argv[i]); - cmdlineargs.hostname_set = TRUE; - continue; - } - if (strcmp(argv[i],"--rootpass") == 0) { - if (++i >= argc) - return FALSE; - if (strlen(argv[i]) >= 63) { - printf("rootpass argument too long or invalid\n"); - return FALSE; - } - gint j; - for (j = 0; j < strlen(argv[i]); j++) { - if (!g_ascii_isalnum(argv[i][j])) { - printf("rootpass argument contains invalid char\n"); - return FALSE; - } - } - strcpy(cmdlineargs.rootpass,argv[i]); - cmdlineargs.rootpass_set = TRUE; - continue; - } - if (strcmp(argv[i],"--user") == 0) { - if (++i >= argc) { - printf("Need username and password\n"); - return FALSE; - } - if (strlen(argv[i]) >= 63) { - printf("username argument too long or invalid\n"); - return FALSE; - } - gint j; - for (j = 0; j < strlen(argv[i]); j++) { - if (!g_ascii_isalnum(argv[i][j])) { - printf("username argument contains invalid char\n"); - return FALSE; - } - } - strcpy(cmdlineargs.username,argv[i]); - - if (++i >= argc) { - printf("Need username and password\n"); - return FALSE; - } - if (strlen(argv[i]) >= 63) { - printf("password argument too long or invalid\n"); - return FALSE; - } - for (j = 0; j < strlen(argv[i]); j++) { - if (!g_ascii_isalnum(argv[i][j])) { - printf("password argument contains invalid char\n"); - return FALSE; - } - } - strcpy(cmdlineargs.userpass,argv[i]); - cmdlineargs.user_set = TRUE; - - continue; - } - if (strcmp(argv[i],"--lilo-mbr") == 0) { - /* - lilo_mode: - 1 - use selected_harddisk MBR - 2 - use selected rootpartition - 3 - don't use lilo - 4 - use selected bootpartition - */ - cmdlineargs.lilo_type = 1; - cmdlineargs.lilo_set = TRUE; - continue; - } - if (strcmp(argv[i],"--lilo-root") == 0) { - cmdlineargs.lilo_type = 2; - cmdlineargs.lilo_set = TRUE; - continue; - } - if (strcmp(argv[i],"--nolilo") == 0) { - cmdlineargs.lilo_type = 3; - cmdlineargs.lilo_set = TRUE; - continue; - } - if (strcmp(argv[i],"--lilo-boot") == 0) { - cmdlineargs.lilo_type = 4; - cmdlineargs.lilo_set = TRUE; - continue; - } - if (strcmp(argv[i],"--ui") == 0) { - if (++i >= argc) - return FALSE; - if (strcmp(argv[i],"cmdline") == 0) { - cmdlineargs.ui_type = UI_CMDLINE_TYPE; - cmdlineargs.ui_set = TRUE; - continue; - } - if (strcmp(argv[i],"gtk") == 0) { - cmdlineargs.ui_type = UI_GTK_TYPE; - cmdlineargs.ui_set = TRUE; - continue; - } - if (strcmp(argv[i],"auto") == 0) { - cmdlineargs.ui_type = UI_AUTO_TYPE; - cmdlineargs.ui_set = TRUE; - continue; - } - } - return FALSE; - } - } int debug(const char *fmt, ...) { --- 48,51 ---- |