summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device-functions.c20
-rw-r--r--device-functions.h2
-rw-r--r--flash.c4
-rw-r--r--globals.h4
-rw-r--r--menus.c8
-rw-r--r--parser.c37
6 files changed, 62 insertions, 13 deletions
diff --git a/device-functions.c b/device-functions.c
index 8812cfa..516bbc9 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -4645,3 +4645,23 @@ int IO_Setup_RS232(int baud, char hardhand, gboolean update_flash)
return OK;
}
+int change_password (gchar *old_password, gchar *new_password) {
+
+ gboolean old_valid = TRUE;
+
+ // Skip password check if the supplied old_password is NULL. This
+ // only happens when resetting the password to the default.
+ if (old_password != NULL) {
+ printf ("verifying old password: %s\n", old_password); //FIXME with real function
+ // check, and set old_valid = FALSE if the password check fails
+ }
+
+ if (old_valid == TRUE) {
+ printf ("setting new password: %s\n" ,new_password); //FIXME with real function
+ // is a success test required?
+ return OK;
+ } else {
+ return password_change_error;
+ }
+}
+
diff --git a/device-functions.h b/device-functions.h
index 6625519..7076035 100644
--- a/device-functions.h
+++ b/device-functions.h
@@ -73,4 +73,6 @@ void Main_update_shift_registers();
int IO_Setup_RS232(int baud, char handshake, gboolean update_flash);
+int change_password (gchar *old_password, gchar *new_password);
+
#endif
diff --git a/flash.c b/flash.c
index e991cef..5228bc5 100644
--- a/flash.c
+++ b/flash.c
@@ -344,9 +344,7 @@ static void initFlashValues(FlashStruct *mem)
mem->ChanKey_logic_level=0;
strcpy(mem->model_num,"unprogrammed");
- strcpy(mem->serial_num,"no S/N");
- strcpy(mem->password,"default");
- strcpy(mem->username,"admin");
+ strcpy(mem->serial_num,"00000");
mem->fully_programmed=Being_Programmed;
diff --git a/globals.h b/globals.h
index 995f399..2e9e700 100644
--- a/globals.h
+++ b/globals.h
@@ -397,8 +397,8 @@ typedef struct {
short spare2; /* 59 */
char ChanKey_route; /* 61 */
char on_off_used; /* 62 */
- char password[32]; /* 63 */
- char username[32]; /* 95 */
+ char password[32]; /* 63 - no longer used */
+ char username[32]; /* 95 - no longer used */
char pcb116c_mon; /* 127 */
diff --git a/menus.c b/menus.c
index bb417f6..fce9623 100644
--- a/menus.c
+++ b/menus.c
@@ -2937,7 +2937,7 @@ static int Submenu_Implement_Changes(void)
{
int error_num;
int call_new_submenu;
- int channel,eprom_loc;
+ int channel;
call_new_submenu=NO;
@@ -3213,11 +3213,7 @@ static int Submenu_Implement_Changes(void)
Nonstd_menu_network();
break;
case mode_password:
- strcpy(globals.Flash.password,"default");
- // FIXME - save password to /etc/shadow here
-
- eprom_loc = (char *) &(globals.Flash.password) - (char *) &(globals.Flash.flash_start);
- writeUserBlock(&globals.Flash, eprom_loc, strlen(globals.Flash.password)+1);
+ change_password (NULL, "default");
break;
case mode_selfcal:
if (error_num=self_cal()) {
diff --git a/parser.c b/parser.c
index c125d2b..c5b0886 100644
--- a/parser.c
+++ b/parser.c
@@ -3613,8 +3613,41 @@ static int Go_puls_sep_89(gchar** response, int channel, char *parameter,char *u
static int Go_sys_pwd_92(gchar** response, int channel, char *parameter,int command_type)
{
- // FIXME - needs /etc/shadow
- return SyntaxError;
+ gchar *old_password = NULL;
+ gchar *new_password = NULL;
+ char *new_loc;
+ int error_num;
+
+ switch (command_type) {
+ case command_withparam:
+ /* new password follows comma */
+
+ new_loc = strchr(parameter,',');
+ if (new_loc == NULL) {
+ return password_change_error;
+ }
+
+ new_password = g_strdup_printf ("%s", new_loc + 1);
+ new_loc[0]=0;
+ old_password = g_strdup (parameter);
+
+ error_num = OK;
+ if ((strlen(new_password)< 6) || (strlen(new_password)< 6)) {
+ error_num = password_change_error;
+ }
+
+ if (!error_num) {
+ error_num = change_password (old_password, new_password);
+ }
+
+ g_free (new_password);
+ g_free (old_password);
+ return error_num;
+
+ default:
+ return SyntaxError;
+ break;
+ }
}