Created
February 14, 2013 04:43
-
-
Save hiroyuki-sato/4950642 to your computer and use it in GitHub Desktop.
netatalk acl check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
etc/afpd/acls.c | |
1285 /* In case we are acting on a directory prepare a default acl. For files default_acl will be NULL. | |
1286 * If the directory already has a default acl it will be preserved. | |
1287 */ | |
1288 EC_ZERO_LOG_ERR(lstat(name, &st), AFPERR_NOOBJ); | |
1289 | |
1290 if (S_ISDIR(st.st_mode)) { | |
1291 default_acl = acl_get_file(name, ACL_TYPE_DEFAULT); | |
1292 | |
1293 if (default_acl) { | |
1294 /* If default_acl is not empty then the dir has a default acl. */ | |
1295 if (acl_get_entry(default_acl, ACL_FIRST_ENTRY, &entry) == 1) | |
1296 default_acl_flags = HAS_DEFAULT_ACL; | |
1297 | |
1298 acl_free(default_acl); | |
1299 } | |
1300 default_acl = acl_dup(access_acl); | |
1301 } | |
1302 /* adds the clients aces */ | |
1303 EC_ZERO_ERR(map_aces_darwin_to_posix(daces, &default_acl, &access_acl, ace_count, &default_acl_flags), AFPERR_MISC); | |
1304 | |
1305 /* calcuate ACL mask */ | |
1306 EC_ZERO_LOG_ERR(acl_calc_mask(&access_acl), AFPERR_MISC); | |
1307 | |
1308 /* is it ok? */ | |
1309 EC_ZERO_LOG_ERR(acl_valid(access_acl), AFPERR_MISC); | |
1310 | |
1311 /* set it */ | |
1312 EC_ZERO_LOG_ERR(acl_set_file(name, ACL_TYPE_ACCESS, access_acl), AFPERR_MISC); | |
1313 EC_ZERO_LOG_ERR(vol->vfs->vfs_acl(vol, name, ACL_TYPE_ACCESS, 0, access_acl), AFPERR_MISC); | |
#ifdef HAVE_POSIX_ACLS | |
static int RF_posix_acl(VFS_FUNC_ARGS_ACL) | |
{ | |
EC_INIT; | |
static char buf[ MAXPATHLEN + 1]; | |
struct stat st; | |
int len; | |
if (stat(path, &st) == -1) | |
EC_FAIL; | |
#ifdef HAVE_POSIX_ACLS | |
#define VFS_FUNC_ARGS_ACL const struct vol *vol, const char *path, acl_type_t type, int count, acl_t acl | |
#define VFS_FUNC_VARS_ACL vol, path, type, count, acl | |
#endif | |
#define EC_ZERO_LOG_ERR(a, b) \ | |
do { \ | |
if ((a) != 0) { \ | |
LOG(log_error, logtype_default, "%s failed: %s", #a, strerror(errno)); \ | |
ret = (b); \ | |
goto cleanup; \ | |
} \ | |
} while (0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment