From 2c0dd783f8909a47875d0269b2ea6c6c1165ae8e Mon Sep 17 00:00:00 2001 From: John Klug Date: Mon, 4 Jun 2018 12:57:00 -0500 Subject: Allow mts-ubpasswd to determine if feature is preset, or if U-Boot currently requires a password. --- src/ubpasswd.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ubpasswd.sh b/src/ubpasswd.sh index 9fea52d..65e35eb 100755 --- a/src/ubpasswd.sh +++ b/src/ubpasswd.sh @@ -27,6 +27,10 @@ usage() { echo "ubpasswd [-u] [-d] [-s salt] [password]" echo " -u means u-boot only (not UNIX password)" echo " -s salt is user supplied salt" + echo " -r returns true if U-Boot password" + echo " is currently required" + echo " -f returns true if U-Boot password" + echo " feature is available." echo " -d debug" echo " password is a user supplied password" echo "A salt not supplied is generated." @@ -37,8 +41,17 @@ usage() { ((hassalt=0)) ((debug=0)) ((upwd=0)) -while getopts ":dus:" opt; do +while getopts ":dfrs:u" opt; do case $opt in + f) + if ! /bin/fgrep "mts password protected" /dev/mtdblock2 >/dev/null 2>&1; then + echo "U-Boot does not support password protection." + exit 1 + else + echo "U-Boot supports password protection." + exit 0 + fi + ;; u) ((ubonly=1)) ;; @@ -46,6 +59,15 @@ while getopts ":dus:" opt; do salt="$OPTARG" ((hassalt=1)) ;; + r) + if /usr/bin/u-boot printenv mtsp >/dev/null 2>&1 ; then + echo "U-Boot password protection is on" + exit 0 + else + echo "U-Boot password protection is off" + exit 1 + fi + ;; d) ((debug=1)) ;; -- cgit v1.2.3