Subversion: Get ip-address of user in pre-commit hook?

前端 未结 2 1977
旧巷少年郎
旧巷少年郎 2020-12-21 11:53

We\'re hosting a subversion repository for distrubuted software development. So non-employees have access to some of our sorce code. Our company\'s IT security policy requir

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 12:25

    I'm using lsof (bash-script pre-commit):

    srcip=$(/usr/sbin/lsof -Pn -p $PPID | grep ESTABLISHED)

    or, to get only the IP:

    srcip=$(/usr/sbin/lsof -Pn|grep ssh|grep ESTA|cut -d\> -f 2|cut -d: -f 1)

    While client connects to server, pre-commit is executed. lsof shows all open files (including TCP connections etc); I select all "files" for this process (-p $PPID) and grep for ESTABLISHED (this is the connection between client and server).

提交回复
热议问题