Skip to content

8.1 Directory and File Access Authorization

The computing platform now applies a stricter security policy: personal directories are private by default and can be accessed only by the owner. If you need to share a directory or file for collaboration, do not open your entire home directory, and do not use broad permissions such aschmod 777. Choose the correct ACL command for the filesystem and grant access only to the required user or group.

8.1.1 Authorization Principles

  • Grant access only to the users or groups that really need it.
  • Share only the required directory. Use a dedicated directory such as~/shareor~/public.
  • Grant only the required permissions. Prefer read-only access when write access is not needed.
  • Grant only the minimum traversal permission on parent directories.
  • Revoke access when it is no longer needed.
  • For sensitive data, experiment data, or unpublished results, confirm the data management requirements of your experiment group first.

8.1.2 Identify the Directory Type

Different filesystems use different ACL commands. Check the path before changing permissions.

Directory type Common paths Commands
AFS /afs/ihep.ac.cn/users/{a-z}/{username} fs setacl,fs listacl
Lustre/POSIX-like /home,/scratchfs,/sharefs,/aifs,/sugonfs,/ihepfs, etc. setfacl,getfacl
EOS /eos/juno,/eos/lhaaso, etc. eos acl

Warning

ACL commands for AFS, Lustre/POSIX-like directories, and EOS are different and cannot be used interchangeably. If you are not sure which filesystem you are using, runpwdand check the path first.

8.1.3 AFS Directories

AFS uses its own ACL mechanism. Standardchmoddoes not manage AFS directory access permissions. AFS permissions are set on directories. To share a file, put it in a directory with the proper ACL.

Common permissions:

Permission Meaning
l list directory contents
r read file contents, usually used together withl
rl enter and read, commonly used for read-only sharing
write write access, including common read/write permissions
all all permissions
none remove access for the user or group

Grant access to a user:

# Allow zhangsan to read ~/publicfssetacl-dir~/public-aclzhangsanrl# Allow zhangsan to read and write ~/projectfssetacl-dir~/project-aclzhangsanwrite

Grant access to a group:

fssetacl-dir~/public-aclbes:membersrl

View and revoke access:

fslistacl-path~/publicfssetacl-dir~/public-aclzhangsannone

Opening a directory to all AFS-accessible users should be treated as an exception and revoked after use:

fssetacl-dir~/public-aclsystem:anyuserrlfssetacl-dir~/public-aclsystem:anyusernone

To let another user access~/public, the user must also be able to reach that path. A safer approach is to grant onlylon the parent directory andrlon the shared directory:

fssetacl-dir~-aclzhangsanlfssetacl-dir~/public-aclzhangsanrl

If you cannot access your own AFS files, your credentials may have expired. Refresh them with:

kinitusernameaklog-d

8.1.4 Lustre/POSIX-like Directories

Directories such as/home,/scratchfs,/sharefs,/aifs,/sugonfs, and/ihepfsusually follow Linux POSIX permission rules. Usesetfaclto grant fine-grained access to a specific user or group.

Grant access to a user:

# Allow zhangsan to enter and readsetfacl-muser:zhangsan:rx/home/cc/myname/share# Allow zhangsan to read and writesetfacl-muser:zhangsan:rwx/home/cc/myname/share

Grant access to a group:

setfacl-mgroup:besusers:rx/home/cc/myname/share

For directories,xmeans the directory can be entered. Read-only sharing usually usesrx.

Apply permissions recursively to existing subdirectories and files:

setfacl-R-muser:zhangsan:rX/home/cc/myname/share

Here-Rmeans recursive. UppercaseXadds execute permission only to directories and files that are already executable. It does not add execute permission to ordinary data files. To make new files inherit the same permission, add a default ACL:

setfacl-R-d-muser:zhangsan:rX/home/cc/myname/share

View and remove ACL entries:

getfacl/home/cc/myname/sharesetfacl-xuser:zhangsan/home/cc/myname/sharesetfacl-b/home/cc/myname/share

A directory with ACL entries will show a+at the end of the permission bits inls -l.setfacl -bremoves all ACL entries and restores the originalchmodpermissions. Use it carefully.

To access/home/cc/myname/share, another user must havexpermission on every parent directory in the path. You can grant onlyxon a parent directory, withoutr, so the user can pass through but cannot list other files:

setfacl-muser:zhangsan:x/home/cc/myname

Note

Only the directory owner can set ACLs on that directory. If a Lustre volume reports that user ACLs or extended attributes are not supported, contactics@ihep.ac.cn.

8.1.5 EOS Directories

Directories such as/eos/junoand/eos/lhaasouse the EOS distributed filesystem. EOS ACLs are usually used for directory-level sharing. Avoid setting ACLs on a large number of individual files, because this may affect namespace management performance.

Grant access to a user:

# Allow zhangsan to enter and readeosacl--useru:zhangsan=rx/eos/myname/share# Allow zhangsan to read and writeeosacl--useru:zhangsan=rwx/eos/myname/share

Grant access to a group:

eosacl--userg:juno=rx/eos/myname/share

Set recursively, view, and remove ACL entries:

eosacl--user-Ru:zhangsan=rx/eos/myname/shareeosacl-l/eos/myname/shareeosacl--useru:zhangsan=/eos/myname/share

Recursive ACL operations on directories with many files may take a long time. Use them carefully.

Note

When granting EOS write access to another user, also confirm that the user has available quota under the shared directory. If no quota is available, contact the directory owner orics@ihep.ac.cn.

8.1.6 Quick Reference

Task AFS Lustre/POSIX-like EOS
Grant read-only access to a user fs setacl -dir DIR -acl USER rl setfacl -m user:USER:rx DIR eos acl --user u:USER=rx DIR
Grant read/write access to a user fs setacl -dir DIR -acl USER write setfacl -m user:USER:rwx DIR eos acl --user u:USER=rwx DIR
Grant read-only access to a group fs setacl -dir DIR -acl GROUP rl setfacl -m group:GROUP:rx DIR eos acl --user g:GROUP=rx DIR
View permissions fs listacl -path DIR getfacl DIR eos acl -l DIR
Revoke a user's access fs setacl -dir DIR -acl USER none setfacl -x user:USER DIR eos acl --user u:USER= DIR
Clear ACLs Set entries tononeone by one setfacl -b DIR Remove entries one by one

For help, contacthelpdesk@ihep.ac.cnor call88236855. For Lustre ACL enablement requests and EOS ACL problems, contactics@ihep.ac.cn.

AI 助手
快速提问 ×

有问题?输入后跳转到对话页继续交流

Baidu
map