网站首页
JSP空间
动态资讯
开源项目
技术文档
资源下载
J2EE资源
客户论坛
在线支付
 
  技术文档>>JAVA>>新手入门>>基础入门>查看文档  
  建立anonymousftpserver     
  文章作者:未知  文章来源:水木森林  
  查看:100次  录入:管理员--2007-11-17  
 
  加入以下资料在 /etc/passwd ,这个例子选择 /export/ftp 作为 anonymous ftp area。设定为不能看见 shell 的?容 /nosuchshell。
  
  ftp:x:30000:30000:anonymous ftp:/export/ftp:/nosuchshell
  
  加入以下资料在 /etc/shadow
  
  ftp:np:6445::::::
  
  以下shell script用?设定anonymous ftp area
  
  把以下?容放入 /etc/ftpanonymous
  
  #!/bin/sh
  # script to setup anonymous ftp area
  #
  
  # verify you are root
  /usr/bin/id | grep -w 'uid=0' >/dev/null 2>&1
  if [ "$?" != "0" ]; then
  echo
  exit 1
  fi
  
  # handle the optional command line argument
  case $# in
  
  # the default location for the anon ftp comes from the passwd file
  0) ftphome="`getent passwd ftp | cut -d: -f6`"
  ;;
  
  1) if [ "$1" = "start" ]; then
  ftphome="`getent passwd ftp | cut -d: -f6`"
  else
  ftphome=$1
  fi
  ;;
  *) echo "usage: $0 [anon-ftp-root]"
  exit 1
  ;;
  esac
  
  if [ -z "${ftphome}" ]; then
  echo "$0: ftphome must be non-null"
  exit 2
  fi
  
  case ${ftphome} in
  /*) # ok
  ;;
  
  *) echo "$0: ftphome must be an absolute pathname"
  exit 1
  ;;
  esac
  
  # this script assumes that ftphome is neither / nor /usr so ...
  if [ -z "${ftphome}" -o "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; then
  echo "$0: ftphome must be non-null and neither / or /usr"
  exit 2
  fi
  
  # if ftphome does not exist but parent does, create ftphome
  if [ ! -d ${ftphome} ]; then
  # lack of -p below is intentional
  mkdir ${ftphome}
  fi
  chown root ${ftphome}
  chmod 555 ${ftphome}
  
  echo setting up anonymous ftp area ${ftphome}
  
  # ensure that the /usr directory exists
  if [ ! -d ${ftphome}/usr ]; then
  mkdir -p ${ftphome}/usr
  fi
  # now set the ownership and modes to match the man page
  chown root ${ftphome}/usr
  chmod 555 ${ftphome}/usr
  
  # ensure that the /usr/bin directory exists
  if [ ! -d ${ftphome}/usr/bin ]; then
  mkdir -p ${ftphome}/usr/bin
  fi
  # now set the ownership and modes to match the man page
  chown root ${ftphome}/usr/bin
  chmod 555 ${ftphome}/usr/bin
  
  # this may not be the right thing to do
  # but we need the bin -> usr/bin link
  rm -f ${ftphome}/bin
  ln -s usr/bin ${ftphome}/bin
  
  # ensure that the /usr/lib and /etc directories exist
  if [ ! -d ${ftphome}/usr/lib ]; then
  mkdir -p ${ftphome}/usr/lib
  fi
  chown root ${ftphome}/usr/lib
  chmod 555 ${ftphome}/usr/lib
  
  if [ ! -d ${ftphome}/usr/lib/security ]; then
  mkdir -p ${ftphome}/usr/lib/security
  fi
  chown root ${ftphome}/usr/lib/security
  chmod 555 ${ftphome}/usr/lib/security
  
  if [ ! -d ${ftphome}/etc ]; then
  mkdir -p ${ftphome}/etc
  fi
  chown root ${ftphome}/etc
  chmod 555 ${ftphome}/etc
  
  # a list of all the commands that should be copied to ${ftphome}/usr/bin
  # /usr/bin/ls is needed at a minimum.
  ftpcmd="/usr/bin/ls"
  
  # ${ftphome}/usr/lib needs to have all the libraries needed by the above
  # commands, plus the runtime linker, and some name service libraries
  
  # to resolve names. we just take all of them here.
  
  ftplib="`ldd $ftpcmd | nawk '$3 ~ /lib/ { print $3 }' | sort | uniq`"
  ftplib="$ftplib /usr/lib/nss_* /usr/lib/straddr* /usr/lib/libmp.so*"
  ftplib="$ftplib /usr/lib/libnsl.so.1 /usr/lib/libsocket.so.1 /usr/lib/ld.so.1"
  ftplib="`echo $ftplib | tr ' ' '/n' | sort | uniq`"
  
  cp ${ftplib} ${ftphome}/usr/lib
  chmod 555 ${ftphome}/usr/lib/*
  
  cp /usr/lib/security/* ${ftphome}/usr/lib/security
  chmod 555 ${ftphome}/usr/lib/security/*
  
  cp ${ftpcmd} ${ftphome}/usr/bin
  chmod 111 ${ftphome}/usr/bin/*
  
  # you also might want to have separate minimal versions of passwd and group
  cp /etc/passwd /etc/group /etc/netconfig /etc/pam.conf ${ftphome}/etc
  chmod 444 ${ftphome}/etc/*
  # need /etc/default/init for timezone to be correct
  if [ ! -d ${ftphome}/etc/default ]; then
  mkdir ${ftphome}/etc/default
  fi
  chown root ${ftphome}/etc/default
  chmod 555 ${ftphome}/etc/default
  cp /etc/default/init ${ftphome}/etc/default
  chmod 444 ${ftphome}/etc/default/init
  
  # copy timezone database
  mkdir -p ${ftphome}/usr/share/lib/zoneinfo
  (cd ${ftphome}/usr/share/lib/zoneinfo
  (cd /usr/share/lib/zoneinfo; find . -print |
  cpio -o) 2>/dev/null | cpio -imdu 2>/dev/null
  find . -print | xargs chmod 555
  find . -print | xargs chown root
  )
  
  # ensure that the /dev directory exists
  if [ ! -d ${ftphome}/dev ]; then
  mkdir -p ${ftphome}/dev
  fi
  
  # make device nodes. ticotsord and udp are necessary for
  # 'ls' to resolve nis names.
  
  for device in zero tcp udp ticotsord ticlts
  do
  line=`ls -ll /dev/${device} | sed -e 's/,//'`
  major=`echo $line | awk '{print $5}'`
  minor=`echo $line | awk '{print $6}'`
  rm -f ${ftphome}/dev/${device}
  mknod ${ftphome}/dev/${device} c ${major} ${minor}
  done
  
  chmod 666 ${ftphome}/dev/*
  
  ## now set the ownership and modes
  chown root ${ftphome}/dev
  chmod 555 ${ftphome}/dev
  
  # uncomment the below if you want a place for people to store things,
  # but beware the security implications
  #if [ ! -d ${ftphome}/pub ]; then
  # mkdir -p ${ftphome}/pub
  #fi
  #chown root ${ftphome}/pub
  #chmod 1755 ${ftphome}/pub
  
  # chmod 755 /etc/ftpanonymous
  # /etc/ftpanonymous ( 执行ftpanonymous )
  # cd ~ftp/etc <--- 检查有没有不能公开的文档
  
  完成
 
 
上一篇: jbuilderx初体验    下一篇: 无需jce用底层api实现开发rsa
  相关文档
java编程中异常问题处理方式的区别和分析 (1) 12-16
java基础:struts 框架之构建 model组件 11-27
scsa认证全面介绍 11-17
几个常见的关于日期的问题解决方法 11-17
使用 java reflection 11-16
一个合格程序员该做的事情——你做好了吗? 11-17
开源技术:在eclipse中构建备忘单 11-17
scjp认证套题解析之十二 11-16
给javabeans 增加xpath功能 11-16
j2ee基础:在struts 2中实现文件上传 11-16
开源技术:如何在eclipse中构建备忘单 11-16
scjp模拟题104道 11-17
熟练使用命令行工具开发java程序 11-17
java初学者实践教程24-反射 11-17
isfinite 方法 11-16
jdbc连接数据库经验技巧集萃 11-16
在java中操作zip文件,压缩/解压 11-17
java入门及faq__1(5) 11-17
深入java中文问题及最优解决方法 11-17
java动画编程基础 11-17
返回首页 | 关于我们 | J网章程 | JSP空间合租 | 客服中心 | 免责声明 | 常见问题 | 参观机房
本站主机空间代理至厦门市华众网络科技有限公司
《中华人民共和国增值电信业务经营许可证》
编号:闽B2-20050079
@2005-2008福建JSP技术网 版权所有 闽ICP备05000928号
技术电话:13616026886
邮箱:admin@fjjsp.com 站长QQ,点击这里给我发消息