15
15
/* As nothing in setuid.c uses STRING_SIZE specifically there's no real reason
16
16
* to redefine it if it already is set */
17
17
#ifndef STRING_SIZE
18
#define STRING_SIZE 1024
22
#define CONFIG_ROOT "/var/ipfire"
26
#define SNAME "SNAME to be filled"
18
#define STRING_SIZE 256
20
#define LETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
21
#define NUMBERS "0123456789"
22
#define LETTERS_NUMBERS LETTERS NUMBERS
23
#define IP_NUMBERS "./" NUMBERS
24
#define PORT_NUMBERS ":-" NUMBERS
25
#define VALID_FQDN LETTERS_NUMBERS ".-"
28
#define VALID_IP(ip) (strlen(ip) > 6 \
30
&& strspn(ip, NUMBERS ".") == strlen(ip))
32
#define VALID_IP_AND_MASK(ip) (strlen(ip) > 6 \
34
&& strspn(ip, IP_NUMBERS) == strlen(ip))
36
#define VALID_PORT(port) (strlen(port) \
38
&& strspn(port, NUMBERS) == strlen(port))
40
#define VALID_PORT_RANGE(port) (strlen(port) \
41
&& strlen(port) < 12 \
42
&& strspn(port, PORT_NUMBERS) == strlen(port))
44
#define VALID_SHORT_MASK(ip) (strlen(ip) > 1 \
46
&& strspn(ip, NUMBERS) == strlen(ip))
48
/* Can't find any info on valid characters/length hopefully these are
49
* reasonable guesses */
50
#define VALID_DEVICE(dev) (strlen(dev) \
52
&& strspn(dev, LETTERS_NUMBERS ":.") == strlen(dev))
54
/* Again, can't find any hard and fast rules for protocol names, these
55
* restrictions are based on the keywords currently listed in
56
* <http://www.iana.org/assignments/protocol-numbers>
57
* though currently the ipcop cgis will only pass tcp, udp or gre anyway */
58
#define VALID_PROTOCOL(prot) (strlen(prot) \
60
&& strspn(prot, LETTERS_NUMBERS "-") == strlen(prot))
29
62
extern char * trusted_env[4];
31
int run(char* command, char** argv);
64
int system_core(char* command, uid_t uid, gid_t gid, char *error);
32
65
int safe_system(char* command);
33
66
int unpriv_system(char* command, uid_t uid, gid_t gid);
67
size_t strlcat(char *dst, const char *src, size_t len);
34
68
int initsetuid(void);
36
int is_valid_argument_alnum(const char* arg);
37
int is_valid_argument_num(const char* arg);
39
/* Compatibility for the local copy of strlcat,
40
* which has been removed. */
41
#define strlcat(src, dst, size) strncat(src, dst, size)
70
/* check whether a file exists */
71
int file_exists(const char *fname);
72
int file_exists_w(const char *fname); //wildcard filename test