diff -U 4 -H -b -w -B -E -d -i -r kdm-3.5.4-orig/kdm/backend/bootman.c kdm-3.5.4/kdm/backend/bootman.c --- kdm-3.5.4-orig/kdm/backend/bootman.c 2006-08-30 17:41:12.000000000 +0200 +++ kdm-3.5.4/kdm/backend/bootman.c 2006-08-30 17:50:20.000000000 +0200 @@ -77,28 +77,30 @@ static int getGrub( char ***opts, int *def, int *cur ) { FILE *f; - char *ptr; + char *ptr, *linp; int len; char line[1000]; - if (!grub && !(grub = locate( "grub" ))) + if (!grub && !(grub = locate( "grub-set-default" ))) return BO_NOMAN; *def = 0; *cur = -1; *opts = initStrArr( 0 ); if (!(f = fopen( GRUB_MENU, "r" ))) return errno == ENOENT ? BO_NOMAN : BO_IO; - while ((len = fGets( line, sizeof(line), f )) != -1) - if ((ptr = match( line, &len, "default", 7 ))) + while ((len = fGets( line, sizeof(line), f )) != -1) { + for (linp = line; isspace(*linp); linp++, len--); + if ((ptr = match( linp, &len, "default", 7 ))) *def = atoi( ptr ); - else if ((ptr = match( line, &len, "title", 5 ))) { + else if ((ptr = match( linp, &len, "title", 5 ))) { for (; isspace( ptr[len - 1] ); len--); *opts = addStrArr( *opts, ptr, len ); } + } fclose( f ); return BO_OK; } @@ -129,21 +131,16 @@ static void commitGrub( void ) { - FILE *f; - int pid; - static const char *args[] = { 0, "--batch", "--no-floppy", 0 }; + char command[256]; if (sdRec.bmstamp != mTime( GRUB_MENU ) && setGrub( sdRec.osname, &sdRec ) != BO_OK) return; - args[0] = grub; - if ((f = pOpen( (char **)args, 'w', &pid ))) { - fprintf( f, "savedefault --default=%d --once\n", sdRec.osindex ); - pClose( f, pid ); - } + sprintf(command, "%s %d", grub, sdRec.osindex); + system(command); } static char *lilo;