Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ There are other options as well, as detailed below:
| Option | Action |
|-------------------------------------------|--------------------------------------------------------|
|`-h`, `--help` | Display the help Text |
|`-c`, `--dry-run` | Don't actually copy any files or set anything up. |
|`-p`, `--print-config` | Print the current configuration and exit. |
|*_Path Options_* | |
|`-r <path>`, `--root-path <path>` | Manually specify the root filesystem path. |
Expand Down Expand Up @@ -122,21 +121,22 @@ If kernelstub is going to be used in a scripted environment, it is useful to
know what return codes it provides in the event of errors. The table below
details these codes and their meaning:

| Exit Code | Meaning |
|-----------|--------------------------------------------------------------|
| 0 | Success |
| 166 | The kernel path supplied/detected was invalid |
| 167 | The initrd path supplied/detected was invalid |
| 168 | No kernel options found/supplied |
| 169 | Malformed configuration found |
| 170 | Couldn't copy kernel image to ESP |
| 171 | Couldn't copy initrd image to ESP |
| 172 | Couldn't create a new NVRAM entry |
| 173 | Couldn't remove an old NVRAM entry |
| 174 | Couldn't detect the block device file for the root partition |
| 175 | Coundn't detect the block device file for the ESP |
| 176 | Wasn't run as root |
| 177 | Couldn't get a required UUID |
| Exit Code | Meaning |
|-----------|---------------------------------------------------------------|
| 0 | Success |
| 166 | The kernel path supplied/detected was invalid |
| 167 | The initrd path supplied/detected was invalid |
| 168 | No kernel options found/supplied |
| 169 | Malformed configuration found |
| 170 | Couldn't copy kernel image to ESP |
| 171 | Couldn't copy initrd image to ESP |
| 172 | Couldn't create a new NVRAM entry |
| 173 | Couldn't remove an old NVRAM entry |
| 174 | Couldn't detect the block device file for the root partition |
| 175 | Coundn't detect the block device file for the ESP |
| 176 | Wasn't run as root |
| 177 | Couldn't get a required UUID |
| 178 | Simulate option used |


### Licence
Expand Down
15 changes: 15 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Security Policy

## Supported Versions
The following versions of Kernelstub currently receive updates for security:

| Version | Supported |
| ------- | ------------------ |
| 3.2.0 | :white_check_mark: |
| 3.1.x | :white_check_mark: |
| < 3.1 | :x: |

## Reporting a Vulnerability

When Filing an issue for a potential security vulnerability, please be sure
to include a `[SECURITY]` tag in the issue title.
180 changes: 95 additions & 85 deletions bin/kernelstub
Original file line number Diff line number Diff line change
Expand Up @@ -39,193 +39,202 @@ terms.
kernelstub will load parameters from the /etc/default/kernelstub config file.
"""

import argparse, os
import argparse
import os

from kernelstub import application

def main(options=None): # Do the thing
def main(options=None):
""" Do the thing - Main Kernelstub Function"""
kernelstub = application.Kernelstub()
# Set up argument processing
parser = argparse.ArgumentParser(
description = "Automatic Kernel EFIstub manager")
description="Automatic Kernel EFIstub manager")
loader_stub = parser.add_mutually_exclusive_group()
install_loader = parser.add_mutually_exclusive_group()

parser.add_argument(
'-c',
'--dry-run',
action = 'store_true',
dest = 'dry_run',
help = 'Don\'t perform any actions, just simulate them.'
action='store_true',
dest='dry_run',
help=argparse.SUPPRESS
)
parser.add_argument(
'-p',
'--print-config',
action = 'store_true',
dest = 'print_config',
help = 'Print the current configuration and exit'
action='store_true',
dest='print_config',
help='Print the current configuration and exit'
)

parser.add_argument(
'-e',
dest = 'esp_path',
metavar = 'ESP,',
help = ''
dest='esp_path',
metavar='ESP,',
help=''
)
parser.add_argument(
'--esp-path',
dest = 'esp_path',
metavar = 'ESP',
help = 'Manually specify the path to the ESP. Default is /boot/efi'
dest='esp_path',
metavar='ESP',
help='Manually specify the path to the ESP. Default is /boot/efi'
)

parser.add_argument(
'-r',
dest = 'root_path',
metavar = 'ROOT',
help = ''
dest='root_path',
metavar='ROOT',
help=''
)
parser.add_argument(
'--root-path',
dest = 'root_path',
metavar = 'ROOT',
help = 'The path where the root filesystem to use is mounted.'
dest='root_path',
metavar='ROOT',
help='The path where the root filesystem to use is mounted.'
)

parser.add_argument(
'-k',
dest = 'kernel_path',
metavar= 'PATH,',
help = ''
dest='kernel_path',
metavar='PATH,',
help=''
)
parser.add_argument(
'--kernel-path',
dest = 'kernel_path',
metavar= 'PATH',
help = 'The path to the kernel image.'
dest='kernel_path',
metavar='PATH',
help='The path to the kernel image.'
)

parser.add_argument(
'-i',
dest = 'initrd_path',
metavar = 'PATH,',
help = ''
dest='initrd_path',
metavar='PATH,',
help=''
)
parser.add_argument(
'--initrd-path',
dest = 'initrd_path',
metavar = 'PATH',
help = 'The path to the initrd image.'
dest='initrd_path',
metavar='PATH',
help='The path to the initrd image.'
)

parser.add_argument(
'-o',
dest = 'k_options',
metavar = '"OPTIONS",',
help = ''
dest='k_options',
metavar='"OPTIONS",',
help=''
)
parser.add_argument(
'--options',
dest = 'k_options',
metavar = '"OPTIONS"',
help = 'The total boot options to be passed to the kernel'
dest='k_options',
metavar='"OPTIONS"',
help='The total boot options to be passed to the kernel'
)

parser.add_argument(
'-a',
dest = 'add_options',
metavar = '"OPTIONS",',
help = ''
dest='add_options',
metavar='"OPTIONS",',
help=''
)
parser.add_argument(
'--add-options',
dest = 'add_options',
metavar = '"OPTIONS"',
help = ('Boot options to add to the configuration '
'(if they aren\'t already present)')
)
dest='add_options',
metavar='"OPTIONS"',
help=(
'Boot options to add to the configuration (if they aren\'t '
'already present)'
)
)

parser.add_argument(
'-d',
dest = 'remove_options',
metavar = "OPTIONS",
help = ''
dest='remove_options',
metavar="OPTIONS",
help=''
)
parser.add_argument(
'--delete-options',
dest = 'remove_options',
metavar = '"OPTIONS"',
help = ('Boot options to remove from the configuration '
'(if they\'re present already)')
dest='remove_options',
metavar='"OPTIONS"',
help=(
'Boot options to remove from the configuration (if they\'re '
'present already)'
)
)

parser.add_argument(
'-g',
dest = 'log_file',
metavar = 'LOG',
help = ''
dest='log_file',
metavar='LOG',
help=''
)
parser.add_argument(
'--log-file',
dest = 'log_file',
metavar = 'LOG',
help = ('The path to the log file to use. Defaults to '
'/var/log/kernelstub.log')
dest='log_file',
metavar='LOG',
help=(
'The path to the log file to use. Defaults to '
'/var/log/kernelstub.log'
)
)

install_loader.add_argument(
'-l',
'--loader',
action = 'store_true',
dest = 'setup_loader',
help = 'Creates a systemd-boot compatible loader configuration'
action='store_true',
dest='setup_loader',
help='Creates a systemd-boot compatible loader configuration'
)
install_loader.add_argument(
'-n',
'--no-loader',
action = 'store_true',
dest = 'off_loader',
help = 'Turns off creating loader configuration'
action='store_true',
dest='off_loader',
help='Turns off creating loader configuration'
)

loader_stub.add_argument(
'-s',
'--stub',
action = 'store_true',
dest = 'install_stub',
help = 'Set up NVRAM entries for the copied kernel'
action='store_true',
dest='install_stub',
help='Set up NVRAM entries for the copied kernel'
)

loader_stub.add_argument(
'-m',
'--manage-only',
action = 'store_true',
dest = 'manage_mode',
help = 'Only copy entries, don\'t set up the NVRAM'
action='store_true',
dest='manage_mode',
help='Only copy entries, don\'t set up the NVRAM'
)

parser.add_argument(
'-f',
'--force-update',
action = 'store_true',
dest = 'force_update',
help = ('Forcibly update any loader.conf to set the new entry as the '
'default')
action='store_true',
dest='force_update',
help=(
'Forcibly update any loader.conf to set the new entry as the default'
)
)

parser.add_argument(
'-v',
'--verbose',
action = 'count',
dest = 'verbosity',
help = 'Increase program verbosity and display extra output.'
action='count',
dest='verbosity',
help='Increase program verbosity and display extra output.'
)

parser.add_argument(
'--preserve-live-mode',
action = 'store_true',
dest = 'preserve_live',
help = argparse.SUPPRESS
action='store_true',
dest='preserve_live',
help=argparse.SUPPRESS
)

args = parser.parse_args()
Expand All @@ -234,8 +243,9 @@ def main(options=None): # Do the thing

if os.geteuid() != 0:
parser.print_help()
print('kernelstub: ERROR: You need to be root or use sudo to run '
'kernelstub!')
print(
'kernelstub:ERROR: You need to be root or use sudo to run kernelstub'
)
exit(176)

kernelstub.main(args)
Expand Down
Loading