#include <dirent.h>#include <errno.h>#include <fcntl.h>#include <libgen.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/time.h>#include <sys/types.h>#include <sys/wait.h>#include <time.h>#include <unistd.h>#include <atalk/acl.h>#include <atalk/adouble.h>#include <atalk/afp.h>#include <atalk/compat.h>#include <atalk/ea.h>#include <atalk/errchk.h>#include <atalk/logger.h>#include <atalk/unix.h>#include <atalk/util.h>#include <atalk/vfs.h>Macros | |
| #define | GROUPSTR_BUFSIZE 1024 |
Functions | |
| static void | closeall (int fd) |
| int | run_cmd (const char *cmd, char **cmd_argv) |
| int | daemonize (void) |
| Fork, exit parent, setsid(), chdir("/"), close all fds. | |
| void | become_root (void) |
| void | unbecome_root (void) |
| const char * | getcwdpath (void) |
| get cwd in static buffer | |
| const char * | fullpathname (const char *name) |
| Request absolute path. | |
| char * | stripped_slashes_basename (char *p) |
| Takes a buffer with a path, strips slashs, returns basename. | |
| const char * | tmpdir (void) |
| Find a suitable temporary directory for Netatalk. | |
| int | ostat (const char *path, struct stat *buf, int options) |
| int | ochown (const char *path, uid_t owner, gid_t group, int options) |
| int | ochmod (char *path, mode_t mode, const struct stat *st, int options) |
| chmod() wrapper for symlink and ACL handling | |
| int | ostatat (int dirfd, const char *path, struct stat *st, int options) |
| ostat/fsstatat multiplexer | |
| int | ochdir (const char *dir, int options) |
| symlink safe chdir replacement | |
| void | randombytes (void *buf, int n) |
| int | gmem (gid_t gid, int ngroups, gid_t *groups) |
| char * | realpath_safe (const char *path) |
| const char * | basename_safe (const char *path) |
| safe basename() replacement | |
| char * | strtok_quote (char *s, const char *delim) |
| extended strtok allows the quoted strings | |
| int | set_groups (AFPObj *obj, struct passwd *pwd) |
| const char * | print_groups (int ngroups, gid_t *groups) |
Variables | |
| static uid_t | saved_uid = -1 |
Netatalk utility functions: unix
| #define GROUPSTR_BUFSIZE 1024 |
| const char * basename_safe | ( | const char * | path | ) |
safe basename() replacement
| void become_root | ( | void | ) |
seteuid(0) and back, if either fails and panic != 0 we PANIC
|
static |
close all FDs >= a specified value
| int daemonize | ( | void | ) |
Fork, exit parent, setsid(), chdir("/"), close all fds.
| const char * fullpathname | ( | const char * | name | ) |
Request absolute path.
| const char * getcwdpath | ( | void | ) |
get cwd in static buffer
| int gmem | ( | gid_t | gid, |
| int | ngroups, | ||
| gid_t * | groups ) |
| int ochdir | ( | const char * | dir, |
| int | options ) |
symlink safe chdir replacement
Only chdirs to dir if it doesn't contain symlinks or if symlink checking is disabled
| int ochmod | ( | char * | path, |
| mode_t | mode, | ||
| const struct stat * | st, | ||
| int | options ) |
chmod() wrapper for symlink and ACL handling
| [in] | path | path |
| [in] | mode | requested mode |
| [in] | st | stat() of path or NULL |
| [in] | options | O_NOFOLLOW | O_NETATALK_ACL |
Option descriptions:
| int ochown | ( | const char * | path, |
| uid_t | owner, | ||
| gid_t | group, | ||
| int | options ) |
| int ostat | ( | const char * | path, |
| struct stat * | buf, | ||
| int | options ) |
| int ostatat | ( | int | dirfd, |
| const char * | path, | ||
| struct stat * | st, | ||
| int | options ) |
ostat/fsstatat multiplexer
ostatat mulitplexes ostat and fstatat.
| [in] | dirfd | -1 gives AT_FDCWD |
| [in] | path | pathname |
| [in,out] | st | pointer to struct stat |
| [in] | options | file options |
| const char * print_groups | ( | int | ngroups, |
| gid_t * | groups ) |
| void randombytes | ( | void * | buf, |
| int | n ) |
Store n random bytes an buf
| char * realpath_safe | ( | const char * | path | ) |
realpath() replacement that always allocates storage for returned path
| int run_cmd | ( | const char * | cmd, |
| char ** | cmd_argv ) |
Run command in a child and wait for it to finish
| int set_groups | ( | AFPObj * | obj, |
| struct passwd * | pwd ) |
| char * stripped_slashes_basename | ( | char * | p | ) |
Takes a buffer with a path, strips slashs, returns basename.
| p | (rw) path |
path may be
or
Result is "file" or "dir"
| char * strtok_quote | ( | char * | s, |
| const char * | delim ) |
extended strtok allows the quoted strings
modified strtok.c in glibc 2.0.6
| const char * tmpdir | ( | void | ) |
Find a suitable temporary directory for Netatalk.
Creates a subdirectory for current gid if it doesn't exist. The result should be copied immediately as it may be overwritten by a subsequent call.
| void unbecome_root | ( | void | ) |
|
static |