netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
cnid_mysql.c File Reference
`#include <arpa/inet.h>`
`#include <errno.h>`
`#include <net/if.h>`
`#include <netdb.h>`
`#include <netinet/in.h>`
`#include <netinet/tcp.h>`
`#include <stdlib.h>`
`#include <sys/param.h>`
`#include <sys/socket.h>`
`#include <sys/stat.h>`
`#include <sys/time.h>`
`#include <sys/uio.h>`
`#include <sys/un.h>`
`#include <time.h>`
`#include <errmsg.h>`
`#include <mysql.h>`
`#include <mysqld_error.h>`
`#include <atalk/adouble.h>`
`#include <atalk/cnid_bdb_private.h>`
`#include <atalk/cnid_mysql_private.h>`
`#include <atalk/errchk.h>`
`#include <atalk/globals.h>`
`#include <atalk/logger.h>`
`#include <atalk/unix.h>`
`#include <atalk/util.h>`
`#include <atalk/volume.h>`

## Functions
static int | init_prepared_stmt_lookup (CNID_mysql_private *db)
static int | init_prepared_stmt_add (CNID_mysql_private *db)
static int | init_prepared_stmt_put (CNID_mysql_private *db)
static int | init_prepared_stmt (CNID_mysql_private *db)
static void | close_prepared_stmt (CNID_mysql_private *db)
static int | cnid_mysql_execute (MYSQL *con, const char *sql)
int | cnid_mysql_delete (struct _cnid_db *cdb, const cnid_t id)
void | cnid_mysql_close (struct _cnid_db *cdb)
int | cnid_mysql_update (struct _cnid_db *cdb, cnid_t id, const struct stat *st, cnid_t did, const char *name, size_t len)
cnid_t | cnid_mysql_lookup (struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t len)
cnid_t | cnid_mysql_add (struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t len, cnid_t hint)
cnid_t | cnid_mysql_get (struct _cnid_db *cdb, cnid_t did, const char *name, size_t len)
char * | cnid_mysql_resolve (struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len)
int | cnid_mysql_getstamp (struct _cnid_db *cdb, void *buffer, const size_t len)
int | cnid_mysql_find (struct _cnid_db *cdb, const char *name, size_t namelen, void *buffer, size_t buflen, bool *more_available)
| Backend implementation of cnid_find() for the mysql backend.
cnid_t | cnid_mysql_rebuild_add (struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t len, cnid_t hint)
int | cnid_mysql_wipe (struct _cnid_db *cdb)
static struct _cnid_db * | cnid_mysql_new (struct vol *vol)
struct _cnid_db * | cnid_mysql_open (struct cnid_open_args *args)

## Variables
static MYSQL_BIND | lookup_param [4]
static MYSQL_BIND | lookup_result [5]
static MYSQL_BIND | add_param [4]
static MYSQL_BIND | put_param [5]
static char | stmt_param_name [MAXPATHLEN]
static unsigned long | stmt_param_name_len
static unsigned long long | stmt_param_id
static unsigned long long | stmt_param_did
static unsigned long long | stmt_param_dev
static unsigned long long | stmt_param_ino
static unsigned long long | lookup_result_id
static unsigned long long | lookup_result_did
static char | lookup_result_name [MAXPATHLEN]
static unsigned long | lookup_result_name_len
static unsigned long long | lookup_result_dev
static unsigned long long | lookup_result_ino
struct _cnid_module | cnid_mysql_module

## Function Documentation

## ◆ close_prepared_stmt()

void close_prepared_stmt | ( | CNID_mysql_private * | db | ) |
| static

## ◆ cnid_mysql_add()

cnid_t cnid_mysql_add | ( | struct _cnid_db * | cdb,
|  | const struct stat * | st,
|  | cnid_t | did,
|  | const char * | name,
|  | size_t | len,
|  | cnid_t | hint )

## ◆ cnid_mysql_close()

void cnid_mysql_close | ( | struct _cnid_db * | cdb | ) |

## ◆ cnid_mysql_delete()

int cnid_mysql_delete | ( | struct _cnid_db * | cdb,
|  | const cnid_t | id )

## ◆ cnid_mysql_execute()

int cnid_mysql_execute | ( | MYSQL * | con,
|  | const char * | sql )
| static

## ◆ cnid_mysql_find()

int cnid_mysql_find | ( | struct _cnid_db * | cdb,
|  | const char * | name,
|  | size_t | namelen,
|  | void * | buffer,
|  | size_t | buflen,
|  | bool * | more_available )

Backend implementation of cnid_find() for the mysql backend.

Parameters are pre-validated by the libatalk/cnid/cnid.c wrapper, so cdb, name, namelen and buflen are all sane on entry. Detects truncation by building "LIMIT max_results + 1" into the SQL and observing whether the extra row was produced; reports it via `more_available`.

The Name LIKE parameter is bound via mysql_stmt_bind_param, never inlined into the SQL string, to prevent a filename SQL-injection vector. The LIMIT literal is not user-controlled (derived from caller's buflen) and is safely interpolated into the SQL string.

## ◆ cnid_mysql_get()

cnid_t cnid_mysql_get | ( | struct _cnid_db * | cdb,
|  | cnid_t | did,
|  | const char * | name,
|  | size_t | len )

## ◆ cnid_mysql_getstamp()

int cnid_mysql_getstamp | ( | struct _cnid_db * | cdb,
|  | void * | buffer,
|  | const size_t | len )

Caller passes buffer where we will store the db stamp

## ◆ cnid_mysql_lookup()

cnid_t cnid_mysql_lookup | ( | struct _cnid_db * | cdb,
|  | const struct stat * | st,
|  | cnid_t | did,
|  | const char * | name,
|  | size_t | len )

## ◆ cnid_mysql_new()

struct _cnid_db * cnid_mysql_new | ( | struct vol * | vol | ) |
| static

## ◆ cnid_mysql_open()

struct _cnid_db * cnid_mysql_open | ( | struct cnid_open_args * | args | ) |

## ◆ cnid_mysql_rebuild_add()

cnid_t cnid_mysql_rebuild_add | ( | struct _cnid_db * | cdb,
|  | const struct stat * | st,
|  | cnid_t | did,
|  | const char * | name,
|  | size_t | len,
|  | cnid_t | hint )

## ◆ cnid_mysql_resolve()

char * cnid_mysql_resolve | ( | struct _cnid_db * | cdb,
|  | cnid_t * | id,
|  | void * | buffer,
|  | size_t | len )

## ◆ cnid_mysql_update()

int cnid_mysql_update | ( | struct _cnid_db * | cdb,
|  | cnid_t | id,
|  | const struct stat * | st,
|  | cnid_t | did,
|  | const char * | name,
|  | size_t | len )

## ◆ cnid_mysql_wipe()

int cnid_mysql_wipe | ( | struct _cnid_db * | cdb | ) |

## ◆ init_prepared_stmt()

int init_prepared_stmt | ( | CNID_mysql_private * | db | ) |
| static

## ◆ init_prepared_stmt_add()

int init_prepared_stmt_add | ( | CNID_mysql_private * | db | ) |
| static

## ◆ init_prepared_stmt_lookup()

int init_prepared_stmt_lookup | ( | CNID_mysql_private * | db | ) |
| static

## ◆ init_prepared_stmt_put()

int init_prepared_stmt_put | ( | CNID_mysql_private * | db | ) |
| static

## Variable Documentation

## ◆ add_param

MYSQL_BIND add_param[4]
| static

## ◆ cnid_mysql_module

struct _cnid_module cnid_mysql_module

Initial value:
= {
"mysql",
{NULL, NULL},
cnid_mysql_open,
0
}
cnid_mysql_open
struct _cnid_db * cnid_mysql_open(struct cnid_open_args *args)
Definition cnid_mysql.c:1073
NULL
#define NULL
Definition utf8util.c:47

## ◆ lookup_param

MYSQL_BIND lookup_param[4]
| static

## ◆ lookup_result

MYSQL_BIND lookup_result[5]
| static

## ◆ lookup_result_dev

unsigned long long lookup_result_dev
| static

## ◆ lookup_result_did

unsigned long long lookup_result_did
| static

## ◆ lookup_result_id

unsigned long long lookup_result_id
| static

lookup result parameters

## ◆ lookup_result_ino

unsigned long long lookup_result_ino
| static

## ◆ lookup_result_name

char lookup_result_name[MAXPATHLEN]
| static

## ◆ lookup_result_name_len

unsigned long lookup_result_name_len
| static

## ◆ put_param

MYSQL_BIND put_param[5]
| static

## ◆ stmt_param_dev

unsigned long long stmt_param_dev
| static

## ◆ stmt_param_did

unsigned long long stmt_param_did
| static

## ◆ stmt_param_id

unsigned long long stmt_param_id
| static

## ◆ stmt_param_ino

unsigned long long stmt_param_ino
| static

## ◆ stmt_param_name

char stmt_param_name[MAXPATHLEN]
| static

Prepared statement parameters

## ◆ stmt_param_name_len

unsigned long stmt_param_name_len
| static