int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char nettype[16] = "visible";
	int sndVar = 0;
	int recVar = -1;
	struct timeval total_timeout;
	enum clnt_stat rslt;

	if (run_mode == 1) {
		printf("Server : %s\n", argc[1]);
		printf("Server # %d\n", progNum);
		printf("Net : %s\n", nettype);
	}
	//Initialisation
	total_timeout.tv_sec = 1;
	total_timeout.tv_usec = 1;
	/**/
	    //Multiple test case
	    rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			    (xdrproc_t) xdr_int, (char *)&sndVar,
			    (xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perrno(rslt);

	rslt = rpc_call(argc[1], 1, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perrno(rslt);

	rslt = rpc_call(argc[1], progNum, 10, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, nettype);
	clnt_perrno(rslt);

	rslt = rpc_call(argc[1], progNum, VERSNUM, PROCNUM,
			(xdrproc_t) xdr_int, (char *)&sndVar,
			(xdrproc_t) xdr_int, (char *)&recVar, "wrong");
	clnt_perrno(rslt);

	//If we are here, test has passed
	test_status = 0;

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Пример #2
0
int
main(int argc, char **argv)
{
	enum clnt_stat stat;
	char *hostname;
	nlm4_notify notify;

	if (argc != 2) {
		fprintf(stderr, "Usage: clear_locks <hostname>\n");
		exit(1);
	}
	hostname = argv[1];

	if (geteuid() != 0) {
		fprintf(stderr, "clear_locks: must be root\n");
		exit(1);
	}

	notify.name = hostname;
	notify.state = 0;
	stat = rpc_call("localhost", NLM_PROG, NLM_VERS4, NLM4_FREE_ALL,
	    (xdrproc_t) xdr_nlm4_notify, (void *) &notify,
	    (xdrproc_t) xdr_void, NULL, NULL);

	if (stat != RPC_SUCCESS) {
		clnt_perrno(stat);
		exit(1);
	}
	fprintf(stderr, "clear_locks: cleared locks for hostname %s\n",
	    hostname);

	return (0);
}
Пример #3
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	enum clnt_stat cs;
	int varSnd = 1;

	//Initialization
	if (run_mode == 1) {
		printf("progNum : %d\n", progNum);
	}

	cs = callrpc(argc[1], progNum, VERSNUM, PROCNUM,
		     (xdrproc_t) xdr_int, (char *)&varSnd,
		     (xdrproc_t) xdr_int, (char *)&varSnd);

	//test_status = varSnd;

	if (cs != RPC_SUCCESS)
		clnt_perrno(cs);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	//printf("%d\n", test_status);

	return 0;		//test_status;
}
Пример #4
0
void read_dir(char *host, char *dir)
{
	extern bool_t xdr_dir();
	enum clnt_stat clnt_stat;
	clnt_stat = callrpc(host, DIRPROG, DIRVERS, READDIR,
					(xdrproc_t)xdr_dir, dir, (xdrproc_t)xdr_dir, dir);
	if (clnt_stat != 0){
		clnt_perrno (clnt_stat);
	}
}
Пример #5
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char proto[8] = "udp";
	CLIENT *clnt = NULL;
	enum clnt_stat cs;
	struct timeval to;
	int varSnd = 10;
	int varRec = -1;

	//Initialization
	to.tv_sec = 1;
	to.tv_usec = 100;

	//First of all, create a client
	clnt = clnt_create(argc[1], progNum, VERSNUM, proto);

	if (run_mode == 1) {
		printf("CLIENT : %p\n", clnt);
		printf("progNum : %d\n", progNum);
		printf("Proto : %s\n", proto);
	}

	if (clnt == NULL) {
		clnt_pcreateerror("err");
		printf("1\n");
		return 1;
	}

	cs = clnt_call(clnt, PROCNUM,
		       (xdrproc_t) xdr_int, (char *)&varSnd,
		       (xdrproc_t) xdr_int, (char *)&varRec, to);

	test_status = (cs == RPC_SUCCESS) ? 0 : 1;

	if (cs != RPC_SUCCESS)
		clnt_perrno(cs);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Пример #6
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   other arguments depend on test case
	
	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1; //Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char nettype[16] = "udp";
	CLIENT *clnt = NULL;
	enum clnt_stat rslt;
    int recVar = -1; 
    struct timeval total_timeout;
	
	if (run_mode == 1)
	{
		printf("Server : %s\n", argc[1]);
		printf("Server # %d\n", progNum);
		printf("Net : %s\n", nettype);
	}	
	
	//Initialisation
	total_timeout.tv_sec = 1;
	total_timeout.tv_usec = 1;/**/
	
	//First of all, create client using top level API
	clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);	
	
	//Then call remote procedure
	rslt = clnt_call((CLIENT *)clnt, PROCNUM, 
						    (xdrproc_t)xdr_int, (char *)&recVar, // xdr_in
                    		(xdrproc_t)xdr_int, (char *)&recVar, // xdr_out
						    total_timeout);	/**/
						    
	clnt_perrno(rslt);
	
	//If we are here, test has passed
	test_status = 0;
	
	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);
	
	return test_status;
}
Пример #7
0
int main (int argc, char *argv[])
{
  char *host ;
  int procnum ;

  matrice22 mat[2] ;
  matrice22 res ;
  
  enum clnt_stat stat ;

  if (argc != 3)
  {
    printf("Usage : %s <machine_serveur> <no de procedure>\n",argv[0]) ;
    exit(1) ;
  }

  host = argv[1] ;

  (mat[0]).tab[0][0] = 1 ;
  (mat[0]).tab[0][1] = 2 ;
  (mat[0]).tab[1][0] = 3 ;
  (mat[0]).tab[1][1] = 4 ;
  
  (mat[1]).tab[0][0] = 1 ;
  (mat[1]).tab[0][1] = 0 ;
  (mat[1]).tab[1][0] = 0 ;
  (mat[1]).tab[1][1] = 2 ;

  procnum = atoi(argv[2]) ;
  
  // si numéro inconne : defaut = 1
  if ((procnum != 1) && (procnum != 2))
    procnum = 1;
  
  // appel RPC
  stat = callrpc(host,PROGNUM,VERSNUM,procnum, (xdrproc_t)xdr_mat2, (char*)&mat, (xdrproc_t)xdr_mat, (char *)&res) ;
  
  if (stat != RPC_SUCCESS)
  { 
    fprintf(stderr, "Echec de l'appel distant\n") ;
    clnt_perrno(stat) ;
    fprintf(stderr, "\n") ;
    return 1 ;
  }

  printf("client, le resultat : \n%f %f \n%f %f\n", res.tab[0][0], res.tab[0][1], res.tab[1][0], res.tab[1][1]) ;
  return 0 ;  
}
Пример #8
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of host ready to answer to broadcast
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 1; //Default test result set to FAILED
	int progNum = atoi(argc[2]);
	enum clnt_stat cs;
	char nettype[16] = "visible";
	int varSnd = 0;
	int varRec;

	bool_t eachResult (char *out, struct sockaddr_in *addr);
	maxAnswer = atoi(argc[3]);
	currentAnswer = 0;

	//Show information in debug mode...
	if (run_mode == 1)
	{
		printf("progNum : %d\n", progNum);
		printf("Max SVC : %d\n", maxAnswer);
	}

	//Call broadcast routine
	cs = rpc_broadcast_exp (progNum, VERSNUM, PINGPROC,
						  	(xdrproc_t)xdr_int, (char *)&varSnd,
						  	(xdrproc_t)xdr_int, (char *)&varRec,
						  	(resultproc_t)eachResult, 0, 100, nettype);

	if (currentAnswer == maxAnswer)
		test_status = 0;

	if (cs != RPC_SUCCESS)
		clnt_perrno(cs);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Пример #9
0
int main (int argc, char **argv) {
	//~ char *host = argv[1];
	char *host = "127.0.0.1";
	enum clnt_stat stat;

	mat2 res;
	mats2 donnees;

	fill_entiers2(&donnees.m1.l1, 1, 2);
	fill_entiers2(&donnees.m1.l2, 3, 4);

	fill_entiers2(&donnees.m2.l1, 1, 2);
	fill_entiers2(&donnees.m2.l2, 3, 4);

	int procnum;
	if (argv[1][0]=='a')
		procnum = APROCNUM;
	if (argv[1][0]=='m')
		procnum = MPROCNUM;

	stat = callrpc(/* host */ host,
		/* prognum */ PROGNUM,
		/* versnum */ VERSNUM,
		/* procnum */ procnum,
		/* encodage argument */ (xdrproc_t) xdr_mats2,
		/* argument */ (char *)&donnees,
		/* decodage retour */ (xdrproc_t)xdr_mat2,
		/* retour de la fonction distante */(char *)&res);

  if (stat != RPC_SUCCESS) 
  { 
	fprintf(stderr, "Echec de l'appel distant\n");
	clnt_perrno(stat);      fprintf(stderr, "\n");
  } 
  else
   {
	print_mat(&donnees.m1);
	printf("\n\n");
	print_mat(&donnees.m2);
	printf("\n\n");   

	print_mat(&res);
	printf("\n");
  }
  return(0);
}
Пример #10
0
int main (int argc, char **argv) {
	char *host = argv[1];
	enum clnt_stat stat;
	entiers2 res;
	entiers2 donnees = {13 , 5};
	stat = callrpc(host, PROGNUM, VERSNUM, PROCNUM,
		(xdrproc_t)xdr_entiers2, (char*)&donnees, (xdrproc_t)xdr_entiers2, (char*)&res); 

	if (stat != RPC_SUCCESS) { 
		fprintf(stderr, "Echec de l'appel distant\n");
		clnt_perrno(stat);      fprintf(stderr, "\n");
	}
	else {
		printf("client res : %d/%d (q:%d r:%d)\n",
		donnees.x,donnees.y,res.x,res.y);
	}
	return(0);
}
Пример #11
0
int main (int argc, char **argv) {
  char *host = argv[1];
  enum clnt_stat stat;

  srand(time(NULL));

  if (argc!=2) {
    printf("Usage :%s [IP serveur]\n",argv[0]);
  }


//
//  if(choix=='m'){
//    stat = callrpc(/* host */ host,
//        /* prognum */ PROGNUM,
//        /* versnum */ VERSNUM,
//        /* procnum */ PROCNUM_MULT,
//        /* encodage argument */ (xdrproc_t) xdr_matrix_couple,
//        /* argument */ (char *)&donnee,
//        /* decodage retour */ (xdrproc_t)xdr_matrix,
//        /* retour de la fonction distante */(char *)&res);
//  }
//*/
//  else if(choix=='a'){
//    stat = callrpc(/* host */ host,
//        /* prognum */ PROGNUM,
//        /* versnum */ VERSNUM,
//        /* procnum */ PROCNUM_ADD,
//        /* encodage argument */ (xdrproc_t) xdr_matrix_couple,
//        /* argument */ (char *)&donnee,
//        /* decodage retour */ (xdrproc_t)xdr_matrix,
//        /* retour de la fonction distante */(char *)&res);
//  }
  
  if (stat != RPC_SUCCESS) { 
    fprintf(stderr, "Echec de l'appel distant\n");
    clnt_perrno(stat);      fprintf(stderr, "\n");
  }
	else{
  }

  return(0);
}
Пример #12
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of test call
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 0; //Default test result set to FAILED
	int i;
	double *resultTbl;
	struct timeval tv1,tv2;
    struct timezone tz;
    long long diff;
    double rslt;
	int progNum = atoi(argc[2]);
	char nettype[16] = "visible";
	CLIENT *clnt = NULL;
	enum clnt_stat cs;
	int sndVar = 0;
    int recVar = -1;
    struct timeval total_timeout;

	//Test initialisation
    maxIter = atoi(argc[3]);
    resultTbl = (double *)malloc(maxIter * sizeof(double));

    total_timeout.tv_sec = 1;
	total_timeout.tv_usec = 1;

	clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);

	if (clnt == NULL)
	{
		printf("5\n");
		return 5;
	}

	//Call tested function several times
	for (i = 0; i < maxIter; i++)
	{
		//Tic
		gettimeofday(&tv1, &tz);

		//Call function
		cs = clnt_call((CLIENT *)clnt, PROCNUM,
						(xdrproc_t)xdr_int, (char *)&sndVar, // xdr_in
                   		(xdrproc_t)xdr_int, (char *)&recVar, // xdr_out
						total_timeout);

		//Toc
		gettimeofday(&tv2, &tz);

		//Add function execution time (toc-tic)
		diff = (tv2.tv_sec-tv1.tv_sec) * 1000000L + (tv2.tv_usec-tv1.tv_usec);
		rslt = (double)diff / 1000;

    	if (cs == RPC_SUCCESS)
    	{
    		resultTbl[i] = rslt;
    	}
    	else
    	{
    		test_status = 1;
    		clnt_perrno(cs);
    		break;
    	}

    	if (run_mode)
    	{
    		fprintf(stderr, "lf time  = %lf usecn\n", resultTbl[i]);
    	}
	}

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);
	printf("%lf %d\n", average(resultTbl), maxIter);
	printf("%lf\n", mini(resultTbl));
	printf("%lf\n", maxi(resultTbl));

	return test_status;
}
Пример #13
0
static int _do_setpass(pam_handle_t* pamh, const char *forwho, char *fromwhat,
		       char *towhat, unsigned int ctrl, int remember)
{
	struct passwd *pwd = NULL;
	int retval = 0;

	D(("called"));

	setpwent();
	pwd = getpwnam(forwho);
	endpwent();

	if (pwd == NULL)
		return PAM_AUTHTOK_ERR;

	if (on(UNIX_NIS, ctrl)) {
		struct timeval timeout;
		struct yppasswd yppwd;
		CLIENT *clnt;
		char *master;
		int status;
		int err = 0;

		/* Make RPC call to NIS server */
		if ((master = getNISserver(pamh)) == NULL)
			return PAM_TRY_AGAIN;

		/* Initialize password information */
		yppwd.newpw.pw_passwd = pwd->pw_passwd;
		yppwd.newpw.pw_name = pwd->pw_name;
		yppwd.newpw.pw_uid = pwd->pw_uid;
		yppwd.newpw.pw_gid = pwd->pw_gid;
		yppwd.newpw.pw_gecos = pwd->pw_gecos;
		yppwd.newpw.pw_dir = pwd->pw_dir;
		yppwd.newpw.pw_shell = pwd->pw_shell;
		yppwd.oldpass = fromwhat;
		yppwd.newpw.pw_passwd = towhat;

		D(("Set password %s for %s", yppwd.newpw.pw_passwd, forwho));

		/* The yppasswd.x file said `unix authentication required',
		 * so I added it. This is the only reason it is in here.
		 * My yppasswdd doesn't use it, but maybe some others out there
		 * do.                                        --okir
		 */
		clnt = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp");
		clnt->cl_auth = authunix_create_default();
		memset((char *) &status, '\0', sizeof(status));
		timeout.tv_sec = 25;
		timeout.tv_usec = 0;
		err = clnt_call(clnt, YPPASSWDPROC_UPDATE,
				(xdrproc_t) xdr_yppasswd, (char *) &yppwd,
				(xdrproc_t) xdr_int, (char *) &status,
				timeout);

		if (err) {
			clnt_perrno(err);
			retval = PAM_TRY_AGAIN;
		} else if (status) {
			fprintf(stderr, "Error while changing NIS password.\n");
			retval = PAM_TRY_AGAIN;
		}
		printf("\nThe password has%s been changed on %s.\n",
		       (err || status) ? " not" : "", master);

		auth_destroy(clnt->cl_auth);
		clnt_destroy(clnt);
		if ((err || status) != 0) {
			retval = PAM_TRY_AGAIN;
		}
#ifdef DEBUG
		sleep(5);
#endif
		return retval;
	}
	/* first, save old password */
	if (save_old_password(forwho, fromwhat, remember)) {
		return PAM_AUTHTOK_ERR;
	}
	if (on(UNIX_SHADOW, ctrl) || (strcmp(pwd->pw_passwd, "x") == 0)) {
		retval = _update_shadow(forwho, towhat);
		if (retval == PAM_SUCCESS)
			retval = _update_passwd(forwho, "x");
	} else {
		retval = _update_passwd(forwho, towhat);
	}

	return retval;
}
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//                                         argc[2] : Server Program Number
	//                                         other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 0;	//Default test result set to FAILED
	int progNum = atoi(argc[2]);
	char proto[8] = "udp";
	CLIENT *clnt = NULL;
	enum clnt_stat cs;
	struct timeval to;
	int varSnd = 0;
	int i;
	struct RES resTbl[MAXCALC];
	struct datas vars;

	//Initialization
	to.tv_sec = 1;
	to.tv_usec = 100;

	//First of all, create a client
	clnt = clnt_create(argc[1], progNum, VERSNUM, proto);

	if (run_mode == 1) {
		printf("CLIENT : %d\n", clnt);
		printf("progNum : %d\n", progNum);
		printf("Proto : %s\n", proto);
	}

	if ((CLIENT *) clnt == NULL) {
		clnt_pcreateerror("err");
		printf("1\n");
		return 1;
	}

	for (i = 0; i < MAXCALC; i++) {
		vars.a = getRand();
		vars.b = getRand();
		vars.c = getRand();

		resTbl[i].locRes = vars.a + (vars.b * vars.c);

		cs = clnt_call(clnt, CALCPROC,
			       (xdrproc_t) xdr_datas, (char *)&vars,
			       (xdrproc_t) xdr_double,
			       (char *)&resTbl[i].svcRes, to);

		if (resTbl[i].locRes != resTbl[i].svcRes) {
			test_status = 1;
			break;
		}

		if (run_mode == 1) {
			fprintf(stderr, "value sent : %lf, %lf, %lf\n", vars.a,
				vars.b, vars.c);
			fprintf(stderr, "value localy calculated : %lf\n",
				resTbl[i].locRes);
			fprintf(stderr, "value from server : %lf\n",
				resTbl[i].svcRes);
		}
	}

	if (cs != RPC_SUCCESS)
		clnt_perrno(cs);

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}
Пример #15
0
int main(int argn, char *argc[])
{
	//Program parameters : argc[1] : HostName or Host IP
	//					   argc[2] : Server Program Number
	//					   argc[3] : Number of test call
	//					   other arguments depend on test case

	//run_mode can switch into stand alone program or program launch by shell script
	//1 : stand alone, debug mode, more screen information
	//0 : launch by shell script as test case, only one printf -> result status
	int run_mode = 0;
	int test_status = 0; //Default test result set to FAILED
	int i;
	double *resultTbl;
	struct timeval tv1,tv2;
    struct timezone tz;
    long long diff;
    double rslt;
	int progNum = atoi(argc[2]);
	enum clnt_stat cs;
	int varSnd = 10;
	int varRec = -1;

	//Test initialisation
    maxIter = atoi(argc[3]);
    resultTbl = (double *)malloc(maxIter * sizeof(double));

	//Call tested function several times
	for (i = 0; i < maxIter; i++)
	{
		//Tic
		gettimeofday(&tv1, &tz);

		//Call function
		cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
				   			(xdrproc_t)xdr_int, (char *)&varSnd,
				   			(xdrproc_t)xdr_int, (char *)&varRec,
				   			eachResult);

		if (cs != RPC_SUCCESS)
			clnt_perrno(cs);

		//Toc
		gettimeofday(&tv2, &tz);

		//Add function execution time (toc-tic)
		diff = (tv2.tv_sec-tv1.tv_sec) * 1000000L + (tv2.tv_usec-tv1.tv_usec);
		rslt = (double)diff / 1000;

    	if (cs == RPC_SUCCESS)
    	{
    		resultTbl[i] = rslt;
    	}
    	else
    	{
    		test_status = 1;
    		break;
    	}

    	if (run_mode)
    	{
    		fprintf(stderr, "lf time  = %lf usecn\n", resultTbl[i]);
    	}
	}

	//This last printf gives the result status to the tests suite
	//normally should be 0: test has passed or 1: test has failed
	printf("%d\n", test_status);

	return test_status;
}