home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-25 | 46.0 KB | 2,272 lines |
- head 5.10;
- branch 5.10.1;
- access;
- symbols
- HWGRCSP12F:5.10.1.7
- HWGRCSP11F:5.10.1.7
- HWGRCSP10F:5.10.1.7
- HWGRCSP9:5.10.1.7
- HWGRCSP8F:5.10.1.6
- HWGRCSP7F:5.10.1.4
- C_15:5.10.1.4
- HWGRCSP6F:5.10.1.3
- HWGRCSP5F:5.10.1.1
- HWGRCSp4:5.10.1.1
- HWGRCSp3:5.10.1
- HWGRCS_Fish:5.10.1
- HWGRCS:5.10.1;
- locks; strict;
- comment @ * @;
-
-
- 5.10
- date 91.10.07.17.32.46; author eggert; state Exp;
- branches
- 5.10.1.1;
- next ;
-
- 5.10.1.1
- date 93.01.18.14.36.30; author heinz; state Exp;
- branches;
- next 5.10.1.2;
-
- 5.10.1.2
- date 93.12.18.16.12.22; author heinz; state Exp;
- branches;
- next 5.10.1.3;
-
- 5.10.1.3
- date 93.12.18.17.17.59; author heinz; state Exp;
- branches;
- next 5.10.1.4;
-
- 5.10.1.4
- date 94.01.06.11.33.27; author heinz; state Exp;
- branches;
- next 5.10.1.5;
-
- 5.10.1.5
- date 94.02.11.19.53.26; author heinz; state Exp;
- branches;
- next 5.10.1.6;
-
- 5.10.1.6
- date 94.03.14.09.22.53; author heinz; state Exp;
- branches;
- next 5.10.1.7;
-
- 5.10.1.7
- date 94.04.23.19.51.04; author heinz; state Exp;
- branches;
- next ;
-
-
- desc
- @Checked in with -k 16.jan.93 HWG
- @
-
-
- 5.10
- log
- @checked in with -k by heinz at 1993/01/17 01:53:17
- @
- text
- @/*
- * RCS utilities
- */
-
- /* Copyright (C) 1982, 1988, 1989 Walter Tichy
- Copyright 1990, 1991 by Paul Eggert
- Distributed under license by the Free Software Foundation, Inc.
-
- This file is part of RCS.
-
- RCS 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 2, or (at your option)
- any later version.
-
- RCS 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 RCS; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Report problems and direct all questions to:
-
- rcs-bugs@@cs.purdue.edu
-
- */
-
-
-
-
- /* $Log: rcsutil.c,v $
- * Revision 5.10 1991/10/07 17:32:46 eggert
- * Support piece tables even if !has_mmap.
- *
- * Revision 5.9 1991/08/19 03:13:55 eggert
- * Add spawn() support. Explicate assumptions about getting invoker's name.
- * Standardize user-visible dates. Tune.
- *
- * Revision 5.8 1991/04/21 11:58:30 eggert
- * Plug setuid security hole.
- *
- * Revision 5.6 1991/02/26 17:48:39 eggert
- * Fix setuid bug. Use fread, fwrite more portably.
- * Support waitpid. Don't assume -1 is acceptable to W* macros.
- * strsave -> str_save (DG/UX name clash)
- *
- * Revision 5.5 1990/12/04 05:18:49 eggert
- * Don't output a blank line after a signal diagnostic.
- * Use -I for prompts and -q for diagnostics.
- *
- * Revision 5.4 1990/11/01 05:03:53 eggert
- * Remove unneeded setid check. Add awrite(), fremember().
- *
- * Revision 5.3 1990/10/06 00:16:45 eggert
- * Don't fread F if feof(F).
- *
- * Revision 5.2 1990/09/04 08:02:31 eggert
- * Store fread()'s result in an fread_type object.
- *
- * Revision 5.1 1990/08/29 07:14:07 eggert
- * Declare getpwuid() more carefully.
- *
- * Revision 5.0 1990/08/22 08:13:46 eggert
- * Add setuid support. Permit multiple locks per user.
- * Remove compile-time limits; use malloc instead.
- * Switch to GMT. Permit dates past 1999/12/31.
- * Add -V. Remove snooping. Ansify and Posixate.
- * Tune. Some USG hosts define NSIG but not sys_siglist.
- * Don't run /bin/sh if it's hopeless.
- * Don't leave garbage behind if the output is an empty pipe.
- * Clean up after SIGXCPU or SIGXFSZ. Print name of signal that caused cleanup.
- *
- * Revision 4.6 89/05/01 15:13:40 narten
- * changed copyright header to reflect current distribution rules
- *
- * Revision 4.5 88/11/08 16:01:02 narten
- * corrected use of varargs routines
- *
- * Revision 4.4 88/08/09 19:13:24 eggert
- * Check for memory exhaustion.
- * Permit signal handlers to yield either 'void' or 'int'; fix oldSIGINT botch.
- * Use execv(), not system(); yield exit status like diff(1)'s.
- *
- * Revision 4.3 87/10/18 10:40:22 narten
- * Updating version numbers. Changes relative to 1.1 actually
- * relative to 4.1
- *
- * Revision 1.3 87/09/24 14:01:01 narten
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- * warnings)
- *
- * Revision 1.2 87/03/27 14:22:43 jenkins
- * Port to suns
- *
- * Revision 4.1 83/05/10 15:53:13 wft
- * Added getcaller() and findlock().
- * Changed catchints() to check SIGINT for SIG_IGN before setting up the signal
- * (needed for background jobs in older shells). Added restoreints().
- * Removed printing of full RCS path from logcommand().
- *
- * Revision 3.8 83/02/15 15:41:49 wft
- * Added routine fastcopy() to copy remainder of a file in blocks.
- *
- * Revision 3.7 82/12/24 15:25:19 wft
- * added catchints(), ignoreints() for catching and ingnoring interrupts;
- * fixed catchsig().
- *
- * Revision 3.6 82/12/08 21:52:05 wft
- * Using DATEFORM to format dates.
- *
- * Revision 3.5 82/12/04 18:20:49 wft
- * Replaced SNOOPDIR with SNOOPFILE; changed addlock() to update
- * lockedby-field.
- *
- * Revision 3.4 82/12/03 17:17:43 wft
- * Added check to addlock() ensuring only one lock per person.
- * Addlock also returns a pointer to the lock created. Deleted fancydate().
- *
- * Revision 3.3 82/11/27 12:24:37 wft
- * moved rmsema(), trysema(), trydiraccess(), getfullRCSname() to rcsfnms.c.
- * Introduced macro SNOOP so that snoop can be placed in directory other than
- * TARGETDIR. Changed %02d to %.2d for compatibility reasons.
- *
- * Revision 3.2 82/10/18 21:15:11 wft
- * added function getfullRCSname().
- *
- * Revision 3.1 82/10/13 16:17:37 wft
- * Cleanup message is now suppressed in quiet mode.
- */
-
-
-
-
- #include "rcsbase.h"
-
- libId(utilId, "$Id: rcsutil.c,v 5.10 1991/10/07 17:32:46 eggert Exp $")
-
- #if !has_memcmp
- int
- memcmp(s1, s2, n)
- void const *s1, *s2;
- size_t n;
- {
- register unsigned char const
- *p1 = (unsigned char const*)s1,
- *p2 = (unsigned char const*)s2;
- register size_t i = n;
- register int r = 0;
- while (i-- && !(r = (*p1++ - *p2++)))
- ;
- return r;
- }
- #endif
-
- #if !has_memcpy
- void *
- memcpy(s1, s2, n)
- void *s1;
- void const *s2;
- size_t n;
- {
- register char *p1 = (char*)s1;
- register char const *p2 = (char const*)s2;
- while (n--)
- *p1++ = *p2++;
- return s1;
- }
- #endif
-
- #if lint
- malloc_type lintalloc;
- #endif
-
- /*
- * list of blocks allocated with ftestalloc()
- * These blocks can be freed by ffree when we're done with the current file.
- * We could put the free block inside struct alloclist, rather than a pointer
- * to the free block, but that would be less portable.
- */
- struct alloclist {
- malloc_type alloc;
- struct alloclist *nextalloc;
- };
- static struct alloclist *alloced;
-
-
- static malloc_type
- okalloc(p)
- malloc_type p;
- {
- if (!p)
- faterror("out of memory");
- return p;
- }
-
- malloc_type
- testalloc(size)
- size_t size;
- /* Allocate a block, testing that the allocation succeeded. */
- {
- return okalloc(malloc(size));
- }
-
- malloc_type
- testrealloc(ptr, size)
- malloc_type ptr;
- size_t size;
- /* Reallocate a block, testing that the allocation succeeded. */
- {
- return okalloc(realloc(ptr, size));
- }
-
- malloc_type
- fremember(ptr)
- malloc_type ptr;
- /* Remember PTR in 'alloced' so that it can be freed later. Yield PTR. */
- {
- register struct alloclist *q = talloc(struct alloclist);
- q->nextalloc = alloced;
- alloced = q;
- return q->alloc = ptr;
- }
-
- malloc_type
- ftestalloc(size)
- size_t size;
- /* Allocate a block, putting it in 'alloced' so it can be freed later. */
- {
- return fremember(testalloc(size));
- }
-
- void
- ffree()
- /* Free all blocks allocated with ftestalloc(). */
- {
- register struct alloclist *p, *q;
- for (p = alloced; p; p = q) {
- q = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
- }
- alloced = nil;
- }
-
- void
- ffree1(f)
- register char const *f;
- /* Free the block f, which was allocated by ftestalloc. */
- {
- register struct alloclist *p, **a = &alloced;
-
- while ((p = *a)->alloc != f)
- a = &p->nextalloc;
- *a = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
- }
-
- char *
- str_save(s)
- char const *s;
- /* Save s in permanently allocated storage. */
- {
- return strcpy(tnalloc(char, strlen(s)+1), s);
- }
-
- char *
- fstr_save(s)
- char const *s;
- /* Save s in storage that will be deallocated when we're done with this file. */
- {
- return strcpy(ftnalloc(char, strlen(s)+1), s);
- }
-
- char *
- cgetenv(name)
- char const *name;
- /* Like getenv(), but yield a copy; getenv() can overwrite old results. */
- {
- register char *p;
-
- return (p=getenv(name)) ? str_save(p) : p;
- }
-
- char const *
- getusername(suspicious)
- int suspicious;
- /* Get the caller's login name. Trust only getwpuid if SUSPICIOUS. */
- {
- static char *name;
-
- if (!name) {
- if (
- /* Prefer getenv() unless suspicious; it's much faster. */
- # if getlogin_is_secure
- (suspicious
- ||
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER")))
- && !(name = getlogin())
- # else
- suspicious
- ||
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER"))
- && !(name = getlogin())
- # endif
- ) {
- #if has_getuid && has_getpwuid
- struct passwd const *pw = getpwuid(ruid());
- if (!pw)
- faterror("no password entry for userid %lu",
- (unsigned long)ruid()
- );
- name = pw->pw_name;
- #else
- #if has_setuid
- faterror("setuid not supported");
- #else
- faterror("Who are you? Please set LOGNAME.");
- #endif
- #endif
- }
- checksid(name);
- }
- return name;
- }
-
-
-
-
- #if has_signal
-
- /*
- * Signal handling
- *
- * Standard C places too many restrictions on signal handlers.
- * We obey as many of them as we can.
- * Posix places fewer restrictions, and we are Posix-compatible here.
- */
-
- static sig_atomic_t volatile heldsignal, holdlevel;
-
- static signal_type
- catchsig(s)
- int s;
- {
- char const *sname;
- char buf[BUFSIZ];
-
- #if sig_zaps_handler
- /* If a signal arrives before we reset the signal handler, we lose. */
- VOID signal(s, SIG_IGN);
- #endif
- if (holdlevel) {
- heldsignal = s;
- return;
- }
- ignoreints();
- setrid();
- if (!quietflag) {
- sname = nil;
- #if has_sys_siglist && defined(NSIG)
- if ((unsigned)s < NSIG) {
- # ifndef sys_siglist
- extern char const *sys_siglist[];
- # endif
- sname = sys_siglist[s];
- }
- #else
- switch (s) {
- #ifdef SIGHUP
- case SIGHUP: sname = "Hangup"; break;
- #endif
- #ifdef SIGINT
- case SIGINT: sname = "Interrupt"; break;
- #endif
- #ifdef SIGPIPE
- case SIGPIPE: sname = "Broken pipe"; break;
- #endif
- #ifdef SIGQUIT
- case SIGQUIT: sname = "Quit"; break;
- #endif
- #ifdef SIGTERM
- case SIGTERM: sname = "Terminated"; break;
- #endif
- #ifdef SIGXCPU
- case SIGXCPU: sname = "Cputime limit exceeded"; break;
- #endif
- #ifdef SIGXFSZ
- case SIGXFSZ: sname = "Filesize limit exceeded"; break;
- #endif
- }
- #endif
- if (sname)
- VOID sprintf(buf, "\nRCS: %s. Cleaning up.\n", sname);
- else
- VOID sprintf(buf, "\nRCS: Signal %d. Cleaning up.\n", s);
- VOID write(STDERR_FILENO, buf, strlen(buf));
- }
- exiterr();
- }
-
- void
- ignoreints()
- {
- ++holdlevel;
- }
-
- void
- restoreints()
- {
- if (!--holdlevel && heldsignal)
- VOID catchsig(heldsignal);
- }
-
-
- static int const sig[] = {
- #ifdef SIGHUP
- SIGHUP,
- #endif
- #ifdef SIGINT
- SIGINT,
- #endif
- #ifdef SIGPIPE
- SIGPIPE,
- #endif
- #ifdef SIGQUIT
- SIGQUIT,
- #endif
- #ifdef SIGTERM
- SIGTERM,
- #endif
- #ifdef SIGXCPU
- SIGXCPU,
- #endif
- #ifdef SIGXFSZ
- SIGXFSZ,
- #endif
- };
- #define SIGS (sizeof(sig)/sizeof(*sig))
-
-
- #if has_sigaction
-
- static void
- check_sig(r)
- int r;
- {
- if (r != 0)
- efaterror("signal");
- }
-
- static void
- setup_catchsig()
- {
- register int i;
- sigset_t blocked;
- struct sigaction act;
-
- check_sig(sigemptyset(&blocked));
- for (i=SIGS; 0<=--i; )
- check_sig(sigaddset(&blocked, sig[i]));
- for (i=SIGS; 0<=--i; ) {
- check_sig(sigaction(sig[i], (struct sigaction*)nil, &act));
- if (act.sa_handler != SIG_IGN) {
- act.sa_handler = catchsig;
- act.sa_mask = blocked;
- check_sig(sigaction(sig[i], &act, (struct sigaction*)nil));
- }
- }
- }
-
- #else
- #if has_sigblock
-
- static void
- setup_catchsig()
- {
- register int i;
- int mask;
-
- mask = 0;
- for (i=SIGS; 0<=--i; )
- mask |= sigmask(sig[i]);
- mask = sigblock(mask);
- for (i=SIGS; 0<=--i; )
- if (
- signal(sig[i], catchsig) == SIG_IGN &&
- signal(sig[i], SIG_IGN) != catchsig
- )
- faterror("signal catcher failure");
- VOID sigsetmask(mask);
- }
-
- #else
-
- static void
- setup_catchsig()
- {
- register i;
-
- for (i=SIGS; 0<=--i; )
- if (
- signal(sig[i], SIG_IGN) != SIG_IGN &&
- signal(sig[i], catchsig) != SIG_IGN
- )
- faterror("signal catcher failure");
- }
-
- #endif
- #endif
-
- void
- catchints()
- {
- static int catching_ints;
- if (!catching_ints) {
- catching_ints = true;
- setup_catchsig();
- }
- }
-
- #endif /* has_signal */
-
-
- void
- fastcopy(inf,outf)
- register RILE *inf;
- FILE *outf;
- /* Function: copies the remainder of file inf to outf.
- */
- {
- #if large_memory
- # if has_mmap
- awrite((char const*)inf->ptr, (size_t)(inf->lim - inf->ptr), outf);
- inf->ptr = inf->lim;
- # else
- for (;;) {
- awrite((char const*)inf->ptr, (size_t)(inf->readlim - inf->ptr), outf);
- inf->ptr = inf->readlim;
- if (inf->ptr == inf->lim)
- break;
- VOID Igetmore(inf);
- }
- # endif
- #else
- char buf[BUFSIZ*8];
- register fread_type rcount;
-
- /*now read the rest of the file in blocks*/
- while (!feof(inf)) {
- if (!(rcount = Fread(buf,sizeof(*buf),sizeof(buf),inf))) {
- testIerror(inf);
- return;
- }
- awrite(buf, (size_t)rcount, outf);
- }
- #endif
- }
-
- #ifndef SSIZE_MAX
- /* This does not work in #ifs, but it's good enough for us. */
- /* Underestimating SSIZE_MAX may slow us down, but it won't break us. */
- # define SSIZE_MAX ((unsigned)-1 >> 1)
- #endif
-
- void
- awrite(buf, chars, f)
- char const *buf;
- size_t chars;
- FILE *f;
- {
- /* Posix 1003.1-1990 ssize_t hack */
- while (SSIZE_MAX < chars) {
- if (Fwrite(buf, sizeof(*buf), SSIZE_MAX, f) != SSIZE_MAX)
- Oerror();
- buf += SSIZE_MAX;
- chars -= SSIZE_MAX;
- }
-
- if (Fwrite(buf, sizeof(*buf), chars, f) != chars)
- Oerror();
- }
-
-
-
-
-
- static int
- movefd(old, new)
- int old, new;
- {
- if (old < 0 || old == new)
- return old;
- # ifdef F_DUPFD
- new = fcntl(old, F_DUPFD, new);
- # else
- new = dup2(old, new);
- # endif
- return close(old)==0 ? new : -1;
- }
-
- static int
- fdreopen(fd, file, flags)
- int fd;
- char const *file;
- int flags;
- {
- int newfd;
- VOID close(fd);
- newfd =
- #if !open_can_creat
- flags&O_CREAT ? creat(file, S_IRUSR|S_IWUSR) :
- #endif
- open(file, flags, S_IRUSR|S_IWUSR);
- return movefd(newfd, fd);
- }
-
- #if !has_spawn
- static void
- tryopen(fd,file,flags)
- int fd, flags;
- char const *file;
- {
- if (file && fdreopen(fd,file,flags) != fd)
- efaterror(file);
- }
- #else
- static int
- tryopen(fd,file,flags)
- int fd, flags;
- char const *file;
- {
- int newfd = -1;
- if (file && ((newfd=dup(fd)) < 0 || fdreopen(fd,file,flags) != fd))
- efaterror(file);
- return newfd;
- }
- static void
- redirect(old, new)
- int old, new;
- {
- if (0 <= old && (close(new) != 0 || movefd(old,new) < 0))
- efaterror("spawn I/O redirection");
- }
- #endif
-
-
-
- #if !has_fork && !has_spawn
- static void
- bufargcat(b, c, s)
- register struct buf *b;
- int c;
- register char const *s;
- /* Append to B a copy of C, plus a quoted copy of S. */
- {
- register char *p;
- register char const *t;
- size_t bl, sl;
-
- for (t=s, sl=0; *t; )
- sl += 3*(*t++=='\'') + 1;
- bl = strlen(b->string);
- bufrealloc(b, bl + sl + 4);
- p = b->string + bl;
- *p++ = c;
- *p++ = '\'';
- while (*s) {
- if (*s == '\'') {
- *p++ = '\'';
- *p++ = '\\';
- *p++ = '\'';
- }
- *p++ = *s++;
- }
- *p++ = '\'';
- *p = 0;
- }
- #endif
-
- /*
- * Run a command specified by the strings in 'inoutargs'.
- * inoutargs[0], if nonnil, is the name of the input file.
- * inoutargs[1], if nonnil, is the name of the output file.
- * inoutargs[2..] form the command to be run.
- */
- int
- runv(inoutargs)
- char const **inoutargs;
- {
- register char const **p;
- int wstatus;
-
- oflush();
- eflush();
- {
- #if has_spawn
- int in, out;
- p = inoutargs;
- in = tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- out = tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- wstatus = spawn_RCS(0, *p, (char*const*)p);
- if (wstatus == -1 && errno == ENOEXEC) {
- *--p = RCS_SHELL;
- wstatus = spawnv(0, *p, (char*const*)p);
- }
- redirect(in, STDIN_FILENO);
- redirect(out, STDOUT_FILENO);
- #else
- #if has_fork
- pid_t pid;
- # if !has_waitpid
- pid_t w;
- # endif
- if (!(pid = vfork())) {
- p = inoutargs;
- tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- VOID exec_RCS(*p, (char*const*)p);
- if (errno == ENOEXEC) {
- *--p = RCS_SHELL;
- VOID execv(*p, (char*const*)p);
- }
- VOID write(STDERR_FILENO, *p, strlen(*p));
- VOID write(STDERR_FILENO, ": not found\n", 12);
- _exit(EXIT_TROUBLE);
- }
- if (pid < 0)
- efaterror("fork");
- # if has_waitpid
- if (waitpid(pid, &wstatus, 0) < 0)
- efaterror("waitpid");
- # else
- do {
- if ((w = wait(&wstatus)) < 0)
- efaterror("wait");
- } while (w != pid);
- # endif
- #else
- static struct buf b;
-
- /* Use system(). On many hosts system() discards signals. Yuck! */
- p = inoutargs+2;
- bufscpy(&b, *p);
- while (*++p)
- bufargcat(&b, ' ', *p);
- if (inoutargs[0])
- bufargcat(&b, '<', inoutargs[0]);
- if (inoutargs[1])
- bufargcat(&b, '>', inoutargs[1]);
- wstatus = system(b.string);
- #endif
- #endif
- }
- if (!WIFEXITED(wstatus))
- faterror("%s failed", inoutargs[2]);
- return WEXITSTATUS(wstatus);
- }
-
- #define CARGSMAX 20
- /*
- * Run a command.
- * The first two arguments are the input and output files (if nonnil);
- * the rest specify the command and its arguments.
- */
- int
- #if has_prototypes
- run(char const *infile, char const *outfile, ...)
- #else
- /*VARARGS2*/
- run(infile, outfile, va_alist)
- char const *infile;
- char const *outfile;
- va_dcl
- #endif
- {
- va_list ap;
- char const *rgargs[CARGSMAX];
- register i = 0;
- rgargs[0] = infile;
- rgargs[1] = outfile;
- vararg_start(ap, outfile);
- for (i = 2; (rgargs[i++] = va_arg(ap, char const*)); )
- if (CARGSMAX <= i)
- faterror("too many command arguments");
- va_end(ap);
- return runv(rgargs);
- }
-
-
- char const *
- date2str(date, datebuf)
- char const date[datesize];
- char datebuf[datesize];
- /*
- * Format a user-readable form of the RCS format DATE into the buffer DATEBUF.
- * Yield DATEBUF.
- */
- {
- register char const *p = date;
-
- while (*p++ != '.')
- ;
- VOID sprintf(datebuf,
- "19%.*s/%.2s/%.2s %.2s:%.2s:%s" +
- (date[2]=='.' && VERSION(5)<=RCSversion ? 0 : 2),
- (int)(p-date-1), date,
- p, p+3, p+6, p+9, p+12
- );
- return datebuf;
- }
-
-
- int RCSversion;
-
- void
- setRCSversion(str)
- char const *str;
- {
- static int oldversion;
-
- register char const *s = str + 2;
- int v = VERSION_DEFAULT;
-
- if (oldversion)
- redefined('V');
- oldversion = true;
-
- if (*s) {
- v = 0;
- while (isdigit(*s))
- v = 10*v + *s++ - '0';
- if (*s)
- faterror("%s isn't a number", str);
- if (v < VERSION_min || VERSION_max < v)
- faterror("%s out of range %d..%d", str, VERSION_min, VERSION_max);
- }
-
- RCSversion = VERSION(v);
- }
-
- int
- getRCSINIT(argc, argv, newargv)
- int argc;
- char **argv, ***newargv;
- {
- register char *p, *q, **pp;
- unsigned n;
-
- if (!(q = cgetenv("RCSINIT")))
- *newargv = argv;
- else {
- n = argc + 2;
- /*
- * Count spaces in RCSINIT to allocate a new arg vector.
- * This is an upper bound, but it's OK even if too large.
- */
- for (p = q; ; ) {
- switch (*p++) {
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- n++;
- continue;
-
- case '\0':
- break;
- }
- break;
- }
- *newargv = pp = tnalloc(char*, n);
- *pp++ = *argv++; /* copy program name */
- for (p = q; ; ) {
- for (;;) {
- switch (*q) {
- case '\0':
- goto copyrest;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- q++;
- continue;
- }
- break;
- }
- *pp++ = p;
- ++argc;
- for (;;) {
- switch ((*p++ = *q++)) {
- case '\0':
- goto copyrest;
-
- case '\\':
- if (!*q)
- goto copyrest;
- p[-1] = *q++;
- continue;
-
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- break;
- }
- break;
- }
- p[-1] = '\0';
- }
- copyrest:
- while ((*pp++ = *argv++))
- ;
- }
- return argc;
- }
-
-
- #define cacheid(E) static uid_t i; static int s; if (!s){ s=1; i=(E); } return i
-
- #if has_getuid
- uid_t ruid() { cacheid(getuid()); }
- #endif
- #if has_setuid
- uid_t euid() { cacheid(geteuid()); }
- #endif
-
-
- #if has_setuid
-
- /*
- * Setuid execution really works only with Posix 1003.1a Draft 5 seteuid(),
- * because it lets us switch back and forth between arbitrary users.
- * If seteuid() doesn't work, we fall back on setuid(),
- * which works if saved setuid is supported,
- * unless the real or effective user is root.
- * This area is such a mess that we always check switches at runtime.
- */
-
- static void
- set_uid_to(u)
- uid_t u;
- /* Become user u. */
- {
- static int looping;
-
- if (euid() == ruid())
- return;
- #if (has_fork||has_spawn) && DIFF_ABSOLUTE
- if (seteuid(u) != 0)
- efaterror("setuid");
- #endif
- if (geteuid() != u) {
- if (looping)
- return;
- looping = true;
- faterror("root setuid not supported" + (u?5:0));
- }
- }
-
- static int stick_with_euid;
-
- void
- /* Ignore all calls to seteid() and setrid(). */
- nosetid()
- {
- stick_with_euid = true;
- }
-
- void
- seteid()
- /* Become effective user. */
- {
- if (!stick_with_euid)
- set_uid_to(euid());
- }
-
- void
- setrid()
- /* Become real user. */
- {
- if (!stick_with_euid)
- set_uid_to(ruid());
- }
- #endif
- @
-
-
- 5.10.1.1
- log
- @Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
- @
- text
- @d2 1
- a2 1
- * RCS utilities
- d35 1
- a35 1
- * Revision 5.10 1991/10/07 17:32:46 eggert
- d67 1
- a67 1
- * Add setuid support. Permit multiple locks per user.
- d78 1
- a78 1
- *
- d81 1
- a81 1
- *
- d86 1
- a86 1
- *
- d90 1
- a90 1
- *
- d92 1
- a92 1
- * Sources now pass through lint (if you ignore printf/sprintf/fprintf
- d94 1
- a94 1
- *
- d97 1
- a97 1
- *
- d103 1
- a103 1
- *
- d302 1
- a302 1
- && !(name = cgetenv("USER")))
- d308 2
- a309 2
- && !(name = cgetenv("USER"))
- && !(name = getlogin())
- d554 1
- a554 1
- /*now read the rest of the file in blocks*/
- d561 1
- a561 1
- }
- d592 1
- a592 1
- #if has_spawn || has_fork
- d651 1
- a651 1
- #endif
- d667 1
- a667 1
- sl += 3*(*t++=='\'') + 1;
- a701 6
- #ifdef AMIGA
- /* Lousy style, I know. But I don't want to patch into the header for this */
- int AMIGArunv(const char **args);
-
- wstatus = AMIGArunv(inoutargs);
- #else
- a758 1
- #endif
- a854 3
- #ifdef AMIGA
- if (!(q = cgetenv("RCS/INIT")))
- #else
- a855 1
- #endif
- @
-
-
- 5.10.1.2
- log
- @Changed all checks for AMIGA to _AMIGA. This is more standard like
- and helps future updates. Major patch cleanup on the way.
- [Note: Added a VOID_CLOSEDIR define for this global change, too!]
- @
- text
- @d2 1
- a2 1
- * RCS utilities
- d35 1
- a35 4
- * Revision 5.10.1.1 1993/01/18 14:36:30 heinz
- * Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
- *
- * Revision 5.10 1991/10/07 17:32:46 eggert
- d67 1
- a67 1
- * Add setuid support. Permit multiple locks per user.
- d139 1
- a139 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.1 1993/01/18 14:36:30 heinz Exp heinz $")
- d142 1
- a142 1
- int
- d144 2
- a145 2
- void const *s1, *s2;
- size_t n;
- d147 8
- a154 8
- register unsigned char const
- *p1 = (unsigned char const*)s1,
- *p2 = (unsigned char const*)s2;
- register size_t i = n;
- register int r = 0;
- while (i-- && !(r = (*p1++ - *p2++)))
- ;
- return r;
- d159 1
- a159 1
- void *
- d161 9
- a169 9
- void *s1;
- void const *s2;
- size_t n;
- {
- register char *p1 = (char*)s1;
- register char const *p2 = (char const*)s2;
- while (n--)
- *p1++ = *p2++;
- return s1;
- d174 1
- a174 1
- malloc_type lintalloc;
- d184 2
- a185 2
- malloc_type alloc;
- struct alloclist *nextalloc;
- d190 1
- a190 1
- static malloc_type
- d192 1
- a192 1
- malloc_type p;
- d194 3
- a196 3
- if (!p)
- faterror("out of memory");
- return p;
- d199 1
- a199 1
- malloc_type
- d201 1
- a201 1
- size_t size;
- d204 1
- a204 1
- return okalloc(malloc(size));
- d207 1
- a207 1
- malloc_type
- d209 2
- a210 2
- malloc_type ptr;
- size_t size;
- d213 1
- a213 1
- return okalloc(realloc(ptr, size));
- d216 1
- a216 1
- malloc_type
- d218 1
- a218 1
- malloc_type ptr;
- d221 4
- a224 4
- register struct alloclist *q = talloc(struct alloclist);
- q->nextalloc = alloced;
- alloced = q;
- return q->alloc = ptr;
- d227 1
- a227 1
- malloc_type
- d229 1
- a229 1
- size_t size;
- d232 1
- a232 1
- return fremember(testalloc(size));
- d235 1
- a235 1
- void
- d239 7
- a245 7
- register struct alloclist *p, *q;
- for (p = alloced; p; p = q) {
- q = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
- }
- alloced = nil;
- d248 1
- a248 1
- void
- d250 1
- a250 1
- register char const *f;
- d253 1
- a253 1
- register struct alloclist *p, **a = &alloced;
- d255 5
- a259 5
- while ((p = *a)->alloc != f)
- a = &p->nextalloc;
- *a = p->nextalloc;
- tfree(p->alloc);
- tfree(p);
- d262 1
- a262 1
- char *
- d264 1
- a264 1
- char const *s;
- d267 1
- a267 1
- return strcpy(tnalloc(char, strlen(s)+1), s);
- d270 1
- a270 1
- char *
- d272 1
- a272 1
- char const *s;
- d275 1
- a275 1
- return strcpy(ftnalloc(char, strlen(s)+1), s);
- d278 1
- a278 1
- char *
- d280 1
- a280 1
- char const *name;
- d283 1
- a283 1
- register char *p;
- d285 1
- a285 1
- return (p=getenv(name)) ? str_save(p) : p;
- d288 1
- a288 1
- char const *
- d290 1
- a290 1
- int suspicious;
- d293 1
- a293 1
- static char *name;
- d295 17
- a311 17
- if (!name) {
- if (
- /* Prefer getenv() unless suspicious; it's much faster. */
- # if getlogin_is_secure
- (suspicious
- ||
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER")))
- && !(name = getlogin())
- # else
- suspicious
- ||
- !(name = cgetenv("LOGNAME"))
- && !(name = cgetenv("USER"))
- && !(name = getlogin())
- # endif
- ) {
- d313 6
- a318 6
- struct passwd const *pw = getpwuid(ruid());
- if (!pw)
- faterror("no password entry for userid %lu",
- (unsigned long)ruid()
- );
- name = pw->pw_name;
- d321 1
- a321 1
- faterror("setuid not supported");
- d323 1
- a323 1
- faterror("Who are you? Please set LOGNAME.");
- d326 4
- a329 4
- }
- checksid(name);
- }
- return name;
- d338 1
- a338 1
- * Signal handling
- d347 1
- a347 1
- static signal_type
- d349 1
- a349 1
- int s;
- d351 2
- a352 2
- char const *sname;
- char buf[BUFSIZ];
- d355 2
- a356 2
- /* If a signal arrives before we reset the signal handler, we lose. */
- VOID signal(s, SIG_IGN);
- d358 8
- a365 8
- if (holdlevel) {
- heldsignal = s;
- return;
- }
- ignoreints();
- setrid();
- if (!quietflag) {
- sname = nil;
- d367 6
- a372 6
- if ((unsigned)s < NSIG) {
- # ifndef sys_siglist
- extern char const *sys_siglist[];
- # endif
- sname = sys_siglist[s];
- }
- d374 1
- a374 1
- switch (s) {
- d376 1
- a376 1
- case SIGHUP: sname = "Hangup"; break;
- d379 1
- a379 1
- case SIGINT: sname = "Interrupt"; break;
- d382 1
- a382 1
- case SIGPIPE: sname = "Broken pipe"; break;
- d385 1
- a385 1
- case SIGQUIT: sname = "Quit"; break;
- d388 1
- a388 1
- case SIGTERM: sname = "Terminated"; break;
- d391 1
- a391 1
- case SIGXCPU: sname = "Cputime limit exceeded"; break;
- d394 1
- a394 1
- case SIGXFSZ: sname = "Filesize limit exceeded"; break;
- d396 1
- a396 1
- }
- d398 7
- a404 7
- if (sname)
- VOID sprintf(buf, "\nRCS: %s. Cleaning up.\n", sname);
- else
- VOID sprintf(buf, "\nRCS: Signal %d. Cleaning up.\n", s);
- VOID write(STDERR_FILENO, buf, strlen(buf));
- }
- exiterr();
- d407 1
- a407 1
- void
- d410 1
- a410 1
- ++holdlevel;
- d413 1
- a413 1
- void
- d416 2
- a417 2
- if (!--holdlevel && heldsignal)
- VOID catchsig(heldsignal);
- d423 1
- a423 1
- SIGHUP,
- d426 1
- a426 1
- SIGINT,
- d429 1
- a429 1
- SIGPIPE,
- d432 1
- a432 1
- SIGQUIT,
- d435 1
- a435 1
- SIGTERM,
- d438 1
- a438 1
- SIGXCPU,
- d441 1
- a441 1
- SIGXFSZ,
- d449 1
- a449 1
- static void
- d451 1
- a451 1
- int r;
- d453 2
- a454 2
- if (r != 0)
- efaterror("signal");
- d457 1
- a457 1
- static void
- d460 15
- a474 15
- register int i;
- sigset_t blocked;
- struct sigaction act;
-
- check_sig(sigemptyset(&blocked));
- for (i=SIGS; 0<=--i; )
- check_sig(sigaddset(&blocked, sig[i]));
- for (i=SIGS; 0<=--i; ) {
- check_sig(sigaction(sig[i], (struct sigaction*)nil, &act));
- if (act.sa_handler != SIG_IGN) {
- act.sa_handler = catchsig;
- act.sa_mask = blocked;
- check_sig(sigaction(sig[i], &act, (struct sigaction*)nil));
- }
- }
- d480 1
- a480 1
- static void
- d483 2
- a484 2
- register int i;
- int mask;
- d486 11
- a496 11
- mask = 0;
- for (i=SIGS; 0<=--i; )
- mask |= sigmask(sig[i]);
- mask = sigblock(mask);
- for (i=SIGS; 0<=--i; )
- if (
- signal(sig[i], catchsig) == SIG_IGN &&
- signal(sig[i], SIG_IGN) != catchsig
- )
- faterror("signal catcher failure");
- VOID sigsetmask(mask);
- d501 1
- a501 1
- static void
- d504 1
- a504 1
- register i;
- d506 6
- a511 6
- for (i=SIGS; 0<=--i; )
- if (
- signal(sig[i], SIG_IGN) != SIG_IGN &&
- signal(sig[i], catchsig) != SIG_IGN
- )
- faterror("signal catcher failure");
- d517 1
- a517 1
- void
- d520 5
- a524 5
- static int catching_ints;
- if (!catching_ints) {
- catching_ints = true;
- setup_catchsig();
- }
- d530 1
- a530 1
- void
- d532 2
- a533 2
- register RILE *inf;
- FILE *outf;
- d538 24
- a561 24
- # if has_mmap
- awrite((char const*)inf->ptr, (size_t)(inf->lim - inf->ptr), outf);
- inf->ptr = inf->lim;
- # else
- for (;;) {
- awrite((char const*)inf->ptr, (size_t)(inf->readlim - inf->ptr), outf);
- inf->ptr = inf->readlim;
- if (inf->ptr == inf->lim)
- break;
- VOID Igetmore(inf);
- }
- # endif
- #else
- char buf[BUFSIZ*8];
- register fread_type rcount;
-
- /*now read the rest of the file in blocks*/
- while (!feof(inf)) {
- if (!(rcount = Fread(buf,sizeof(*buf),sizeof(buf),inf))) {
- testIerror(inf);
- return;
- }
- awrite(buf, (size_t)rcount, outf);
- }
- d568 1
- a568 1
- # define SSIZE_MAX ((unsigned)-1 >> 1)
- d571 1
- a571 1
- void
- d573 11
- a583 11
- char const *buf;
- size_t chars;
- FILE *f;
- {
- /* Posix 1003.1-1990 ssize_t hack */
- while (SSIZE_MAX < chars) {
- if (Fwrite(buf, sizeof(*buf), SSIZE_MAX, f) != SSIZE_MAX)
- Oerror();
- buf += SSIZE_MAX;
- chars -= SSIZE_MAX;
- }
- d585 2
- a586 2
- if (Fwrite(buf, sizeof(*buf), chars, f) != chars)
- Oerror();
- d593 1
- a593 1
- static int
- d595 1
- a595 1
- int old, new;
- d597 8
- a604 8
- if (old < 0 || old == new)
- return old;
- # ifdef F_DUPFD
- new = fcntl(old, F_DUPFD, new);
- # else
- new = dup2(old, new);
- # endif
- return close(old)==0 ? new : -1;
- d607 1
- a607 1
- static int
- d609 7
- a615 7
- int fd;
- char const *file;
- int flags;
- {
- int newfd;
- VOID close(fd);
- newfd =
- d617 1
- a617 1
- flags&O_CREAT ? creat(file, S_IRUSR|S_IWUSR) :
- d619 2
- a620 2
- open(file, flags, S_IRUSR|S_IWUSR);
- return movefd(newfd, fd);
- d624 1
- a624 1
- static void
- d626 2
- a627 2
- int fd, flags;
- char const *file;
- d629 2
- a630 2
- if (file && fdreopen(fd,file,flags) != fd)
- efaterror(file);
- d633 1
- a633 1
- static int
- d635 2
- a636 2
- int fd, flags;
- char const *file;
- d638 4
- a641 4
- int newfd = -1;
- if (file && ((newfd=dup(fd)) < 0 || fdreopen(fd,file,flags) != fd))
- efaterror(file);
- return newfd;
- d643 1
- a643 1
- static void
- d645 1
- a645 1
- int old, new;
- d647 2
- a648 2
- if (0 <= old && (close(new) != 0 || movefd(old,new) < 0))
- efaterror("spawn I/O redirection");
- d655 1
- a655 1
- static void
- d657 3
- a659 3
- register struct buf *b;
- int c;
- register char const *s;
- d662 21
- a682 21
- register char *p;
- register char const *t;
- size_t bl, sl;
-
- for (t=s, sl=0; *t; )
- sl += 3*(*t++=='\'') + 1;
- bl = strlen(b->string);
- bufrealloc(b, bl + sl + 4);
- p = b->string + bl;
- *p++ = c;
- *p++ = '\'';
- while (*s) {
- if (*s == '\'') {
- *p++ = '\'';
- *p++ = '\\';
- *p++ = '\'';
- }
- *p++ = *s++;
- }
- *p++ = '\'';
- *p = 0;
- d692 1
- a692 1
- int
- d694 1
- a694 1
- char const **inoutargs;
- d696 2
- a697 2
- register char const **p;
- int wstatus;
- d699 2
- a700 2
- oflush();
- eflush();
- d702 3
- a704 3
- #ifdef _AMIGA
- /* Lousy style, I know. But I don't want to patch into the header for this */
- int AMIGArunv(const char **args);
- d706 1
- a706 2
- /* This does the complete work to run a command. */
- wstatus = AMIGArunv(inoutargs);
- d709 11
- a719 11
- int in, out;
- p = inoutargs;
- in = tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- out = tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- wstatus = spawn_RCS(0, *p, (char*const*)p);
- if (wstatus == -1 && errno == ENOEXEC) {
- *--p = RCS_SHELL;
- wstatus = spawnv(0, *p, (char*const*)p);
- }
- redirect(in, STDIN_FILENO);
- redirect(out, STDOUT_FILENO);
- d722 42
- a763 41
- pid_t pid;
- # if !has_waitpid
- pid_t w;
- # endif
- if (!(pid = vfork())) {
- p = inoutargs;
- tryopen(STDIN_FILENO, *p++, O_BINARY|O_RDONLY);
- tryopen(STDOUT_FILENO, *p++, O_BINARY|O_CREAT|O_TRUNC|O_WRONLY);
- VOID exec_RCS(*p, (char*const*)p);
- if (errno == ENOEXEC) {
- *--p = RCS_SHELL;
- VOID execv(*p, (char*const*)p);
- }
- VOID write(STDERR_FILENO, *p, strlen(*p));
- VOID write(STDERR_FILENO, ": not found\n", 12);
- _exit(EXIT_TROUBLE);
- }
- if (pid < 0)
- efaterror("fork");
- # if has_waitpid
- if (waitpid(pid, &wstatus, 0) < 0)
- efaterror("waitpid");
- # else
- do {
- if ((w = wait(&wstatus)) < 0)
- efaterror("wait");
- } while (w != pid);
- # endif
- #else
- static struct buf b;
-
- /* Use system(). On many hosts system() discards signals. Yuck! */
- p = inoutargs+2;
- bufscpy(&b, *p);
- while (*++p)
- bufargcat(&b, ' ', *p);
- if (inoutargs[0])
- bufargcat(&b, '<', inoutargs[0]);
- if (inoutargs[1])
- bufargcat(&b, '>', inoutargs[1]);
- wstatus = system(b.string);
- a765 1
- #endif /* _AMIGA */
- d767 3
- a769 3
- if (!WIFEXITED(wstatus))
- faterror("%s failed", inoutargs[2]);
- return WEXITSTATUS(wstatus);
- d778 1
- a778 1
- int
- d782 1
- a782 1
- /*VARARGS2*/
- d784 16
- a799 16
- char const *infile;
- char const *outfile;
- va_dcl
- #endif
- {
- va_list ap;
- char const *rgargs[CARGSMAX];
- register i = 0;
- rgargs[0] = infile;
- rgargs[1] = outfile;
- vararg_start(ap, outfile);
- for (i = 2; (rgargs[i++] = va_arg(ap, char const*)); )
- if (CARGSMAX <= i)
- faterror("too many command arguments");
- va_end(ap);
- return runv(rgargs);
- d803 1
- a803 1
- char const *
- d805 2
- a806 2
- char const date[datesize];
- char datebuf[datesize];
- d812 1
- a812 1
- register char const *p = date;
- d814 9
- a822 9
- while (*p++ != '.')
- ;
- VOID sprintf(datebuf,
- "19%.*s/%.2s/%.2s %.2s:%.2s:%s" +
- (date[2]=='.' && VERSION(5)<=RCSversion ? 0 : 2),
- (int)(p-date-1), date,
- p, p+3, p+6, p+9, p+12
- );
- return datebuf;
- d828 1
- a828 1
- void
- d830 1
- a830 1
- char const *str;
- d832 1
- a832 1
- static int oldversion;
- d834 2
- a835 2
- register char const *s = str + 2;
- int v = VERSION_DEFAULT;
- d837 3
- a839 3
- if (oldversion)
- redefined('V');
- oldversion = true;
- d841 9
- a849 9
- if (*s) {
- v = 0;
- while (isdigit(*s))
- v = 10*v + *s++ - '0';
- if (*s)
- faterror("%s isn't a number", str);
- if (v < VERSION_min || VERSION_max < v)
- faterror("%s out of range %d..%d", str, VERSION_min, VERSION_max);
- }
- d851 1
- a851 1
- RCSversion = VERSION(v);
- d854 1
- a854 1
- int
- d856 2
- a857 2
- int argc;
- char **argv, ***newargv;
- d859 2
- a860 2
- register char *p, *q, **pp;
- unsigned n;
- d862 74
- a935 80
- #ifdef _AMIGA
- /* This is a change to keep ENV: clean on the Amiga. Every RCS
- specific environment should be in ENV:RCS! While this is
- theoretically not necessary because RCS works anyway, I consider
- it good style. It keeps ENV: from being cluttered and doesn't
- slow down standard ENV: accesses by adding "just one more". */
-
- if (!(q = cgetenv("RCS/INIT")))
- #else
- if (!(q = cgetenv("RCSINIT")))
- #endif /* _AMIGA */
- *newargv = argv;
- else {
- n = argc + 2;
- /*
- * Count spaces in RCSINIT to allocate a new arg vector.
- * This is an upper bound, but it's OK even if too large.
- */
- for (p = q; ; ) {
- switch (*p++) {
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- n++;
- continue;
-
- case '\0':
- break;
- }
- break;
- }
- *newargv = pp = tnalloc(char*, n);
- *pp++ = *argv++; /* copy program name */
- for (p = q; ; ) {
- for (;;) {
- switch (*q) {
- case '\0':
- goto copyrest;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- q++;
- continue;
- }
- break;
- }
- *pp++ = p;
- ++argc;
- for (;;) {
- switch ((*p++ = *q++)) {
- case '\0':
- goto copyrest;
-
- case '\\':
- if (!*q)
- goto copyrest;
- p[-1] = *q++;
- continue;
-
- default:
- continue;
-
- case ' ':
- case '\b': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- break;
- }
- break;
- }
- p[-1] = '\0';
- }
- copyrest:
- while ((*pp++ = *argv++))
- ;
- }
- return argc;
- d942 1
- a942 1
- uid_t ruid() { cacheid(getuid()); }
- d945 1
- a945 1
- uid_t euid() { cacheid(geteuid()); }
- d960 1
- a960 1
- static void
- d962 1
- a962 1
- uid_t u;
- d965 1
- a965 1
- static int looping;
- d967 2
- a968 2
- if (euid() == ruid())
- return;
- d970 2
- a971 2
- if (seteuid(u) != 0)
- efaterror("setuid");
- d973 6
- a978 6
- if (geteuid() != u) {
- if (looping)
- return;
- looping = true;
- faterror("root setuid not supported" + (u?5:0));
- }
- d983 1
- a983 1
- void
- d987 1
- a987 1
- stick_with_euid = true;
- d990 1
- a990 1
- void
- d994 2
- a995 2
- if (!stick_with_euid)
- set_uid_to(euid());
- d998 1
- a998 1
- void
- d1002 2
- a1003 2
- if (!stick_with_euid)
- set_uid_to(ruid());
- @
-
-
- 5.10.1.3
- log
- @Some cosmetic changes to prepare for test diffing to the RCS5.6.0.1
- sources.
- @
- text
- @a34 5
- * Revision 5.10.1.2 1993/12/18 16:12:22 heinz
- * Changed all checks for AMIGA to _AMIGA. This is more standard like
- * and helps future updates. Major patch cleanup on the way.
- * [Note: Added a VOID_CLOSEDIR define for this global change, too!]
- *
- d142 1
- a142 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.2 1993/12/18 16:12:22 heinz Exp heinz $")
- d595 1
- a595 8
-
- #ifndef _AMIGA
- /* We don't have spawn or fork on the Amiga, so we don't need this stuff!
- Leaving it in would only create compile problems. Actually this applies
- to any host, so it IMHO should be an: "ifdef has_spawn || has_fork".
- But for now it is an Amiga change only!
- */
-
- d654 1
- a654 2
- #endif /* _AMIGA */
-
- a705 7
- /* As the Amiga does not have fork(), we have to do it differently. I use
- one of my support routines, but that is not the only way to do it. One
- might as well create something out of system() or System(). Whatever you
- want. I don't use system here, because I think it behaves rather dim in
- SAS/C 6.3. If you like it, try it.
- */
-
- d867 5
- a871 6
- /* This is a change to keep ENV: clean on the Amiga. Every RCS
- specific environment should be in ENV:RCS! While this is
- theoretically not necessary because RCS works anyway, I consider
- it good style. It keeps ENV: from being cluttered and doesn't
- slow down standard ENV: accesses by adding "just one more var".
- */
- @
-
-
- 5.10.1.4
- log
- @Put in the change by Paul Eggert.
- @
- text
- @a34 4
- * Revision 5.10.1.3 1993/12/18 17:17:59 heinz
- * Some cosmetic changes to prepare for test diffing to the RCS5.6.0.1
- * sources.
- *
- d147 1
- a147 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.3 1993/12/18 17:17:59 heinz Exp heinz $")
- d601 6
- a606 1
- #if has_fork || has_spawn
- d666 1
- d670 1
- a670 1
- #else /* !has_fork && !has_spawn */
- @
-
-
- 5.10.1.5
- log
- @getRCSINIT now ignores RCS_link and tries to use a command
- specific RCS/INIT.
- @
- text
- @a34 3
- * Revision 5.10.1.4 1994/01/06 11:33:27 heinz
- * Put in the change by Paul Eggert.
- *
- d151 1
- a151 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.4 1994/01/06 11:33:27 heinz Exp heinz $")
- d885 1
- a885 10
- /*
- First, we remove all command line references to RCS_link here.
- They can come from filename expansion in the startup and disrupt
- normal RCS processing.
-
- The we check for RCS[/]INIT_<prgname> and only if this one does not
- exist, we check for RCS[/]INIT. This allows the user to have different
- preferences for the different commands.
-
- This is a change to keep ENV: clean on the Amiga. Every RCS
- a889 1
-
- a890 17
- AMIGA_ignorercslink(&argc, argv);
-
- #define RCSINITNAME "RCS/INIT"
- {
- char buf[BUFSIZ];
-
- strcpy(buf, RCSINITNAME);
- strcat(buf, "_");
- strcat(buf, argv[0]);
-
- q = cgetenv(buf);
- }
-
- if(!q)
- {
- q = cgetenv(RCSINITNAME);
- } /* if */
- d892 1
- a892 1
- if(!q)
- @
-
-
- 5.10.1.6
- log
- @RCS_link preprocessing and inti variable stuff should work fine, now.
- @
- text
- @a34 4
- * Revision 5.10.1.5 1994/02/11 19:53:26 heinz
- * getRCSINIT now ignores RCS_link and tries to use a command
- * specific RCS/INIT.
- *
- d154 1
- a154 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.5 1994/02/11 19:53:26 heinz Exp heinz $")
- d891 1
- a891 2
- normal RCS processing. We also check RCS_link for any option specs that
- we should use for the command.
- d904 1
- a904 1
- q = AMIGA_handlercslink(&argc, argv);
- a906 1
- if(!q)
- d912 1
- a912 1
- strcat(buf, basename(argv[0]));
- d915 1
- a915 1
- } /* if */
- @
-
-
- 5.10.1.7
- log
- @delete bit is now handled more relaxed.
- @
- text
- @a34 3
- * Revision 5.10.1.6 1994/03/14 09:22:53 heinz
- * RCS_link preprocessing and inti variable stuff should work fine, now.
- *
- d158 1
- a158 1
- libId(utilId, "$Id: rcsutil.c,v 5.10.1.6 1994/03/14 09:22:53 heinz Exp heinz $")
- a636 8
- #ifdef _AMIGA
- /* We want the delete bit, too! */
-
- #if !open_can_creat
- flags&O_CREAT ? creat(file, S_IRUSR|S_IWUSR|S_IDUSR) :
- #endif
- open(file, flags, S_IRUSR|S_IWUSR|S_IDUSR);
- #else
- a640 1
- #endif /* _AMIGA */
- @
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-