歡迎您光臨本站 註冊首頁

試了一下 SAMBA 的可寫不可刪還是沒弄出來 求教~

←手機掃碼閱讀     火星人 @ 2014-03-05 , reply:0

試了一下 SAMBA 的可寫不可刪還是沒弄出來 求教~

用了chattr 試了一下

除了 -i 和 -a 沒有其他發現
-a后sMB用戶在WIN下登陸新建個文本文檔 結果一這個操作建立了1000個文本文檔。。

英文不好

帖個man chattr  哪個哥們幫我想想如何達成在SAMBA上可寫不可刪的目的 十分感謝


# man chattr
CHATTR(1)                                                            CHATTR(1)

NAME
       chattr - change file attributes on a Linux second extended file system

SYNOPSIS
       chattr [ -RV ] [ -v version ] [ mode ] files...

DESCRIPTION
       chattr changes the file attributes on a Linux second extended file sys-
       tem.

       The format of a symbolic mode is +-=.

       The operator `+' causes the selected attributes  to  be  added  to  the
       existing  attributes  of  the files; `-' causes them to be removed; and
       `=' causes them to be the only attributes that the files have.

       The letters `ASacDdijsu' select the new attributes for the files: don't
       update  atime  (A),  synchronous  updates  (S),  synchronous  directory
       updates (D), append only (a), compressed (c), no  dump  (d),  immutable
       (i),  data journalling (j), secure deletion (s), top of directory hier-
       archy (T), no tail-merging (t), and undeletable (u).

OPTIONS
       -R     Recursively change attributes of directories and their contents.
              Symbolic links encountered during recursive directory traversals
              are ignored.

       -V     Be verbose with chattr's output and print the program version.

       -v version
              Set the file's version/generation number.

ATTRIBUTES
       When a file with the 'A' attribute set is accessed, its atime record is
       not modified.  This avoids a certain amount of disk I/O for laptop sys-
       tems.

       A file with the `a' attribute set can only be open in append  mode  for
       writing.    Only   the   superuser   or   a   process   pessessing  the
       CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

       A file with the `c' attribute set is automatically  compressed  on  the
       disk  by  the kernel.  A read from this file returns uncompressed data.
       A write to this file compresses data before storing them on the disk.

       When a directory with the `D' attribute set is  modified,  the  changes
       are  written  synchronously  on  the  disk;  this  is equivalent to the
       `dirsync' mount option applied to a subset of the files.

       A file with the `d' attribute set is not candidate for backup when  the
       dump(8) program is run.

       The  'E'  attribute  is used by the experimental compression patches to
       indicate that a compressed file has a compression error.  It may not be
       set  or  reset  using  chattr(1),  although  it  can  be  displayed  by
       lsattr(1).

       The 'I' attribute is used by the htree code to indicate that  a  direc-
       tory  is behind indexed using hashed trees.  It may not be set or reset
       using chattr(1), although it can be displayed by lsattr(1).

       A file with the `i' attribute cannot be modified: it cannot be  deleted
       or  renamed,  no  link  can  be created to this file and no data can be
       written to the file.  Only the superuser or a  process  pessessing  the
       CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

       A  file  with the `j' attribute has all of its data written to the ext3
       journal before being written to the file itself, if the  filesystem  is
       mounted  with the "data=ordered" or "data=writeback" options.  When the
       filesystem is mounted with the "data=journalled" option all  file  data
       is already journalled and this attribute has no effect.  Only the supe-
       ruser or a process possessing the CAP_SYS_RESOURCE capability  can  set
       or clear this attribute.

       When  a  file  with  the  `s'  attribute set is deleted, its blocks are
       zeroed and written back to the disk.

       When a file with the `S' attribute set is  modified,  the  changes  are
       written  synchronously  on  the  disk; this is equivalent to the `sync'
       mount option applied to a subset of the files.

       A directory with the 'T' attribute will be deemed  to  be  the  top  of
       directory  hierarchies  for  the  purposes of the Orlov block allocator
       (which is used in on systems with Linux 2.5.46 or later).

       A file with the 't' attribute will not have a partial block fragment at
       the  of  the  file merged with other files (for those filesystems which
       support tail-merging).  This is necessary for applications such as LILO
       which  read  the  filesystem  directly,  and who don't understand tail-
       merged files.

       When a file with the `u' attribute set is  deleted,  its  contents  are
       saved.  This allows the user to ask for its undeletion.

       The  'X'  attribute  is used by the experimental compression patches to
       indicate that a raw contents of  a  compressed  file  can  be  accessed
       directly.   It  currently  may  not  be  set  or reset using chattr(1),
       although it can be displayed by lsattr(1).

       The 'Z' attribute is used by the experimental  compression  patches  to
       indicate  a compressed file is dirty.  It may not be set or reset using
       chattr(1), although it can be displayed by lsattr(1).

AUTHOR
       chattr was written by Remy Card <Remy.Card@linux.org>.

BUGS AND LIMITATIONS
       As of Linux 2.2, the `c', 's',  and `u' attribute are  not  honored  by
       the  kernel filesystem code.    These attributes will be implemented in
       a future ext2 fs version.

       The `j' option is only useful if the filesystem is mounted as ext3.

       The `D' option is only useful on Linux kernel 2.5.19 and later.

AVAILABILITY
       chattr  is  part  of  the  e2fsprogs  package  and  is  available  from
       http://e2fsprogs.sourceforge.net.

SEE ALSO
       lsattr(1)

E2fsprogs version 1.32           November 2002                       CHATTR(1)
(END)
《解決方案》

  chattr
  
  1.作用
  
  修改ext2和ext3文件系統屬性(attribute),使用許可權超級用戶。
  
  2.格式
  
  chattr [-RV] [-+=AacDdijsSu] [-v version] 文件或目錄
  
  3.主要參數
  
  -R:遞歸處理所有的文件及子目錄。
  
  -V:詳細顯示修改內容,並列印輸出。
  
  -:失效屬性。
  
  +:激活屬性。
  
  = :指定屬性。
  
  A:Atime,告訴系統不要修改對這個文件的最後訪問時間。
  
  S:Sync,一旦應用程序對這個文件執行了寫操作,使系統立刻把修改的結果寫到磁碟。
  
  a:Append Only,系統只允許在這個文件之後追加數據,不允許任何進程覆蓋或截斷這個文件。如果目錄具有這個屬性,系統將只允許在這個目錄下建立和修改文件,而不允許刪除任何文件。
  
  i:Immutable,系統不允許對這個文件進行任何的修改。如果目錄具有這個屬性,那麼任何的進程只能修改目錄之下的文件,不允許建立和刪除文件。
  
  D:檢查壓縮文件中的錯誤。
  
  d:No dump,在進行文件系統備份時,dump程序將忽略這個文件。
  
  C:Compress,系統以透明的方式壓縮這個文件。從這個文件讀取時,返回的是解壓之後的數據;而向這個文件中寫入數據時,數據首先被壓縮之後才寫入磁碟。
  
  :Secure Delete,讓系統在刪除這個文件時,使用0填充文件所在的區域。
  
  u:Undelete,當一個應用程序請求刪除這個文件,系統會保留其數據塊以便以後能夠恢復刪除這個文件。
《解決方案》

不知道samba是否能夠實現這樣的控制。

不過,樓主是否可以考慮使用個ftp呢?
《解決方案》

剛才我試了一下,有些問題:

linux下用命令:chattr -RV +a $SAMBA_SHARE_DIR/path/

然後在windows下進入path/目錄下,新建文件可以,複製文件到path/目錄下,發現只能複製一個文件名,內容為空,不管什麼文件複製過去都是0位元組。不過刪除倒是真的不能刪除,不管有無許可權的用戶或Linux下的root用戶均不能刪除。和+i屬性一樣。

不知哪位大俠有好的辦法?
《解決方案》

自己建立的文件卻不準自己刪除掉,實在不可理解。要是不小心就來了個「新建文件夾」,然後再來個「新建文件夾(2)」,真不知要怎樣累死管理員?
還是喜歡samba的自己的文件只有自己能夠刪除這一特色功能,NTFS的那個功能實在沒有多大的用處。真的要是有一個文件極其重要,ssh上去修改屬主不是很好嗎?
《解決方案》

應該可做到,用Se Linux 或lids 可以進行更多的控制。
《解決方案》

說什麼為了預防搗蛋,只准追加不準刪減,人家直接來個刷屏,更會氣死人的。准許刪減嘛,直接清零比刪除文件還惡劣。
《解決方案》

無果
《解決方案》

聽同事說是用sudo實現的 可他也忘啦
《解決方案》

chattr我也試過。結果和你說的一樣。不行!!!

新建立文件夾可以,建立一個文件成了一千個。。。而且現在我用ROOT也刪除不了:em12::em12::em12::em12:

[火星人 ] 試了一下 SAMBA 的可寫不可刪還是沒弄出來 求教~已經有484次圍觀

http://coctec.com/docs/service/show-post-44837.html