diff options
author | John Klug <john.klug@multitech.com> | 2018-06-28 14:06:52 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2018-06-28 14:06:52 -0500 |
commit | 7172a72ac22f4ed7380f603c9519299ded612bb8 (patch) | |
tree | 72f3f5bf0d5b10f9efe51891241f4f7dc7f267a7 /src | |
parent | cfe8af3b0629368eeb61354e52ec12cc3d8637bd (diff) | |
download | mts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.tar.gz mts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.tar.bz2 mts-id-eeprom-7172a72ac22f4ed7380f603c9519299ded612bb8.zip |
mts-ubpasswd to use uuid and device-id rather than MAC by default
Diffstat (limited to 'src')
-rw-r--r-- | src/hashpwd.cpp | 24 | ||||
-rwxr-xr-x | src/ubpasswd.sh | 10 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/hashpwd.cpp b/src/hashpwd.cpp index 414ffbd..6bc322c 100644 --- a/src/hashpwd.cpp +++ b/src/hashpwd.cpp @@ -10,6 +10,8 @@ #include <string.h> #include <openssl/sha.h> +#define MYVERSION "1.1" + using namespace std; int v = 0; @@ -148,28 +150,33 @@ void usage(void) { cout << "usage:" << endl << " mts-hashpwd [-v] [[-d did] [-m mac] | [-p password]] salt" << endl << + " -V version" << endl << " -v verbose" << endl << " -d did Device ID (serial #)" << endl << " -m mac Ethernet mac address" << endl << " -p password" << endl << - "Either password must be supplied, or Device-ID and Ethernet Mac address" << endl << + " -u uuid UUID (base 16)" << endl << + "Either password must be supplied, or Device-ID and " << endl + << "either Ethernet Mac address or UUID" << endl << "salt is required." <<endl; exit(1); } int main(int argc, char **argv) { - int opt = 0, p = 0, d = 0, m = 0; + int opt = 0, p = 0, d = 0, m = 0, u=0; unsigned long long fudge = 0; short unsigned int prefix; - string did, mac, pwd, salt; + string did, mac, pwd, salt, uuid; - while ((opt = getopt(argc,argv,"d:m:p:v")) != EOF) + while ((opt = getopt(argc,argv,"Vd:m:p:u:v")) != EOF) switch(opt) { + case 'V': cout << MYVERSION << endl; exit(0); case 'v': v = 1; cout << " verbose" <<endl; break; case 'd': d = 1; did = optarg ; (v==1) && cout << "device-id is " << did << endl; break; case 'm': m = 1; mac = optarg ; (v==1) && cout << "Ethernet mac is " << mac << endl; break; case 'p': p = 1; pwd = optarg ; (v==1) && cout << "User defined password is \"" << pwd << "\"" << endl; break; + case 'u': u = 1; uuid = optarg ; (v==1) && cout << "UUID is \"" << uuid << "\"" << endl; break; case '?': usage(); break; default: cout<<endl; abort(); } @@ -184,8 +191,8 @@ int main(int argc, char **argv) { cout << "Must use either a supplied password or Device ID and Ethernet MAC address, but not all three." << endl; usage(); } - if ((d && !m) || (m && !d)) { - cout << "Must have both a Device-ID and an Ethernet MAC address." << endl; + if ((d && (!m && !u)) || (m && !d) || (u && !d)) { + cout << "Must have both a Device-ID and either a UUID or Ethernet MAC address." << endl; usage(); } if (optind != argc-1) { @@ -212,7 +219,10 @@ int main(int argc, char **argv) { unsigned char hash[SHA256_DIGEST_LENGTH]; if(!p) { - passwd0 = did + "|" + mac; + if (m) + passwd0 = did + "|" + mac; + else if (u) + passwd0 = did + "|" + uuid; passwdnew = passwd0; while (1) { diff --git a/src/ubpasswd.sh b/src/ubpasswd.sh index 8a6abf9..65e35eb 100755 --- a/src/ubpasswd.sh +++ b/src/ubpasswd.sh @@ -24,8 +24,7 @@ if ! [[ -x /sbin/mts-hashpwd ]] ; then exit 1 fi usage() { - echo "ubpasswd [-c] [-r] [-u] [-d] [-s salt] [password]" - echo " -c clear the U-Boot password" + 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" @@ -42,13 +41,8 @@ usage() { ((hassalt=0)) ((debug=0)) ((upwd=0)) -while getopts ":cdfrs:u" opt; do +while getopts ":dfrs:u" opt; do case $opt in - c) - u-boot setenv mtsp - u-boot setenv mtss - exit 0 - ;; f) if ! /bin/fgrep "mts password protected" /dev/mtdblock2 >/dev/null 2>&1; then echo "U-Boot does not support password protection." |