From 20ffd6693d73b9b00d1906e32445aabd2f9e98df Mon Sep 17 00:00:00 2001 From: David Kaasen Date: Thu, 1 Mar 2018 16:03:04 +0000 Subject: [PATCH] Oppdaterte bruker- og passordbehandling til MySQL V5.7. Korrigerte e-postadr. ("Report bugs"). --- mysql-dbadm.c | 4 ++-- mysql-useradm.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-dbadm.c b/mysql-dbadm.c index 0e9f087..b237b2b 100644 --- a/mysql-dbadm.c +++ b/mysql-dbadm.c @@ -81,7 +81,7 @@ usage() printf(" Run '%s --help-editperm' for more\n" " information.\n",program_name); printf("\n"); - printf("Report bugs to drift@stud.ntnu.no\n"); + printf("Report bugs to orakel@ntnu.no\n"); return 0; } @@ -109,7 +109,7 @@ usage_editperm() printf(" Temp - Enables use of CREATE TEMPORARY TABLE\n"); printf(" Lock - Enables use of LOCK TABLE\n"); printf("\n"); - printf("Report bugs to drift@stud.ntnu.no\n"); + printf("Report bugs to orakel@ntnu.no\n"); return 0; } diff --git a/mysql-useradm.c b/mysql-useradm.c index aecb406..04bcdca 100644 --- a/mysql-useradm.c +++ b/mysql-useradm.c @@ -29,7 +29,7 @@ usage() printf(" show give information about the USERS(s), or, if\n"); printf(" none are given, all the users you have.\n"); printf("\n"); - printf("Report bugs to drift@stud.ntnu.no\n"); + printf("Report bugs to orakel@ntnu.no\n"); return 0; } @@ -43,7 +43,7 @@ is_password_set(MYSQL *pmysql, const char *user) MYSQL_ROW row; int check = 0; - end = strmov(query, "SELECT password FROM user WHERE user='"); + end = strmov(query, "SELECT authentication_string FROM user WHERE user='"); end += mysql_real_escape_string(pmysql, end, user, strlen(user)); *end++ = '\''; *end = '\0'; @@ -77,9 +77,9 @@ create(MYSQL *pmysql, const char *user) { char query[1024], *end; - end = strmov(query, "INSERT INTO user (host, user) VALUES ('%', '"); + end = strmov(query, "CREATE USER '"); end += mysql_real_escape_string(pmysql, end, user, strlen(user)); - end = strmov(end, "')"); + end = strmov(end, "'"); if (mysql_query(pmysql, query)) return dberror(pmysql, "Failed to create user '%s'.", user); @@ -93,7 +93,7 @@ delete(MYSQL *pmysql, const char *user) { char query[1024], *end; - end = strmov(query, "DELETE FROM user WHERE user='"); + end = strmov(query, "DROP USER '"); end += mysql_real_escape_string(pmysql, end, user, strlen(user)); *end++ = '\''; *end = '\0'; @@ -128,10 +128,10 @@ passwd(MYSQL *pmysql, const char *user) } free(confirm_password); - end = strmov(query, "UPDATE user SET password = PASSWORD('"); - end += mysql_real_escape_string(pmysql, end, password, strlen(password)); - end = strmov(end, "') WHERE user='"); + end = strmov(query, "ALTER user '"); end += mysql_real_escape_string(pmysql, end, user, strlen(user)); + end = strmov(end, "' IDENTIFIED BY '"); + end += mysql_real_escape_string(pmysql, end, password, strlen(password)); *end++ = '\''; *end = '\0';