From: Todd C. Miller Date: Wed, 9 Mar 1994 23:51:22 +0000 (+0000) Subject: Initial revision X-Git-Tag: SUDO_1_3_1~305 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e37e623c246e6a29be440a7c73c4c001546da4be;p=sudo Initial revision --- diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 000000000..f7f1ad6b6 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,227 @@ +#* +#* CU sudo version 1.3 (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. +#* +#* 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 +#* the Free Software Foundation; either version 1, or (at your option) +#* any later version. +#* +#* This program is distributed in the hope that it will be useful, +#* but WITHOUT ANY WARRANTY; without even the implied warranty of +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#* GNU General Public License for more details. +#* +#* You should have received a copy of the GNU General Public License +#* along with this program; if not, write to the Free Software +#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#* + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = @srcdir@ + +# Compiler & tools to use +CC = @CC@ +LEX = @LEX@ +YACC = @YACC@ +SENDMAIL = @SENDMAIL@ + +# Which install program? +INSTALL = @INSTALL@ + +DEFS = -DMAILER=\"$(SENDMAIL)\" @DEFS@ +LIBS = @LIBS@ + +# Usually -g or -O +CFLAGS = -O +LDFLAGS = @STATIC_FLAGS@ + +prefix = /usr/local +exec_prefix = $(prefix) +man_prefix = $(prefix) + +# Directory in which to install sudo. +sudodir = $(exec_prefix)/bin + +# Directory in which to install visudo +visudodir = $(exec_prefix)/etc + +# Directory in which to install the man page +mandir = $(man_prefix)/man/man1 +manext = 1 + +# User and Group the installed file should be owned by +owner = root +group = staff + +################################################################################ +# The following macros can be defined when compiling. +# +# FQDN - if you have fully qualified hostnames +# in your SUDOERS files +# +# SYSLOG - if you want to use syslog instead +# of a log file +# ( This is a nice feature. You can +# collect all your sudo logs at a +# single host) +# +# NO_ROOT_SUDO - sudo will exit if called by root +# +# SOLARIS - define if using Solaris 2.x +# +# SEND_MAIL_WHEN_NOT_OK - if you want a message sent to ALERTMAIL +# when the user is in the SUDOERS but +# does not have permission to execute +# the command entered +# ( This can be used at paranoid sites ) +# +# SEND_MAIL_WHEN_NO_USER - if you want a message sent to ALERTMAIL +# when the user is not in the SUDOERS file +# ( This is generally the case ) +# +# TIMEDIR the directory where the timestamp +# files are kept. +# +# TIMEOUT the number of minutes that can elapse +# before sudo will ask for a passwd again +# +# TRIES_FOR_PASSWORD the number of times sudo will let you +# guess are you password before screaming +# +# INCORRECT_PASSWORD the message that is displayed if you +# incorrectly enter your password +# +# MAILSUBJECT the subject of the mail sent to ALERTMAIL +# +# ALERTMAIL the recipient of mail from sudo +# +# SUDOERS the location of the sudoers file +# +# TMPSUDOERS the location of the lock file for visudo +# +# EDITOR the location of the editor +# +# ENV_EDITOR if this variable is defined then the +# EDITOR and VISUAL envariables are consulted +# +# LOGFILE log file location IF NOT USING SYSLOG +# +# SECURE_PATH if this variable is set, its value is +# used as the PATH variable +# +# UMASK umask that sudo should use, comment out +# of sudo.h to preserve umask of the caller, +# default is 022 +# +# BROKEN_GETPASS if using a os with a broken getpass() +# hpux,aix,irix need this, sudo.h has details +# +# HAVE_STRDUP if your os has strdup(3) +# +# HAVE_CWD if you have getcwd(3) +# +# USE_TERMIO if you have sysV terminal control +# (defined by default for hpux and irix) +# +# SHORT_MESSAGE if you don't want the full copyright message +# with the "we expect you have..." banner +# +# USE_INSULTS if you want to be insulted for typing an +# incorrect password like the original sudo(8) +# +# HAL if you want lines from 2001 instead of +# insults (must define USE_INSULTS too) +# +# STDC_HEADERS if you have ansi-compliant header files +# +# USE_EXECV if you want to use execv() instead of +# execvp() +# +# Macro: Default: +# Syslog_ident "sudo" +# Syslog_options LOG_PID +# Syslog_facility LOG_LOCAL2 +# Syslog_priority_OK LOG_NOTICE +# Syslog_priority_NO LOG_ALERT +################################################################################ + +OPTIONS = -DSYSLOG -DSEND_MAIL_WHEN_NO_USER -DSyslog_options=0 @OPTIONS@ + +#### End of system configuration section. #### + +SHELL = /bin/sh + +SRCS = check.c find_path.c getpass.c logging.c parse.c sudo.c parse.yacc \ + parse.lex + +OBJS = check.o find_path.o getpass.o logging.o parse.o sudo.o y.tab.o \ + lex.yy.o + +HDRS = sudo.h insults.h + +all: @PROGS@ + +.c.o: + $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) -I$(srcdir) $< + +sudo : $(OBJS) + $(CC) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) + +y.tab.o y.tab.h: parse.yacc $(HDRS) + $(YACC) -d parse.yacc + $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) -I$(srcdir) y.tab.c + +lex.yy.o: parse.lex y.tab.h $(HDRS) + $(LEX) parse.lex + $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) -I$(srcdir) lex.yy.c + +$(OBJS) : $(HDRS) + +visudo : + ( cd visudoers && make "OPTIONS=$(OPTIONS)" $@ ) + +install: install-binaries install-sudoers install-man + +install-binaries: $(PROGS) + $(INSTALL) -o $(owner) -g $(group) -m 4111 -s sudo $(sudodir)/sudo + $(INSTALL) -o $(owner) -g $(group) -m 0111 -s visudoers/visudo $(visudodir)/visudo + +install-sudoers: + @ if [ -f $(SUDOERSDIR)/sudoers ]; then \ + echo "Will not overwrite existing $(SUDOERSDIR)/sudoers file."; \ + else \ + $(INSTALL) -o $(owner) -g $(group) -m 0400 sudoers $(SUDOERSDIR)/sudoers; \ + fi + +install-man: + $(INSTALL) -o $(owner) -g $(group) -m 0644 sudo.man $(mandir)/sudo.$(manext) + +clean: + -rm -f lex.yy.* y.tab.* *.o $(PROGS) core + ( cd visudoers && make $@ ) + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status + ( cd visudoers && make $@ ) + +realclean: distclean + rm -f TAGS + ( cd visudoers && make $@ ) + +TAGS: + etags ${srcdir}/*.m4 ${srcdir}/*.sh ${srcdir}/[a-z]*.in ${srcdir}/*.texi + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 000000000..a0b527738 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,147 @@ +dnl Local m4 macors for autoconf (used by sudo) +dnl +dnl checks for programs +dnl +define(SUDO_PROG_INSTALL, +[# Make sure to not get the incompatible SysV /etc/install and +# /usr/sbin/install, which might be in PATH before a BSD-like install, +# or the SunOS /usr/etc/install directory, or the AIX /bin/install, +# or the AFS install, which mishandles nonexistent args, or +# /usr/ucb/install on SVR4, which tries to use the nonexistent group +# `staff'. On most BSDish systems install is in /usr/bin, not /usr/ucb +# anyway. Sigh. We can always use the installbsd in $srcdir. +if test "z${INSTALL}" = "z" ; then + echo checking for install + savepath="$PATH" + PATH="${PATH}:${srcdir}" + IFS="${IFS= }"; saveifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + case $dir in + /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;; + *) + if test -f $dir/installbsd; then + INSTALL="$dir/installbsd -c" # OSF1 + INSTALL_PROGRAM='$(INSTALL)' + INSTALL_DATA='$(INSTALL) -m 644' + break + fi + if test -f $dir/install; then + if grep dspmsg $dir/install >/dev/null 2>&1; then + : # AIX + else + INSTALL="$dir/install -c" + INSTALL_PROGRAM='$(INSTALL)' + INSTALL_DATA='$(INSTALL) -m 644' + break + fi + fi + ;; + esac + done + IFS="$saveifs" + PATH="$savepath" +fi +INSTALL=${INSTALL-cp} +AC_SUBST(INSTALL)dnl +test -n "$verbose" && echo " setting INSTALL to $INSTALL" +INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} +AC_SUBST(INSTALL_PROGRAM)dnl +test -n "$verbose" && echo " setting INSTALL_PROGRAM to $INSTALL_PROGRAM" +INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} +AC_SUBST(INSTALL_DATA)dnl +test -n "$verbose" && echo " setting INSTALL_DATA to $INSTALL_DATA" +])dnl +dnl +dnl check for sendmail +dnl +define(SUDO_PROG_SENDMAIL, +[if test -f "/usr/sbin/sendmail"; then + SENDMAIL="/usr/sbin/sendmail" +elif test -f "/usr/lib/sendmail"; then + SENDMAIL="/usr/lib/sendmail" +elif test -f "/usr/etc/sendmail"; then + SENDMAIL="/usr/etc/sendmail" +elif test -f "/usr/local/lib/sendmail"; then + SENDMAIL="/usr/local/lib/sendmail" +elif test -f "/usr/local/bin/sendmail"; then + SENDMAIL="/usr/local/bin/sendmail" +else + SENDMAIL="" +fi +])dnl +dnl +dnl checks for UNIX variants +dnl +define(SUDO_AIX, +[echo checking for AIX +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#ifdef _AIX + yes +#endif +], AC_DEFINE(_ALL_SOURCE) [$1], [$2]) +])dnl +dnl +define(SUDO_HPUX, +[echo checking for HP-UX +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#if defined(hpux) || defined(__hpux) + yes +#endif +], [$1], [$2]) +])dnl +dnl +define(SUDO_DEC_OSF1, +[echo checking for DEC OSF/1 +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#ifdef __alpha + yes +#endif +], [$1], [$2]) +])dnl +dnl +define(SUDO_LINUX, +[echo checking for linux +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#if defined(linux) || defined(__linux) + yes +#endif +], [$1], [$2]) +])dnl +dnl +define(SUDO_CONVEX, +[echo checking for ConvexOS +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#ifdef convex + yes +#endif +], AC_DEFINE(_CONVEX_SOURCE) [$1], [$2]) +])dnl +dnl +define(SUDO_KSR, +[echo checking for KSROS +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[#ifdef __ksr__ + yes +#endif +], INSTALL=/usr/sbin/install [$1], [$2]) +])dnl +dnl +define(SUDO_SUNOS, +[echo checking for SunOS +AC_BEFORE([$0], [AC_COMPILE_CHECK])AC_BEFORE([$0], [AC_TEST_PROGRAM])AC_BEFORE([ +$0], [AC_HEADER_EGREP])AC_BEFORE([$0], [AC_TEST_CPP])AC_PROGRAM_EGREP(yes, +[ +#include +#if defined(sun) && !defined(BSD) + yes +#endif +], [$1], [$2]) +])dnl +dnl diff --git a/configure.in b/configure.in new file mode 100644 index 000000000..14b76f903 --- /dev/null +++ b/configure.in @@ -0,0 +1,107 @@ +dnl Process this file with autoconf to produce a configure script. +echo Configuring cu sudo version 1.3.1 +AC_INIT(sudo.h) +dnl +dnl Variables that get substituted in the Makefile +dnl +PROGS="sudo visudo" +AC_SUBST(PROGS)dnl +STATIC_FLAGS="" +AC_SUBST(STATIC_FLAGS)dnl +SENDMAIL="" +AC_SUBST(SENDMAIL)dnl +OPTIONS="" +AC_SUBST(OPTIONS)dnl +dnl +dnl did they say --with-csops? +dnl +AC_WITH(csops, OPTIONS="$OPTIONS -DUSE_INSULTS -DENV_EDITOR -DSHORT_MESSAGE" +echo 'CSOps--adding options: USE_INSULTS ENV_EDITOR SHORT_MESSAGE') +dnl +dnl C compiler checks +dnl +AC_PROG_CC +AC_PROG_CPP +dnl +dnl what architecture are we on? +dnl +AC_HEADER_CHECK(elf.h, AC_DEFINE(SVR4)) +SUDO_AIX([if test -n "$GCC"; then +STATIC_FLAGS="-static" +else +STATIC_FLAGS="-bnoso -bI:/lib/syscalls.exp" +fi +])dnl +dnl +if test -z "$SVR4"; then +SUDO_SUNOS([if test -n "$GCC"; then +STATIC_FLAGS="-static" +else +STATIC_FLAGS="-Bstatic" +fi +])dnl +fi +dnl +SUDO_HPUX([if test -n "$GCC"; then +STATIC_FLAGS="-static" +else +STATIC_FLAGS="-Wl,-a,archive" +fi +])dnl +dnl +SUDO_DEC_OSF1([if test -n "$GCC"; then +STATIC_FLAGS="-static" +else +STATIC_FLAGS="-non_shared" +fi +])dnl +dnl +SUDO_LINUX([STATIC_FLAGS="-static"]) +dnl +SUDO_CONVEX() +dnl +SUDO_KSR() +dnl +dnl program checks +dnl +AC_GCC_TRADITIONAL +AC_PROG_YACC +AC_PROG_LEX +SUDO_PROG_INSTALL +SUDO_PROG_SENDMAIL +dnl +dnl Header file checks +dnl +AC_STDC_HEADERS +AC_HAVE_HEADERS(string.h) +AC_HAVE_HEADERS(strings.h) +AC_HAVE_HEADERS(unistd.h) +AC_HAVE_HEADERS(malloc.h) +dnl +dnl typedef checks +dnl +AC_MODE_T +AC_UID_T +AC_SIZE_T +AC_RETSIGTYPE +dnl +dnl function checks +dnl +AC_HAVE_FUNCS(getcwd) +AC_HAVE_FUNCS(strdup) +dnl +dnl library checks +dnl +AC_IRIX_SUN +AC_HAVE_LIBRARY(ucb) +AC_HAVE_LIBRARY(bsd) +AC_HAVE_LIBRARY(BSD) +AC_HAVE_LIBRARY(socket) +AC_HAVE_LIBRARY(nsl) +AC_HAVE_LIBRARY(elf) +AC_HAVE_LIBRARY(malloc) +AC_HAVE_LIBRARY(shadow) +dnl +dnl Makefiles to substitute +dnl +AC_OUTPUT(Makefile visudoers/Makefile)