3 * definitions shared between client and daemon
5 * userv is copyright Ian Jackson and other contributors.
6 * See README for full authorship information.
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with userv; if not, see <http://www.gnu.org/licenses/>.
25 #define COPYRIGHT(indent,nl) \
26 indent "Copyright (C)1996-2012 Ian Jackson; copyright (C)2000 Ben Harris." nl \
27 indent "there is NO WARRANTY; type `userv --copyright' for details." nl
31 static const unsigned char protocolchecksumversion[PCSUMSIZE]= {
36 # define VARDIR "/var/run/userv"
40 # define RENDEZVOUS "socket"
43 #ifndef RENDEZVOUSPATH
44 # define RENDEZVOUSPATH VARDIR "/" RENDEZVOUS
48 # define PIPEFORMAT "%lx.%lx.%x"
49 # define PIPEPATTERN "[0-9a-f]*.[0-9a-f]*.*[0-9a-f]"
50 # define PIPEFORMATEXTEND ((int)(sizeof(unsigned long)*2*2+(int)sizeof(int)*2+3))
51 # define PIPEMAXLEN ((int)(sizeof(PIPEFORMAT)+PIPEFORMATEXTEND))
54 #ifndef PIPEPATHFORMAT
55 # define PIPEPATHFORMAT VARDIR "/" PIPEFORMAT
56 # define PIPEPATHMAXLEN ((int)(sizeof(PIPEPATHFORMAT)+PIPEFORMATEXTEND))
59 #define MAX_ALLOW_FD 1024
60 #define MAX_GENERAL_STRING (1024*1024)
61 #define MAX_OVERRIDE_LEN MAX_GENERAL_STRING
62 #define MAX_ERRMSG_STRING 4096
63 #define MAX_ARGSDEFVAR 4096
67 # define BASE_MAGIC 0x5deb7567UL /* "\x5d\xebug" */
69 # define BASE_MAGIC 0x755e7276UL /* "u\x5erv" */
73 OPENING_MAGIC= BASE_MAGIC+1,
77 PROGRESS_ERRMSG_END_MAGIC,
83 unsigned char protocolchecksumversion[PCSUMSIZE];
84 pid_t overlordpid, serverpid;
89 pid_t clientpid; /* or -1 if no service is required and this was a version check */
92 int loginnamelen, spoofed; /* spoofed is 0 or 1 */
93 int cwdlen, overridelen;
95 int ngids, nreadfds, nwritefds, nargs, nvars;
97 * serviceuserlen bytes for the service user (unterminated)
98 * servicelen bytes for the service (unterminated)
99 * loginnamelen bytes for the login name (unterminated)
100 * cwdlen bytes for the cwd (unterminated)
101 * overridelen bytes for the override data (with extra \n but unterminated),
102 * or nothing if overridelen==-1
103 * ngids gid_ts for the primary group and supplementary groups
104 * nreadfds and then nwritefds ints for the file descriptors
105 * for each of the nargs arguments
106 * an int for the string length
107 * that many characters (unterminated)
108 * for each for the nvars variable keys
109 * an int for the key length
110 * that many characters (unterminated)
111 * an int for the value length
112 * that many characters (unterminated)
113 * one unsigned long, endmagic;
117 struct progress_msg {
119 enum { pt_ok, pt_errmsg, pt_failed, pt_terminated } type;
121 struct { int messagelen; } errmsg;
122 struct { int status; } terminated;
124 /* follwed by variable-length part:
125 * for ok, failed, terminated: nothing
126 * for errmsg: messagelen bytes for the error message (unterminated, no \n)
127 * unsigned long PROGRESS_ERRMSG_END_MAGIC
133 enum { et_confirm, et_closereadfd, et_disconnect } type;
135 struct { int fd; } closereadfd;