-userv (0.57.1); urgency=high
+userv (0.58); urgency=high
+ * Fixed failure to set gid when invoking service !!
+ * Fixed failure to set fd value in et_closereadfd messages from client.
+
+ * Save filename string in parse_file for error reporting (in case it is
+ overwritten by parsing code).
+ * Fixed obscure race in process.c:getevent (et_closereadfd and hold fds).
* `builtin version' service had error message and errno string reserve
values exchanged.
- --
+ -- Ian Jackson <ian@davenant.greenend.org.uk> Sat, 24 Jan 1998 19:13:34 +0000
userv (0.57); urgency=high
memset(&event_mbuf,0,sizeof(event_mbuf));
event_mbuf.magic= EVENT_MAGIC;
event_mbuf.type= et_closereadfd;
+ event_mbuf.data.closereadfd.fd= fd;
r= fwrite(&event_mbuf,1,sizeof(event_mbuf),swfile);
if (r != sizeof(event_mbuf) || fflush(swfile))
if (errno != EPIPE) syscallerror("inform service of closed read fd");
}
int parse_string(const char *string, const char *descrip, int isinternal) {
- /* Returns the same things as parser, except that tokv_eof
- * is turned into 0.
+ /* Returns the same things as parser, except that tokv_eof is turned
+ * into 0. *string must be statically allocated or copied, so that
+ * it is not overwritten while the parsing takes place (unlike with
+ * parse_file).
*/
static const struct stat blankstab;
}
static int parse_file(const char *string, int *didexist) {
- /* Returns the same things as parser, except that tokv_eof
- * is turned into 0. If *didexist is 0 then errno will
- * have been set.
+ /* Returns the same things as parser, except that tokv_eof is turned
+ * into 0. If *didexist is 0 then errno will have been set.
+ * *string will be copied by parse_file so it may be be overwritten
+ * during the parsing (so, for example, yytext need not be copied).
*/
static int fileparselevel= 0;
YY_BUFFER_STATE ybuf;
int r;
FILE *file;
+ char *filename;
struct stat newstab;
if (fileparselevel >= MAX_INCLUDE_NEST) {
if (didexist) *didexist= 1;
+ filename= xstrsave(string);
ybuf= yy_create_buffer(file,YY_BUF_SIZE);
if (!ybuf) syscallerror("unable to create flex buffer for file");
- parser_push(&usestate,string,&newstab,ybuf,0);
+ parser_push(&usestate,filename,&newstab,ybuf,0);
fileparselevel++;
r= parser(0);
parseerrprint("error reading configuration file `%s'",string);
r= tokv_error;
}
-
+
fileparselevel--;
parser_pop();
+ free(filename);
fclose(file);
if (r == tokv_eof) r= 0;
return r;
serviceuser_shell= xstrsave(pw->pw_shell);
serviceuser_uid= pw->pw_uid;
+ if (setregid(pw->pw_gid,pw->pw_gid)) syscallerror("setregid 1");
if (initgroups(pw->pw_name,pw->pw_gid)) syscallerror("initgroups");
if (setreuid(pw->pw_uid,pw->pw_uid)) syscallerror("setreuid 1");
if (setreuid(pw->pw_uid,pw->pw_uid)) syscallerror("setreuid 2");
if (!setreuid(pw->pw_uid,0)) miscerror("setreuid 3 unexpectedly succeeded");
if (errno != EPERM) syscallerror("setreuid 3 failed in unexpected way");
}
+ if (setregid(pw->pw_gid,pw->pw_gid)) syscallerror("setregid 2");
service_ngids= getgroups(0,0); if (service_ngids == -1) syscallerror("getgroups(0,0)");
if (service_ngids > MAX_GIDS) miscerror("service user is in far too many groups");
if (fdarray[fd].holdfd != -1) {
if (close(fdarray[fd].holdfd))
syscallfailure("close unwanted hold descriptor for %d",fd);
+ fdarray[fd].holdfd= -1;
}
}
}