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) * CU sudo version 1.3.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.
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 #ifndef lint
@@ -61,13 +51,15 @@ static char rcsid[] = "$Id$";
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include "sudo.h" #include "sudo.h"
/* /*
* Globals * Globals
*/ */
int parse_error = FALSE; int parse_error = FALSE;
extern int clearaliases;
extern struct interface *interfaces;
extern int num_interfaces;
char *cmnd; char *cmnd;
char *user; char *user;
@@ -78,13 +70,13 @@ char **Argv;
int Argc; int Argc;
uid_t uid; uid_t uid;
/* /*
* return TRUE if cmnd matches, in the sudo sense, * return TRUE if cmnd matches, in the sudo sense,
* the pathname in path; otherwise, return FALSE * the pathname in path; otherwise, return FALSE
*/ */
int int path_matches(cmnd, path)
path_matches(cmnd, path) char *cmnd, *path;
char *cmnd, *path;
{ {
int clen, plen; int clen, plen;
@@ -109,39 +101,35 @@ char *cmnd, *path;
return strncmp(cmnd, path, plen) == 0; return strncmp(cmnd, path, plen) == 0;
} }
int
addr_matches(n) int addr_matches(n)
char *n; char *n;
{ {
struct in_addr **in; int i;
struct hostent *he; struct in_addr addr;
int ntwk;
ntwk = inet_network(n); addr.s_addr = inet_addr(n);
if ((he = gethostbyname(host)) == NULL) for (i = 0; i < num_interfaces; i++)
return FALSE; if (interfaces[i].addr.s_addr == addr.s_addr ||
if (he->h_length != sizeof **in) { (interfaces[i].addr.s_addr & interfaces[i].netmask.s_addr)
yyerror("IP addrs broken\n"); == addr.s_addr)
return FALSE; return(TRUE);
}
for (in = (struct in_addr **) he->h_addr_list; *in; in++)
if (inet_netof(**in) == ntwk)
return TRUE;
return FALSE; return(FALSE);
} }
void
set_perms(i) void set_perms(i)
int i; int i;
{ {
return; return;
} }
main(argc, argv) main(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
#ifdef YYDEBUG #ifdef YYDEBUG
extern int yydebug; extern int yydebug;
@@ -160,9 +148,13 @@ char **argv;
user = argv[2]; user = argv[2];
strcpy(host, argv[3]); strcpy(host, argv[3]);
if (yyparse() || parse_error) clearaliases = 0;
load_interfaces();
if (yyparse() || parse_error) {
printf("doesn't parse.\n"); printf("doesn't parse.\n");
else { } else {
printf("parses OK.\n\n"); printf("parses OK.\n\n");
if (top == 0) if (top == 0)
printf("User %s not found\n", user); printf("User %s not found\n", user);