-CPPFLAGS = -DHAVE_CONFIG_H -I.
+CPPFLAGS = -I.
CCCMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
RCOBJS = builtins.o except.o builtins.o except.o exec.o fn.o footobar.o getopt.o glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o nalloc.o open.o parse.o print.o redir.o signal.o status.o tree.o utils.o var.o wait.o walk.o which.o sigmsgs.o edit-null.o system.o
$(CCCMD)
clean:
- $(RM) rc *.o
+ $(RM) rc *.o mksignal mkstatval sigmsgs.* statval.h
+++ /dev/null
-/*
- This file is NOT BUILT by default. Together with addon.h, it
- provides an example of how to add new builtins to rc.
-*/
-
-#include "rc.h"
-#include "addon.h"
-
-void b_sum(char **av) {
- long sum = 0;
-
- while (*++av)
- sum += atol(*av);
- fprint(1, "%ld\n", sum);
- set(TRUE);
-}
-
-void b_prod(char **av) {
- long sum = 1;
-
- while (*++av)
- sum *= atol(*av);
- fprint(1, "%ld\n", sum);
- set(TRUE);
-}
+++ /dev/null
-/*
- This file is NOT BUILT by default. Together with addon.c, it
- provides an example of how to add new builtins to rc.
-
- To define a new builtin, it must appear in the macro ADDONS, which
- is a comma-separated list of pairs of function pointers (the
- implementation of the new builtin) and string literals (the name of
- the new builtin).
-
- Any new builtin functions must also have proper prototypes in this
- file. This is always of the same form.
-
- void b_NAME(char **av);
-
- The first argument, av[0], is the name of the builtin. The last
- argument is followed by a NULL pointer.
-
- Builtins report their exit status using set(TRUE) or set(FALSE).
-
-*/
-
-#if RC_ADDON
-
-#define ADDONS \
- { b_sum, "+" }, \
- { b_prod, "x" },
-
-extern void b_sum(char **av);
-extern void b_prod(char **av);
-
-#endif
#include <setjmp.h>
#include <errno.h>
-#include "addon.h"
#include "input.h"
#include "jbwrap.h"
#include "rlimit.h"
static void b_break(char **), b_cd(char **), b_eval(char **), b_exit(char **),
b_newpgrp(char **), b_return(char **), b_shift(char **), b_umask(char **),
- b_wait(char **), b_whatis(char **);
-
-#if HAVE_SETRLIMIT
-static void b_limit(char **);
-#endif
-
-#if RC_ECHO
-static void b_echo(char **);
-#endif
+ b_wait(char **), b_whatis(char **), b_limit(char **), b_echo(char **);
static struct {
builtin_t *p;
char *name;
} builtins[] = {
- { b_break, "break" },
- { b_builtin, "builtin" },
- { b_cd, "cd" },
-#if RC_ECHO
- { b_echo, "echo" },
-#endif
- { b_eval, "eval" },
- { b_exec, "exec" },
- { b_exit, "exit" },
-#if HAVE_SETRLIMIT
- { b_limit, "limit" },
-#endif
- { b_newpgrp, "newpgrp" },
- { b_return, "return" },
- { b_shift, "shift" },
- { b_umask, "umask" },
- { b_wait, "wait" },
- { b_whatis, "whatis" },
- { b_dot, "." },
-#ifdef ADDONS
- ADDONS
-#endif
+ { b_break, "break" },
+ { b_builtin, "builtin" },
+ { b_cd, "cd" },
+ { b_echo, "echo" },
+ { b_eval, "eval" },
+ { b_exec, "exec" },
+ { b_exit, "exit" },
+ { b_limit, "limit" },
+ { b_newpgrp, "newpgrp" },
+ { b_return, "return" },
+ { b_shift, "shift" },
+ { b_umask, "umask" },
+ { b_wait, "wait" },
+ { b_whatis, "whatis" },
+ { b_dot, "." },
};
extern builtin_t *isbuiltin(char *s) {
extern void b_exec(char **ignore) {
}
-#if RC_ECHO
/* echo -n omits a newline. echo -- -n echos '-n' */
static void b_echo(char **av) {
fprint(1, format, av);
set(TRUE);
}
-#endif
/* cd. traverse $cdpath if the directory given is not an absolute pathname */
/* Berkeley limit support was cleaned up by Paul Haahr. */
-#if HAVE_SETRLIMIT
static const struct Suffix
kbsuf = { NULL, 1024, "k" },
mbsuf = { &kbsuf, 1024*1024, "m" },
set(TRUE);
}
}
-#endif
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
/* The default interpreter */
#define DEFAULTINTERP "/bin/sh"
/* The default path */
#define DEFAULTPATH "/usr/local/bin","/usr/bin","/bin","."
-/* Define to the type of elements in the array set by `getgroups'. Usually
- this is either `int' or `gid_t'. */
-#define GETGROUPS_T gid_t
-
-/* Define to 1 if your kernel understands `#!' magic numbers */
-#define HASH_BANG 1
-
-/* Define to 1 if you have /dev/fd. */
-#define HAVE_DEV_FD 1
-
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
- */
-#define HAVE_DIRENT_H 1
-
-/* Define to 1 if you have the `mkfifo' function. */
-/* #undef HAVE_FIFO */
-
-/* Define to 1 if you have the `getgroups' function. */
-#define HAVE_GETGROUPS 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `lstat' function. */
-#define HAVE_LSTAT 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mkfifo' function. */
-/* #undef HAVE_MKFIFO */
-
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
-/* #undef HAVE_NDIR_H */
-
-/* Define to 1 if you have the `getgroups' function with POSIX semantics. */
-#define HAVE_POSIX_GETGROUPS 1
-
-/* Define to 1 if you have /proc/self/fd. */
-/* #undef HAVE_PROC_SELF_FD */
-
-/* Define to 1 if you have the `quad_t' type. */
-/* #undef HAVE_QUAD_T */
-
-/* Define to 1 if system calls automatically restart after interruption by a
- signal. */
-/* #undef HAVE_RESTARTABLE_SYSCALLS */
-
-/* Define to 1 if you have the `rlim_t' type. */
-#define HAVE_RLIM_T 1
-
-/* Define to 1 if you have the `setpgrp' function. */
-#define HAVE_SETPGRP 1
-
-/* Define to 1 if you have the `setrlimit' function. */
-#define HAVE_SETRLIMIT 1
-
-/* Define to 1 if you have the `sigaction' function. */
-#define HAVE_SIGACTION 1
-
-/* Define to 1 if you have the `sigsetjmp' function or macro. */
-#define HAVE_SIGSETJMP 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strerror' function or macro. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Has SysV SIGCLD */
-#define HAVE_SYSV_SIGCLD 1
-
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
- */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
- */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
/* Name of package */
#define PACKAGE "rc"
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "rc"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "rc 1.7.4"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "rc"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.7.4"
-
/* Define to 1 to encode exported environment names. */
#define PROTECT_ENV 1
-/* Define to 1 to use addon functions. */
-/* #undef RC_ADDON */
-
-/* Define to 1 to include `echo' as a builtin. */
-#define RC_ECHO 1
-
/* Define to 1 to use job-control-style backgrounding. */
#define RC_JOB 1
/* Release date */
#define RELDATE "2017-03-13"
-/* Define to 1 if `_KERNEL' must be defined for `RLIMIT_*' macros. */
-/* #undef RLIMIT_NEEDS_KERNEL */
-
-/* Define to 1 if `rlim_t' is `quad_t'. */
-/* #undef RLIM_T_IS_QUAD_T */
-
-/* Define to 1 if the `setpgrp' function takes no argument. */
-#define SETPGRP_VOID 1
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
/* Version number of package */
#define VERSION "1.7.4"
-/* Enable large inode numbers on Mac OS X 10.5. */
-#ifndef _DARWIN_USE_64_BIT_INODE
-# define _DARWIN_USE_64_BIT_INODE 1
-#endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define to `int' if <sys/types.h> does not define. */
-/* #undef pid_t */
-
-/* Define to 1 if you have the `sig_atomic_t' type. */
-/* #undef sig_atomic_t */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
-
-/* Define to `long' if <sys/types.h> does not define. */
-/* #undef ssize_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
return;
rc_exit(getstatus());
}
- rc_execve(path, (char * const *) av, (char * const *) ev);
+ execve(path, (char * const *) av, (char * const *) ev);
#ifdef DEFAULTINTERP
if (errno == ENOEXEC) {
+++ /dev/null
-/* execve.c: an execve() for geriatric unices without #! */
-
-/*
- NOTE: this file depends on a hack in footobar.c which places two free
- spots before av[][] so that execve does not have to call malloc.
-*/
-
-#include "rc.h"
-
-#include <errno.h>
-
-#define giveupif(x) { if (x) goto fail; }
-
-extern int rc_execve(char *path, char **av, char **ev) {
- int fd, len, fst, snd, end;
- bool noarg;
- char pb[256]; /* arbitrary but generous limit */
- execve(path, av, ev);
- if (errno != ENOEXEC)
- return -1;
- fd = rc_open(path, rFrom);
- giveupif(fd < 0);
- len = read(fd, pb, sizeof pb);
- close(fd);
- /* reject scripts which don't begin with #! */
- giveupif(len <= 0 || pb[0] != '#' || pb[1] != '!');
- for (fst = 2; fst < len && (pb[fst] == ' ' || pb[fst] == '\t'); fst++)
- ; /* skip leading whitespace */
- giveupif(fst == len);
- for (snd = fst; snd < len && pb[snd] != ' ' && pb[snd] != '\t' && pb[snd] != '\n'; snd++)
- ; /* skip first arg */
- giveupif(snd == len);
- noarg = (pb[snd] == '\n');
- pb[snd++] = '\0'; /* null terminate the first arg */
- if (!noarg) {
- while (snd < len && (pb[snd] == ' ' || pb[snd] == '\t'))
- snd++; /* skip whitespace to second arg */
- giveupif(snd == len);
- noarg = (pb[snd] == '\n'); /* could have trailing whitespace after only one arg */
- if (!noarg) {
- for (end = snd; end < len && pb[end] != ' ' && pb[end] != '\t' && pb[end] != '\n'; end++)
- ; /* skip to the end of the second arg */
- giveupif(end == len);
- if (pb[end] == '\n') {
- pb[end] = '\0'; /* null terminate the first arg */
- } else { /* else check for a spurious third arg */
- pb[end++] = '\0';
- while (end < len && (pb[end] == ' ' || pb[end] == '\t'))
- end++;
- giveupif(end == len || pb[end] != '\n');
- }
- }
- }
- *av = path;
- if (!noarg)
- *--av = pb + snd;
- *--av = pb + fst;
- execve(*av, av, ev);
- return -1;
-fail: errno = ENOEXEC;
- return -1;
-}
null.type = nBody;
null.u[0].p = null.u[1].p = NULL;
for (i = 1; i < NUMOFSIGNALS; i++)
-#if HAVE_SYSV_SIGCLD
- if (i != SIGCLD)
-#endif
if (sighandlers[i] == SIG_IGN)
fnassign(signals[i].name, NULL); /* ignore incoming ignored signals */
if (interactive || sighandlers[SIGINT] != SIG_IGN) {
new->def = newdef;
new->extdef = NULL;
if (strncmp(name, "sig", conststrlen("sig")) == 0) { /* slight optimization */
-#if HAVE_SYSV_SIGCLD /* System V machines treat SIGCLD very specially */
- if (streq(name, "sigcld"))
- rc_error("can't trap SIGCLD");
-#endif
if (streq(name, "sigexit"))
runexit = TRUE;
for (i = 1; i < NUMOFSIGNALS; i++) /* zero is a bogus signal */
+++ /dev/null
-#if HAVE_GETGROUPS
-#if HAVE_POSIX_GETGROUPS
-/* We love POSIX. */
-#else
-/* OK, so you've got getgroups, but you don't have the POSIX semantics
-of a zero first argument. The conclusion is that you're on a reasonably
-pure BSD system, and we can include <sys/param.h> for NGROUPS. */
-#include <sys/param.h>
-#endif
-#endif
/* glob.c: rc's (ugly) globber. This code is not elegant, but it works */
#include "rc.h"
-#include "stat.h"
+#include <sys/stat.h>
/* Lifted from autoconf documentation.*/
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
-# endif
-#endif
+#include <dirent.h>
+#define NAMLEN(dirent) strlen((dirent)->d_name)
static List *dmatch(char *, char *, char *);
static List *doglob(char *, char *);
next->n = NULL;
}
-#if HAVE_DEV_FD || HAVE_PROC_SELF_FD
-static List *mkcmdarg(Node *n) {
- char *name;
- List *ret = nnew(List);
- Estack *e = nnew(Estack);
- Edata efd;
- int p[2];
- if (pipe(p) < 0) {
- uerror("pipe");
- return NULL;
- }
- if (rc_fork() == 0) {
- setsigdefaults(FALSE);
- if (mvfd(p[n->u[0].i == rFrom], n->u[0].i == rFrom) < 0) /* stupid hack */
- exit(1);
- close(p[n->u[0].i != rFrom]);
- redirq = NULL;
- walk(n->u[2].p, FALSE);
- exit(getstatus());
- }
-
-#if HAVE_DEV_FD
- name = nprint("/dev/fd/%d", p[n->u[0].i != rFrom]);
-#else
- name = nprint("/proc/self/fd/%d", p[n->u[0].i != rFrom]);
-#endif
-
- efd.fd = p[n->u[0].i != rFrom];
- except(eFd, efd, e);
- close(p[n->u[0].i == rFrom]);
- ret->w = name;
- ret->m = NULL;
- ret->n = NULL;
- return ret;
-}
-
-#elif HAVE_FIFO
-
-#if HAVE_MKFIFO
-/* Have POSIX mkfifo(). */
-#else
-#define mkfifo(n,m) mknod(n, S_IFIFO | m, 0)
-#endif
-
static List *mkcmdarg(Node *n) {
int fd;
char *name;
return ret;
}
-#else
-
-static List *mkcmdarg(Node *n) {
- rc_error("command arguments are not supported");
- return NULL;
-}
-
-#endif
-
extern List *glom(Node *n) {
List *v, *head, *tail;
Node *words;
jmp_bufs don't preserve signal masks. I'm not worrying about this till
someone reports it as a bug :-). */
-#if HAVE_SIGSETJMP
-#else
-#define sigjmp_buf jmp_buf
-#define sigsetjmp(x,y) setjmp(x)
-#define siglongjmp longjmp
-#endif /* HAVE_SIGSETJMP */
-
-
/* Certain braindamaged environments don't define jmp_buf as an array,
so wrap it in a structure. Potentially, we could use configure to do
this only where it needs to be done, but the effort is probably not
return TRUE; \
}
-Flag(uconv, FMT_unsigned)
+Flag(uconv, FMT_unsigned)
Flag(rc_lconv, FMT_long)
-
-#if HAVE_QUAD_T
-Flag(qconv, FMT_quad)
-#endif
-
+Flag(qconv, FMT_quad)
Flag(altconv, FMT_altform)
Flag(leftconv, FMT_leftside)
Flag(dotconv, FMT_f2set)
flags = format->flags;
-#if HAVE_QUAD_T
- if (flags & FMT_quad)
- n = va_arg(format->args, quad_t);
- else
-#endif
-
if (flags & FMT_long)
n = va_arg(format->args, long);
else
fmttab['-'] = leftconv;
fmttab['.'] = dotconv;
-#if HAVE_QUAD_T
- fmttab['q'] = qconv;
-#endif
-
fmttab['0'] = zeroconv;
for (i = '1'; i <= '9'; i++)
fmttab[i] = digitconv;
file, or---for older systems---declaring the functions directly.
*/
-#if HAVE_SYS_TYPES_H
#include <sys/types.h>
-#endif
#include <signal.h>
-#if HAVE_QUAD_T
-typedef quad_t align_t;
-#else
typedef long align_t;
-#endif
/*
We need <stdarg.h>. If you really need to build rc on a system which
#define va_copy(x,y) (x)=(y)
#endif
-#if STDC_HEADERS
-
#include <stdlib.h>
#include <string.h>
-
-#else /* STDC_HEADERS */
-
-/* fake string.h */
-extern int strncmp(const char *, const char *, size_t);
-extern int strcmp(const char *, const char *);
-extern size_t strlen(const char *);
-extern char *strchr(const char *, int);
-extern char *strrchr(const char *, int);
-extern char *strcpy(char *, const char *);
-extern char *strncpy(char *, const char *, size_t);
-extern char *strcat(char *, const char *);
-extern char *strncat(char *, const char *, size_t);
-extern void *memcpy(void *, const void *, size_t);
-extern void *memset(void *, int, size_t);
-
-/* fake stdlib.h */
-extern void exit(int);
-extern void free(void *);
-extern void *malloc(size_t);
-extern void *realloc(void *, size_t);
-extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
-
-#endif /* STDC_HEADERS */
-
-#if HAVE_STRERROR
-/* Smells like POSIX. */
-#else
-/* Assume BSD-style sys_errlist[]. */
-extern int sys_nerr;
-extern char *sys_errlist[];
-#define strerror(x) ((0 <= (x)) && (errno < (x)) ? sys_errlist[x] : (char *)0)
-#endif
-
-#if HAVE_UNISTD_H
#include <unistd.h>
-#endif
-
-#if HAVE_SETPGRP
-
-#if SETPGRP_VOID
-/* Smells like POSIX: should all be ok. */
-#else
-/* Old BSD: fake it. */
-#define setpgid(pid, pgrp) setpgrp(pid, pgrp)
-#include <sys/ioctl.h>
-#define tcgetpgrp(fd) ioctl((fd), TIOCGPGRP)
-#define tcsetpgrp(fd, pgrp) ioctl((fd), TIOCSPGRP, &(pgrp))
-#endif
-
-#else /* HAVE_SETPGRP */
-/* Nothing doing. */
-#define setpgid()
-#define tcgetpgrp()
-#define tcsetpgrp()
-
-#endif /*HAVE_SETPGRP */
-
-
-/* fake errno.h for mips (which doesn't declare errno in errno.h!?!?) */
-#ifdef host_mips
-extern int errno;
-#endif
/* exec.c */
extern void exec(List *, bool);
-#if HASH_BANG
-#define rc_execve execve
-#else
-/* execve.c */
-extern int my_execve(char *, char **, char **);
-#endif
-
/* footobar.c */
extern char **list2array(List *, bool);
extern char *get_name(char *);
/* What a mess. This file attempts to straighten everything out. */
-#if HAVE_SETRLIMIT
-
-#if HAVE_SYS_RESOURCE_H
#include <sys/time.h>
-#if RLIMIT_NEEDS_KERNEL
-#define _KERNEL
-#endif
#include <sys/resource.h>
-#if RLIMIT_NEEDS_KERNEL
-#undef _KERNEL
-#endif
-#else
-#include <sys/times.h>
-#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
-#ifndef HAVE_RLIM_T
-#if RLIM_T_IS_QUAD_T
-typedef quad_t rlim_t;
-#else
-typedef long rlim_t;
-#endif
-#endif
-
-#if HAVE_QUAD_T
-#define RLIM_CONV quad_t
-#define RLIM_FMT "%s \t%qd%s\n"
-#else
#define RLIM_CONV long
#define RLIM_FMT "%s \t%ld%s\n"
-#endif
#if defined(RLIMIT_OFILE) && !defined (RLIMIT_NOFILE)
#define RLIMIT_NOFILE RLIMIT_OFILE
int flag;
const struct Suffix *suffix;
};
-#endif /* HAVE_SETRLIMIT */
#include "sigmsgs.h"
#include "jbwrap.h"
-#if HAVE_SIGACTION
void (*sys_signal(int signum, void (*handler)(int)))(int) {
struct sigaction new, old;
sigaction(signum, &new, &old);
return old.sa_handler;
}
-#else
-void (*sys_signal(int signum, void (*handler)(int)))(int) {
- return signal(signum, handler);
-}
-#endif
void (*sighandlers[NUMOFSIGNALS])(int);
caught[s] = 1;
}
sys_signal(s, catcher);
-
-#if HAVE_RESTARTABLE_SYSCALLS
- if (slow) {
- siglongjmp(slowbuf.j, s);
- }
-#endif
}
extern void sigchk() {
void (*h)(int);
int i;
-#if HAVE_SYSV_SIGCLD
- /* Ensure that SIGCLD is not SIG_IGN. Solaris's rshd does this. :-( */
- h = sys_signal(SIGCLD, SIG_IGN);
- if (h != SIG_IGN && h != SIG_ERR)
- sys_signal(SIGCLD, h);
- else
- sys_signal(SIGCLD, SIG_DFL);
-#endif
-
for (i = 1; i < NUMOFSIGNALS; i++) {
#ifdef SIGKILL
if (i == SIGKILL) continue;
+++ /dev/null
-#include <sys/stat.h>
-
-#if HAVE_LSTAT
-#else
-#define lstat(name, buf) (stat((name), (buf)))
-#endif
-#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
-#endif
/* Fake the POSIX wait() macros if we don't have them. */
#ifndef WIFEXITED
#include <errno.h>
#include <sys/stat.h>
-#include "getgroups.h"
-
#define X_USR 0100
#define X_GRP 0010
#define X_OTH 0001
static uid_t uid;
static gid_t gid;
-#if HAVE_GETGROUPS
static int ngroups;
-static GETGROUPS_T *gidset;
+static gid_t* gidset;
/* determine whether gid lies in gidset */
return 1;
return 0;
}
-#else
-#define ingidset(g) (FALSE)
-#endif
/*
A home-grown access/stat. Does the right thing for group-executable files.
initialized = TRUE;
uid = geteuid();
gid = getegid();
-#if HAVE_GETGROUPS
-#if HAVE_POSIX_GETGROUPS
- ngroups = getgroups(0, (GETGROUPS_T *)0);
+ ngroups = getgroups(0, (gid_t *)0);
if (ngroups < 0) {
uerror("getgroups");
rc_exit(1);
}
-#else
- ngroups = NGROUPS;
-#endif
if (ngroups) {
- gidset = ealloc(ngroups * sizeof(GETGROUPS_T));
+ gidset = ealloc(ngroups * sizeof(gid_t));
getgroups(ngroups, gidset);
}
-#endif
}
if (isabsolute(name)) /* absolute pathname? */
return rc_access(name, verbose) ? name : NULL;