]> granicus.if.org Git - sudo/commitdiff
updated to work with configure + pathnames.h
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 12 Mar 1994 18:36:53 +0000 (18:36 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 12 Mar 1994 18:36:53 +0000 (18:36 +0000)
check.c
find_path.c
getpass.c
logging.c
parse.c
sudo.c

diff --git a/check.c b/check.c
index 74bf0e41f2043460bc3aa1beb6edc91209bbf643..f3bbc1d41142c208a1e204c37444a26a98402df2 100644 (file)
--- a/check.c
+++ b/check.c
 static char rcsid[] = "$Id$";
 #endif /* lint */
 
+#include "config.h"
+
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
 #include <strings.h>
+#endif /* HAVE_STRINGS_H */
 #include <fcntl.h>
 #include <sys/param.h>
 #include <sys/types.h>
@@ -109,7 +118,7 @@ static int check_timestamp()
     register int timestamp_is_old = -1;
     time_t now;
 
-    (void) sprintf(timestampfile, "%s/%s", TIMEDIR, user);
+    (void) sprintf(timestampfile, "%s/%s", _PATH_SUDO_TIMEDIR, user);
     timestampfile_p = timestampfile;
 
     timedir_is_good = 1;       /* now there's an assumption for ya... */
@@ -120,10 +129,10 @@ static int check_timestamp()
     /*
      * walk through the path one directory at a time
      */
-    for (p = timestampfile + 1; p = index(p, '/'); *p++ = '/') {
+    for (p = timestampfile + 1; p = strchr(p, '/'); *p++ = '/') {
        *p = '\0';
        if (stat(timestampfile, &statbuf) < 0) {
-           if (strcmp(timestampfile, TIMEDIR))
+           if (strcmp(timestampfile, _PATH_SUDO_TIMEDIR))
                (void) fprintf(stderr, "Cannot stat() %s\n", timestampfile);
            timedir_is_good = 0;
            *p = '/';
@@ -152,11 +161,11 @@ static int check_timestamp()
      */
     else {
        timestamp_is_old = 1;   /* user has to enter password */
-       if (mkdir(TIMEDIR, 0700)) {     /* make the TIMEDIR directory */
+       if (mkdir(_PATH_SUDO_TIMEDIR, 0700)) {  /* make the TIMEDIR directory */
            perror("check_timestamp: mkdir");
            timedir_is_good = 0;
        } else {
-           timedir_is_good = 1;/* TIMEDIR now exists         */
+           timedir_is_good = 1;/* _PATH_SUDO_TIMEDIR now exists         */
            reminder();
        }
     }
@@ -206,7 +215,7 @@ static void update_timestamp()
 
 static void check_passwd()
 {
-#if !(defined (linux) && defined (SHADOW_PWD))
+#if !(defined (linux) && defined (HAVE_LIBSHADOW))
     char *crypt();
 #endif /* linux */
     struct passwd *pw_ent;
index 516db417593862e377f192c5be349237bc017f69..bbc81b6e18c39e7e05ed1018156b55c82c23ad33 100644 (file)
 static char rcsid[] = "$Id$";
 #endif /* lint */
 
+#include "config.h"
+
 #include <stdio.h>
-#ifdef STD_HEADERS
+#ifdef STDC_HEADERS
 #include <stdlib.h>
-#endif /* STD_HEADERS */
+#endif /* STDC_HEADERS */
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
 #include <strings.h>
+#endif /* HAVE_STRINGS_H */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif /* HAVE_MALLOC_H */
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include "sudo.h"
 
-#ifndef STD_HEADERS
+#ifndef STDC_HEADERS
 extern char *malloc();
 extern char *getenv();
 extern char *strcpy();
@@ -68,15 +80,15 @@ extern int fprintf();
 extern int readlink();
 extern int stat();
 extern int lstat();
-#ifdef USE_CWD
+#ifdef HAVE_GETCWD
 extern char *getcwd();
 #else
 extern char *getwd();
-#endif
-#ifndef NEED_STRDUP
+#endif /* HAVE_GETCWD */
+#ifdef HAVE_STRDUP
 extern char *strdup();
-#endif
-#endif /* !STD_HEADERS */
+#endif /* HAVE_STRDUP */
+#endif /* !STDC_HEADERS */
 
 
 /*******************************************************************
@@ -105,7 +117,7 @@ char *find_path(file)
     /*
      * do we need to search the path?
      */
-    if (index(file, '/'))
+    if (strchr(file, '/'))
        return (qualify(file));
 
     /*
@@ -120,7 +132,7 @@ char *find_path(file)
     }
 
     do {
-       if ((n = index(path, ':')))
+       if ((n = strchr(path, ':')))
            *n = '\0';
 
        /*
@@ -207,11 +219,11 @@ char *qualify(n)
      * if n is relative, fill full with working dir
      */
     if (*n != '/') {
-#ifdef USE_CWD
+#ifdef HAVE_GETCWD
        if (!getcwd(full, (size_t) (MAXPATHLEN + 1))) {
 #else
        if (!getwd(full)) {
-#endif
+#endif /* HAVE_GETCWD */
            (void) fprintf(stderr, "%s:  Can't get working directory!\n",
                Argv[0]);
            exit(1);
@@ -230,14 +242,14 @@ char *qualify(n)
        /*
         * find and terminate end of path component
         */
-       if ((end = index(beg, '/')))
+       if ((end = strchr(beg, '/')))
            *end = '\0';
 
        if (beg == end)
            continue;
        else if (!strcmp(beg, "."));    /* ignore "." */
        else if (!strcmp(beg, "..")) {
-           if ((tmp = rindex(full, '/')))
+           if ((tmp = strrchr(full, '/')))
                *tmp = '\0';
        } else {
            strcat(full, "/");
@@ -280,8 +292,8 @@ char *qualify(n)
            }
            if (newname[0] == '/')      /* reset full if necesary */
                full[0] = '\0';
-           else if ((tmp = rindex(full, '/'))) /* remove component from full */
-               *tmp = '\0';
+           else if ((tmp = strrchr(full, '/')))
+               *tmp = '\0';            /* remove component from full */
 
            strcpy(name, newname);      /* reset name with new path */
            beg = NULL;         /* since we have a new name */
@@ -298,7 +310,7 @@ char *qualify(n)
 }
 
 
-#ifdef NEED_STRDUP
+#ifndef HAVE_STRDUP
 /******************************************************************
  *
  *  strdup()
@@ -318,4 +330,4 @@ char *strdup(s1)
     (void) strcpy(s, s1);
     return (s);
 }
-#endif
+#endif /* !HAVE_STRDUP */
index 03f3aa66b440a2dec7cb0f6aa471794d3eb78fe0..ea9524256685d569ee72c4be8c03f7f40fbb8398 100644 (file)
--- a/getpass.c
+++ b/getpass.c
 static char sccsid[] = "@(#)getpass.c  based on 5.3 (Berkeley) 9/22/88";
 #endif                         /* LIBC_SCCS and not lint */
 
-/*
- * HP-UX and Irix defines
-*/
-#if defined(sgi) || defined(hpux)
-#ifndef USE_TERMIO
-#define USE_TERMIO
-#endif /* USE_TERMIO */
-#endif /* sgi || hpux */
+#include "config.h"
 
 #include <fcntl.h>
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
 #include <termio.h>
 #else
 #include <sgtty.h>
@@ -50,7 +43,7 @@ char *
     getpass(prompt)
     char *prompt;
 {
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
     struct termio ttyb;
 #else
     struct sgttyb ttyb;
@@ -60,7 +53,7 @@ char *
     FILE *fp, *outfp;
     long omask;
     int fd_tmp;
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
     tcflag_t svflagval;
 #else
     int svflagval;
@@ -77,7 +70,7 @@ char *
        outfp = stderr;
        fp = stdin;
     }
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
     (void) ioctl(fileno(fp), TCGETA, &ttyb);
     svflagval = ttyb.c_lflag;
     ttyb.c_lflag &= ~ECHO;
@@ -99,7 +92,7 @@ char *
     *p = '\0';
     (void) write(fileno(outfp), "\n", 1);
 
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
     ttyb.c_lflag = svflagval;
     (void) ioctl(fileno(fp), TCSETA, &ttyb);
 #else
index dcd4d3f745fee6bcf350d27ce3746a9d59e4c249..7fef6370bcf001df6bb968fbe792918027cb758f 100644 (file)
--- a/logging.c
+++ b/logging.c
 static char rcsid[] = "$Id$";
 #endif /* lint */
 
+#include "config.h"
+
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -53,7 +63,7 @@ static char rcsid[] = "$Id$";
 void log_error();
 void readchild();
 static void send_mail();
-static void reapchild();
+static RETSIGTYPE reapchild();
 static int appropriate();
 
 static char logline[MAXLOGLEN + 8];
@@ -99,11 +109,11 @@ void log_error(code)
     /*
      * so we know where we are...
      */
-#ifdef USE_CWD
+#ifdef HAVE_GETCWD
     getcwd(cwd, (size_t) (MAXPATHLEN + 1));
 #else
     getwd(cwd);
-#endif
+#endif /* HAVE_GETCWD */
 
     switch (code) {
 
@@ -129,7 +139,8 @@ void log_error(code)
            break;
 
        case VALIDATE_ERROR:
-           (void) sprintf(p, "error in %s ; PWD=%s ; command: ", SUDOERS, cwd);
+           (void) sprintf(p, "error in %s ; PWD=%s ; command: ",
+               _PATH_SUDO_SUDOERS, cwd);
 #ifdef SYSLOG
            pri = Syslog_priority_NO;
 #endif
@@ -161,7 +172,8 @@ void log_error(code)
        case NO_SUDOERS_FILE:
            switch (errno) {
                case ENOENT:
-                   (void) sprintf(p, "There is no %s file.  ", SUDOERS);
+                   (void) sprintf(p, "There is no %s file.  ",
+                       _PATH_SUDO_SUDOERS);
                    break;
                case EACCES:
                    (void) sprintf(p, "%s needs to run setuid root.  ",
@@ -169,7 +181,7 @@ void log_error(code)
                    break;
                default:
                    (void) sprintf(p, "There is a problem opening %s ",
-                       SUDOERS);
+                       _PATH_SUDO_SUDOERS);
                    break;
            }
 #ifdef SYSLOG
@@ -268,10 +280,10 @@ void log_error(code)
     be_root();
 
     oldmask = umask(077);
-    fp = fopen(LOGFILE, "a");
+    fp = fopen(_PATH_SUDO_LOGFILE, "a");
     (void) umask(oldmask);
     if (fp == NULL) {
-       (void) sprintf(logline, "Can\'t open log file: %s", LOGFILE);
+       (void) sprintf(logline, "Can\'t open log file: %s", _PATH_SUDO_LOGFILE);
        send_mail();
     } else {
        char *beg, *oldend, *end;
@@ -283,7 +295,7 @@ void log_error(code)
        beg = end = logline;
        while (beg) {
            oldend = end;
-           end = index(oldend, ' ');
+           end = strchr(oldend, ' ');
 
            if (end) {
                *end = '\0';
@@ -427,7 +439,7 @@ static void send_mail()
  *  This function gets rid fo all the ugly zombies
  */
 
-static void reapchild()
+static RETSIGTYPE reapchild()
 {
         (void) wait(NULL);
 }
diff --git a/parse.c b/parse.c
index ab7c99a06fc771b358ec93f12959bad7320c4cf2..f20a91d19efef852ffc15a321c56592ee0f5681b 100644 (file)
--- a/parse.c
+++ b/parse.c
 static char rcsid[] = "$Id$";
 #endif /* lint */
 
+#include "config.h"
+
 #include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif /* HAVE_STRINGS_H */
+#ifdef HAVE_MALLOC_H 
+#include <malloc.h>
+#endif /* HAVE_MALLOC_H */ 
 #include <ctype.h>
 #include <sys/param.h>
 #include <sys/types.h>
@@ -430,8 +443,8 @@ int validate()
     /* become root */
     be_root();
 
-    if ((sudoers_fp = fopen(SUDOERS, "r")) == NULL) {
-       perror(SUDOERS);
+    if ((sudoers_fp = fopen(_PATH_SUDO_SUDOERS, "r")) == NULL) {
+       perror(_PATH_SUDO_SUDOERS);
        log_error(NO_SUDOERS_FILE);
        exit(1);
     }
diff --git a/sudo.c b/sudo.c
index 1f5b88d4ce095a9ed6305b27674a7e3c53fa00f8..b5be38513c0a596eee0275b7432f9c0a5012deea 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -56,15 +56,24 @@ static char rcsid[] = "$Id$";
 
 #define MAIN
 
+#include "config.h"
+
 #include <stdio.h>
-#ifdef STD_HEADERS
+#ifdef STDC_HEADERS
 #include <stdlib.h>
-#ifndef NeXT
+#endif /* STDC_HEADERS */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* !NeXT */
-#endif /* STD_HEADERS */
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
 #include <strings.h>
+#endif /* HAVE_STRINGS_H */
+#ifdef HAVE_MALLOC_H 
+#include <malloc.h>   
+#endif /* HAVE_MALLOC_H */ 
 #include <pwd.h>
 #include <netdb.h>
 #include <sys/param.h>
@@ -72,12 +81,13 @@ static char rcsid[] = "$Id$";
 #include <sys/id.h>
 #endif /* _AIX */
 #include "sudo.h"
-#ifndef STD_HEADERS
+
+#ifndef STDC_HEADERS
 extern char *malloc();
-#ifndef NEED_STRDUP
+#ifdef HAVE_STRDUP
 extern char *strdup();
-#endif
-#endif
+#endif /* HAVE_STRDUP */
+#endif /* STDC_HEADERS */
 
 
 int Argc;
@@ -248,7 +258,7 @@ static void load_globals()
      * We don't want to return the fully quallified name all the time...
      */
 #ifndef FQDN
-       if ((p = index(host, '.')))
+       if ((p = strchr(host, '.')))
            *p = '\0';
 #endif
     }