mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 22:51:03 +02:00
make_factory_package: sudo if --diskimg is a block device
Usually make_factory_package operates with normal files that does not need root permission - except if output is a block device. This CL tries to grant root permission by sudo if a block device is assigned to --diskimg. BUG=chrome-os-partner:2827 TEST=(as normal user) ./make_factory_acpakge --factory FACTORY \ --release RELEASE --hwid none --diskimg /dev/sde # completed Change-Id: Ie1285e6b6f46f1af286e795a02a83294fce4eeaa Reviewed-on: http://gerrit.chromium.org/gerrit/8789 Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Tammo Spalink <tammo@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Ready: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
parent
8429b4eb07
commit
abfb85f6b2
@ -64,6 +64,7 @@ DEFINE_string config "" \
|
||||
|
||||
# Parse command line
|
||||
FLAGS "$@" || exit 1
|
||||
ORIGINAL_PARAMS="$@"
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
on_exit() {
|
||||
@ -138,6 +139,13 @@ check_parameters() {
|
||||
check_file_param_or_none FLAGS_hwid_updater "in --diskimg mode"
|
||||
check_empty_param FLAGS_complete_script "in --diskimg mode"
|
||||
check_empty_param FLAGS_install_shim "in --diskimg mode"
|
||||
if [ -b "${FLAGS_diskimg}" -a ! -w "${FLAGS_diskimg}" ] &&
|
||||
[ -z "$MFP_SUDO" -a "$(id -u)" != "0" ]; then
|
||||
# Restart the command with original parameters with sudo for writing to
|
||||
# block device that needs root permission.
|
||||
# MFP_SUDO is a internal flag to prevent unexpected recursion.
|
||||
MFP_SUDO=TRUE exec sudo "$0" $ORIGINAL_PARAMS
|
||||
fi
|
||||
else
|
||||
check_file_param_or_none FLAGS_firmware_updater "in mini-omaha mode"
|
||||
check_file_param_or_none FLAGS_hwid_updater "in mini-omaha mode"
|
||||
|
Loading…
x
Reference in New Issue
Block a user