/*
- * CU sudo version 1.3.1 (based on Root Group sudo version 1.1)
- *
- * This software comes with no waranty whatsoever, use at your own risk.
- *
- * Please send bugs, changes, problems to sudo-bugs.cs.colorado.edu
- *
- */
-
-/*
- * sudo version 1.1 allows users to execute commands as root
- * Copyright (C) 1991 The Root Group, Inc.
+ * CU sudo version 1.3.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- **************************************************************************
+ * Please send bugs, changes, problems to sudo-bugs@cs.colorado.edu
+ *
+ *******************************************************************
*
- * parse.c, sudo project
- * David R. Hieb
- * March 18, 1991
+ * testsudoers.c -- frontend for parser testing and developement.
*
- * routines to implement and maintain the parsing and list management.
+ * Chris Jepeway <jepeway@cs.utk.edu>
*/
#ifndef lint
#include <sys/stat.h>
#include <dirent.h>
-
#include "sudo.h"
/*
* Globals
*/
int parse_error = FALSE;
+extern int clearaliases;
+extern struct interface *interfaces;
+extern int num_interfaces;
char *cmnd;
char *user;
int Argc;
uid_t uid;
+
/*
* return TRUE if cmnd matches, in the sudo sense,
* the pathname in path; otherwise, return FALSE
*/
-int
-path_matches(cmnd, path)
-char *cmnd, *path;
+int path_matches(cmnd, path)
+ char *cmnd, *path;
{
int clen, plen;
return strncmp(cmnd, path, plen) == 0;
}
-int
-addr_matches(n)
-char *n;
+
+int addr_matches(n)
+ char *n;
{
- struct in_addr **in;
- struct hostent *he;
- int ntwk;
+ int i;
+ struct in_addr addr;
- ntwk = inet_network(n);
+ addr.s_addr = inet_addr(n);
- if ((he = gethostbyname(host)) == NULL)
- return FALSE;
- if (he->h_length != sizeof **in) {
- yyerror("IP addrs broken\n");
- return FALSE;
- }
- for (in = (struct in_addr **) he->h_addr_list; *in; in++)
- if (inet_netof(**in) == ntwk)
- return TRUE;
+ for (i = 0; i < num_interfaces; i++)
+ if (interfaces[i].addr.s_addr == addr.s_addr ||
+ (interfaces[i].addr.s_addr & interfaces[i].netmask.s_addr)
+ == addr.s_addr)
+ return(TRUE);
- return FALSE;
+ return(FALSE);
}
-void
-set_perms(i)
-int i;
+
+void set_perms(i)
+ int i;
{
return;
}
+
main(argc, argv)
-int argc;
-char **argv;
+ int argc;
+ char **argv;
{
#ifdef YYDEBUG
extern int yydebug;
user = argv[2];
strcpy(host, argv[3]);
- if (yyparse() || parse_error)
+ clearaliases = 0;
+
+ load_interfaces();
+
+ if (yyparse() || parse_error) {
printf("doesn't parse.\n");
- else {
+ } else {
printf("parses OK.\n\n");
if (top == 0)
printf("User %s not found\n", user);