顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


主題 - chienwen

頁: [1]
1
執行 postgrey 之後,我查一下它的 socket 檔案 (/var/spool/postfix/postgrey/socket),可以看到權限是 666
代碼: [選擇]
srw-rw-rw-  1 postgrey  postgrey  0 Jan 24 09:32 socket
很直覺的,看到 o=rw,就想把它改成 660。
但是我查一下 postgrey 的執行檔程式碼 (/usr/local/sbin/postgrey),發現它特別標記要 666
代碼: [選擇]
668    # unix socket permissions should be 666
669    if($self->{server}{port}[0] =~ /^(.*)\|unix$/) {
670        chmod 0666, $1;
671    }

想請問一下:
1. socket permissions 為何要 666
2. 這樣沒有資安疑慮嗎?要怎麼改善?

2
BSD 討論版 / FreeBSD 升級 Perl 5.20 分享
« 於: 2015-01-23 10:09 »
這兩天將 Perl 5.18 升級到 5.20 (ports 標準安裝),發現一件事,檔案位置改變了:
從 /usr/bin/perl 變成 /usr/local/bin/perl
原本的 CGI 檔案,變成無法使用,而且出現 error
代碼: [選擇]
[Sun Jan 18 22:25:12 2015] [error] [client 192.168.1.111] (2)No such file or directory: exec of '/usr/local/www/index.pl' failed
[Sun Jan 18 22:25:12 2015] [error] [client 192.168.1.111] Premature end of script headers: index.pl
請修正 CGI 第一行,將 #!/usr/bin/perl 改為 #!/usr/local/bin/perl (每個 CGI 都要改,不建議)
或建立 perl 連結:(不更動 CGI,建議這樣改)
代碼: [選擇]
ln -s /usr/local/bin/perl /usr/bin/perl

3
引用
FollowSymLinks
    The server will follow symbolic links in this directory.

    Even though the server follows the symlink it does not change the pathname used to match against <Directory> sections.

    Note also, that this option gets ignored if set inside a <Location> section.

    Omitting this option should not be considered a security restriction, since symlink testing is subject to race conditions that make it circumventable.
( http://httpd.apache.org/docs/2.2/mod/core.html#options )

請教紅字部分的意思,是不是說「不要為了安全性而刪除這個選項」?

4
我用 FreeBSD 架了一個小小的 server,上面有 mail, phpbb, wiki 等等。雖然是小小的 server,這些資料對我來說,還蠻珍貴的。
因為擔心硬碟會掛點,本來想加裝 RAID,朋友建議我說,RAID 太貴了,業餘玩家不用裝到 RAID,寫個自動備份程式,每天存到 USB 隨身碟就好。
程式還不難寫,寫個 .sh 做一些 tar, mysqldump ... 等等,交給 crontab 就 OK 了。不過發現了一個很頭大的問題,就是 FreeBSD 對於 USB Storage 存在很多 bug,目前還無解!
網路上,如此說法: ([1],[2],[3],[4])

Yes, this is a known problem, for which there is no workaround at the moment.
The reason it hasn't been fixed is because "there isn't an easy fix".

我自己測試的心得是:插入或拔掉 USB Storage 時,有時侯系統會死當,有時侯不會,不知道問題出在哪兒。camcontrol 指令,似乎還不穩定,有些廠牌的 USB Storage 可以控制,有些不行。camcontrol eject/load 太多次之後,會無法 mount!

5
BSD 討論版 / save-entropy 是做什麼用途?
« 於: 2006-10-31 23:05 »
我的主機 (FreeBSD 5.3),收到大量的這種郵件,請問是代表什麼意思?
最近並沒有改什麼設定,只是按時 portupgrade -a
代碼: [選擇]
日期: Tue, 31 Oct 2006 22:55:00 +0800 (CST)
寄件者: operator@mail.my_domain (Cron Daemon)
收件者: operator@mail.my_domain
主旨: Cron <operator@mail> /usr/libexec/save-entropy
 
: not found
: not found


crontab 檔案,可以看到這些內容:
代碼: [選擇]
# Save some entropy so that /dev/random can re-seed on boot.
*/11 * * * * operator /usr/libexec/save-entropy

謝謝您。

6
我最近在處理一些文字轉換的工作。
我用程式去檢查錯誤。程式碼如下
代碼: [選擇]
package input ;

sub check_chinese_spell {
my $s = join( ", " , @_ ) ;
$s =~ s/\xB6\xD7\xB3\xF8/\xB7\x4A\xB3\xF8/g ; # 匯報 - 彙報
$s =~ s/\xB6\xD7\xBD\x73/\xB7\x4A\xBD\x73/g ; # 匯編 - 彙編
$s =~ s/\xB6\xD7\xA5\x5A/\xB7\x4A\xA5\x5A/g ; # 匯刊 - 彙刊
$s =~ s/\xB6\xD7\xB6\xB0/\xB7\x4A\xB6\xB0/g ; # 匯集 - 彙集
# ..... (有7000筆的比對項目)....
$s =~ s/\xB4\xE5\xA6\xE6/\xB9\x43\xA6\xE6/g ; # 游行 - 遊行
$s =~ s/\xB4\xE5\xBF\xB3/\xB9\x43\xBF\xB3/g ; # 游興 - 遊興
$s =~ s/\xB4\xE5\xBE\xC7/\xB9\x43\xBE\xC7/g ; # 游學 - 遊學
$s =~ s/\xAA\xED\xB5\xFD/\xAA\xED\xC3\xD2/g ; # 表証 - 表證
$s =~ s/\xBF\xEB\xB5\xFD/\xBF\xEB\xC3\xD2/g ; # 辨証 - 辨證
$s =~ s/\xC5\x47\xB5\xFD/\xC5\x47\xC3\xD2/g ; # 辯証 - 辯證

return $s ;
} ;

1 ;


程式碼約7000行 (7000個比對項目)
比對的資料約有 70萬筆。(每筆大約100個中文字)

在 PIII 1.6G, Ram 1.3G 的電腦下,須 6 個小時,程式才能跑完。
不知有沒有其他方法改寫程式,以加快執行速度?
謝謝您

7
程式討論版 / 請教如何使用 Encode::HanConvert
« 於: 2006-04-12 13:24 »
請教如何使用 Encode::HanConvert

我的系統是 FreeBSD 5.3 ; 第一次學習使用 perl + CPAN
我想把 utf8 的簡體中文, 轉成 big5 的正體中文, 但是試不成功!
請教學長們, 我錯在哪兒? 謝謝您.

我的步驟如下:

1. 安裝: Encode-2.15
下載, 並解開 http://search.cpan.org/CPAN/authors/id/D/DA/DANKOGAI/Encode-2.15.tar.gz
su 之後, 執行

perl Makefile.PL
make
make test
make install

2. 安裝: Encode-HanConvert-0.31
下載, 並解開 http://search.cpan.org/CPAN/authors/id/A/AU/AUTRIJUS/Encode-HanConvert-0.31.tar.gz

perl Makefile.PL
make
make test
make install
enc2xs -C   # optional; updates Encode.pm's on-demand loading DB

exit 離開 su.

3. 執行 perl

>perl ttt.pl
>

無錯誤訊息, 但並無法正確產生 big5 編碼的文件.

ttt.pl code 如下:
代碼: [選擇]

#!/usr/bin/perl

&test() ;

sub test {

use Encode ;
use Encode::HanConvert ;

open TXT, ">ttt.txt" ;

$w_def = "分数" ;  # utf8 simple chinese

$w_def = simp_to_big5($w_def) ;

print TXT "$w_def\n" ;

close (TXT) ;
}


產生錯誤編碼的文件, 內容如下:
代碼: [選擇]

?�?佅X

8
我本來的電腦是 256 MB ram, ( CPU 1.6 G) 用來跑 win98, win2000, FreeBSD 都很穩定.
(使用硬碟抽取盒, 一個硬碟只裝一種 OS, 分開硬碟使用, 不用 boot manager)
今天新買了 1 GB ram, 裝上去之後 (總共 1GB256MB ram),
原來的 win2000, FreeBSD 不用更改硬碟設定, 仍然跑得很穩定.
但 win98 就是開不了機, 跳出選擇 normal mode, safe mode, DOS prompt ...等等的選單.
選擇 DOS prompt 可以順利到 C:> 出現,
但選擇 normal mode, safe mode 等, 就一直進入重開機的循環, 無法進入 windows.

請問 win98 是不是無法支援太大的 ram ?? (不只無法利用多餘的 ram, 連開機都不行)
有什麼辦法可以解決嗎?? (除了再把 ram 拔掉之外!!)

謝謝您.

9
系統安全討論版 / 可以不用 reboot 嗎?
« 於: 2005-11-11 17:49 »
這些網站,幾乎一整年都不用 reboot:

http://uptime.netcraft.com/up/hosted?netname=EC17-1-YAHOO1,64.58.76.0,64.58.79.255

難道他們都不用 make buildworld 或是更新 patch 修補漏洞嗎?
還是他們有其他 upgrade 但不用 reboot 的方法?

謝謝您。

10
BSD 討論版 / DocBook Processing in FreeBSD
« 於: 2005-10-19 13:10 »
自從學習 FreeBSD 之後,常常在 handbook 的網頁中打滾。我注意到 handbook 的網頁編排,非常的有條理,似乎是有某種規則存在。而這種規則,也常常在其他的技術文章看到。我猜想應該是有某種程式,可以做出這種效果。而在我的工作上,有許多作業準則,必須寫成如 handbook 這樣的文作,又常常苦於必須把同一份文件轉成網頁 (html),列印成書面資料 (.pdf) 等各種不同格式。

後來我在 FreeBSD Chinese HOWTO 裡看到:「這份文件是由 SGML 所編寫而成的。」10 經過不斷的搜尋 "SGML",終於發現有 "DocBook" 這種文件格式,並且有相關的程式可以轉換 SGML/XML 成 html、pdf、rtf 等。這正是我要找尋的答案。

在 study-area 己有收錄四篇 Mr.老貢生 的精彩的文章:
DocBook 文件寫作入門
http://www.study-area.org/tips/docw/docwrite.html
DocBook 文件製作進階(一) 文件模組化
http://www.study-area.org/tips/docadv/docadv.html
DocBook XML/SGML Processing Using OpenJade
http://www.study-area.org/tips/doctrans/doctrans.html
在 MS Windows 下建立 DocBook 的解譯環境
http://www.study-area.org/tips/doconwin/doconwin.htm

在 FreeBSD 文件計畫下,DocBook 所須的相關套件,己經很方便的收錄在 ports 裡。因此您再也不必辛苦的到處下載 TarBall、rpm 等程式套件。摸索了將近三個月,謹將這三個月來的一點小小心得,與大家分享。

詳細的說明,以 DocBook 格式寫作,編譯成 .html 格式:
http://aa.idv.tw/note/docbook_fbsd.html
初生之犢的文章,敬請指教。

11
BSD 討論版 / pf 也可以用於防止砍站嗎?
« 於: 2005-09-29 10:20 »
曾經讀過學長發表的「防砍站scripts」(使用 IPFW)
http://phorum.study-area.org/viewtopic.php?t=13643&postdays=0&postorder=asc&start=115

最近閱讀 OpenBSD pf 有一段文章:
(原文:  http://www.openbsd.org/faq/pf/filter.html#stateopts )

An example:

    table <abusive_hosts> persist
    block in quick from <abusive_hosts>

    pass in on $ext_if proto tcp to $web_server \
        port www flags S/SA keep state \
        (max-src-conn 100, max-src-conn-rate 15/5, overload <abusive_hosts> flush)

This does the following:

    * Limits the maximum number of connections per source to 100
    * Rate limits the number of connections to 15 in a 5 second span
    * Puts the IP address of any host that breaks these limits into the <abusive_hosts> table
    * For any offending IP addresses, flush any states created by this rule.

請問 pf 的這個 rule 是不是也可以用於防止砍站?
我看不懂 scripts,也沒有再使用 IPFW,所以想問問看 pf 可否取代。
謝謝您

12
BSD 討論版 / 請教 kernel log messages 訊息
« 於: 2005-09-24 20:08 »
請問一下,螢幕上常常顯示下列訊息,並且 security run output 也會收到一份 E-mail

kernel log messages:
> Connection attempt to TCP 127.0.0.1:113 from 127.0.0.1:50102 flags:0x02
> Connection attempt to TCP 127.0.0.1:113 from 127.0.0.1:62564 flags:0x02
> Connection attempt to UDP 127.0.0.1:512 from 127.0.0.1:63039
> Connection attempt to UDP 127.0.0.1:512 from 127.0.0.1:56125
這些 localhost 的之間的連線,是代表什麼?


這兩天注意到不同的訊息:

> Connection attempt to TCP 192.168.1.123:64492 from 66.151.150.22:2703 flags:0x12

我用 IP 分享器,只有把 port 80, 443 指向 192.168.1.123,
為什麼 192.168.1.123 會記錄到 64492 的 port 連線? (從不知是誰的 66.151.150.22)


> pid 24801 (httpd), uid 80: exited on signal 6
> pid 24803 (httpd), uid 80: exited on signal 6
> pid 24711 (httpd), uid 80: exited on signal 6
這一天用 portupgrade 更新 apache,和這個有關嗎?

謝謝您

13
請問要如何用 pf 拒絕正反解不合的 mail?
http://www.openbsd.org/faq/pf/ 找不到答案!
謝謝您。

我目前只知道 TCP Wrapper 的方法:
# Block possibly spoofed requests to sendmail:
sendmail : PARANOID : deny

頁: [1]