3 * definitions shared between client and daemon
6 * Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
7 * Copyright 2000 Ben Harris <bjh21@cam.ac.uk>
8 * Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
10 * This is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with userv; if not, see <http://www.gnu.org/licenses/>.
27 #define COPYRIGHT(indent,nl) \
28 indent "Copyright (C)1996-2012 Ian Jackson; copyright (C)2000 Ben Harris." nl \
29 indent "there is NO WARRANTY; type `userv --copyright' for details." nl
33 static const unsigned char protocolchecksumversion[PCSUMSIZE]= {
38 # define VARDIR "/var/run/userv"
42 # define RENDEZVOUS "socket"
45 #ifndef RENDEZVOUSPATH
46 # define RENDEZVOUSPATH VARDIR "/" RENDEZVOUS
50 # define PIPEFORMAT "%lx.%lx.%x"
51 # define PIPEPATTERN "[0-9a-f]*.[0-9a-f]*.*[0-9a-f]"
52 # define PIPEFORMATEXTEND ((int)(sizeof(unsigned long)*2*2+(int)sizeof(int)*2+3))
53 # define PIPEMAXLEN ((int)(sizeof(PIPEFORMAT)+PIPEFORMATEXTEND))
56 #ifndef PIPEPATHFORMAT
57 # define PIPEPATHFORMAT VARDIR "/" PIPEFORMAT
58 # define PIPEPATHMAXLEN ((int)(sizeof(PIPEPATHFORMAT)+PIPEFORMATEXTEND))
61 #define MAX_ALLOW_FD 1024
62 #define MAX_GENERAL_STRING (1024*1024)
63 #define MAX_OVERRIDE_LEN MAX_GENERAL_STRING
64 #define MAX_ERRMSG_STRING 4096
65 #define MAX_ARGSDEFVAR 4096
69 # define BASE_MAGIC 0x5deb7567UL /* "\x5d\xebug" */
71 # define BASE_MAGIC 0x755e7276UL /* "u\x5erv" */
75 OPENING_MAGIC= BASE_MAGIC+1,
79 PROGRESS_ERRMSG_END_MAGIC,
85 unsigned char protocolchecksumversion[PCSUMSIZE];
86 pid_t overlordpid, serverpid;
91 pid_t clientpid; /* or -1 if no service is required and this was a version check */
94 int loginnamelen, spoofed; /* spoofed is 0 or 1 */
95 int cwdlen, overridelen;
97 int ngids, nreadfds, nwritefds, nargs, nvars;
99 * serviceuserlen bytes for the service user (unterminated)
100 * servicelen bytes for the service (unterminated)
101 * loginnamelen bytes for the login name (unterminated)
102 * cwdlen bytes for the cwd (unterminated)
103 * overridelen bytes for the override data (with extra \n but unterminated),
104 * or nothing if overridelen==-1
105 * ngids gid_ts for the primary group and supplementary groups
106 * nreadfds and then nwritefds ints for the file descriptors
107 * for each of the nargs arguments
108 * an int for the string length
109 * that many characters (unterminated)
110 * for each for the nvars variable keys
111 * an int for the key length
112 * that many characters (unterminated)
113 * an int for the value length
114 * that many characters (unterminated)
115 * one unsigned long, endmagic;
119 struct progress_msg {
121 enum { pt_ok, pt_errmsg, pt_failed, pt_terminated } type;
123 struct { int messagelen; } errmsg;
124 struct { int status; } terminated;
126 /* follwed by variable-length part:
127 * for ok, failed, terminated: nothing
128 * for errmsg: messagelen bytes for the error message (unterminated, no \n)
129 * unsigned long PROGRESS_ERRMSG_END_MAGIC
135 enum { et_confirm, et_closereadfd, et_disconnect } type;
137 struct { int fd; } closereadfd;