Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/logsrvd/logsrv_util.h
1532 views
1
/*
2
* SPDX-License-Identifier: ISC
3
*
4
* Copyright (c) 2019-2020 Todd C. Miller <[email protected]>
5
*
6
* Permission to use, copy, modify, and distribute this software for any
7
* purpose with or without fee is hereby granted, provided that the above
8
* copyright notice and this permission notice appear in all copies.
9
*
10
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
19
#ifndef SUDO_LOGSRV_UTIL_H
20
#define SUDO_LOGSRV_UTIL_H
21
22
#include <netinet/in.h> /* for INET_ADDRSTRLEN and INET6_ADDRSTRLEN */
23
24
#ifndef INET_ADDRSTRLEN
25
# define INET_ADDRSTRLEN 16
26
#endif
27
#ifndef INET6_ADDRSTRLEN
28
# define INET6_ADDRSTRLEN 46
29
#endif
30
31
/* Default ports to listen on */
32
#define DEFAULT_PORT "30343"
33
#define DEFAULT_PORT_TLS "30344"
34
35
/* Maximum message size (2Mb) */
36
#define MESSAGE_SIZE_MAX (2 * 1024 * 1024)
37
38
struct peer_info {
39
const char *name;
40
#if defined(HAVE_STRUCT_IN6_ADDR)
41
char ipaddr[INET6_ADDRSTRLEN];
42
#else
43
char ipaddr[INET_ADDRSTRLEN];
44
#endif
45
};
46
47
struct connection_buffer {
48
TAILQ_ENTRY(connection_buffer) entries;
49
uint8_t *data;
50
size_t size;
51
size_t len;
52
size_t off;
53
};
54
TAILQ_HEAD(connection_buffer_list, connection_buffer);
55
56
/* dotdot.c */
57
bool contains_dot_dot(const char *str);
58
59
/* logsrv_util.c */
60
struct iolog_file;
61
bool expand_buf(struct connection_buffer *buf, size_t needed);
62
bool iolog_open_all(int dfd, const char *iolog_dir, struct iolog_file *iolog_files, const char *mode);
63
bool iolog_seekto(int iolog_dir_fd, const char *iolog_path, struct iolog_file *iolog_files, struct timespec *elapsed_time, const struct timespec *target);
64
65
66
#endif /* SUDO_LOGSRV_UTIL_H */
67
68