LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 948|回复: 3

linux 如何实现账号唯一在线?

[复制链接]
发表于 2005-6-10 21:59:25 | 显示全部楼层 |阅读模式
我最近在学习redhat 里的pppoe-server实现pppoe服务器,配置好/etc/ppp/pppoe-server-option,以及在/etc/ppp/pap-secrets下添加了相应的账号与密码,这时在几台客户机上使用pppoe连接服务器,一切都很正常.
      现在唯一的问题是,这几台客户机可以使用同一个帐号同时连接服务器,我想知道有没有什么办法来实现每一个账号只能在一个时刻连接服务器.就是禁止一个账号"同时"连接多次?不知道有没有什么解决办法?
      同样的,我在redhat 服务器上开通了telnet服务,可以远程登录这个服务器,但是也是一个用户可以同时登录多次?有没有办法禁止一个账号同时登录多次?
      说了这么多,不知道我描述清楚了没有,望朋友们多指点,谢谢!
 楼主| 发表于 2005-6-11 17:14:21 | 显示全部楼层
自己先顶一下!
回复 支持 反对

使用道具 举报

发表于 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.
...
...
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-12 09:58:35 | 显示全部楼层
嗯,感谢,我要试验一下,不过我对脚本不是太熟,如果有现成的脚本就好了!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表