Chris's profile小斯PhotosBlogLists Tools Help

Blog


    6/18/2009

    fuse

    - 什麼是 fuse ?
       - Filesystem in user space.
     
    Linux 在後來有 build in ntfs 的 module 不過這只能讓 user 做 read 而不能 write
    如果要 write 就要透過 kernel fuse 的 support, 在搭配 ntfs-3g 來做 write 的動作.

    這樣提供了很多好處,因為如果因為要增加某個 feature 就不需要重新 build kernel, build kernel 是一件耗大的工程

    稍微 看了一下 fuse 其實 透過 udev listens to netlink socket to create /dev/fuse node. 這個 kernel module 主要是將底層的
    api 實作出來,讓 userspace 透過 systemcall 來呼叫.

    <待續>

    6/12/2009

    什麼是 S U I D

    什麼是 S U I D ?

     執行檔案時,在當下能獲得該檔案使用者(owner)的執行權限。

    有什麼功能和限制 ?

     1 - SUID 只對執行檔有效 (x)
     2 - 執行者對於該程式需要有執行的權限.
     3 - 在 run-time 會 "暫時" 獲得檔案擁有者的權限.

    舉個例:
     
      在 linux 下都會有 passwd 這個檔案,我以這個檔案來做個小實驗.
     
      chris@chris-x60:/tmp$ cp /usr/bin/passwd  .
      chris@chris-x60:/tmp$ ls -l passwd
      -rwxr-xr-x 1 chris chris 37084 2009-06-12 22:23 passwd
      
      chris@chris-x60:/tmp$ sudo chown root.root passwd 
      chris@chris-x60:/tmp$ ls -l passwd
      -rwxr-xr-x 1 root root 37084 2009-06-12 22:23 passwd
     
      chris@chris-x60:/tmp$ sudo chmod 700 passwd
      chris@chris-x60:/tmp$ ls -l passwd
      -rwx------ 1 root root 37084 2009-06-12 22:23 passwd
      
      這個檔案目前只有 root 能開啟 其它人是沒有任何權限的...
     
      編輯如下程式
      #include <stdio.h>

      int main() {
           FILE *fp;
           fp=fopen("passwd", "rb");

           if(fp!=NULL) {
              printf("Open Success ...\n");
           } else {
              printf("Open Fail ...\n");
           }

      return 0;
    }

     gcc -o test.c test
     
     <沒有設 SUID 時執行時>
     chris@chris-x60:/tmp$ ls -l test
     -rwxr-xr-x 1 root root 9185 2009-06-12 22:00 test

     chris@chris-x60:/tmp$ ./test
     Open Fail ...

     <設 SUID 時>
     chris@chris-x60:/tmp$ chmod 4755 test
     chris@chris-x60:/tmp$ ls -l test
     -rwsr-xr-x 1 root root 9185 2009-06-12 22:00 test

     chris@chris-x60:/tmp$ ./test
     Open Success ...
    6/11/2009

    usb mount fail

    今天發現機器上的 USB 無法自動 mount 起來,所以觀察了一下 發現了原來是 kernel 少 build in utf-8 語系。
    在console 下,觀察 dmesg 的輸出 

    while true; do dmesg -c; done



    於是檢查了一下 kernel 的 config
    發現 CONFIG_NLS_UTF8=n
    所以我們只要把它build in 就不會再出現這樣的問題囉!




    要檢查是不是有勾選 kernel 某個選項除了從 /boot/config-$(uname -r) 外還可以從 /proc/config.gz 去判斷
    zless /proc/config.gz

    不過當然要有這個 node 也是要把 kernel 的選項勾起來才有 support

    General setup
      -> [ * ] kernel .config support
      -> [ * ] Enable access .config through /proc/config.gz