ソースを参照

v0.6-dev Security Updated!

  Please remember to change your allowDev and sysop_pass for your
system!
david 4 年 前
コミット
addced25ed
1 ファイル変更54 行追加10 行削除
  1. 54 10
      main.c

+ 54 - 10
main.c

@@ -1,11 +1,11 @@
 /*
-    Space Construct v0.5-dev
+    Space Construct v0.6-dev
     Beanzilla@21:4/110  on FsxNet
     Beanzilla@637:1/110 on HappyNet
 */
 
 #define VERSION_MAJOR 0
-#define VERSION_MINOR 5
+#define VERSION_MINOR 6
 #ifndef VERSION_TYPE
 #define VERSION_TYPE "dev"
 #endif
@@ -41,6 +41,10 @@ char * log_path = "logs";
 int inuse = 0; // Are any other copies of us running? (We are a single user door!)
 int debug = 0; // Are we in debug mode?
 
+// Please change it for your system!
+int allowDev = 0; // Allow "Beanzilla" to not need the password.
+char * sysop_pass = "spaceISbig"; // Not case insensitive!
+
 // User Structure (This includes guns, fuel, armor, shields, HP)
 typedef struct user_info {
   int uid; // Primary Key
@@ -1571,14 +1575,12 @@ void main_menu() {
   dT targ_age; // Date Struct
   char targ_real[256];
   char ch;
+  int auth; // Security
+  char sys[48]; // Security
   // 0 means we got the lock first, 1 means someone else has it already!
   while(!done) {
     md_clr_scr();
-    if(strcmp(mdcontrol.user_alias, mdcontrol.sysop_name) == 0 || strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
-      md_sendfile("ansis/sc_mainh.ans", TRUE);
-    } else {
-      md_sendfile("ansis/sc_mainl.ans", TRUE);
-    }
+    md_sendfile("ansis/sc_mainl.ans", TRUE);
     ch = md_get_answer("PpLlVvQqRrNnSsAa\r");
     md_clr_scr();
     switch(tolower(ch)){
@@ -1645,7 +1647,21 @@ void main_menu() {
         break;
       case 'r':
         // Give only Sysop and dev access to restricted commands
-        if(strcmp(mdcontrol.user_alias, mdcontrol.sysop_name) == 0 || strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+        auth = 0;
+        if(allowDev && strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+          md_printf("`bright green`Access Granted\r\n");
+          auth = 1;
+        } else {
+          md_printf("`bright red`Sysop Password: ");
+          strcpy(sys, "");
+          md_getstring(sys, 32, 32, 126);
+          md_printf("\r\n");
+          if(strcmp(sys, sysop_pass) == 0) {
+            md_printf("`bright green`Access Granted\r\n");
+            auth = 1;
+          }
+        }
+        if(auth) {
           inuse = check_lock();
           if(inuse == 1) {
             md_printf("`bright red`Reset is unavalible because someone is playing the game!\r\n");
@@ -1668,8 +1684,22 @@ void main_menu() {
         paws();
         break;
       case 's':
+        auth = 0;
+        if(allowDev && strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+          md_printf("`bright green`Access Granted\r\n");
+          auth = 1;
+        } else {
+          md_printf("`bright red`Sysop Password: ");
+          strcpy(sys, "");
+          md_getstring(sys, 32, 32, 126);
+          md_printf("\r\n");
+          if(strcmp(sys, sysop_pass) == 0) {
+            md_printf("`bright green`Access Granted\r\n");
+            auth = 1;
+          }
+        }
         // Give only Sysop and dev access to restricted commands
-        if(strcmp(mdcontrol.user_alias, mdcontrol.sysop_name) == 0 || strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+        if(auth) {
           inuse = check_lock();
           md_printf("`bright yellow`__ Show Debug ___\r\n");
           if(inuse == 1) {
@@ -1701,7 +1731,21 @@ void main_menu() {
         break;
       case 'n':
         // Give only Sysop and dev access to restricted commands
-        if(strcmp(mdcontrol.user_alias, mdcontrol.sysop_name) == 0 || strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+        auth = 0;
+        if(allowDev && strcmp(mdcontrol.user_alias, "Beanzilla") == 0) {
+          md_printf("`bright green`Access Granted\r\n");
+          auth = 1;
+        } else {
+          md_printf("`bright red`Sysop Password: ");
+          strcpy(sys, "");
+          md_getstring(sys, 32, 32, 126);
+          md_printf("\r\n");
+          if(strcmp(sys, sysop_pass) == 0) {
+            md_printf("`bright green`Access Granted\r\n");
+            auth = 1;
+          }
+        }
+        if(auth) {
           inuse = check_lock();
           if(inuse == 1) {
             md_printf("`bright yellow`New Day is unavalible because someone is playing the game!\r\n");