X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=common.h;h=bf600469a184684cc0239381d15f1988967c9018;hb=e5294e9e174ea671d2e8f3454d3fbf25fd106c36;hp=539ecf000f3a50cbb3201a5289605f931a14f21f;hpb=703b99b834625829d6b285e5bca619475ef54511;p=userv.git diff --git a/common.h b/common.h index 539ecf0..bf60046 100644 --- a/common.h +++ b/common.h @@ -2,11 +2,14 @@ * userv - common.h * definitions shared between client and daemon * - * Copyright (C)1996-1997 Ian Jackson + * userv is + * Copyright 1996-2017 Ian Jackson . + * Copyright 2000 Ben Harris + * Copyright 2016-2017 Peter Benie * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but @@ -15,13 +18,16 @@ * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with userv; if not, write to the Free Software - * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with userv; if not, see . */ #ifndef COMMON_H #define COMMON_H +#define COPYRIGHT(indent,nl) \ + indent "Copyright (C)1996-2012 Ian Jackson; copyright (C)2000 Ben Harris." nl \ + indent "there is NO WARRANTY; type `userv --copyright' for details." nl + #define PCSUMSIZE 16 static const unsigned char protocolchecksumversion[PCSUMSIZE]= { @@ -32,39 +38,37 @@ static const unsigned char protocolchecksumversion[PCSUMSIZE]= { # define VARDIR "/var/run/userv" #endif -#define DIRSEP "/" - #ifndef RENDEZVOUS # define RENDEZVOUS "socket" #endif #ifndef RENDEZVOUSPATH -# define RENDEZVOUSPATH VARDIR DIRSEP RENDEZVOUS +# define RENDEZVOUSPATH VARDIR "/" RENDEZVOUS #endif #ifndef PIPEFORMAT -# ifdef AC_SYS_LONG_FILENAMES -# define PIPEFORMAT "pipe.%lu.%lu.%d" -# define PIPEFORMATEXTEND (sizeof(long)*3*2+sizeof(int)*3+1) -# else -# define PIPEFORMAT "%lx.%lx.%x" -# define PIPEFORMATEXTEND (sizeof(long)*2*2+sizeof(int)*2+1) -# endif +# define PIPEFORMAT "%lx.%lx.%x" +# define PIPEPATTERN "[0-9a-f]*.[0-9a-f]*.*[0-9a-f]" +# define PIPEFORMATEXTEND ((int)(sizeof(unsigned long)*2*2+(int)sizeof(int)*2+3)) +# define PIPEMAXLEN ((int)(sizeof(PIPEFORMAT)+PIPEFORMATEXTEND)) #endif #ifndef PIPEPATHFORMAT -# define PIPEPATHFORMAT VARDIR DIRSEP PIPEFORMAT -# define PIPEPATHMAXLEN (sizeof(PIPEPATHFORMAT)+PIPEFORMATEXTEND) +# define PIPEPATHFORMAT VARDIR "/" PIPEFORMAT +# define PIPEPATHMAXLEN ((int)(sizeof(PIPEPATHFORMAT)+PIPEFORMATEXTEND)) #endif -#define MAX_ALLOW_FD 255 -#define MAX_INCLUDE_NEST 40 -#define MAX_OVERRIDE_LEN (1024*1024) +#define MAX_ALLOW_FD 1024 +#define MAX_GENERAL_STRING (1024*1024) +#define MAX_OVERRIDE_LEN MAX_GENERAL_STRING +#define MAX_ERRMSG_STRING 4096 +#define MAX_ARGSDEFVAR 4096 +#define MAX_GIDS 1024 #ifdef DEBUG -# define BASE_MAGIC 0x5deb7567 /* "\x5d\xebug" */ +# define BASE_MAGIC 0x5deb7567UL /* "\x5d\xebug" */ #else -# define BASE_MAGIC 0x755e7276 /* "u\x5erv" */ +# define BASE_MAGIC 0x755e7276UL /* "u\x5erv" */ #endif enum { @@ -79,23 +83,25 @@ enum { struct opening_msg { unsigned long magic; unsigned char protocolchecksumversion[PCSUMSIZE]; - pid_t serverpid; + pid_t overlordpid, serverpid; }; struct request_msg { unsigned long magic; - pid_t clientpid; + pid_t clientpid; /* or -1 if no service is required and this was a version check */ int serviceuserlen; int servicelen; - int lognamelen; - int cwdlen; + int loginnamelen, spoofed; /* spoofed is 0 or 1 */ + int cwdlen, overridelen; uid_t callinguid; - int ngids, nreadfds, nwritefds, nargs, nvars, overridelen; + int ngids, nreadfds, nwritefds, nargs, nvars; /* Followed by: * serviceuserlen bytes for the service user (unterminated) * servicelen bytes for the service (unterminated) - * lognamelen bytes for the login name (unterminated) + * loginnamelen bytes for the login name (unterminated) * cwdlen bytes for the cwd (unterminated) + * overridelen bytes for the override data (with extra \n but unterminated), + * or nothing if overridelen==-1 * ngids gid_ts for the primary group and supplementary groups * nreadfds and then nwritefds ints for the file descriptors * for each of the nargs arguments @@ -118,10 +124,9 @@ struct progress_msg { struct { int status; } terminated; } data; /* follwed by variable-length part: - * for ok: nothing - * for errmsg: messagelen bytes for the error message (unterminated) - * unsigned long PROGRESS_MAGIC - * for terminated: nothing + * for ok, failed, terminated: nothing + * for errmsg: messagelen bytes for the error message (unterminated, no \n) + * unsigned long PROGRESS_ERRMSG_END_MAGIC */ };