Shara Gnaneshan wrote:

> I downloaded base-1.2.17b.tar.gz and and trying to install in our Linux 
> system for test
> purposes and when running make getting an error and installation fails.
> 
> Error: 
> [...] parse error before `struct'
> 
> Our system specs:
> 
> An old sun server running its own Linux system (probably Redhat 7) Info from 
> uname -a
> is  Linux lx2 2.4.20-28.7.SLbigmem

Hi there.
The bad news is that your compiler predates the C99 standard. The
good news is that a while back I fixed that problem, and I'm attaching
a version of jobRunner.c that should compile on your system.

//Carl

-- 
 Carl Troein - [EMAIL PROTECTED]
 http://www.thep.lu.se/~carl/
// $Id: jobRunner.c,v 1.7 2005/12/09 18:25:17 troein Exp $
//
// BioArray Software Environment (BASE) - homepage http://base.thep.lu.se/
// Copyright (C) 2003-2005 Carl Troein
//
// This file is part of BASE.
//
// BASE 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 (at your option) any later version.
//
// BASE is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

// This program is to be installed as suid basejob (or whatever you
// choose to call that user). It takes the first argument to be the
// name of a plugin to run and subsequent arguments to be arguments
// to that program, just like nice or time or whatnot. The plugin is
// then run as the basejob user rather than the base user. If used
// correctly, this will protect your BASE installation against broken
// or malicious plugins, as well as against anyone who has managed to
// gain access to the plugin definition page in BASE.

#ifdef HAVE_CONFIG_H
	#include <config.h>
#endif

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
extern int errno;

#ifndef BASE_USER_UID
#error BASE_USER_UID must be defined (as the UID of the BASE user)
#endif
#ifndef JOBRUNNER_USER_UID
#error JOBRUNNER_USER_UID must be defined (as the UID of the BASE job user)
#endif

int main(int argc, char **argv)
{
	uid_t uid, euid;
	struct rlimit rl;
	int cpulim;
	long ramlim;

	if(argc < 5)
	{
		fprintf(stderr, "jobRunner: too few arguments\n"
			"Usage: jobRunner nice maxCPU maxRAM program [options...]\n"
			"May only be run by uid %d, euid %d\n",
			BASE_USER_UID, JOBRUNNER_USER_UID);
		errno = EINVAL;
		return 125;
	}
	
	if(BASE_USER_UID != JOBRUNNER_USER_UID)
	{
		uid = getuid();
		if(uid != BASE_USER_UID)
		{
			fprintf(stderr, "jobRunner: may only be run by user %d "
				"(current uid: %d)\n", BASE_USER_UID, uid);
			errno = EINVAL;
			return 125;
		}
		euid = geteuid();
		if(euid != JOBRUNNER_USER_UID)
		{
			fprintf(stderr, "jobRunner: the effective (suid) UID must be %d "
				"(current euid: %d)\n", JOBRUNNER_USER_UID, euid);
			errno = EPERM;
			return 125;
		}
		if(setreuid(euid, (uid_t)-1))
		{
			perror("jobRunner: Unable to setreuid()");
			return 125;
		}
	}

//	signal(SIGHUP, SIG_IGN);

	nice(atoi(argv[1]));

	cpulim = atoi(argv[2]);
	if(cpulim >= 0)
	{
		rl.rlim_cur = cpulim;
		rl.rlim_max = cpulim;
		setrlimit(RLIMIT_CPU, &rl);
	}
	ramlim = strtol(argv[3], NULL, 0);
/*#ifdef RLIMIT_AS
	rl.rlim_cur = ramlim;
	rl.rlim_max = ramlim;
	setrlimit(RLIMIT_AS, &rl);
#else*/
	rl.rlim_cur = ramlim;
	rl.rlim_max = ramlim;
	setrlimit(RLIMIT_DATA, &rl);
	rl.rlim_cur = ramlim / 4;
	rl.rlim_max = ramlim / 4;
	setrlimit(RLIMIT_STACK, &rl);
//#endif

	execvp(argv[4], argv + 4);
	perror("jobRunner: plugin failed to execute");
	return 125;
}

Reply via email to