netatalk: unix.c File Reference

netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
unix.c File Reference
`#include <errno.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/acl.h>`
`#include <sys/stat.h>`
`#include <sys/types.h>`
`#include <time.h>`
`#include <unistd.h>`
`#include <atalk/acl.h>`
`#include <atalk/afp.h>`
`#include <atalk/logger.h>`
`#include <atalk/unix.h>`
`#include <atalk/util.h>`

## Macros
#define | SEARCH_GROUP_OBJ 0x01
#define | SEARCH_MASK 0x02

## Functions
int | get_nfsv4_acl (const char *name, ace_t **retAces)
| Get ACL.
ace_t * | concat_aces (ace_t *aces1, int ace1count, ace_t *aces2, int ace2count)
int | strip_trivial_aces (ace_t **saces, int sacecount)
| Remove any trivial ACE "in-place".
int | strip_nontrivial_aces (ace_t **saces, int sacecount)
| Remove non-trivial ACEs "in-place".
int | nfsv4_chmod (char *name, mode_t mode)
| Change mode of file preserving existing explicit ACEs.
int | posix_chmod (const char *name, mode_t mode)
| POSIX ACL chmod.
int | posix_fchmod (int fd, mode_t mode)
| POSIX ACL fchmod.

## Macro Definition Documentation

## ◆ SEARCH_GROUP_OBJ

#define SEARCH_GROUP_OBJ 0x01

## ◆ SEARCH_MASK

#define SEARCH_MASK 0x02

## Function Documentation

## ◆ concat_aces()

ace_t * concat_aces | ( | ace_t * | aces1,
|  | int | ace1count,
|  | ace_t * | aces2,
|  | int | ace2count )

Concatenate ACEs

## ◆ get_nfsv4_acl()

int get_nfsv4_acl | ( | const char * | name,
|  | ace_t ** | retAces )

Get ACL.

Note
  Allocates storage as needed. Caller must free.

Returns
  no of ACEs or -1 on error.

## ◆ nfsv4_chmod()

int nfsv4_chmod | ( | char * | name,
|  | mode_t | mode )

Change mode of file preserving existing explicit ACEs.

nfsv4_chmod

1. reads objects ACL (acl1), may return 0 or -1 NFSv4 ACEs on e.g. UFS fs
2. removes all trivial ACEs from the ACL by calling strip_trivial_aces(), possibly leaving 0 ACEs in the ACL if there were only trivial ACEs as mapped from the mode
3. calls chmod() with mode, we're done if step (1) returned 0 for noaces
4. reads the changed ACL (acl2) which a. might still contain explicit ACEs (up to onnv132) b. will have any explicit ACE removed (starting with onnv145/Openindiana)
5. strip any explicit ACE from acl2 using strip_nontrivial_aces()
6. merge acl2 and acl2
7. set the ACL merged ACL on the object

## ◆ posix_chmod()

int posix_chmod | ( | const char * | name,
|  | mode_t | mode )

POSIX ACL chmod.

This is a workaround for chmod() on filestystems supporting Posix 1003.1e draft 17 compliant ACLs. For objects with extended ACLs, e.g. objects with an ACL_MASK entry, chmod() manipulates ACL_MASK instead of ACL_GROUP_OBJ. As OS X isn't aware of this behavior calling FPSetFileDirParms may lead to unpredictable results. For more information see section 23.1.2 of Posix 1003.1e draft 17.

Note
  accepts the same arguments as chmod()

Returns
  0 in case of success or -1 in case something went wrong.

## ◆ posix_fchmod()

int posix_fchmod | ( | int | fd,
|  | mode_t | mode )

POSIX ACL fchmod.

Note
  accepts the same arguments as fchmod()

Returns
  0 in case of success or -1 in case something went wrong.

## ◆ strip_nontrivial_aces()

int strip_nontrivial_aces | ( | ace_t ** | saces,
|  | int | sacecount )

Remove non-trivial ACEs "in-place".

Returns
  no of trivial ACEs.

## ◆ strip_trivial_aces()

int strip_trivial_aces | ( | ace_t ** | saces,
|  | int | sacecount )

Remove any trivial ACE "in-place".

Returns
  no of non-trivial ACEs