※ 引述《demonhuang.bbs@csie.nctu.edu.tw (小黄)》之铭言:
: ==> 在 haha.bbs@bsd.hs.ntnu.edu.tw (haha) 的文章中提到:
: : 我想让使用者只用ftp 进来主机
: : 但不让这些使用者用te.net 进来主机
: : (but有些使用者还是可以让它进来)
: : 对於这些特别的使用者如何设定呢???
: 把那些使用者的 shell 改掉 .like /noexistence ..
刚好最近也在处理类似的 ftp/login 机制,除了传统做法 -- 改 login shell 外,
还可配合其它机制的辅助让 login access control 更有弹性。
/nonexistent
/sbin/nologin
是典型的 no login shells,若要让 ftp account 能正常使用得在 /etc/shells
有对应的 entries。
ftp://freebsd.ntu.edu.tw/freebsd/woju/source/te.netd.tgz
有更新,修改了 safe_exit() 让 deny try 的「代价」少一点:
safe_exit(int n)
{
struct rtprio rp;
rp.prio = rtp_prio_max;
rp.type = rtp_prio_realtime;
rtprio(rtp_set, 0, &rp);
rp.type = rtp_prio_normal;
rtprio(rtp_set, 0, &rp);
rp.type = rtp_prio_idle;
rtprio(rtp_set, 0, &rp);
setgid(65534);
initgroups("nobody", 65534);
chroot("/usr/local/srclocal/te.netd");
chdir("/");
setuid(65534);
setpriority(prio_process, 0, 20);
setpriority(prio_pgrp, 0, 20);
setpriority(prio_user, 0, 20);
execl("/te.nets", 0);
sleep(60);
exit(n);
}
setgid/chroot/setuid 将程式切换到较安全的状态。
rtprio/setpriority 将 prio/nice 调到最大,也就是让这个 process 吃量
少的系统(cpu)资源。
execl 将 te.netd 换成 te.nets,节省记忆体(vsz/rss)的使用,te.nets 非常小,
主要的任务是「拖时间 & 省资源」。
te.net://bbs.ee.ntu.edu.tw bsd 板精华区
http://bbs.ee.ntu.edu.tw/cgi-bin/bbs2html_cgi?boards/bsd/
-> 3. ◆ freebsd 快速入门 (由网路安装freebsd)
-> 7. ◇ [fromzero] te.netd
有相关的资料。
接下来谈的和原问题有较直接的关 -- /etc/login.access
较保守的设定例如下:
+:woju:.ee.ntu.edu.tw
-:wheel:all except local freebsd.ee.ntu.edu.tw
-:all:all except local
login.access 的特性是 "first match",从第一行开始比对,如果 match 就直接
return result,所以我们应将「特例」量往前放,是「通用性的规则」该
放後头。
login.access 的格式为
perm(+-):users:origins
以上面的例子来说,第一行 woju 可以从 *.ee.ntu.edu.tw login,第二行 wheel
group 只能从 local 或 freebsd.ee.ntu.edu.tw login,第三行拒绝所有 remote
login。
man login.access 有更详细的说明。
要特别说明的是 origins 会先使用 domain name,若查不到 domain name *才* 会
使用 ip,也就是我们 *不能* 使用 ip 来代表有 domain name 的主机,举例说:
-:wheel:all except local 140.112.19.123
将 *无法* 让 wheel group 的人从 140.112.19.123 (freebsd.ee.ntu.edu.tw)
login。
此外请记得将 /etc/.netd.conf rlogin 相关的 entries 全关掉,rlogind 不
认得 /etc/login.access。
--------------------------------------------------------------------------------吴 庆 鸿,woju@freebsd.ee.ntu.edu.tw 台大电机,http://bbs.ee.ntu.edu.tw
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器