vsftpd 安裝與設定  

2009年11月16日 星期一 , Posted by 曾easy in

vsftpd 安裝與設定



tar zxvf vsftpd-2.2.1.tar.gz
cd vsftpd-2.2.1
make
make install
(以下可參考INSTALL檔案)
useradd nobody
mkdir /usr/share/empty/
cp vsftpd.conf /etc
cp RedHat/vsftpd.pam /etc/pam.d/ftp


修改/etc/vsftpd.conf 如下

anonymous_enable=NO

local_enable=YES

userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd.user_list

chroot_local_user=YES


將允許登入FTP的系統帳號寫入/etc/vsftpd.user_list
vi /etc/vsftpd.user_list

test1

★ 修改使用者家目錄,要不要讓使用者用shell登入
vi /etc/passwd
test1:x:501:501::/ftproot:/sbin/nologin

★ 如有需要加入開機就執行服務
vi /etc/rc.local

/usr/local/sbin/vsftpd &


大功告成!

C macro notes  

2009年11月11日 星期三 , Posted by 曾easy in

C macro notes



★ WinCE 上 debug (沒有console, 只能寫檔看訊息)

#ifdef _WSOCK_DEBUG_
#define W_FOPEN(args) FILE *wsock_pFile;\
wsock_pFile = fopen args;
#define W_PRINT(str, ...) { fprintf(wsock_pFile, str,__VA_ARGS__); }
#define W_FCLOSE() fclose(wsock_pFile);
#else
#define W_FOPEN(args) { }
#define W_PRINT(str, ...) { }
#define W_FCLOSE() { }
#endif

☆ ---使用方式---
W_FOPEN( ("My Documents/test_lib.htm","w+") ) //W_FOPEN()裡頭一定要再加括號

W_PRINT("%s:%d", "test", 2 )
W_PRINT("\nthe end\n" )

W_FCLOSE()


來工研院也將近四年了 (去年文章)  

2009年11月9日 星期一 , Posted by 曾easy

來工研院也將近四年了
參加第四次院運. 第一次參加個人競賽~ 也可能是最後一次了 XD
以前只參加3200公尺大隊接力, 真的滿輕鬆的:P
今年跑完100公尺, 男子400接力, 3200公尺大隊接力...
腳就像不是自己的了 Orz...

如果... 明年這個時後還在工研院的話...
希望100公尺短跑可以再進步~ 所以要提前練習 :P


第一次穿釘鞋~! 只有100公尺個人賽可以穿!

男青...
男子400公尺接力的夥伴們... (第一棒規定是主管... 不在這 :P)
飲恨啦。男子400接力 大會記錄是 47.95 秒... 我們48.14, 差0.2秒 就有些微破記錄獎金了 !_!
電光去年破記錄... 今年又破記錄... 是怎樣 = =" (100公尺第一、二名都在電光 @_@)
... 今年沒破記錄... 明年要破46.66有點難了 Orz



strcat 的實作  

2009年10月8日 星期四 , Posted by 曾easy in

★ glibc strcat


#include <string.h>
#include <memcopy.h>

#undef strcat

/* Append SRC on the end of DEST. */
char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
reg_char c;

/* Find the end of the string. */
do
c = *s1++;
while (c != '\0');

/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;

do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');

return dest;
}



★ vc6.0中strcat

char * __cdecl strcat (
char * dst,
const char * src
)
{
char * cp = dst;

while( *cp )
cp++; /* find end of dst */

while( *cp++ = *src++ ) ; /* Copy src to end of dst */

return( dst ); /* return dst */

}



由這些實作來看,要注意的就是 dest 的空間要足夠(至少strlen(dest)+strlen(src)+1),且dest所指的字串一定要有'\0'結尾!

有cscope設置的 .vimrc  

2009年10月5日 星期一 , Posted by 曾easy in

有cscope設置的 .vimrc


let g:miniBufExplSplitToEdge = 0

set hls " hlsearch
set nolbr " linebreak
set ar " autoread
set ruler " show the cursor position all the time
set rulerformat=%63(%f\ %m%=%l,%c%V\ %P%)
set showcmd " display incomplete commands

set bs=2 " bacespace, allow backspacing over everything in insert mode
set enc=big5 " encoding
set mps+=<:> " matchpairs
set pt=<F10> " pastetoggle, switch between paste mode and not
set tags=tags; " search tags files recursively upward to root directory

" Auto-indent
set sts=4 " softtabstop
set sw=4 " shiftwidth
set cin " autoindent

" linux kernel code style
set shiftwidth=4
set cmdheight=2

set cino=:0t0
set fo=tcroq " formatoptions

if glob("`find $HOME/.vim/doc/ -name \*.txt -print`") != ""
helptags ~/.vim/doc
en

" color setting
syntax enable
set background=light
hi Comment ctermfg=Green
hi Search term=reverse ctermbg=4 ctermfg=7
hi Normal ctermbg=black ctermfg=white

" This tests to see if vim was configured with the '--enable-cscope' option
" when it was compiled. If it wasn't, time to recompile vim...
if has("cscope")

""""""""""""" Standard cscope/vim boilerplate

" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag

" check cscope for definition of a symbol before checking ctags: set to 1
" if you want the reverse search order.
set csto=0

" add any cscope database in current directory
"if filereadable("cscope.out") "errors in VIM 7.0
if exists("cscope.out") "OK in VIM 7.0
cs add cscope.out
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif

" show msg when any other cscope db added
set cscopeverbose


""""""""""""" My cscope/vim key mappings
"
" The following maps all invoke one of the following cscope search types:
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
"
" Below are three sets of the maps: one set that just jumps to your
" search result, one that splits the existing vim window horizontally and
" diplays your search result in the new window, and one that does the same
" thing, but does a vertical split instead (vim 6 only).
"
" I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
" unlikely that you need their default mappings (CTRL-\'s default use is
" as part of CTRL-\ CTRL-N typemap, which basically just does the same
" thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
" If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
" of these maps to use other keys. One likely candidate is 'CTRL-_'
" (which also maps to CTRL-/, which is easier to type). By default it is
" used to switch between Hebrew and English keyboard mode.
"
" All of the maps involving the <cfile> macro use '^<cfile>$': this is so
" that searches over '#include <time.h>" return only references to
" 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
" files that contain 'time.h' as part of their name).


" To do the first type of search, hit 'CTRL-\', followed by one of the
" cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope
" search will be displayed in the current window. You can use CTRL-T to
" go back to where you were before the search.
"

nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>


" Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
" makes the vim window split horizontally, with search result displayed in
" the new window.
"
" (Note: earlier versions of vim may not have the :scs command, but it
" can be simulated roughly via:
" nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>

nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>


" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one (vim 6 and up only)
"
" (Note: you may wish to put a 'set splitright' in your .vimrc
" if you prefer the new window on the right instead of the left

nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>


""""""""""""" key map timeouts
"
" By default Vim will only wait 1 second for each keystroke in a mapping.
" You may find that too short with the above typemaps. If so, you should
" either turn off mapping timeouts via 'notimeout'.
"
"set notimeout
"
" Or, you can keep timeouts, by uncommenting the timeoutlen line below,
" with your own personal favorite value (in milliseconds):
"
"set timeoutlen=4000
"
" Either way, since mapping timeout settings by default also set the
" timeouts for multicharacter 'keys codes' (like <F1>), you should also
" set ttimeout and ttimeoutlen: otherwise, you will experience strange
" delays as vim waits for a keystroke after you hit ESC (it will be
" waiting to see if the ESC is actually part of a key code like <F1>).
"
"set ttimeout
"
" personally, I find a tenth of a second to work well for key code
" timeouts. If you experience problems and have a slow terminal or network
" connection, set it higher. If you don't set ttimeoutlen, the value for
" timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
"
"set ttimeoutlen=100

endif

82法則  

2009年9月17日 星期四 , Posted by 曾easy in

..閱讀全文..

freeradius 安裝  

2009年7月10日 星期五 , Posted by 曾easy in


■ freeradius + MySQL認證 (OS: RHEL5)

tar zxvf freeradius-server-2.1.6.tar.gz
cd freeradius-server-2.1.6
./configure
make
make install

接著用phpMyAdmin建立一個radius的資料庫 (使用前, mysql service要開啟,沒登入過密碼要設定)


mysqladmin -u root password YOURPASSWORD
cd /usr/lcdocal/etc/raddb/sql/mysql
mysql -uroot -pYOURPASSWORD radius < schema.sql
vi /usr/local/etc/raddb/sql.conf
vi /usr/local/etc/raddb/clients.conf
vi /usr/local/etc/raddb/sites-enabled/default

編緝sites-enabled/default 可以將unix, files mark掉, 將sql unmark
在radius.conf, 記得uncomment 下面這行
#$INCLUDE sql.conf



■ 自訂attribute
新增一檔案
vi /usr/local/share/freeradius/dictionary.vmax
檔案內容如下:

VENDOR          VMAX                    7777

BEGIN-VENDOR    VMAX
#
#       Standard attribute
#

ATTRIBUTE       VMAX-group                      1       string


END-VENDOR      VMAX


vi /usr/local/share/freeradius/dictionary
在適當位置加入
$INCLUDE dictionary.vmax

這樣freeradius就會認得VMAX-group了
便可在radreply, radgroupreply 使用此attribute.