Exemple #1
0
/*
 * Very simply exercise that we can get and set each option.  If we're running
 * as root, run it also as nobody.  If not as root, complain about that.
 */
int
main(int argc, char *argv[])
{
	int ch;

	while ((ch = getopt(argc, argv, "M:rv")) != -1) {
		switch (ch) {
		case 'M':
			nmcastgroups = atoi(optarg);
			break;
		case 'r':
			dorandom = 1;	/* introduce non-determinism */
			break;
		case 'v':
			verbose = 1;
			break;
		default:
			usage();
		}
	}

	printf("1..1\n");

	if (geteuid() != 0) {
		warnx("Not running as root, can't run tests as root");
		fprintf(stderr, "\n");
		fprintf(stderr,
		   "Running tests with uid %d sock uid %d\n", geteuid(),
		    geteuid());
		testsuite(PRIV_ASIS);
	} else {
		fprintf(stderr,
		    "Running tests with ruid %d euid %d sock uid 0\n",
		    getuid(), geteuid());
		testsuite(PRIV_ASIS);
		if (seteuid(65534) != 0)
			err(-1, "seteuid(65534)");
		fprintf(stderr,
		    "Running tests with ruid %d euid %d sock uid 65534\n",
		    getuid(), geteuid());
		testsuite(PRIV_ASIS);
		fprintf(stderr,
		    "Running tests with ruid %d euid %d sock uid 0\n",
		    getuid(), geteuid());
		testsuite(PRIV_GETROOT);
	}
	printf("ok 1 - ipsockopt\n");
	exit(0);
}
Exemple #2
0
/*
 * main() : Entry point
 */
int main(int argc, char *argv[]) {

  if (argc < 2 || strcmp(argv[1], "-?") == 0) {
    /* Print usage */
    return printusage();
  }

  if (strcmp(argv[1], "-s") == 0) {
    /* Hash string */
    return hashstring(argv[2]);
  }

  if (strcmp(argv[1], "-t") == 0) {
    /* Time trial */
    return timetrial();
  }

  if (strcmp(argv[1], "-x") == 0) {
    /* Test suite */
    return testsuite();
  }

  /* Hash file */
  return hashfile(argv[1]);
}
Exemple #3
0
int main(int argc, char *argv[])
/*
 *  main program. calls one or more of the test routines depending
 *  on command line arguments. see the header of this file.
 *
 */
{
  unsigned int   i, j;
  byte          *hashcode;

   if (argc == 1) {
      printf("For each command line argument in turn:\n");
      printf("  filename  -- compute hash code of file binary read\n");
      printf("  -sstring  -- print string & hashcode\n");
      printf("  -t        -- perform time trial\n");
      printf("  -x        -- execute standard test suite, ASCII input\n");
   }
   else {
      for (i = 1; i < argc; i++) {
         if (argv[i][0] == '-' && argv[i][1] == 's') {
            printf("\n\nmessage: %s", argv[i]+2);
            hashcode = RMD((byte *)argv[i] + 2);
            printf("\nhashcode: ");
            for (j=0; j<RMDsize/8; j++)
               printf("%02x", hashcode[j]);
            printf("\n");
         }
         else if (strcmp (argv[i], "-t") == 0)
            speedtest ();
         else if (strcmp (argv[i], "-x") == 0)
            testsuite ();
         else {
            hashcode = RMDbinary (argv[i]);
            printf("\n\nmessagefile (binary): %s", argv[i]);
            printf("\nhashcode: ");
            for (j=0; j<RMDsize/8; j++)
               printf("%02x", hashcode[j]);
            printf("\n");
         }
      }
   }
   printf("\n");

   return 0;
}