Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Fixes for project analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
diocas committed Nov 4, 2021
1 parent 3f3d63f commit 686384b
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions python/cernbox_utils/cmd_share_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ def verify(args,config,eos,db):

import pwd

if not args.shares_owner.strip():
logger.critical("Must provide a shares_owner or '-'")
return

if args.shares_owner == '-':
if args.project_name:
logger.info("Analysing an entire project (and all shares). Skipping shares_owner")
args.shares_owner = ''
eos_project_path = os.path.join(config['eos_project_prefix'],args.project_name[0],args.project_name)

if args.deep_fs_check:
if not args.shares_owner:
logger.critical("Must provide a single shares_owner for --deep-fs-check option")
else:
if not args.shares_owner.strip():
logger.critical("Must provide a shares_owner or '-'")
return

if args.shares_owner == '-':
args.shares_owner = ''

if args.deep_fs_check:
if not args.shares_owner:
logger.critical("Must provide a single shares_owner for --deep-fs-check option")
return

if args.logdir:
import logging
fix_str = ""
Expand Down Expand Up @@ -99,6 +105,12 @@ def verify(args,config,eos,db):
if args.fix:
db.set_orphan(s.id)
continue

if args.project_name:
if not f.file.startsWith(eos_project_path):
logger.info("NOT_PROJECT_SHARE id=%d owner=%s sharee=%s target='%s' fid=%s, skipping",s.id,s.uid_owner,s.share_with,s.file_target,fid)
continue

except subprocess.CalledProcessError,x:
if x.returncode == 2:
# eos entry does not exist
Expand Down Expand Up @@ -223,7 +235,7 @@ def verify(args,config,eos,db):
return

if args.project_name:
homedir = os.path.join(config['eos_project_prefix'],args.project_name[0],args.project_name)
homedir = eos_project_path
eos_to_check = cernbox_utils.eos.EOS(get_eos_server(args.project_name, 'project'))

elif args.homedir:
Expand Down Expand Up @@ -295,19 +307,20 @@ def is_blacklisted(path):
cnt_skipped += 1
continue

# expected ACL
uid = str(pwd.getpwnam(args.shares_owner).pw_uid)
expected_acls = [eos.AclEntry(entity="u",name=uid,bits="rwx")] # this acl entry should be always set for every directory in homedir

p = os.path.normpath(file)

if args.project_name:
expected_acls += [eos.AclEntry(entity="egroup",name='cernbox-project-%s-writers'%args.project_name, bits="rwx+d"),
expected_acls = [eos.AclEntry(entity="egroup",name='cernbox-project-%s-writers'%args.project_name, bits="rwx+d"),
eos.AclEntry(entity="egroup",name='cernbox-project-%s-readers'%args.project_name, bits="rx")]


if p.startswith(os.path.join(homedir,'www')):
expected_acls += [eos.AclEntry(entity="u",name='83367',bits='rx')] # uid wwweos

else:
# expected ACL
uid = str(pwd.getpwnam(args.shares_owner).pw_uid)
expected_acls = [eos.AclEntry(entity="u",name=uid,bits="rwx")] # this acl entry should be always set for every directory in homedir

p += "/" # add trailing slash to directories, this will make sure that the top-of-shared-directory-tree also matches

Expand Down

0 comments on commit 686384b

Please sign in to comment.