Archive for category linux

vsftpd不能chroot的问题的问题

前两天在公司的服务器上配了一个ftp服务器,用的是vsftpd。
今天同事和我说不能创建目录也不能上传文件。
表现为使用mkdir提示:
550 Create directory operation failed.
使用put提示:
553 Could not create file.

登上去一看,果然如此。只有ls命令还能用,于是ls一下,看看有什么文件、目录之类没有,发现没有任何文件存在嘛,于是ssh远程登录上去创建一个文件夹,但是在ftp客户端中ls还是没有显示出来。据此猜测应该是ftp服务器没有改变到用户目录去。
在google上搜索之,找到一个vsftpd的配置说明。http://vsftpd.beasts.org/vsftpd_conf.html
有此段:
chroot_local_user
If set to YES, local users will be (by default) placed in a chroot() jail in their home directory after login. Warning: This option has security implications, especially if the users have upload permission, or shell access. Only enable if you know what you are doing. Note that these security implications are not vsftpd specific. They apply to all FTP daemons which offer to put local users in chroot() jails.
Default: NO

配上之后重启服务器,登录,提示 vsftpd 500 OOPS: chroot
在google之找到http://www.linuxquestions.org/questions/linux-networking-3/ftp-500-oops-cannot-change-directory-432558/
于是知道是selinux的问题,它有一个叫做”Allow ftp to read/write in the user home directories” 的选项。使用如下命令
/usr/sbin/setsebool -P ftp_home_dir 1
打开选项,重启服务器,登录,一切ok了。

感谢google,感谢…你懂的。

1 Comment

新浪微博使用curl

  1. SINAUSER=username
  2. SINAPASS=password
  3. SINACOOKIE=/path/store/sina/cookie
  4. curl -d "service=miniblog&entry=miniblog&username=${SINAUSER}&password=${SINAPASS}&url=http://t.sina.com.cn/ajaxlogin.php"  "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.0)" -e "http://t.sina.com.cn/" -c ${SINACOOKIE} -s >> /dev/null
  5.  curl -d "content=${STATUS}&pic=&from=myprofile" "http://t.sina.com.cn/mblog/publish.php" -e "http://t.sina.com.cn/jinuljt" -b ${SINACOOKIE}

,

No Comments

默认google dns 服务器

Local DNS Cache for Faster Browsing

推荐上文。说的是在本机建立一个dns缓存机制,每次dns请求先尝试找找本机的缓存。不过对于个人计算机而言有意义有多大?不管他,反正我装了。不过我关心的不再此处,而是以下。

通过编辑 /etc/dhcp3/dhclient.conf 增加

prepend domain-name-servers 8.8.8.8;

prepend domain-name-servers 8.8.4.4;

两个配置项使得每次dhcp之后都会默认增加google 的两个dns服务器。

,

No Comments

安了ubuntu 9.10后遇到的问题

emacs 23 切换输入法不能。设置 LC_CTYPE=”zh_CN.UTF-8″
未装中文语言包,还是不行。。。
x模式的话使用emacs自带的输入法。console模式可以使用输入法。
xterm中alt键不能作为meta。 在~/.Xdefaults 加入 XTerm*VT100.metaSendsEscape: true

freemind的中文显示问题。字体问题,修改freemind字体为WenQuanYi Zen Hei。

No Comments

linux通过Blackberry上网

我的设备:blackberry 8700
我的运营商:中国移动

文件一:/etc/ppp/peers/cmwap

connect “/usr/sbin/chat -f /etc/chatscripts/cmwap.chat”

noauth
user “”
password “”

defaultroute
usepeerdns

noipdefault
nodetach
novj
nodeflate
nobsdcomp
noaccomp
nocrtscts
nomultilink
nopcomp
nomagic

passive

ipcp-restart 7
ipcp-accept-local
ipcp-accept-remote

lcp-echo-interval 0
lcp-echo-failure 999

mtu 1492

debug

pty “/usr/sbin/pppob”

文件二:/etc/chatscripts/cmwap.chat

ABORT BUSY ABORT ‘NO CARRIER’ ABORT VOICE ABORT ‘NO DIALTONE’ ABORT ‘NO DIAL TONE’ ABORT ‘NO ANSWER’ ABORT DELAYED ABORT ERROR
OK ‘AT+CGDCONT=1,”IP”,”cmwap”‘
OK ‘ATDT*99#’

命令:sudo pppd call cmwap

ps:显然将/etc/chatscripts/cmwap.chat文件中的cmwap改为cmnet,就可以上cmnet了。
pps:显然文件名与 call 的文件名是相关的,随便改。

No Comments

同时更新renren与twitter

同时更新 renren与twitter状态的bash脚本。

对于renren网,使用curl模拟登录与提交。
之与twiiter则使用curl直接调用其api提交。

  1. #!/bin/bash
  2. CURL=/usr/bin/curl
  3. COOKIE=/tmp/renren.cookie
  4. STATUS=$1
  5. RRUSER=renren username
  6. RRPASS=renren password
  7. TWUSER=twitter username
  8. TWPASS=twitter password
  9. ${CURL} -d "email=${RRUSER}&password=${RRPASS}" "http://passport.renren.com/PLogin.do"   -c ${COOKIE} -L -s  >> /dev/null
  10. RESPONSE=`${CURL} -d "c=${STATUS}&raw=${STATUS}&isAtHome=1" "http://status.renren.com/doing/update.do?" -e "http://status.renren.com/ajaxproxy.htm"  -b ${COOKIE} -L -s`
  11. #echo ${RESPONSE}
  12. echo "Update renren.com"
  13. if echo ${RESPONSE}|grep -q "updateStatusId"
  14. then
  15. echo "successful"
  16. else
  17. echo "fail"
  18. fi
  19.  
  20. RESPONSE=`${CURL} -u "${TWUSER}:${TWPASS}" -d status="${STATUS}" https://twitter.com/statuses/update.xml -s`
  21. #echo ${RESPONSE}
  22. echo "Update twitter.com"
  23. if echo ${RESPONSE}|grep -q "status"
  24. then
  25. echo "successful"
  26. else
  27. echo "fail"
  28. fi

, ,

2 Comments

inotifywait + rsync 同步源代码

  1. #!/bin/sh
  2. SRC_DIR=$1
  3. DST_DIR=$2
  4. #etc:rsync_moniter /home/user/cpp_src user@pc_name:/home/user/
  5. echo "if there file modify,create,delete happens on  \"$1\" ,it will auto  rsync with \"$2\""
  6. inotifywait -mrq –exclude ".*(swp|swx|~)" -e modify,create,delete $SRC_DIR|
  7. while read line
  8. do
  9. rsync -a $SRC_DIR $DST_DIR
  10. done

一般在本机上写代码,需要在rhel5上面编译,跑程序。

懒得复制来复制去的(- -b,代码相当ugly,debug比较多)。

inotifywait监控文件增删改,然后调用rsync同步文件。

, ,

No Comments

openssh-client 支持socks4a代理

买了vps之后就建了一个vpn,可是很明显,vpn不能够满足我的要求。

所有的数据都从vpn走的话,是很方便,不用分辨哪些网站不能走正常途径。可是访问国内网站就比较慢了。所以还是选择使用ssh隧道来做到动态选择。

唯一的问题在于ssh隧道支持不支持socks4a,那么dns解析只能在本地进行。而dns总是会得到一些fake 信息,也挺烦人的。

万幸,搜到此文 Patch for SOCKS4A in OpenSsh ,于是换了ssh客户端。

privoxy socks4a + ssh tunnel 搞定一切代理,过滤。

,

No Comments

抛弃gds换用beagle

放弃google desktop search(gds)这个略显臃肿的东西,换上beagle。
每次计算机打开gds都要狂读一阵硬盘,对于检索的结果我也不甚满意。其实比较怀疑它是导致我计算机移动死机的元凶。毕竟从不起动它到如今的这段日子里面没有这类事情发生了。使用windows时放弃gds是因其无缘无故cpu占用99%。之前还使用过的google web accelerator 也是这个原因。
对于beagle唯一不是很满意的地方在于使用的是mono。
beagle 好用嘛?不知。且试试,不过至少可以检索我的pidgin聊天记录了。为什么gds死活不行呢?我已经把目录加到index列表了。

No Comments

使用s3curl备份blog

对于备份blog我已经有很长时间的念想了。

把数据库备份在本机这种烂事我不想干……

每日发邮件备份?这个我是最先想到的,不过挺麻烦的,没有仔细整。

今日看blog的时候真好有人说的amazon s3服务,便宜,使用简单,于是一试。

期间也遇到一些问题参考了该文

写了一个脚本,在cron里让丫每天执行一次备份,从此省心了。

看了一下,目前我的blog db压缩后只有144kb,s3的服务又如此廉价,我很放心。

, ,

No Comments