Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 03 Mar 2015, 08:56
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Puppy Grub legacy hidden or seldom used functions
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Wed 24 Dec 2014, 17:31    Post subject:  Puppy Grub legacy hidden or seldom used functions  

Puppy's Grub-0.97 is actually an Ubuntu-Patched Grub .

It has the funny quiet option .

Funny , because it is useless :

Set on by default in /stage2/builtins.c
Code:
+/* Whether to quiet boot messages or not. */
+int quiet_boot = 1;


and does not even simple toggle like the 'debug' function .
Just sets on again
Code:
+/* quietboot */
+static int
+quietboot_func (char *arg, int flags)
+{
+  quiet_boot = 1;
+  return 0;
+}
+
+static struct builtin builtin_quietboot =
+{
+  "quiet",
+  quietboot_func,
+  BUILTIN_CMDLINE | BUILTIN_HELP_LIST,
+  "quietboot",
+  "Quiet boot messages."
+};


Laughing and behold "quietboot" is not the command - it is "quiet" .


Then there is viewport :

Code:
+    /* minimum size is 65 colums and 16 rows */
+    if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1 > 30)
+       return 1;

The comment is misleading, it is actually 66 that is executed .
Maximum is
Code:
viewport 0 0 80 30

That should show 17 menu-entries .
Minimum viewports are
Code:
viewport 0 0 66 16
viewport 14 14 80 30


A viewport in the middle of x would have this code:
Code:
viewport 7 0 73 30


There is not much empty space to gain by these dimensions .
minimum 16 lines for y would show 3 menu entries .
3 lines apparently the minimum to show up and down arrows .


Now setkey :
Setkey maps the first key onto the second .
But does not remap the second key onto the first .
On a qwertz keyboard it is almost lethal to
Code:
setkey z y

beacuse the y-key gets replaced by the z-key .
Now there are two z-keys to use , but the y-key is lost .
Grub-0.97 has a
Code:
shared.h:#define HISTORY_SIZE           5

So before experimenting with the setkey command in the grub shell
run simply
Code:
setkey

first, to be able to revoke the setkey-command by using the arrow up key
[ If no argument is specified, reset key mappings. ]

If you see setkey examples like
Code:
setkey    y z     
setkey    z y    
setkey    Y Z    
setkey    Z Y

like here : http://debiananwenderhandbuch.de/administration.html at debian, be aware !
And people want Linux in Space .. Twisted Evil

_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2334

PostPosted: Thu 25 Dec 2014, 04:26    Post subject:  

Linux is in space and has been for a long time. Would you rather have CPM(Appollo) or WindowsME?
Back to top
View user's profile Send private message 
darry1966

Joined: 26 Feb 2012
Posts: 662
Location: New Zealand

PostPosted: Thu 25 Dec 2014, 19:16    Post subject:  

Nah MikeOS.
_________________
Using AnitaOS and Dpup486 Frugal and Semplice LXDE
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Fri 26 Dec 2014, 19:45    Post subject:  

Some pics about setkey, quiet (recompiled with toggle code), and viewport :
viewport-0-0-66-30-squiggles-533x400xRGBx60%.JPG
 Description   
 Filesize   34.49 KB
 Viewed   98 Time(s)

viewport-0-0-66-30-squiggles-533x400xRGBx60%.JPG

Quiet-recompiled-533x400xRGBx60%.JPG
 Description   
 Filesize   18.88 KB
 Viewed   101 Time(s)

Quiet-recompiled-533x400xRGBx60%.JPG

quiet-unset-533x400xRGBx60%.JPG
 Description   
 Filesize   19.6 KB
 Viewed   101 Time(s)

quiet-unset-533x400xRGBx60%.JPG

Grub-recompiled-quiet-toggle.JPG
 Description   
 Filesize   20.35 KB
 Viewed   100 Time(s)

Grub-recompiled-quiet-toggle.JPG

setkeyz-533x400xRGBx60%.JPG
 Description   
 Filesize   15.21 KB
 Viewed   99 Time(s)

setkeyz-533x400xRGBx60%.JPG


_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Fri 26 Dec 2014, 19:54    Post subject: hiddenmenu  

Howto hiddenmenu

hiddenmenu command in menu.lst is useful in that sort of combination:

Code:

hiddenmenu
timeout 0

default 0
fallback 1 2 3

title "Enter password"
 password woofwoof
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Enter password"
 password woofwoof
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Enter password"
 password woofwoof
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Three times password failed"
 halt

What the code does :
Does not show the menu,
jumps immediately to title nr 1 ( 0 in grub arithmetic ),
which is neccessary to prevent your brother to hit the ESC-key,
to close the timeout and show the menu and edit the menuentries
to either delete the password line or read the password phrase,
asks for a password,
if password is right,
uses a second configfile called menu-main.lst .
If password is not right, asks up to two times
more for a password.
If the third password attempt failed,
jumps to title nr 4 and halts the computer ( in my cases really poweroffs ) .


What it needs :
a /boot/grub/menu.lst with just the above code,
a second real menu.lst with bootable title lines.

I would suggest to rename the existing menu.lst,
create the new menu.lst,
with configfile lines pointing to the real menu.lst (named menu-main.lst in the above code) .
Make sure it points to the right disk-nr,partition-nr .
Easy on USB partition nr 1: If BIOS set to seek USB first,
hdX is always hd0 and partition1 hdX,Y is hdX,0 (hd0,0) in this case.

If the real menu-main.lst has a timeout entry , then
there would show up this interactive line :
Code:

  /* If the timeout was expired or wasn't set, force to show the menu
     interface. */
  if (grub_timeout < 0)
    show_menu = 1;

  /* If SHOW_MENU is false, don't display the menu until ESC is pressed.  */
  if (! show_menu)
< SNIP >
                * Print a message.  */
              grub_printf ("\rPress `ESC' to enter the menu... %d   ",
                           grub_timeout);
            }
        }
    }

  /* Only display the menu if the user wants to see it. */
  if (show_menu)
    {

by default show_menu is set
Code:

/* Whether to show the menu or not.  */
int show_menu = 1;
3times-passwd-533x400xRGBx60%.JPG
 Description   
 Filesize   15.53 KB
 Viewed   98 Time(s)

3times-passwd-533x400xRGBx60%.JPG

PressESCtoshow_menu-533x400xRGBx60%.JPG
 Description   
 Filesize   9.73 KB
 Viewed   94 Time(s)

PressESCtoshow_menu-533x400xRGBx60%.JPG


_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Mon 29 Dec 2014, 12:15    Post subject:  

About hiddenmenu :

Even with timeout 0
I was able to make the menu.lst show up
while pressing several times the ESC key in the
phase where the BIOS switched to stage1 (MBR) or
stage1 handed over to stage2 :

Security_value = 0 ....
ESC-pressed-timeout0-533x400xRGBx60%.jpg
 Description   
 Filesize   22.47 KB
 Viewed   64 Time(s)

ESC-pressed-timeout0-533x400xRGBx60%.jpg


_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Mon 29 Dec 2014, 12:28    Post subject: grub password  

password

password function has two switches :
One switch in context above the title lines
( global setting )
and the second switch beneath any title line .


password set as global prevents editing of title entries
and access to the grub commandline .
When the global password is entered , the title editing feature
and commandline become accessible .

A third feature of global password is the ability to use the
"lock" command.

This is what info grub says about it :
Code:

   Another thing which may be dangerous is that any user can choose any
menu entry. Usually, this wouldn't be problematic, but you might want to
permit only administrators to run some of your menu entries, such as an
entry for booting an insecure OS like DOS.

   GRUB provides the command `lock' (*note lock::). This command always
fails until you enter the valid password, so you can use it, like this:

     title Boot DOS
     lock
     rootnoverify (hd0,1)
     makeactive
     chainload +1

   You should insert `lock' right after `title', because any user can
execute commands in an entry until GRUB encounters `lock'.

   You can also use the command `password' instead of `lock'. In this
case the boot process will ask for the password and stop if it was
entered incorrectly.  Since the `password' takes its own PASSWORD
argument this is useful if you want different passwords for different
entries.

password has an optional option : --md5

Since Grub is insecure with editing feature,
it is advised to use a md5crypt password .

In a running Puppy , a crypted password can be generated as
Code:

grub --batch <<EoI >>/tmp/md5crypt.txt
md5crypt
woofwoof
quit
EoI

where woofwoof can be replaced by the desired password.

The code should create a file /tmp/md5crypt.txt
with content as
Code:

    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)

       [ Minimal BASH-like line editing is supported.   For
         the   first   word,  TAB  lists  possible  command
         completions.  Anywhere else TAB lists the possible
         completions of a device/filename. ]
grub> md5crypt
Password: woofwoof
Encrypted: $1$yVbA2$9V5wdwpNazBuvp7P0fz8I.
grub> quit

Note: if the line "Encrypted: <CRYPT>" ends with a period|dot,
the dot is part of the password and not a sentence ending sign.

The legacy grub shell commandline usually reside(s|d) in /usr/sbin/ directory .
The /usr/sbin/grub is a stage2 emutator.

Sidenote:
Sadly, the Linux distributions that patch stage2 with features,
omitt to add these features to the emulator binary .

So a more secure hiddenmenu menu.lst should look like

Code:

# a global password prevents editing of title entries if ESC was able
# to skip the timeout 0
password --md5 $1$yVbA2$9V5wdwpNazBuvp7P0fz8I.
hiddenmenu
timeout 0

default 0
fallback 1 2 3

title "Enter password"
 password --md5 $1$yVbA2$9V5wdwpNazBuvp7P0fz8I.
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Enter password"
 password --md5 $1$yVbA2$9V5wdwpNazBuvp7P0fz8I.
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Enter password"
 password --md5 $1$yVbA2$9V5wdwpNazBuvp7P0fz8I.
 configfile (hd0,2)/boot/grub/menu-main.lst

title "Three times password failed"
 halt



splashimage and password :

Whenever there is a
splashimage /path/to/some-640x480x14-16.xpm
and the splashimage is not found,
some leftovers appear in the password entry line ( three asterix )
and the password feature does not work .
It needs to clear buffers by selecting a menu entry that does boot nothing
ie an menu entry that just prints something .

grub4dos does not have this problem, because the code is altered from
Code:

          /* Wipe out the previously entered password */
          grub_memset (entered, 0, sizeof (entered));
          get_cmdline (" Password: ", entered, 31, '*', 0);

to
Code:

          /* Wipe out the previously entered password */
          grub_memset (entered, 0, sizeof (entered));
          prompt = "Password: ";
          maxlen = sizeof (entered) - 1;
          echo_char = '*';
          readline = 0;
          get_cmdline (entered);

likely .

But grub4dos does not allow to select title lines that do nothing
- prints them, but using up-down-arrow-keys just jumps over such title lines .
password-when-splashimage-fails-533x400xRGBx60%.jpg
 Description   
 Filesize   29.29 KB
 Viewed   64 Time(s)

password-when-splashimage-fails-533x400xRGBx60%.jpg


_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4005
Location: Kiel,Germany

PostPosted: Mon 29 Dec 2014, 12:33    Post subject: Grub print feature  

print and pause combination can be used to present some README

like :
Code:

title Puppy Linux Boot Options README
 print If you need particular boot options, type e to edit menu entry,
 print go to the line that starts with kernel, then type e again.
 print Some boot options:
 print These help locating files at bootup. Examples:
 print pdev1=sdc1       :The boot partition.
 print psubdir=puppies/wary501  :Path in which Puppy is installed.
 print psavemark=2      :Partition no. (in boot drive) to save session to.
 print pmedia=usbflash  :Type of media booting from. Choose one of these:
 print usbflash usbhd usbcd ataflash atahd atacd atazip scsihd scsicd cd
 print pupsfs=sdc1:/puppies/wary501/puppy.sfs  :Override auto search.
 print zdrv=sdc1:/puppies/wary501/zdrv.sfs     :Override auto search.
 print underdog=sda9    :Mount an entire Linux distro (in sda9) underneath Puppy.
 print pmedia=cd pfix=ram  :Ignore saved session and do not look in other drives
 print
 print The following are for debugging, for experts only:
 print loglevel=<n>    :Bootup verbosity. 7 is high verbosity for debugging.
 print pfix=rdsh       :Execute 'init' then dropout to prompt in initramfs.
 print pfix=rdsh0      :Dropout early, before loading kernel drivers.
 print pfix=rdsh6      :Dropout just before mount layered filesystem.
 print
 print More help here: http://kernel.org/doc/Documentation/kernel-parameters.txt
 pause Press any key to return to the menu

pause at last line is necessary , otherwise returns to menu without giving time
to
read the printed lines .
There is no pager for such print screens, so would scroll to the last line,
without giving the chance to read the first lines if the pause line is 24th .
The cursor starts at the first line after the pause line,
not after the last character of the printed pause line
( pause works similar to
> echo "Some text"
> read Key

in bash .
)

print is not in original grub source :

Code:

+2005-16-10  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+       * docs/grub.texi: Added print command description.
+       * stage2/builtins.c(print_func): New function.
+       (builtin_print): New variable.
+       (builtin_table): Added builtin_print in table.
+
+Debian Status Following:
++/* print */
++static int
++print_func (char *arg, int flags)
++{
++  printf("%s\n", arg);
++
++  return 0;
++}
++
++static struct builtin builtin_print =
++{
++  "print",
++  print_func,
++  BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO,
++  "print [MESSAGE ...]",
++  "Print MESSAGE."
++};


NOTE: grub4dos does not support "print" .
print-help-msg-533x400xRGBx60%.jpg
 Description   
 Filesize   34.7 KB
 Viewed   68 Time(s)

print-help-msg-533x400xRGBx60%.jpg


_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1042s ][ Queries: 12 (0.0043s) ][ GZIP on ]