1*ce7279d8Sjsg /* $OpenBSD: extern.h,v 1.49 2024/05/21 05:00:48 jsg Exp $ */ 260a32ee9Sbenno /* 360a32ee9Sbenno * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> 460a32ee9Sbenno * 560a32ee9Sbenno * Permission to use, copy, modify, and distribute this software for any 660a32ee9Sbenno * purpose with or without fee is hereby granted, provided that the above 760a32ee9Sbenno * copyright notice and this permission notice appear in all copies. 860a32ee9Sbenno * 960a32ee9Sbenno * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1060a32ee9Sbenno * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1160a32ee9Sbenno * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1260a32ee9Sbenno * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1360a32ee9Sbenno * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1460a32ee9Sbenno * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1560a32ee9Sbenno * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1660a32ee9Sbenno */ 1760a32ee9Sbenno #ifndef EXTERN_H 1860a32ee9Sbenno #define EXTERN_H 1960a32ee9Sbenno 20dcad62ecSclaudio #include <openssl/md4.h> 21dcad62ecSclaudio 2260a32ee9Sbenno /* 2360a32ee9Sbenno * This is the rsync protocol version that we support. 2460a32ee9Sbenno */ 2560a32ee9Sbenno #define RSYNC_PROTOCOL (27) 2660a32ee9Sbenno 2760a32ee9Sbenno /* 2860a32ee9Sbenno * Maximum amount of file data sent over the wire at once. 2960a32ee9Sbenno */ 3060a32ee9Sbenno #define MAX_CHUNK (32 * 1024) 3160a32ee9Sbenno 3260a32ee9Sbenno /* 3360a32ee9Sbenno * This is the minimum size for a block of data not including those in 3460a32ee9Sbenno * the remainder block. 3560a32ee9Sbenno */ 3660a32ee9Sbenno #define BLOCK_SIZE_MIN (700) 3760a32ee9Sbenno 3860a32ee9Sbenno /* 39e397242dSclaudio * Maximum number of base directories that can be used. 40e397242dSclaudio */ 41e397242dSclaudio #define MAX_BASEDIR 20 42e397242dSclaudio 43e397242dSclaudio #define BASE_MODE_COMPARE 1 44e397242dSclaudio #define BASE_MODE_COPY 2 45e397242dSclaudio #define BASE_MODE_LINK 3 46e397242dSclaudio 47e397242dSclaudio /* 4860a32ee9Sbenno * The sender and receiver use a two-phase synchronisation process. 4960a32ee9Sbenno * The first uses two-byte hashes; the second, 16-byte. 5060a32ee9Sbenno * (The second must hold a full MD4 digest.) 5160a32ee9Sbenno */ 5260a32ee9Sbenno #define CSUM_LENGTH_PHASE1 (2) 5360a32ee9Sbenno #define CSUM_LENGTH_PHASE2 (16) 5460a32ee9Sbenno 5564a7cfb7Sflorian /* 56f642adf7Sclaudio * Rsync error codes. 57f642adf7Sclaudio */ 58f642adf7Sclaudio #define ERR_SYNTAX 1 59f642adf7Sclaudio #define ERR_PROTOCOL 2 60f642adf7Sclaudio #define ERR_SOCK_IO 10 61f642adf7Sclaudio #define ERR_FILE_IO 11 62f642adf7Sclaudio #define ERR_WIREPROTO 12 63f642adf7Sclaudio #define ERR_IPC 14 /* catchall for any kind of syscall error */ 64f642adf7Sclaudio #define ERR_TERMIMATED 16 65f642adf7Sclaudio #define ERR_WAITPID 21 66f642adf7Sclaudio #define ERR_NOMEM 22 67f642adf7Sclaudio 68f642adf7Sclaudio /* 69a84b4914Sclaudio * Use this for --timeout. 7064a7cfb7Sflorian * All poll events will use it and catch time-outs. 7164a7cfb7Sflorian */ 72a84b4914Sclaudio extern int poll_timeout; 730889042fSflorian 7460a32ee9Sbenno /* 752eaa6f4eSjob * Use this for --contimeout. 762eaa6f4eSjob */ 772eaa6f4eSjob extern int poll_contimeout; 782eaa6f4eSjob 792eaa6f4eSjob /* 8060a32ee9Sbenno * Operating mode for a client or a server. 8160a32ee9Sbenno * Sender means we synchronise local files with those from remote. 8260a32ee9Sbenno * Receiver is the opposite. 8360a32ee9Sbenno * This is relative to which host we're running on. 8460a32ee9Sbenno */ 8560a32ee9Sbenno enum fmode { 8660a32ee9Sbenno FARGS_SENDER, 8760a32ee9Sbenno FARGS_RECEIVER 8860a32ee9Sbenno }; 8960a32ee9Sbenno 9060a32ee9Sbenno /* 9160a32ee9Sbenno * File arguments given on the command line. 9260a32ee9Sbenno * See struct opts. 9360a32ee9Sbenno */ 9460a32ee9Sbenno struct fargs { 9560a32ee9Sbenno char *host; /* hostname or NULL if local */ 9660a32ee9Sbenno char **sources; /* transfer source */ 9760a32ee9Sbenno size_t sourcesz; /* number of sources */ 9860a32ee9Sbenno char *sink; /* transfer endpoint */ 9960a32ee9Sbenno enum fmode mode; /* mode of operation */ 10060a32ee9Sbenno int remote; /* uses rsync:// or :: for remote */ 10160a32ee9Sbenno char *module; /* if rsync://, the module */ 10260a32ee9Sbenno }; 10360a32ee9Sbenno 10460a32ee9Sbenno /* 10560a32ee9Sbenno * The subset of stat(2) information that we need. 10660a32ee9Sbenno * (There are some parts we don't use yet.) 10760a32ee9Sbenno */ 10860a32ee9Sbenno struct flstat { 10960a32ee9Sbenno mode_t mode; /* mode */ 11060a32ee9Sbenno uid_t uid; /* user */ 11160a32ee9Sbenno gid_t gid; /* group */ 112434f41cdSflorian dev_t rdev; /* device type */ 11360a32ee9Sbenno off_t size; /* size */ 11460a32ee9Sbenno time_t mtime; /* modification */ 11560a32ee9Sbenno unsigned int flags; 11660a32ee9Sbenno #define FLSTAT_TOP_DIR 0x01 /* a top-level directory */ 11760a32ee9Sbenno 11860a32ee9Sbenno }; 11960a32ee9Sbenno 12060a32ee9Sbenno /* 12160a32ee9Sbenno * A list of files with their statistics. 12260a32ee9Sbenno */ 12360a32ee9Sbenno struct flist { 12460a32ee9Sbenno char *path; /* path relative to root */ 12560a32ee9Sbenno const char *wpath; /* "working" path for receiver */ 12660a32ee9Sbenno struct flstat st; /* file information */ 12760a32ee9Sbenno char *link; /* symlink target or NULL */ 12860a32ee9Sbenno }; 12960a32ee9Sbenno 13060a32ee9Sbenno /* 13160a32ee9Sbenno * Options passed into the command line. 13260a32ee9Sbenno * See struct fargs. 13360a32ee9Sbenno */ 13460a32ee9Sbenno struct opts { 13560a32ee9Sbenno int sender; /* --sender */ 13660a32ee9Sbenno int server; /* --server */ 13760a32ee9Sbenno int recursive; /* -r */ 13860a32ee9Sbenno int dry_run; /* -n */ 13960a32ee9Sbenno int preserve_times; /* -t */ 14060a32ee9Sbenno int preserve_perms; /* -p */ 14160a32ee9Sbenno int preserve_links; /* -l */ 142d7f0b03cSbenno int preserve_gids; /* -g */ 1438f34fbc5Sflorian int preserve_uids; /* -u */ 14460a32ee9Sbenno int del; /* --delete */ 145434f41cdSflorian int devices; /* --devices */ 146434f41cdSflorian int specials; /* --specials */ 1473bf4cfb6Sjob int no_motd; /* --no-motd */ 148244291d8Sbenno int numeric_ids; /* --numeric-ids */ 1491c3d4160Sbket int one_file_system; /* -x */ 1508d16211cSclaudio int ignore_times; /* -I */ 15197d9fd37Sjob int ignore_dir_times; /* -O */ 15216f87427Sclaudio int ignore_link_times; /* -J */ 1538d16211cSclaudio int size_only; /* --size-only */ 154e397242dSclaudio int alt_base_mode; 15582ecafa1Sclaudio off_t max_size; /* --max-size */ 15682ecafa1Sclaudio off_t min_size; /* --min-size */ 1574725c4c2Sderaadt char *rsync_path; /* --rsync-path */ 158474155c9Sderaadt char *ssh_prog; /* --rsh or -e */ 15994851233Sderaadt char *port; /* --port */ 160a52e5c3aSclaudio char *address; /* --address */ 161e397242dSclaudio char *basedir[MAX_BASEDIR]; 16260a32ee9Sbenno }; 16360a32ee9Sbenno 16457987d16Sclaudio enum rule_type { 16557987d16Sclaudio RULE_NONE, 16657987d16Sclaudio RULE_EXCLUDE, 16757987d16Sclaudio RULE_INCLUDE, 16857987d16Sclaudio RULE_CLEAR, 16957987d16Sclaudio #ifdef NOTYET 17057987d16Sclaudio RULE_MERGE, 17157987d16Sclaudio RULE_DIR_MERGE, 17257987d16Sclaudio RULE_SHOW, 17357987d16Sclaudio RULE_HIDE, 17457987d16Sclaudio RULE_PROTECT, 17557987d16Sclaudio RULE_RISK, 17657987d16Sclaudio #endif 17757987d16Sclaudio }; 17857987d16Sclaudio 17960a32ee9Sbenno /* 18060a32ee9Sbenno * An individual block description for a file. 18160a32ee9Sbenno * See struct blkset. 18260a32ee9Sbenno */ 18360a32ee9Sbenno struct blk { 18460a32ee9Sbenno off_t offs; /* offset in file */ 18560a32ee9Sbenno size_t idx; /* block index */ 18660a32ee9Sbenno size_t len; /* bytes in block */ 18760a32ee9Sbenno uint32_t chksum_short; /* fast checksum */ 18860a32ee9Sbenno unsigned char chksum_long[CSUM_LENGTH_PHASE2]; /* slow checksum */ 18960a32ee9Sbenno }; 19060a32ee9Sbenno 19164a7cfb7Sflorian enum blkstatst { 19264a7cfb7Sflorian BLKSTAT_NONE = 0, 19355cb9f91Sbenno BLKSTAT_NEXT, 19464a7cfb7Sflorian BLKSTAT_DATA, 19564a7cfb7Sflorian BLKSTAT_TOK, 19664a7cfb7Sflorian BLKSTAT_HASH, 19755cb9f91Sbenno BLKSTAT_DONE, 19855cb9f91Sbenno BLKSTAT_PHASE, 19964a7cfb7Sflorian }; 20064a7cfb7Sflorian 20160a32ee9Sbenno /* 2020889042fSflorian * Information for the sender updating receiver blocks reentrantly. 2030889042fSflorian */ 2040889042fSflorian struct blkstat { 2050889042fSflorian off_t offs; /* position in sender file */ 2060889042fSflorian off_t total; /* total amount processed */ 2070889042fSflorian off_t dirty; /* total amount sent */ 20864a7cfb7Sflorian size_t hint; /* optimisation: next probable match */ 2090889042fSflorian void *map; /* mapped file or MAP_FAILED otherwise */ 2100889042fSflorian size_t mapsz; /* size of file or zero */ 2110889042fSflorian int fd; /* descriptor girding the map */ 21264a7cfb7Sflorian enum blkstatst curst; /* FSM for sending file blocks */ 21364a7cfb7Sflorian off_t curpos; /* sending: position in file to send */ 21464a7cfb7Sflorian off_t curlen; /* sending: length of send */ 21564a7cfb7Sflorian int32_t curtok; /* sending: next matching token or zero */ 216ea555712Sflorian struct blktab *blktab; /* hashtable of blocks */ 217ea555712Sflorian uint32_t s1; /* partial sum for computing fast hash */ 218ea555712Sflorian uint32_t s2; /* partial sum for computing fast hash */ 219dcad62ecSclaudio MD4_CTX ctx; /* context for hash_file */ 2200889042fSflorian }; 2210889042fSflorian 2220889042fSflorian /* 22360a32ee9Sbenno * When transferring file contents, we break the file down into blocks 22460a32ee9Sbenno * and work with those. 22560a32ee9Sbenno */ 22660a32ee9Sbenno struct blkset { 22760a32ee9Sbenno off_t size; /* file size */ 22860a32ee9Sbenno size_t rem; /* terminal block length if non-zero */ 22960a32ee9Sbenno size_t len; /* block length */ 23060a32ee9Sbenno size_t csum; /* checksum length */ 23160a32ee9Sbenno struct blk *blks; /* all blocks */ 23260a32ee9Sbenno size_t blksz; /* number of blks */ 23360a32ee9Sbenno }; 23460a32ee9Sbenno 23560a32ee9Sbenno /* 23660a32ee9Sbenno * Values required during a communication session. 23760a32ee9Sbenno */ 23860a32ee9Sbenno struct sess { 23960a32ee9Sbenno const struct opts *opts; /* system options */ 24060a32ee9Sbenno int32_t seed; /* checksum seed */ 24160a32ee9Sbenno int32_t lver; /* local version */ 24260a32ee9Sbenno int32_t rver; /* remote version */ 24360a32ee9Sbenno uint64_t total_read; /* non-logging wire/reads */ 24460a32ee9Sbenno uint64_t total_size; /* total file size */ 24560a32ee9Sbenno uint64_t total_write; /* non-logging wire/writes */ 24660a32ee9Sbenno int mplex_reads; /* multiplexing reads? */ 24760a32ee9Sbenno size_t mplex_read_remain; /* remaining bytes */ 24860a32ee9Sbenno int mplex_writes; /* multiplexing writes? */ 24960a32ee9Sbenno }; 25060a32ee9Sbenno 251997d99f9Sbenno /* 252997d99f9Sbenno * Combination of name and numeric id for groups and users. 253997d99f9Sbenno */ 254997d99f9Sbenno struct ident { 255997d99f9Sbenno int32_t id; /* the gid_t or uid_t */ 256997d99f9Sbenno int32_t mapped; /* if receiving, the mapped gid */ 257997d99f9Sbenno char *name; /* resolved name */ 258997d99f9Sbenno }; 259997d99f9Sbenno 2604d864e8fSderaadt typedef struct arglist arglist; 2614d864e8fSderaadt struct arglist { 2624d864e8fSderaadt char **list; 2634d864e8fSderaadt u_int num; 2644d864e8fSderaadt u_int nalloc; 2654d864e8fSderaadt }; 2663a011501Sclaudio void addargs(arglist *, const char *, ...) 2674d864e8fSderaadt __attribute__((format(printf, 2, 3))); 2684d864e8fSderaadt void freeargs(arglist *); 2694d864e8fSderaadt 27060a32ee9Sbenno struct download; 27160a32ee9Sbenno struct upload; 27260a32ee9Sbenno 273b2a7eac7Sbenno extern int verbose; 274b2a7eac7Sbenno 2753748d632Sderaadt #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) 27664a7cfb7Sflorian 277b2a7eac7Sbenno #define LOG0(_fmt, ...) \ 2787ddad9c7Sderaadt rsync_log( -1, (_fmt), ##__VA_ARGS__) 279b2a7eac7Sbenno #define LOG1(_fmt, ...) \ 2807ddad9c7Sderaadt rsync_log( 0, (_fmt), ##__VA_ARGS__) 281b2a7eac7Sbenno #define LOG2(_fmt, ...) \ 2827ddad9c7Sderaadt rsync_log( 1, (_fmt), ##__VA_ARGS__) 283b2a7eac7Sbenno #define LOG3(_fmt, ...) \ 2847ddad9c7Sderaadt rsync_log( 2, (_fmt), ##__VA_ARGS__) 285b2a7eac7Sbenno #define LOG4(_fmt, ...) \ 2867ddad9c7Sderaadt rsync_log( 3, (_fmt), ##__VA_ARGS__) 287b2a7eac7Sbenno #define ERRX1(_fmt, ...) \ 2887ddad9c7Sderaadt rsync_errx1( (_fmt), ##__VA_ARGS__) 289b2a7eac7Sbenno #define WARNX(_fmt, ...) \ 2907ddad9c7Sderaadt rsync_warnx( (_fmt), ##__VA_ARGS__) 291b2a7eac7Sbenno #define WARN(_fmt, ...) \ 2927ddad9c7Sderaadt rsync_warn(0, (_fmt), ##__VA_ARGS__) 293b2a7eac7Sbenno #define WARN1(_fmt, ...) \ 2947ddad9c7Sderaadt rsync_warn(1, (_fmt), ##__VA_ARGS__) 295b2a7eac7Sbenno #define WARN2(_fmt, ...) \ 2967ddad9c7Sderaadt rsync_warn(2, (_fmt), ##__VA_ARGS__) 297b2a7eac7Sbenno #define ERR(_fmt, ...) \ 2987ddad9c7Sderaadt rsync_err( (_fmt), ##__VA_ARGS__) 299b2a7eac7Sbenno #define ERRX(_fmt, ...) \ 3007ddad9c7Sderaadt rsync_errx( (_fmt), ##__VA_ARGS__) 30160a32ee9Sbenno 3027ddad9c7Sderaadt void rsync_log(int, const char *, ...) 3037ddad9c7Sderaadt __attribute__((format(printf, 2, 3))); 3047ddad9c7Sderaadt void rsync_warn(int, const char *, ...) 3057ddad9c7Sderaadt __attribute__((format(printf, 2, 3))); 3067ddad9c7Sderaadt void rsync_warnx(const char *, ...) 3077ddad9c7Sderaadt __attribute__((format(printf, 1, 2))); 3087ddad9c7Sderaadt void rsync_err(const char *, ...) 3097ddad9c7Sderaadt __attribute__((format(printf, 1, 2))); 3107ddad9c7Sderaadt void rsync_errx(const char *, ...) 3117ddad9c7Sderaadt __attribute__((format(printf, 1, 2))); 3127ddad9c7Sderaadt void rsync_errx1(const char *, ...) 3137ddad9c7Sderaadt __attribute__((format(printf, 1, 2))); 31460a32ee9Sbenno 3151db0096aSclaudio int flist_del(struct sess *, int, const struct flist *, size_t); 3161db0096aSclaudio int flist_gen(struct sess *, size_t, char **, struct flist **, size_t *); 31760a32ee9Sbenno void flist_free(struct flist *, size_t); 3181db0096aSclaudio int flist_recv(struct sess *, int, struct flist **, size_t *); 3191db0096aSclaudio int flist_send(struct sess *, int, int, const struct flist *, size_t); 3201db0096aSclaudio int flist_gen_dels(struct sess *, const char *, struct flist **, size_t *, 32160a32ee9Sbenno const struct flist *, size_t); 32260a32ee9Sbenno 323e397242dSclaudio const char *alt_base_mode(int); 324ac024dd4Snaddy char **fargs_cmdline(struct sess *, const struct fargs *, size_t *); 32560a32ee9Sbenno 32660a32ee9Sbenno int io_read_buf(struct sess *, int, void *, size_t); 32760a32ee9Sbenno int io_read_byte(struct sess *, int, uint8_t *); 328ba617adaSbenno int io_read_check(int); 32960a32ee9Sbenno int io_read_flush(struct sess *, int); 33060a32ee9Sbenno int io_read_int(struct sess *, int, int32_t *); 331aa1dcd86Sderaadt int io_read_uint(struct sess *, int, uint32_t *); 33260a32ee9Sbenno int io_read_long(struct sess *, int, int64_t *); 33360a32ee9Sbenno int io_read_size(struct sess *, int, size_t *); 33460a32ee9Sbenno int io_read_ulong(struct sess *, int, uint64_t *); 33560a32ee9Sbenno int io_write_buf(struct sess *, int, const void *, size_t); 33660a32ee9Sbenno int io_write_byte(struct sess *, int, uint8_t); 33760a32ee9Sbenno int io_write_int(struct sess *, int, int32_t); 338aa1dcd86Sderaadt int io_write_uint(struct sess *, int, uint32_t); 33960a32ee9Sbenno int io_write_line(struct sess *, int, const char *); 34060a32ee9Sbenno int io_write_long(struct sess *, int, int64_t); 341aa1dcd86Sderaadt int io_write_ulong(struct sess *, int, uint64_t); 34260a32ee9Sbenno 3431db0096aSclaudio int io_lowbuffer_alloc(struct sess *, void **, size_t *, size_t *, size_t); 3441db0096aSclaudio void io_lowbuffer_int(struct sess *, void *, size_t *, size_t, int32_t); 3451db0096aSclaudio void io_lowbuffer_buf(struct sess *, void *, size_t *, size_t, const void *, 3461db0096aSclaudio size_t); 34764a7cfb7Sflorian 348ba617adaSbenno void io_buffer_int(void *, size_t *, size_t, int32_t); 349ba617adaSbenno void io_buffer_buf(void *, size_t *, size_t, const void *, size_t); 35060a32ee9Sbenno 3511db0096aSclaudio void io_unbuffer_int(const void *, size_t *, size_t, int32_t *); 352ba617adaSbenno int io_unbuffer_size(const void *, size_t *, size_t, size_t *); 353ba617adaSbenno void io_unbuffer_buf(const void *, size_t *, size_t, void *, size_t); 35460a32ee9Sbenno 35560a32ee9Sbenno int rsync_receiver(struct sess *, int, int, const char *); 35660a32ee9Sbenno int rsync_sender(struct sess *, int, int, size_t, char **); 35760a32ee9Sbenno int rsync_client(const struct opts *, int, const struct fargs *); 3581db0096aSclaudio int rsync_connect(const struct opts *, int *, const struct fargs *); 359ac024dd4Snaddy int rsync_socket(const struct opts *, int, const struct fargs *); 36060a32ee9Sbenno int rsync_server(const struct opts *, size_t, char *[]); 36160a32ee9Sbenno int rsync_downloader(struct download *, struct sess *, int *); 3621db0096aSclaudio int rsync_set_metadata(struct sess *, int, int, const struct flist *, 3631db0096aSclaudio const char *); 3641db0096aSclaudio int rsync_set_metadata_at(struct sess *, int, int, const struct flist *, 3651db0096aSclaudio const char *); 3661db0096aSclaudio int rsync_uploader(struct upload *, int *, struct sess *, int *); 36760a32ee9Sbenno int rsync_uploader_tail(struct upload *, struct sess *); 36860a32ee9Sbenno 3691db0096aSclaudio struct download *download_alloc(struct sess *, int, const struct flist *, 3701db0096aSclaudio size_t, int); 37160a32ee9Sbenno void download_free(struct download *); 372ba617adaSbenno struct upload *upload_alloc(const char *, int, int, size_t, 37360a32ee9Sbenno const struct flist *, size_t, mode_t); 37460a32ee9Sbenno void upload_free(struct upload *); 37560a32ee9Sbenno 376ea555712Sflorian struct blktab *blkhash_alloc(void); 377ea555712Sflorian int blkhash_set(struct blktab *, const struct blkset *); 378ea555712Sflorian void blkhash_free(struct blktab *); 379ea555712Sflorian 38060a32ee9Sbenno struct blkset *blk_recv(struct sess *, int, const char *); 381ba617adaSbenno void blk_recv_ack(char [20], const struct blkset *, int32_t); 38264a7cfb7Sflorian void blk_match(struct sess *, const struct blkset *, 3830889042fSflorian const char *, struct blkstat *); 3841db0096aSclaudio int blk_send(struct sess *, int, size_t, const struct blkset *, 3851db0096aSclaudio const char *); 38660a32ee9Sbenno int blk_send_ack(struct sess *, int, struct blkset *); 38760a32ee9Sbenno 38860a32ee9Sbenno uint32_t hash_fast(const void *, size_t); 3891db0096aSclaudio void hash_slow(const void *, size_t, unsigned char *, 3901db0096aSclaudio const struct sess *); 391dcad62ecSclaudio 392dcad62ecSclaudio void hash_file_start(MD4_CTX *, const struct sess *); 393dcad62ecSclaudio void hash_file_buf(MD4_CTX *, const void *, size_t); 394dcad62ecSclaudio void hash_file_final(MD4_CTX *, unsigned char *); 39560a32ee9Sbenno 396e397242dSclaudio void copy_file(int, const char *, const struct flist *); 397e397242dSclaudio 398ba617adaSbenno int mkpath(char *); 39960a32ee9Sbenno 400dbed5971Sflorian int mkstempat(int, char *); 401dbed5971Sflorian char *mkstemplinkat(char*, int, char *); 402434f41cdSflorian char *mkstempfifoat(int, char *); 403434f41cdSflorian char *mkstempnodat(int, char *, mode_t, dev_t); 404434f41cdSflorian char *mkstempsock(const char *, char *); 405ba617adaSbenno int mktemplate(char **, const char *, int); 406dbed5971Sflorian 40757987d16Sclaudio int parse_rule(char *line, enum rule_type); 4080345af14Sclaudio void parse_file(const char *, enum rule_type); 40957987d16Sclaudio void send_rules(struct sess *, int); 41057987d16Sclaudio void recv_rules(struct sess *, int); 41157987d16Sclaudio int rules_match(const char *, int); 41257987d16Sclaudio 41357987d16Sclaudio int rmatch(const char *, const char *, int); 41457987d16Sclaudio 415ba617adaSbenno char *symlink_read(const char *); 416ba617adaSbenno char *symlinkat_read(int, const char *); 41760a32ee9Sbenno 41860a32ee9Sbenno int sess_stats_send(struct sess *, int); 41960a32ee9Sbenno int sess_stats_recv(struct sess *, int); 42060a32ee9Sbenno 421ba617adaSbenno int idents_add(int, struct ident **, size_t *, int32_t); 4221db0096aSclaudio void idents_assign_gid(struct sess *, struct flist *, size_t, 4231db0096aSclaudio const struct ident *, size_t); 4241db0096aSclaudio void idents_assign_uid(struct sess *, struct flist *, size_t, 4251db0096aSclaudio const struct ident *, size_t); 4268f34fbc5Sflorian void idents_free(struct ident *, size_t); 427997d99f9Sbenno int idents_recv(struct sess *, int, struct ident **, size_t *); 4288f34fbc5Sflorian void idents_remap(struct sess *, int, struct ident *, size_t); 429e5bf8365Sbenno int idents_send(struct sess *, int, const struct ident *, size_t); 430997d99f9Sbenno 43160a32ee9Sbenno #endif /*!EXTERN_H*/ 432