#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) |
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) |
const char * | tmpdir (void) |
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) |
int | ostatat (int dirfd _U_, const char *path, struct stat *st, int options) |
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) |
char * | strtok_quote (char *s, const char *delim) |
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
#define GROUPSTR_BUFSIZE 1024 |
const char * basename_safe | ( | const char * | path | ) |
Returns pointer to static buffer with basename of path
void become_root | ( | void | ) |
|
static |
int daemonize | ( | void | ) |
Daemonize
Fork, exit parent, setsid(), chdir("/"), close all fds
returns -1 on failure, but you can't do much except exit in that case since we may already have forked
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
path | (r) path |
mode | (r) requested mode |
st | (r) stat() of path or NULL |
options | (r) O_NOFOLLOW | O_NETATALK_ACL |
Options description: O_NOFOLLOW: don't chmod() symlinks, do nothing, return 0 O_NETATALK_ACL: call chmod_acl() instead of chmod() O_IGNORE: ignore chmod() request, directly return 0
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 | _U_, |
const char * | path, | ||
struct stat * | st, | ||
int | 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 | ) |
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 "[/][dir/[...]]file" or "[/][dir/[...]]dir/[/]" 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 | ) |
void unbecome_root | ( | void | ) |
|
static |