1 /* 2 cfg.h - all the configurable options in cvsd 3 4 Copyright (C) 2003, 2004, 2006 Arthur de Jong. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 22 #ifndef _CVSDCFG_H 23 #define _CVSDCFG_H 1 24 25 26 #include <unistd.h> 27 #include <sys/types.h> 28 #ifdef USE_CAPABILITIES 29 #include <sys/capability.h> 30 #endif /* USE_CAPABILITIES */ 31 32 /* values for uid and gid */ 33 #define NOUID ((gid_t)-1) 34 #define NOGID ((gid_t)-1) 35 36 37 /* the index where to set CVSUMASK=<cvs_umask> in cfg->cvsenv 38 see also the static char *default_environment in cfg.c */ 39 #define CVSUMASK_IDX 4 40 41 42 /* the addresses to listen on */ 43 struct cvsd_addrs 44 { 45 char *node; /* supplied node(address) name in config */ 46 char *service; /* supplied service(port) name in config */ 47 struct addrinfo *addrs; /* addresses asiciated with node+service */ 48 struct cvsd_addrs *next; /* next configured node+service */ 49 }; 50 51 52 /* default address/port combination to listen on 53 if nothing is supplied in the config file */ 54 #define DEFAULT_ADDR "*" 55 #define DEFAULT_PORT "2401" 56 57 58 /* struct to hold all configuration information 59 initial values are set in cfg_new() */ 60 struct cvsd_cfg 61 { 62 63 /* the configuration file 64 DEFAULT_CONFIGFILE is set in config.h */ 65 char *configfile; 66 67 /* the pid file 68 default is no pidfile (NULL) */ 69 char *pidfile; 70 71 /* whether debugging mode is enabled */ 72 int debugging; 73 74 /* the location of the rootjail 75 NULL or "none": no chroot */ 76 char *rootjail; 77 78 /* the user id cvs should be run as 79 NOUID: don't change */ 80 uid_t uid; 81 82 /* the group id cvs should be run as 83 NOGID: don't change */ 84 gid_t gid; 85 86 /* the nice value the daemon should run as 87 0: don't change */ 88 int nice; 89 90 /* the umask that should be used to create files */ 91 mode_t umask; 92 93 /* TODO: limits (are currently stored in structures in reslimit.c)*/ 94 95 #ifdef USE_CAPABILITIES 96 /* the capabilities for cvs */ 97 cap_t capabilities; 98 #endif /* USE_CAPABILITIES */ 99 100 /* the addresses/ports that should be listened on */ 101 struct cvsd_addrs *addresses; 102 103 /* the maximum number of connections to handle 104 0: unlimited */ 105 int maxconnections; 106 107 /* TODO: repositories (currently only added to cvsargs below) */ 108 109 /* the command that will be run (location of the binary) */ 110 char *cvscmd; 111 112 /* the arguments that will be passed */ 113 char **cvsargs; 114 115 /* the environment that should be used */ 116 char **cvsenv; 117 118 }; 119 120 121 /* initialize the configuration with some reasonable default values */ 122 struct cvsd_cfg *cfg_new(void); 123 124 125 /* add a string as a command line argument to the cvs command */ 126 void cfg_addcvsarg(struct cvsd_cfg *cfg,const char *arg); 127 128 129 /* add the given node and service to the list of addresses that 130 will be listened on */ 131 void cfg_addaddress(struct cvsd_cfg *cfg, 132 const char *filename,int lnr, 133 const char *node,const char *service); 134 135 #endif /* not _CVSDCFG_H */ 136