2009-08-25 Vladimir Serbinenko <phcoder@gmail.com>
Authentication support. * commands/password.c: New file. * conf/common.rmk (pkglib_MODULES): Add password.mod. (password_mod_SOURCES): New variable. (password_mod_CFLAGS): Likewise. (password_mod_LDFLAGS): Likewise. (normal_mod_SOURCES): Add normal/auth.c. * conf/i386-coreboot.rmk (grub_emu_SOURCES): Add commands/password.c and normal/auth.c. * conf/i386-efi.rmk (grub_emu_SOURCES): Likewise. * conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/i386-pc.rmk (grub_emu_SOURCES): Likewise. * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise. * conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise. * include/grub/auth.h: New file. * include/grub/err.h (grub_err_t): New enum value GRUB_ERR_ACCESS_DENIED. * include/grub/menu.h (grub_menu_entry): New fields 'restricted' and 'users'. * include/grub/normal.h (grub_cmdline_get): New argument 'history'. * normal/cmdline.c (grub_cmdline_get): New argument 'history'. All users updated. * normal/auth.c: New file. * normal/main.c (grub_normal_add_menu_entry): Handle --users option. (grub_cmdline_run): Don't allow to go to command line without authentication. * normal/menu.c (grub_menu_execute_entry): Handle restricted entries. * normal/menu_entry.c (grub_menu_entry_run): Don't allow editing menuentry without superuser rights. * normal/menu_viewer.c (grub_menu_viewer_show_menu): Don't exit if user isn't a superuser.
This commit is contained in:
parent
70f1161d13
commit
e7e1f93ff6
20 changed files with 531 additions and 20 deletions
45
include/grub/auth.h
Normal file
45
include/grub/auth.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef GRUB_AURH_HEADER
|
||||
#define GRUB_AUTH_HEADER 1
|
||||
|
||||
#include <grub/err.h>
|
||||
|
||||
/* Macros for indistinguishibility. */
|
||||
#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.")
|
||||
#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get ("Enter password: ", \
|
||||
string, len, \
|
||||
'*', 0, 0)
|
||||
|
||||
/* Like strcmp but untimeable. Accepts NULL as second argument. */
|
||||
int grub_auth_strcmp (const char *user_input, const char *template);
|
||||
/* Like strcmp but untimeable and ignores commas in needle. */
|
||||
int grub_auth_strword (const char *haystack, const char *needle);
|
||||
|
||||
typedef grub_err_t (*grub_auth_callback_t) (const char*, void *);
|
||||
|
||||
grub_err_t grub_auth_register_authentication (const char *user,
|
||||
grub_auth_callback_t callback,
|
||||
void *arg);
|
||||
grub_err_t grub_auth_unregister_authentication (const char *user);
|
||||
|
||||
grub_err_t grub_auth_authenticate (const char *user);
|
||||
grub_err_t grub_auth_deauthenticate (const char *user);
|
||||
grub_err_t grub_auth_check_authentication (const char *userlist);
|
||||
|
||||
#endif /* ! GRUB_AUTH_HEADER */
|
|
@ -53,7 +53,8 @@ typedef enum
|
|||
GRUB_ERR_BAD_GZIP_DATA,
|
||||
GRUB_ERR_MENU,
|
||||
GRUB_ERR_TIMEOUT,
|
||||
GRUB_ERR_IO
|
||||
GRUB_ERR_IO,
|
||||
GRUB_ERR_ACCESS_DENIED
|
||||
}
|
||||
grub_err_t;
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ struct grub_menu_entry
|
|||
/* The title name. */
|
||||
const char *title;
|
||||
|
||||
/* If set means not everybody is allowed to boot this entry. */
|
||||
int restricted;
|
||||
|
||||
/* Allowed users. */
|
||||
const char *users;
|
||||
|
||||
/* The classes associated with the menu entry:
|
||||
used to choose an icon or other style attributes.
|
||||
This is a dummy head node for the linked list, so for an entry E,
|
||||
|
|
|
@ -56,7 +56,7 @@ void grub_cmdline_run (int nested);
|
|||
|
||||
/* Defined in `cmdline.c'. */
|
||||
int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
|
||||
int echo_char, int readline);
|
||||
int echo_char, int readline, int history);
|
||||
grub_err_t grub_set_history (int newsize);
|
||||
|
||||
/* Defined in `completion.c'. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue