3 * definitions used in the daemon's source code
5 * Copyright (C)1996-1997 Ian Jackson
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with userv; if not, write to the Free Software
19 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <sys/types.h>
27 #define RESET_CONFIGURATION " \n\
28 cd " USERDIRPREFIX " \n\
30 no-set-environment \n\
33 allow-fd 1-2 write \n\
38 #ifndef SYSTEMCONFIGDIR
40 # define SYSTEMCONFIGDIR "slash-etc"
42 # define SYSTEMCONFIGDIR "/etc"
46 #ifndef DEFAULTPATH_USER
47 # define DEFAULTPATH_USER "/usr/local/bin:/bin:/usr/bin"
50 #ifndef DEFAULTPATH_ROOT
51 # define DEFAULTPATH_ROOT "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
54 #ifndef SETENVIRONMENT
55 # define SETENVIRONMENT "environment"
58 #define USERRCFILE "rc"
59 #define SYSTEMUSERVCONFIGDIR "userv"
60 #define SHELLLIST "shells"
61 #define SYSTEMRCFILEDEFAULT "system.default"
62 #define SYSTEMRCFILEOVERRIDE "system.override"
63 #define NONEINCLUDELOOKUP ":none"
64 #define DEFAULTINCLUDELOOKUP ":default"
65 #define EMPTYINCLUDELOOKUP ":empty"
67 #define USERDIRPREFIX USERDIR "/"
68 #define USERCONFIGDIRBASE SYSTEMUSERVCONFIGDIR
69 #define USERCONFIGDIR HIDDENPREFIX USERCONFIGDIRBASE
70 #define USERUSERVCONFIGPATH USERDIR "/" USERCONFIGDIR
71 #define USERRCFILEPATH USERUSERVCONFIGPATH "/" USERRCFILE
72 #define SYSTEMUSERVCONFIGPATH SYSTEMCONFIGDIR "/" SYSTEMUSERVCONFIGDIR
73 #define SYSTEMRCFILEDEFAULTPATH SYSTEMUSERVCONFIGPATH "/" SYSTEMRCFILEDEFAULT
74 #define SYSTEMRCFILEOVERRIDEPATH SYSTEMUSERVCONFIGPATH "/" SYSTEMRCFILEOVERRIDE
75 #define SHELLLISTPATH SYSTEMCONFIGDIR "/" SHELLLIST
76 #define SETENVIRONMENTPATH SYSTEMCONFIGDIR "/" SETENVIRONMENT
79 #define HIDDENPREFIX "."
81 #define USERVD_LOGIDENT "uservd"
82 #define USERVD_LOGFACILITY LOG_DAEMON
83 #define DEFUSERLOGFACILITY LOG_DAEMON
84 #define DEFUSERLOGLEVEL LOG_ERR
86 #define TOPLEVEL_CONFIGURATION " \n\
88 user-rcfile " USERRCFILEPATH " \n\
90 _include-sysconfig " SYSTEMRCFILEDEFAULTPATH " \n\
91 if grep service-user-shell " SHELLLISTPATH " \n\
94 _include-user-rcfile \n\
98 _include-sysconfig " SYSTEMRCFILEOVERRIDEPATH " \n\
102 #define TOPLEVEL_OVERRIDDEN_CONFIGURATION " \n\
105 _include-client-config \n\
109 #define MAX_INCLUDE_NEST 40
110 #define MAX_ERRMSG_LEN 2048
111 #define ERRMSG_RESERVE_ERRNO 128
113 int parse_string(const char *string, const char *descrip, int isinternal);
114 void parseerrprint(const char *fmt, ...) PRINTFFORMAT(1,2);
115 void ensurelogopen(int wantfacility);
116 void ensurefdarray(int fd);
117 const char *printtoken(int token);
118 void senderrmsgstderr(const char *errmsg);
119 void disconnect(int exitstatus) NONRETURNING;
121 void debug_dumprequest(pid_t mypid);
122 void debug_dumpexecsettings(void);
123 void debug_dumpparameter(const char *parm, char **values);
124 pid_t nondebug_fork(void);
125 const char *nondebug_serviceuserdir(const char *ifnondebug);
127 void execservice(const int synchsocket[], int clientfd) NONRETURNING;
128 void servicerequest(int sfd) NONRETURNING;
129 int synchread(int fd, int ch);
132 int iswrite, realfd, holdfd;
134 /* tokv_word_requirefd, tokv_word_allowfd, tokv_nullfd, tokv_word_rejectfd
135 * (all of which have tokt_wantfdstate set) */
137 /* tokv_word_read, tokv_word_write */
140 extern char **argarray;
141 extern char *((*defvararray)[2]);
142 extern struct fdstate *fdarray; /* indexed by nominal fd */
143 extern int fdarraysize, fdarrayused;
144 extern int restfdwantstate, restfdwantrw;
145 extern struct request_msg request_mbuf;
146 extern char *serviceuser, *service, *logname, *cwd;
147 extern char *overridedata, *userrcfile;
148 extern char *serviceuser_dir, *serviceuser_shell, *callinguser_shell;
149 extern int service_ngids;
150 extern gid_t *calling_gids, *service_gids;
151 extern const char **calling_groups, **service_groups;
152 extern uid_t serviceuser_uid;
153 extern char *execpath, **execargs;
154 extern int execute; /* One of the execution modes tokt_execmode */
155 extern int setenvironment, suppressargs, disconnecthup;
156 extern int syslogopenfacility;