]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/misc-progs/setuid.h
1 /* SmoothWall helper program - header file
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 * Simple header file for all setuid progs.
7 * $Id: setuid.h,v 1.4.2.4 2005/11/20 23:20:13 franck78 Exp $
15 #include <sys/types.h>
17 /* As nothing in setuid.c uses STRING_SIZE specifically there's no real reason
18 * to redefine it if it already is set */
20 #define STRING_SIZE 256
22 #define LETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
23 #define NUMBERS "0123456789"
24 #define LETTERS_NUMBERS LETTERS NUMBERS
25 #define IP_NUMBERS "./" NUMBERS
26 #define PORT_NUMBERS ":-" NUMBERS
27 #define VALID_FQDN LETTERS_NUMBERS ".-"
30 #define VALID_IP(ip) (strlen(ip) > 6 \
32 && strspn(ip, NUMBERS ".") == strlen(ip))
34 #define VALID_IP_AND_MASK(ip) (strlen(ip) > 6 \
36 && strspn(ip, IP_NUMBERS) == strlen(ip))
38 #define VALID_PORT(port) (strlen(port) \
40 && strspn(port, NUMBERS) == strlen(port))
42 #define VALID_PORT_RANGE(port) (strlen(port) \
43 && strlen(port) < 12 \
44 && strspn(port, PORT_NUMBERS) == strlen(port))
46 #define VALID_SHORT_MASK(ip) (strlen(ip) > 1 \
48 && strspn(ip, NUMBERS) == strlen(ip))
50 /* Can't find any info on valid characters/length hopefully these are
51 * reasonable guesses */
52 #define VALID_DEVICE(dev) (strlen(dev) \
54 && strspn(dev, LETTERS_NUMBERS ":.") == strlen(dev))
56 /* Again, can't find any hard and fast rules for protocol names, these
57 * restrictions are based on the keywords currently listed in
58 * <http://www.iana.org/assignments/protocol-numbers>
59 * though currently the ipcop cgis will only pass tcp, udp or gre anyway */
60 #define VALID_PROTOCOL(prot) (strlen(prot) \
62 && strspn(prot, LETTERS_NUMBERS "-") == strlen(prot))
64 extern char * trusted_env
[4];
66 int system_core(char* command
, uid_t uid
, gid_t gid
, char *error
);
67 int safe_system(char* command
);
68 int unpriv_system(char* command
, uid_t uid
, gid_t gid
);
69 size_t strlcat(char *dst
, const char *src
, size_t len
);
72 /* check whether a file exists */
73 int file_exists(const char *fname
);
74 int file_exists_w(const char *fname
); //wildcard filename test
77 #define MOUNTPOINT "/home/httpd/html/backup"
78 #define BACKUP_KEY CONFIG_ROOT"/backup/backup.key"
80 /* defines for config create/restore return status*/
81 #define ERR_ANY 1 // unspecified error
82 #define ERR_KEY 2 // error creating key file
83 #define ERR_TAR 3 // error creating .tar
84 #define ERR_GZ 4 // error creating .tar.gz
85 #define ERR_ENCRYPT 5 // error creating .dat
86 #define ERR_DECRYPT 6 // error decrypting .dat file
87 #define ERR_UNTARTST 7 // error (test) untarring .tar.gz
88 #define ERR_UNTAR 8 // error (real) untarring .tar.gz
89 #define ERR_DAT 9 // missing .dat file