update_key generation now in cfgbin; update.sh auth changed

This commit is contained in:
Giulio 2020-09-19 18:31:38 +02:00
parent 6cde529c76
commit 0e54eb8c85
2 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <sys/stat.h>
typedef union uwb typedef union uwb
@ -175,6 +176,15 @@ int gen_serial()
} }
} }
int gen_update_key()
{
if (fopen("/etc/update_key", "r") == NULL)
{
system("/usr/bin/hexdump -n 32 -e '4/4 \"%08X\"' /dev/urandom > /etc/update_key");
}
chmod("/etc/update_key", 0600);
}
int gen_ssid() int gen_ssid()
{ {
char *serial; char *serial;

View File

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
if [[ -z $clearpassword ]]; then if [[ -z $key ]]; then
/bin/echo "Usage: sudo clearpassword=<password> -E update.sh" /bin/echo "Usage: sudo key=<update_key> -E update.sh"
exit 1 exit 1
fi fi
password=`/bin/cat /etc/txtpwd` password=`/bin/cat /etc/update_key | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1`
auth=`/bin/echo -n $clearpassword | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1` auth=`/bin/echo -n $key | /usr/bin/sha512sum | /usr/bin/cut -d' ' -f 1`
if [[ "$auth" != "$password" ]]; then if [[ "$auth" != "$password" ]]; then
/bin/echo "Wrong password" /bin/echo "Wrong password"