Skip to content

Commit

Permalink
Multi-login: Log kicked client's pid in the kick log
Browse files Browse the repository at this point in the history
- Add function `blog_pid` for calling `blog` with `pid` specified
- `tn_login()`: Use `blog_pid()` to log the kick event
  • Loading branch information
IepIweidieng committed Oct 6, 2020
1 parent 3058115 commit ebc07f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void brd_edit(int bno);
int a_editbrd(void);
int u_verify(void);
/* bbsd.c */
void blog_pid(const char *mode, const char *msg, pid_t pid);
void blog(const char *mode, const char *msg);
void u_exit(const char *mode);
GCC_NORETURN void abort_bbs(void);
Expand Down
18 changes: 14 additions & 4 deletions maple/bbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ int treat=0;
/* ----------------------------------------------------- */

void
blog(
blog_pid(
const char *mode,
const char *msg
const char *msg,
pid_t pid
)
{
char buf[512], data[256];
Expand All @@ -64,13 +65,22 @@ blog(
if (!msg)
{
msg = data;
sprintf(data, "Stay: %d (%d)", (int)(now - ap_start) / 60, currpid);
sprintf(data, "Stay: %d (%d)", (int)(now - ap_start) / 60, pid);
}

sprintf(buf, "%s %-5.5s %-13s%s\n", Etime(&now), mode, cuser.userid, msg);
f_cat(FN_USIES, buf);
}

void
blog(
const char *mode,
const char *msg
)
{
blog_pid(mode, msg, currpid);
}


#ifdef MODE_STAT
void
Expand Down Expand Up @@ -718,7 +728,7 @@ tn_login(void)
if (vans("偵測到多重登入,您想刪除其他重複的 login (Y/n)嗎?[Y] ") != 'n')
{
kill(pid, SIGTERM);
blog("MULTI", cuser.username);
blog_pid("MULTI", cuser.username, pid);
break;
}

Expand Down

0 comments on commit ebc07f2

Please sign in to comment.