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

Commit 3d63baf

Browse files
committed
Check and fix public links
1 parent d4e0a85 commit 3d63baf

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

cernbox-share

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def main():
9797
subcmd.add_argument("--project-name", default="", action='store', help="check project and override home directory")
9898
subcmd.add_argument("--logdir",default="",action="store",help="log directory")
9999
subcmd.add_argument("--orphans", default=False, action='store_true', help="check for shares already marked as orphans")
100+
subcmd.add_argument("--public-links", default=False, action='store_true', help="Check public links as well (if not, it will only check internal shares)")
100101
subcmd.add_argument("shares_owner", help="'-' to check all users in the system")
101102

102103
subcmd = subparser.add_parser('remove-orphan-xbits', help="remove xbits which were set in the initial implementation in the parent ACLs")

python/cernbox_utils/cmd_share_admin.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ def verify(args,config,eos,db):
3939
fh.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
4040
logger.addHandler(fh)
4141

42-
shares=db.get_share(owner=args.shares_owner,share_type="regular",orphans=args.orphans)
42+
share_type="regular"
43+
if args.public_links:
44+
if args.deep_fs_check:
45+
logger.critical("Cannot set deep fs scan with public links option")
46+
return
47+
# Search for normal shares AND public links
48+
share_type=None
49+
50+
shares=db.get_share(owner=args.shares_owner,share_type=share_type,orphans=args.orphans)
4351

4452
# if needed this can be used to split read from write traffic in order not to overload the instance
4553

@@ -142,7 +150,7 @@ def verify(args,config,eos,db):
142150
except KeyError:
143151
unique_share_keys[unique_key] = s
144152

145-
if s.file_target.count("/")>1:
153+
if s.share_type != 3 and s.file_target.count("/")>1:
146154
logger.error("FILE_TARGET_MULTIPLE_SLASH_PROBLEM id=%d owner=%s sharee=%s target='%s' fid=%s stime=%s",s.id,s.uid_owner,s.share_with,s.file_target,fid,s.stime)
147155
fixed_target='/%s'%os.path.basename(s.file_target)
148156
assert("'" not in fixed_target)
@@ -164,6 +172,8 @@ def verify(args,config,eos,db):
164172

165173
if s.share_type == 1:
166174
logger.info("Share type 1 (egroup). Not checking if destination exists")
175+
elif s.share_type == 3:
176+
logger.info("Share type 3 (public link). Not checking if destination exists")
167177
else:
168178
try:
169179
pwd.getpwnam(s.share_with)
@@ -181,16 +191,16 @@ def verify(args,config,eos,db):
181191
if args.fix:
182192
db.set_orphan(s.id, orphan=0)
183193

184-
185-
# this is the expected ACL entry in the shared directory tree
186-
acl = cernbox_utils.sharing.share2acl(s)
194+
if s.share_type != 3:
195+
# this is the expected ACL entry in the shared directory tree
196+
acl = cernbox_utils.sharing.share2acl(s)
187197

188-
shared_fids.setdefault(fid,[]).append(acl)
198+
shared_fids.setdefault(fid,[]).append(acl)
189199

190-
p = os.path.normpath(f.file)+"/" # append trailing slash, otherwise directories which basename is a substring give false positive, e.g.: /eos/user/k/kuba/tmp.readonly /eos/user/k/kuba/tmp
191-
p = p.decode('utf8')
192-
shared_paths[p] = fid
193-
shared_acls.setdefault(p,[]).append(acl)
200+
p = os.path.normpath(f.file)+"/" # append trailing slash, otherwise directories which basename is a substring give false positive, e.g.: /eos/user/k/kuba/tmp.readonly /eos/user/k/kuba/tmp
201+
p = p.decode('utf8')
202+
shared_paths[p] = fid
203+
shared_acls.setdefault(p,[]).append(acl)
194204

195205

196206
logger.info("Expected shared paths with visibility to others (%s)",len(shared_acls))

0 commit comments

Comments
 (0)