now uses ip addrs and netmasks via load_interfaces()

This commit is contained in:
Todd C. Miller
1995-05-02 03:30:45 +00:00
parent e991fcfa70
commit 1250db5a9b

View File

@@ -1,15 +1,5 @@
/*
* 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
@@ -25,13 +15,13 @@
* 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
*******************************************************************
*
* routines to implement and maintain the parsing and list management.
* testsudoers.c -- frontend for parser testing and developement.
*
* Chris Jepeway <jepeway@cs.utk.edu>
*/
#ifndef lint
@@ -61,13 +51,15 @@ static char rcsid[] = "$Id$";
#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;
@@ -78,13 +70,13 @@ char **Argv;
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;
@@ -109,39 +101,35 @@ char *cmnd, *path;
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;
@@ -160,9 +148,13 @@ char **argv;
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);