Skip to content

Commit 8406e26

Browse files
committed
MGM: Add "recycle ls --project <path>" listing for recycle projects
Allow non-privileged users to list the contents of a recycle project bin by supplying an explicit path via "recycle ls --project <path>". The server reads the sys.forced.recycleid xattr on the given path and, if present, lists the corresponding rid:<val> recycle area. If the path does not belong to a recycle project, an error is returned to the client instead of silently falling back to the per-uid listing. Fixes EOS-6603
1 parent 604330e commit 8406e26

1 file changed

Lines changed: 94 additions & 13 deletions

File tree

console/commands/native/recycle-proto-native.cc

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,100 @@
1212
namespace {
1313
std::string MakeRecycleHelp()
1414
{
15-
return "Usage: recycle [ls|purge|restore|config|project] [OPTIONS]\n\n"
16-
" [-m] print status of recycle bin\n"
17-
" ls [<date> [<limit>]] [-m] [-n] [--all] [--uid] [--rid <val>]\n"
18-
" list files in the recycle bin\n"
19-
" purge [--all] [--uid] [--rid <val>] <date> | -k <key>\n"
20-
" purge files by date or by key\n"
21-
" restore [-p] [-f|--force-original-name] [-r|--restore-versions] <key>\n"
22-
" undo deletion identified by recycle key\n"
23-
" project --path <path> [--acl <val>]\n"
24-
" setup recycle id for given top level directory\n"
25-
" config <key> <value>\n"
26-
" configure recycle policy (--dump, --add-bin, --remove-bin, "
27-
"--enable, etc.)\n";
15+
std::ostringstream oss;
16+
oss << "Usage: recycle [ls|purge|restore|config ...]\n"
17+
<< " provides recycle bin functionality\n"
18+
<< " recycle [-m]\n"
19+
<< " print status of recycle bin and config status if executed by root\n"
20+
<< " -m : display info in monitoring format\n"
21+
<< "\n"
22+
<< " recycle ls [<date> [<limit>]] [-m] [-n] [--all] [--uid] [--rid <val>] "
23+
"[--project <path>]\n"
24+
<< " list files in the recycle bin\n"
25+
<< " <date> : can be <year>, <year>/<month> or <year>/<month>/<day> "
26+
"or\n"
27+
<< " <year>/<month>/<day>/<index>\n"
28+
<< " <limit> : maximum number of entries to return when listing\n"
29+
<< " e.g.: recycle ls 2018/08/12 1000\n"
30+
<< " -m : display info in monitoring format\n"
31+
<< " -n : display numeric uid/gid(s) instead of names\n"
32+
<< " --all : display entries of all users - only if root or admin\n"
33+
<< " --uid : display entries for the current user id [default]\n"
34+
<< " --rid <val> : display entries corresponding to the given recycle id\n"
35+
<< " which represents the container id of the top directory\n"
36+
<< " e.g. recycle ls --rid 1001\n"
37+
<< " --project <path> : list the recycle project that the given path belongs\n"
38+
<< " to. The path must carry the sys.forced.recycleid\n"
39+
<< " extended attribute, otherwise an error is returned.\n"
40+
<< "\n"
41+
<< " recycle purge [--all] [--uid] [--rid <val>] <date> | -k <key>\n"
42+
<< " purge files in the recycle bin either by date or by key\n"
43+
<< " --all : purge entries of all users - only if root or admin\n"
44+
<< " --uid : purge entries for the current user [default]\n"
45+
<< " --rid <val> : purge entries corresponding to the given recycle id\n"
46+
<< " <date> : can be <year>, <year>/<month> or <year>/<month>/<day>\n"
47+
<< " and can't be used together with a recycle key\n"
48+
<< " -k <key> : purge only the given key\n"
49+
<< "\n"
50+
<< " recycle restore [-p] [-f|--force-original-name] [-r|--restore-versions] "
51+
"<key>\n"
52+
<< " undo the deletion identified by the recycle <key>\n"
53+
<< " -p : create all missing parent directories\n"
54+
<< " -f : move deleted files/dirs back to their original location\n"
55+
<< " (otherwise the key entry will have a <.inode> suffix)\n"
56+
<< " -r : restore all previous versions of a file\n"
57+
<< "\n"
58+
<< " recycle project --path <path> [--acl <val>]\n"
59+
<< " setup a recycle id that will group all the recycled paths from\n"
60+
<< " the given top level directory <path>. Optionally, specify a list\n"
61+
<< " of ACLs that are appended to the recycle location and control the\n"
62+
<< " access to the recycled entries. The recycle id is represented by the\n"
63+
<< " container id of <path> and is used to construct the recycle path:\n"
64+
<< " /eos/<instance>/proc/recycle/rid:<cid_value>/2025...\n"
65+
<< " ACL val is the usual string representation of ACLs e.g u:1234=rx\n"
66+
<< "\n"
67+
<< " recycle config <key> <value>\n"
68+
<< " where <key> and <value> need to be one of the following:\n"
69+
<< " --dump\n"
70+
<< " dump the current recycle policy configuration\n"
71+
<< " [--add-bin|--remove-bin] <sub-tree>\n"
72+
<< " --add-bin : enable recycle bin for deletion in <sub-tree>\n"
73+
<< " --remove-bin : disable recycle bin for <sub-tree>\n"
74+
<< " --enable <on/off>\n"
75+
<< " enable or disable the recycle bin functionality\n"
76+
<< " Default value: on\n"
77+
<< " --enforce <on/off>\n"
78+
<< " enforce default recycle bin location globally on the instance\n"
79+
<< " Default value: off\n"
80+
<< " --lifetime <seconds>\n"
81+
<< " configure FIFO lifetime for the recycle bin\n"
82+
<< " --ratio <0..1.0>\n"
83+
<< " configure the volume/inode keep ratio. E.g.: 0.8 means files\n"
84+
<< " will only be recycled if more than 80% of the volume/inodes\n"
85+
<< " quota is used. The low-watermark is by default 10% below the\n"
86+
<< " the given ratio.\n"
87+
<< " --size <value>[K|M|G]\n"
88+
<< " configure the quota for the maximum size of the recycle bin\n"
89+
<< " If no unit is set explicitly then bytes is assumed.\n"
90+
<< " --inodes <value>[K|M|G]\n"
91+
<< " configure the quota for the maximum number of inodes in the\n"
92+
<< " recycle bin.\n"
93+
<< " --dry-run <yes/no>\n"
94+
<< " when dry-run mode is enabled, no removal of entries is performed\n"
95+
<< " --collect-interval <seconds>\n"
96+
<< " how ofen the recycler collects new entries to be removed from\n"
97+
<< " the recycle bin. Default once per day i.e 86400 seconds.\n"
98+
<< " Change only for testing!\n"
99+
<< " --remove-interval <seconds>\n"
100+
<< " how often the recycler removes collected entries. The collected\n"
101+
<< " container ids to be removed are sharded and the removal is spread\n"
102+
<< " evenly across collect-interval/remove-interval slots. Default once\n"
103+
<< " every hour i.e. 3600. Change only for testing!\n"
104+
<< " Note: The last two parameters should be changed only for testing\n"
105+
<< " and while maintaining the following order:\n"
106+
<< " remove-interval << collection-interval\n"
107+
<< "\n";
108+
return oss.str();
28109
}
29110

30111
void ConfigureRecycleApp(CLI::App& app)

0 commit comments

Comments
 (0)