|
|
发表于 2005-6-12 01:27:05
|
显示全部楼层
比方说:当用户mike登陆成功后,在auth-up脚本里将当前pppd进程的pid记录到/var/run/pppstat/mike这个文件,每次auth-up脚本执行时检查该用户对应的pid文件是否已存在,如果存在,杀掉该进程即可。可参考pppd的man-page里的SCRIPTS一节,摘录如下:
SCRIPTS
Pppd invokes scripts at various stages in its processing which can be
used to perform site-specific ancillary processing. These scripts are
usually shell scripts, but could be executable code files instead.
Pppd does not wait for the scripts to finish. The scripts are exe-
cuted as root (with the real and effective user-id set to 0), so that
they can do things such as update routing tables or run privileged
daemons. Be careful that the contents of these scripts do not compro-
mise your system’s security. Pppd runs the scripts with standard
input, output and error redirected to /dev/null, and with an environ-
ment that is empty except for some environment variables that give
information about the link. The environment variables that pppd sets
are:
DEVICE The name of the serial tty device being used.
IFNAME The name of the network interface being used.
IPLOCAL
The IP address for the local end of the link. This is only set
when IPCP has come up.
IPREMOTE
The IP address for the remote end of the link. This is only
set when IPCP has come up.
PEERNAME
The authenticated name of the peer. This is only set if the
peer authenticates itself.
SPEED The baud rate of the tty device.
ORIG_UID
The real user-id of the user who invoked pppd.
PPPLOGNAME
The username of the real user-id that invoked pppd. This is
always set.
For the ip-down and auth-down scripts, pppd also sets the following
variables giving statistics for the connection:
CONNECT_TIME
The number of seconds from when the PPP negotiation started
until the connection was terminated.
BYTES_SENT
The number of bytes sent (at the level of the serial port) dur-
ing the connection.
BYTES_RCVD
The number of bytes received (at the level of the serial port)
during the connection.
LINKNAME
The logical name of the link, set with the linkname option.
DNS1 If the peer supplies DNS server addresses, this variable is set
to the first DNS server address supplied.
DNS2 If the peer supplies DNS server addresses, this variable is set
to the second DNS server address supplied.
Pppd invokes the following scripts, if they exist. It is not an error
if they don’t exist.
...
...
/etc/ppp/auth-up
A program or script which is executed after the remote system
successfully authenticates itself. It is executed with the
parameters
interface-name peer-name user-name tty-device speed
Note that this script is not executed if the peer doesn’t
authenticate itself, for example when the noauth option is used.
/etc/ppp/auth-down
A program or script which is executed when the link goes down,
if /etc/ppp/auth-up was previously executed. It is executed in
the same manner with the same parameters as /etc/ppp/auth-up.
/etc/ppp/ip-up
A program or script which is executed when the link is avail-
able for sending and receiving IP packets (that is, IPCP has
come up). It is executed with the parameters
interface-name tty-device speed local-IP-address remote-IP-
address ipparam
/etc/ppp/ip-down
A program or script which is executed when the link is no
longer available for sending and receiving IP packets. This
script can be used for undoing the effects of the /etc/ppp/ip-
up script. It is invoked in the same manner and with the same
parameters as the ip-up script.
...
... |
|