/* screen 3.9.15 に時限式端末ロックを入れたいパッチ 関係ありげなとこだけ斜め読みして quick hack。 タイマ関係は screen 内部のイベントドリブンに沿ったつもりだけど、 あちこちバグバグだー! timedlock_time にロックするまでの秒数を指定する。 ただしハードコーディング。 だれか .screenrc で設定できるようにしてみない? (分単位がいいナ) あと勝手にユーザのパスワードを使ってくれない。 最初の一回だけキーを入れる必要あり。utmp 関係? だれか(略 それから外部の lock プログラムも使ってくんネーナ… だれか(略 極めつけに、デタッチ中の親 screen のロードアベレージが ぐんぐん上がる。(ちなみに getpass() でも上がるデフォなのか?) timedlock イベントのせいで sched() 内の select() を通りま くってるからなんだけど… グボハァ! もう俺にはハクする時間がねェ。。。だれか(略 環境は FreeBSD 4.5。 */ diff -c1 screen-3.9.15/display.c screen-3.9.15x/display.c *** screen-3.9.15/display.c Mon Feb 24 20:53:35 2003 --- screen-3.9.15x/display.c Thu May 15 08:23:16 2003 *************** *** 3494 **** --- 3494,3514 ---- #endif + + #ifdef TIMEDLOCK + /* Do as same as C-a x */ + void + timedlock_fn(struct event *ev, char *data) + { + char *noarg[1]; + struct action act; + struct display *disp; + + act.nr = RC_LOCKSCREEN; + (act.args = noarg)[0] = NULL; + disp = display; + display = displays; + DoAction(&act, 0); + display = disp; + + evenq(&timedlock); + } + #endif /* TIMEDLOCK */ diff -c1 screen-3.9.15/sched.c screen-3.9.15x/sched.c *** screen-3.9.15/sched.c Wed Jan 9 20:41:54 2002 --- screen-3.9.15x/sched.c Thu May 15 08:25:54 2003 *************** *** 235,236 **** --- 235,241 ---- debug2(" + hit ev fd %d type %d!\n", ev->fd, ev->type); + #ifdef TIMEDLOCK + /* reset timedlock timer */ + if (ev->type == EV_READ) + SetTimeout(&timedlock, timedlock_time * 1000); + #endif /* TIMEDLOCK */ ev->handler(ev, ev->data); diff -c1 screen-3.9.15/screen.c screen-3.9.15x/screen.c *** screen-3.9.15/screen.c Tue Feb 25 02:03:47 2003 --- screen-3.9.15x/screen.c Thu May 15 09:29:01 2003 *************** *** 331,332 **** --- 331,337 ---- + #ifdef TIMEDLOCK + struct event timedlock; + int timedlock_time = 10; /* 10 sec. (test) */ + //int timedlock_time = 5 * 60; /* 5 min. */ + #endif /* TIMEDLOCK */ *************** *** 1356,1357 **** --- 1361,1368 ---- logflushev.handler = logflush_fn; + + #ifdef TIMEDLOCK + SetTimeout(&timedlock, timedlock_time * 1000); + timedlock.handler = timedlock_fn; + evenq(&timedlock); + #endif /* TIMEDLOCK */ diff -c1 screen-3.9.15/screen.h screen-3.9.15x/screen.h *** screen-3.9.15/screen.h Fri Mar 29 03:00:58 2002 --- screen-3.9.15x/screen.h Thu May 15 08:25:12 2003 *************** *** 289 **** --- 289,298 ---- }; + + + #define TIMEDLOCK + + #ifdef TIMEDLOCK + extern struct event timedlock; + extern int timedlock_time; + void timedlock_fn(struct event *, char *); + #endif /* TIMEDLOCK */