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>
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... */
/*
* 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 = '/';
*/
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();
}
}
static void check_passwd()
{
-#if !(defined (linux) && defined (SHADOW_PWD))
+#if !(defined (linux) && defined (HAVE_LIBSHADOW))
char *crypt();
#endif /* linux */
struct passwd *pw_ent;
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();
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 */
/*******************************************************************
/*
* do we need to search the path?
*/
- if (index(file, '/'))
+ if (strchr(file, '/'))
return (qualify(file));
/*
}
do {
- if ((n = index(path, ':')))
+ if ((n = strchr(path, ':')))
*n = '\0';
/*
* 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);
/*
* 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, "/");
}
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 */
}
-#ifdef NEED_STRDUP
+#ifndef HAVE_STRDUP
/******************************************************************
*
* strdup()
(void) strcpy(s, s1);
return (s);
}
-#endif
+#endif /* !HAVE_STRDUP */
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>
getpass(prompt)
char *prompt;
{
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
struct termio ttyb;
#else
struct sgttyb ttyb;
FILE *fp, *outfp;
long omask;
int fd_tmp;
-#ifdef USE_TERMIO
+#ifdef HAVE_TERMIO_H
tcflag_t svflagval;
#else
int svflagval;
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;
*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
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>
void log_error();
void readchild();
static void send_mail();
-static void reapchild();
+static RETSIGTYPE reapchild();
static int appropriate();
static char logline[MAXLOGLEN + 8];
/*
* 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) {
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
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. ",
break;
default:
(void) sprintf(p, "There is a problem opening %s ",
- SUDOERS);
+ _PATH_SUDO_SUDOERS);
break;
}
#ifdef SYSLOG
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;
beg = end = logline;
while (beg) {
oldend = end;
- end = index(oldend, ' ');
+ end = strchr(oldend, ' ');
if (end) {
*end = '\0';
* This function gets rid fo all the ugly zombies
*/
-static void reapchild()
+static RETSIGTYPE reapchild()
{
(void) wait(NULL);
}
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>
/* 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);
}
#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>
#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;
* 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
}