3 * definitions shared between client and daemon
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.
27 static const unsigned char protocolchecksumversion[PCSUMSIZE]= {
32 # define VARDIR "/var/run/userv"
36 # define RENDEZVOUS "socket"
39 #ifndef RENDEZVOUSPATH
40 # define RENDEZVOUSPATH VARDIR "/" RENDEZVOUS
44 # define PIPEFORMAT "%lx.%lx.%x"
45 # define PIPEPATTERN "[0-9a-f]*.[0-9a-f]*.*[0-9a-f]"
46 # define PIPEFORMATEXTEND ((int)(sizeof(unsigned long)*2*2+(int)sizeof(int)*2+3))
47 # define PIPEMAXLEN ((int)(sizeof(PIPEFORMAT)+PIPEFORMATEXTEND))
50 #ifndef PIPEPATHFORMAT
51 # define PIPEPATHFORMAT VARDIR "/" PIPEFORMAT
52 # define PIPEPATHMAXLEN ((int)(sizeof(PIPEPATHFORMAT)+PIPEFORMATEXTEND))
55 #define MAX_ALLOW_FD 1024
56 #define MAX_GENERAL_STRING (1024*1024)
57 #define MAX_OVERRIDE_LEN MAX_GENERAL_STRING
58 #define MAX_ERRMSG_STRING 4096
59 #define MAX_ARGSDEFVAR 4096
63 # define BASE_MAGIC 0x5deb7567UL /* "\x5d\xebug" */
65 # define BASE_MAGIC 0x755e7276UL /* "u\x5erv" */
69 OPENING_MAGIC= BASE_MAGIC+1,
73 PROGRESS_ERRMSG_END_MAGIC,
79 unsigned char protocolchecksumversion[PCSUMSIZE];
80 pid_t overlordpid, serverpid;
85 pid_t clientpid; /* or -1 if no service is required and this was a version check */
88 int lognamelen, spoofed; /* spoofed is 0 or 1 */
89 int cwdlen, overridelen;
91 int ngids, nreadfds, nwritefds, nargs, nvars;
93 * serviceuserlen bytes for the service user (unterminated)
94 * servicelen bytes for the service (unterminated)
95 * lognamelen bytes for the login name (unterminated)
96 * cwdlen bytes for the cwd (unterminated)
97 * overridelen bytes for the override data (with extra \n but unterminated),
98 * or nothing if overridelen==-1
99 * ngids gid_ts for the primary group and supplementary groups
100 * nreadfds and then nwritefds ints for the file descriptors
101 * for each of the nargs arguments
102 * an int for the string length
103 * that many characters (unterminated)
104 * for each for the nvars variable keys
105 * an int for the key length
106 * that many characters (unterminated)
107 * an int for the value length
108 * that many characters (unterminated)
109 * one unsigned long, endmagic;
113 struct progress_msg {
115 enum { pt_ok, pt_errmsg, pt_failed, pt_terminated } type;
117 struct { int messagelen; } errmsg;
118 struct { int status; } terminated;
120 /* follwed by variable-length part:
121 * for ok, failed, terminated: nothing
122 * for errmsg: messagelen bytes for the error message (unterminated, no \n)
123 * unsigned long PROGRESS_ERRMSG_END_MAGIC
129 enum { et_confirm, et_closereadfd, et_disconnect } type;
131 struct { int fd; } closereadfd;