密猟オンラインサーバープログラム
管理者コマンドにパスワード変更を追加
@@ -5590,6 +5590,45 @@ | ||
5590 | 5590 | return; |
5591 | 5591 | } |
5592 | 5592 | |
5593 | +/* */ | |
5594 | +static void | |
5595 | +adminChangePassword (unsigned char *p) | |
5596 | +{ | |
5597 | + int nuser; | |
5598 | + | |
5599 | + puts ("Attempt to change password..."); | |
5600 | + nuser = SearchUser ((char *) p); | |
5601 | + if (nuser == -1) | |
5602 | + { | |
5603 | + puts ("no user."); | |
5604 | + } | |
5605 | + else if (nuser == 0) | |
5606 | + { | |
5607 | + puts ("Can't change administrator password!"); | |
5608 | + } | |
5609 | + else | |
5610 | + { | |
5611 | + int i; | |
5612 | + char wkpassword[PASSWORD_LEN]; | |
5613 | + unsigned char *ppassword = p + USERNAME_LEN; | |
5614 | + for (i = 0; i < PASSWORD_LEN; i++, ppassword++) | |
5615 | + { | |
5616 | + if (*ppassword == '\0') | |
5617 | + { | |
5618 | + break; | |
5619 | + } | |
5620 | + wkpassword[i] = (char) *ppassword; | |
5621 | + } | |
5622 | + for (; i < PASSWORD_LEN; i++) | |
5623 | + { | |
5624 | + wkpassword[i] = ' '; | |
5625 | + } | |
5626 | + printf ("Change %-.24s password to [%-.24s]\n", User[nuser].name, | |
5627 | + wkpassword); | |
5628 | + memcpy (User[nuser].password, wkpassword, PASSWORD_LEN); | |
5629 | + } | |
5630 | +} | |
5631 | + | |
5593 | 5632 | /* execute admin command */ |
5594 | 5633 | static void |
5595 | 5634 | doAdminCommand (unsigned char *p) |
@@ -5606,6 +5645,11 @@ | ||
5606 | 5645 | /* gain HP */ |
5607 | 5646 | n = ntohl (*(unsigned long *) (p + 1)); |
5608 | 5647 | cause_heal (0, n); |
5648 | + break; | |
5649 | + case 3: | |
5650 | + /* change PASSWORD */ | |
5651 | + adminChangePassword (p + 1); | |
5652 | + break; | |
5609 | 5653 | default: |
5610 | 5654 | printf ("unknown admin command %02X\n", (unsigned) *p); |
5611 | 5655 | break; |