• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

密猟オンラインサーバープログラム


Commit MetaInfo

Revision11 (tree)
Time2016-12-21 17:15:47
Authormanjihq

Log Message

管理者コマンドにパスワード変更を追加

Change Summary

Incremental Difference

--- trunk/huntserv.c (revision 10)
+++ trunk/huntserv.c (revision 11)
@@ -5590,6 +5590,45 @@
55905590 return;
55915591 }
55925592
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+
55935632 /* execute admin command */
55945633 static void
55955634 doAdminCommand (unsigned char *p)
@@ -5606,6 +5645,11 @@
56065645 /* gain HP */
56075646 n = ntohl (*(unsigned long *) (p + 1));
56085647 cause_heal (0, n);
5648+ break;
5649+ case 3:
5650+ /* change PASSWORD */
5651+ adminChangePassword (p + 1);
5652+ break;
56095653 default:
56105654 printf ("unknown admin command %02X\n", (unsigned) *p);
56115655 break;