|
23 | 23 |
|
24 | 24 | from sambacc import config
|
25 | 25 | from sambacc import leader
|
| 26 | +from sambacc import permissions |
26 | 27 | from sambacc import simple_waiter
|
27 | 28 |
|
28 | 29 | _INOTIFY_OK = True
|
@@ -153,5 +154,34 @@ def best_leader_locator(
|
153 | 154 | return ctdb.CLILeaderLocator()
|
154 | 155 |
|
155 | 156 |
|
| 157 | +def perms_handler( |
| 158 | + config: config.PermissionsConfig, |
| 159 | + path: str, |
| 160 | +) -> permissions.PermissionsHandler: |
| 161 | + """Fetch and instantiate the appropriate permissions handler for the given |
| 162 | + configuration. |
| 163 | + """ |
| 164 | + if config.method == "none": |
| 165 | + _logger.info("Using no-op permissions handler") |
| 166 | + return permissions.NoopPermsHandler( |
| 167 | + path, config.status_xattr, options=config.options |
| 168 | + ) |
| 169 | + if config.method == "initialize-share-perms": |
| 170 | + _logger.info("Using initializing posix permissions handler") |
| 171 | + return permissions.InitPosixPermsHandler( |
| 172 | + path, config.status_xattr, options=config.options |
| 173 | + ) |
| 174 | + if config.method == "always-share-perms": |
| 175 | + _logger.info("Using always-setting posix permissions handler") |
| 176 | + return permissions.AlwaysPosixPermsHandler( |
| 177 | + path, config.status_xattr, options=config.options |
| 178 | + ) |
| 179 | + # fall back to init perms handler |
| 180 | + _logger.info("Using initializing posix permissions handler") |
| 181 | + return permissions.InitPosixPermsHandler( |
| 182 | + path, config.status_xattr, options=config.options |
| 183 | + ) |
| 184 | + |
| 185 | + |
156 | 186 | commands = CommandBuilder()
|
157 | 187 | setup_steps = CommandBuilder()
|
0 commit comments