diff options
Diffstat (limited to 'src/util')
28 files changed, 570 insertions, 131 deletions
diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 9a3cb27..4f30329 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,3 +1,27 @@ +Fri Mar 12 15:29:17 1999 Tom Yu <tlyu@mit.edu> + + * mkrel: Update from trunk. + +Thu Nov 13 20:28:31 1997 Theodore Y. Ts'o <tytso@mit.edu> + + * libupdate.sh: Add semicolons to prevent Bash 2.0 from + complaining. [krb5-build/486] + +Wed Oct 8 16:19:49 1997 Tom Yu <tlyu@mit.edu> + + * mkrel: Allow for edits of relevant files that should be changed + each time a release is cut. Some snapshot support. Add "-9" flag + to gzip. + +Mon Nov 25 21:00:24 1996 Tom Yu <tlyu@mit.edu> + + * mkrel: Add support for --srconly, --doconly, --nocheckout, + --repository, etc. They do the obvious things. + +Fri Nov 22 11:08:16 1996 Sam Hartman <hartmans@tertius.mit.edu> + + * makeshlib.sh (VERSION): Fix SunOS shared libs [226] + Tue Nov 12 17:32:08 1996 Barry Jaspan <bjaspan@mit.edu> * send-pr/send-pr.sh (MAIL_AGENT): change "[-x" to "[ -x" diff --git a/src/util/db2/ChangeLog b/src/util/db2/ChangeLog index fdabe09..41774ba 100644 --- a/src/util/db2/ChangeLog +++ b/src/util/db2/ChangeLog @@ -1,3 +1,13 @@ +Sun Dec 21 18:33:14 1997 Tom Yu <tlyu@mit.edu> + + * hash/dbm.c: Rename the errno member of HTAB. + + * hash/hash.h: Rename the errno member of HTAB to local_errno to + avoid a collision with a glibc macro. + + * hash/hash.c: Rename the errno member of HTAB to local_errno to + avoid a collision with a glibc macro. + Mon Nov 11 17:01:29 1996 Mark Eichin <eichin@cygnus.com> * db2: overflow_page fixes, __P redef diff --git a/src/util/db2/hash/dbm.c b/src/util/db2/hash/dbm.c index c4ba92b..4745127 100644 --- a/src/util/db2/hash/dbm.c +++ b/src/util/db2/hash/dbm.c @@ -328,7 +328,7 @@ dbm_error(db) HTAB *hp; hp = (HTAB *)db->internal; - return (hp->errno); + return (hp->local_errno); } int @@ -338,7 +338,7 @@ dbm_clearerr(db) HTAB *hp; hp = (HTAB *)db->internal; - hp->errno = 0; + hp->local_errno = 0; return (0); } diff --git a/src/util/db2/hash/hash.c b/src/util/db2/hash/hash.c index 2811688..e522754 100644 --- a/src/util/db2/hash/hash.c +++ b/src/util/db2/hash/hash.c @@ -632,7 +632,7 @@ hash_get(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag) { - hashp->errno = errno = EINVAL; + hashp->local_errno = errno = EINVAL; return (ERROR); } return (hash_access(hashp, HASH_GET, (DBT *)key, data)); @@ -649,11 +649,11 @@ hash_put(dbp, key, data, flag) hashp = (HTAB *)dbp->internal; if (flag && flag != R_NOOVERWRITE) { - hashp->errno = errno = EINVAL; + hashp->local_errno = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->local_errno = errno = EPERM; return (ERROR); } return (hash_access(hashp, flag == R_NOOVERWRITE ? @@ -670,11 +670,11 @@ hash_delete(dbp, key, flag) hashp = (HTAB *)dbp->internal; if (flag) { - hashp->errno = errno = EINVAL; + hashp->local_errno = errno = EINVAL; return (ERROR); } if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->errno = errno = EPERM; + hashp->local_errno = errno = EPERM; return (ERROR); } @@ -849,7 +849,7 @@ cursor_get(dbp, cursorp, key, val, flags) hashp = (HTAB *)dbp->internal; if (flags && flags != R_FIRST && flags != R_NEXT) { - hashp->errno = errno = EINVAL; + hashp->local_errno = errno = EINVAL; return (ERROR); } #ifdef HASH_STATISTICS diff --git a/src/util/db2/hash/hash.h b/src/util/db2/hash/hash.h index a12c8d4..170c24c 100644 --- a/src/util/db2/hash/hash.h +++ b/src/util/db2/hash/hash.h @@ -94,7 +94,7 @@ typedef struct htab { /* Memory resident data structure */ u_int8_t *bigkey_buf; /* Temporary Buffer for BIG keys */ u_int16_t *split_buf; /* Temporary buffer for splits */ CURSOR *seq_cursor; /* Cursor used for hash_seq */ - int32_t errno; /* Error Number -- for DBM compatability */ + int32_t local_errno; /* Error Number -- for DBM compatability */ int32_t new_file; /* Indicates if fd is backing store or no */ int32_t save_file; /* Indicates whether we need to flush file at * exit */ diff --git a/src/util/db2/obj/ChangeLog b/src/util/db2/obj/ChangeLog index d2c8bb8..6f09fcd 100644 --- a/src/util/db2/obj/ChangeLog +++ b/src/util/db2/obj/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 25 16:20:35 1996 Sam Hartman <hartmans@mit.edu> + + * Makefile.in (check): Remove install rule to fix pmake problem. [236] + Wed Sep 11 18:55:38 1996 Tom Yu <tlyu@mit.edu> * Makefile.in (memmove.o): add -DMEMMOVE to compile as memmove diff --git a/src/util/db2/obj/Makefile.in b/src/util/db2/obj/Makefile.in index 4445e37..0c022e2 100644 --- a/src/util/db2/obj/Makefile.in +++ b/src/util/db2/obj/Makefile.in @@ -56,10 +56,6 @@ check:: dbtest TMPDIR=$(TMPDIR) $(FCTSH) $(top_srcdir)/test/run.test install:: - cp $(LIBDB) $(libdir) - $(RANLIB) $(libdir)/$(LIBDB) - cp $(top_srcdir)/include/db.h $(includedir) - cp ../db-config.h $(includedir) clean:: rm -f $(ALL_OBJS) $(LIBDB) \ diff --git a/src/util/et/ChangeLog b/src/util/et/ChangeLog index 38d80eb..227dc7c 100644 --- a/src/util/et/ChangeLog +++ b/src/util/et/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 18 20:37:19 1996 Ezra Peisach <epeisach@mit.edu> + + * configure.in: Set shared library version to 1.0. [krb5-libs/201] + Wed Nov 13 19:19:08 1996 Tom Yu <tlyu@mit.edu> * Makefile.in (clean-unix): Remove shared/*. diff --git a/src/util/et/configure.in b/src/util/et/configure.in index 7b0cf00..15fd8d8 100644 --- a/src/util/et/configure.in +++ b/src/util/et/configure.in @@ -25,5 +25,5 @@ AC_HEADER_STDARG AC_HAVE_HEADERS(stdlib.h) CopySrcHeader(com_err.h,$(BUILDTOP)/include) V5_SHARED_LIB_OBJS -V5_MAKE_SHARED_LIB(libcom_err,0.1,[$](TOPLIBD), ../util/et) +V5_MAKE_SHARED_LIB(libcom_err,1.0,[$](TOPLIBD), ../util/et) V5_AC_OUTPUT_MAKEFILE diff --git a/src/util/libupdate.sh b/src/util/libupdate.sh index fe0dab8..8c3e61e 100644 --- a/src/util/libupdate.sh +++ b/src/util/libupdate.sh @@ -25,7 +25,7 @@ oblist=$2 shift shift for dir do - oblists="$oblists${oblists+ }$dir/$oblist" + oblists="$oblists${oblists+ }$dir/$oblist"; done stamp=`echo $library | sed -e 's/.a$/.stamp/'` @@ -41,4 +41,4 @@ echo "Updating library $library from $oblists" $rmcmd $arcmd $library `for dir do (cd $dir; cat $oblist | \ - sed -e "s;^\([^ ]*\);$dir/\1;g" -e "s; \([^ ]*\); $dir/\1;g") done` + sed -e "s;^\([^ ]*\);$dir/\1;g" -e "s; \([^ ]*\); $dir/\1;g"); done` diff --git a/src/util/makeshlib.sh b/src/util/makeshlib.sh index 74c73b7..a8afb3b 100644 --- a/src/util/makeshlib.sh +++ b/src/util/makeshlib.sh @@ -96,15 +96,16 @@ mips-sni-sysv4) optflags="" if test "$HAVE_GCC"x = "x" ; then - optflags="-h $library" + optflags="" + CC=ld else # XXX assumes that we're either using # recent gld (binutils 2.7?) or else using native ld - optflags="-Wl,-h -Wl,$library" + optflags="" fi echo ld -dp -assert pure-text $ldflags -o $library $optflags $FILES $libdirfl - ld -dp -assert pure-text $ldflags -o $library $optflags $FILES $libdirfl +ld -dp -assert pure-text $ldflags -o $library $optflags $FILES $libdirfl stat=$? ;; *-*-aix*) diff --git a/src/util/mkrel b/src/util/mkrel index 20b61a3..ae7a1ed 100644 --- a/src/util/mkrel +++ b/src/util/mkrel @@ -1,60 +1,133 @@ #!/bin/sh -: ${repository=/afs/athena.mit.edu/astaff/project/krbdev/.cvsroot} -case $# in -2);; -*) - echo "usage: $0 release-tag release-dir" +repository=:kserver:cvs.mit.edu:/cvs/krbdev +dodoc=t +dosrc=t +checkout=t +while test $# -gt 2; do + case $1 in + --srconly) + dodoc=nil;; + --doconly) + dosrc=nil;; + --repository) + shift; repository=$1;; + --nocheckout) + checkout=nil;; + esac + shift +done +if test $# -lt 2; then + echo "usage: $0 [opts] release-tag release-dir" exit 1 - ;; -esac +fi reltag=$1 reldir=$2 -case reldir in +relmajor=0 +relminor=0 +relpatch=0 +relhead= +reltail= +reldate=`date +%Y%m%d` + +case "$reldir" in */*) echo "release-dir may not contain slashes." exit 1 ;; +*" "*|*" "*) + echo "release-dir may not contain whitespace." + exit 1 + ;; +krb5-*.*.*-*) + release=`echo $reldir|sed -e 's/krb5-//'` + relhead=`echo $release|sed -e 's/-.*//'` + reltail=`echo $release|sed -e 's/.*-//'` + relmajor=`echo $relhead|awk -F. '{print $1}'` + relminor=`echo $relhead|awk -F. '{print $2}'` + relpatch=`echo $relhead|awk -F. '{print $3}'` + ;; +krb5-*.*.*) + release=`echo $reldir|sed -e 's/krb5-//'` + relmajor=`echo $release|awk -F. '{print $1}'` + relminor=`echo $release|awk -F. '{print $2}'` + relpatch=`echo $release|awk -F. '{print $3}'` + ;; +krb5-*.*) + release=`echo $reldir|sed -e 's/krb5-//'` + relmajor=`echo $release|awk -F. '{print $1}'` + relminor=`echo $release|awk -F. '{print $2}'` + ;; +krb5-current) + release=current-$reldate + ;; *);; esac -if test ! -d $reldir; then - mkdir $reldir +if test $checkout = t; then + echo "Checking out krb5 with tag $reltag into directory $reldir..." + cvs -q -d $repository export -r$reltag -d $reldir krb5 +fi + +if test $dosrc = t; then + echo "Building autoconf..." + (cd $reldir/src/util/autoconf + M4=gm4 ./configure + make) + + echo "Creating configure scripts..." + (cd $reldir/src; util/reconf) + + echo "Cleaning src/util/autoconf..." + (cd $reldir/src/util/autoconf; make distclean) fi -echo "Checking out krb5 with tag $reltag into directory $reldir..." -(cd $reldir; cvs -q -d $repository export -r$reltag krb5) +echo "Editing release-specific files..." -echo "Building autoconf..." -(cd $reldir/src/util/autoconf - M4=gm4 ./configure - make) +(cd $reldir/src/lib/krb5/krb && \ + sed -e '/static/s%KRB5_BRAND:[^"]*"%'"KRB5_BRAND: $reltag $release $reldate"'"%' \ + brand.c > brand.c.new && mv brand.c.new brand.c; \ + rm -f brand.c.new) -echo "Creating configure scripts..." -(cd $reldir/src; util/reconf) +(cd $reldir/src/util/send-pr && \ + sed -e 's%RELEASE=.*%RELEASE='"krb5-$release"'%' Makefile.in \ + > Makefile.in.new && mv Makefile.in.new Makefile.in) -echo "Cleaning src/util/autoconf..." -(cd $reldir/src/util/autoconf; make distclean) +(cd $reldir/src && \ + cat > patchlevel.h <<EOF +#define KRB5_MAJOR_RELEASE $relmajor +#define KRB5_MINOR_RELEASE $relminor +#define KRB5_PATCHLEVEL $relpatch +EOF +) echo "Nuking unneeded files..." find $reldir \( -name TODO -o -name todo -o -name .cvsignore \ -o -name BADSYMS -o -name .Sanitize \) -print \ | xargs rm -f -echo "Building doc..." -(cd $reldir/doc; make) +if test $dodoc = t; then + echo "Building doc..." + (cd $reldir/doc; make) +fi echo "Generating tarfiles..." -gtar --exclude $reldir/src/lib/crypto \ - --exclude $reldir/src/lib/des425 \ - -zcf ${reldir}.src.tar.gz $reldir +GZIP=-9; export GZIP +if test $dosrc = t; then + gtar --exclude $reldir/src/lib/crypto \ + --exclude $reldir/src/lib/des425 \ + --exclude $reldir/doc \ + -zcf ${reldir}.src.tar.gz $reldir -gtar zcf ${reldir}.crypto.tar.gz \ - $reldir/src/lib/crypto \ - $reldir/src/lib/des425 + gtar zcf ${reldir}.crypto.tar.gz \ + $reldir/src/lib/crypto \ + $reldir/src/lib/des425 +fi -gtar zcf ${reldir}.doc.tar.gz $reldir/doc $reldir/README +if test $dodoc = t; then + gtar zcf ${reldir}.doc.tar.gz $reldir/doc $reldir/README +fi ls -l ${reldir}.*.tar.gz diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 9bfcde8..3e61d02 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,21 @@ +1998-08-06 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * prof_tree.c (profile_delete_node_relation): Fix bug where + deleting a node would corrupt the linked list. + (profile_add_node): Fix another linked list corruption + problem where an insertion into the middle of the linked + list didn't update a previous link. [krb5-libs/615] + +Fri Jan 23 20:55:06 1998 Theodore Ts'o <tytso@rsts-11.mit.edu> + + * prof_parse.c (parse_std_line, parse_quoted_string, + need_double_quotes, output_quoted_string, dump_profile, + dump_profile_to_file): Vastly improved the profile + parsing; whitespace at the end of lines are now ignored. + Added quoted string parsing, complete with backquote + processing. Strings which need to be quoted are properly + quoted on output. + Mon Nov 4 17:04:51 1996 Theodore Y. Ts'o <tytso@mit.edu> * prof_parse.c (parse_std_line): Accept either ';' or '#' on the diff --git a/src/util/profile/prof_parse.c b/src/util/profile/prof_parse.c index 941cc33..e7e72b8 100644 --- a/src/util/profile/prof_parse.c +++ b/src/util/profile/prof_parse.c @@ -43,6 +43,36 @@ static void strip_line(line) } } +static void parse_quoted_string(char *str) +{ + char *to, *from; + + to = from = str; + + for (to = from = str; *from && *from != '"'; to++, from++) { + if (*from == '\\') { + from++; + switch (*from) { + case 'n': + *to = '\n'; + break; + case 't': + *to = '\t'; + break; + case 'b': + *to = '\b'; + break; + default: + *to = *from; + } + continue; + } + *to = *from; + } + *to = '\0'; +} + + static errcode_t parse_init_state(state) struct parse_state *state; { @@ -126,12 +156,19 @@ static errcode_t parse_std_line(line, state) } cp = skip_over_blanks(cp+1); value = cp; - if (value[0] == 0) { + if (value[0] == '"') { + value++; + parse_quoted_string(value); + } else if (value[0] == 0) { do_subsection++; state->state = STATE_GET_OBRACE; - } - if (value[0] == '{' && value[1] == 0) + } else if (value[0] == '{' && value[1] == 0) do_subsection++; + else { + cp = value + strlen(value) - 1; + while ((cp > value) && isspace(*cp)) + *cp-- = 0; + } if (do_subsection) { retval = profile_add_node(state->current_section, tag, 0, &state->current_section); @@ -200,6 +237,60 @@ errcode_t profile_parse_file(f, root) return 0; } +/* + * Return TRUE if the string begins or ends with whitespace + */ +static int need_double_quotes(str) + char *str; +{ + if (!str || !*str) + return 0; + if (isspace(*str) ||isspace(*(str + strlen(str) - 1))) + return 1; + if (strchr(str, '\n') || strchr(str, '\t') || strchr(str, '\b')) + return 1; + return 0; +} + +/* + * Output a string with double quotes, doing appropriate backquoting + * of characters as necessary. + */ +static void output_quoted_string(str, f) + char *str; + FILE *f; +{ + char ch; + + fputc('"', f); + if (!str) { + fputc('"', f); + return; + } + while (ch = *str++) { + switch (ch) { + case '\\': + fputs("\\\\", f); + break; + case '\n': + fputs("\\n", f); + break; + case '\t': + fputs("\\t", f); + break; + case '\b': + fputs("\\b", f); + break; + default: + fputc(ch, f); + break; + } + } + fputc('"', f); +} + + + #if defined(_MSDOS) || defined(_WIN32) #define EOL "\r\n" #endif @@ -232,7 +323,13 @@ void dump_profile(root, level) break; for (i=0; i < level; i++) printf(" "); - printf("%s = '%s'%s", name, value, EOL); + if (need_double_quotes(value)) { + fputs(name, stdout); + fputs(" = ", stdout); + output_quoted_string(value, stdout); + fputs(EOL, stdout); + } else + printf("%s = '%s'%s", name, value, EOL); } while (iter != 0); iter = 0; @@ -269,7 +366,13 @@ void dump_profile_to_file(root, level, dstfile) break; for (i=0; i < level; i++) fprintf(dstfile, "\t"); - fprintf(dstfile, "%s = %s%s", name, value, EOL); + if (need_double_quotes(value)) { + fputs(name, dstfile); + fputs(" = ", dstfile); + output_quoted_string(value, dstfile); + fputs(EOL, dstfile); + } else + fprintf(dstfile, "%s = %s%s", name, value, EOL); } while (iter != 0); iter = 0; diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index a192e1d..24b447e 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -145,9 +145,14 @@ errcode_t profile_add_node(section, name, value, ret_node) if (section->value) return PROF_ADD_NOT_SECTION; + /* + * Find the place to insert the new node. We look for the + * place *after* the last match of the node name, since + * order matters. + */ for (p=section->first_child, last = 0; p; last = p, p = p->next) { cmp = strcmp(p->name, name); - if (cmp >= 0) + if (cmp > 0) break; } retval = profile_create_node(name, value, &new); @@ -155,19 +160,14 @@ errcode_t profile_add_node(section, name, value, ret_node) return retval; new->group_level = section->group_level+1; new->parent = section; - if (cmp == 0) { - do { - last = p; - p = p->next; - } while (p && strcmp(p->name, name) == 0); - } new->prev = last; + new->next = p; + if (p) + p->prev = new; if (last) last->next = new; else section->first_child = new; - if (p) - new->next = p; if (ret_node) *ret_node = new; return 0; @@ -317,7 +317,7 @@ errcode_t profile_delete_node_relation(section, name) section->first_child = p->next; next = p->next; if (p->next) - p->next->prev = p; + p->next->prev = p->prev; profile_free_node(p); p = next; } diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index 8816ca8..e504899 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,3 +1,83 @@ +Wed Mar 31 17:12:14 1999 Tom Yu <tlyu@mit.edu> + + * cleanup.c (pty_cleanup): Temporary hack to not call revoke() + under AIX. + +Sun Mar 28 17:50:57 1999 Tom Yu <tlyu@mit.edu> + + * update_wtmp.c: Define WTMPX_FILE to be _PATH_WTMPX in case we're + on a system that cleans up the namespace that way. + +Wed Feb 17 19:47:36 1999 Tom Yu <tlyu@mit.edu> + + * sane_hostname.c (pty_make_sane_hostname): Remove unused + "char *scratch". + +Tue Feb 16 20:18:40 1999 Tom Yu <tlyu@mit.edu> + + * sane_hostname.c: Re-order so that pty-int.h precedes libpty.h to + prevent conflicting definitions of struct sockaddr_in + +Thu Feb 11 22:24:03 1999 Tom Yu <tlyu@mit.edu> + + * sane_hostname.c: Force maxlen to be 16 if it's less than 16, + since otherwise a numeric IP address won't fit. + + * Makefile.in: Add sane_hostname.{o,c} + + * libpty.h: Add prototype for make_sane_hostname. + + * sane_hostname.c: New file; add function to "sanitize" hostname + for logging purposes. + +1998-07-05 <hartmans@fundsxpress.com> + + * update_utmp.c (pty_update_utmp): If the ut_exit differs test + indicates the structures differ, and we don't have a special case, + do nothing rather than trying to copy the field. It's not worth + breaking the build over. + +Mon Apr 6 19:35:33 1998 Tom Yu <tlyu@voltage-multiplier.mit.edu> + + * update_utmp.c (pty_update_utmp): Don't record LOGIN_PROCESS + entries, as they confuse last on some systems. [pty/569] + +Thu Mar 12 18:09:25 1998 Tom Yu <tlyu@mit.edu> + + * update_utmp.c (pty_update_utmp): Fix bogus entry of + PTY_LOGIN_PROCESS types on BSD-ish systems. [pty/531] + +Sun Dec 7 00:05:28 1997 Tom Yu <tlyu@mit.edu> + + * getpty.c (pty_getpty): Fix goof in previous, which introduced + another fencepost error. + +Thu Dec 4 21:48:12 1997 Tom Yu <tlyu@mit.edu> + + * getpty.c (pty_getpty): Fix checks on string lengths to account + for terminating nul character. Some whitespace fixups. + +Wed Dec 3 17:16:44 1997 Tom Yu <tlyu@mit.edu> + + * pty_err.et: Add PTY_OPEN_SLAVE_TOOSHORT error code. + + * open_slave.c (pty_open_slave): Check to ensure that the slave + name is not NULL or zero-length. + +Tue Jun 3 23:05:07 1997 Theodore Y. Ts'o <tytso@mit.edu> + + * getpty.c (pty_getpty): Remove erroneous space from the HPUX open(). + +Thu Dec 5 22:43:35 1996 Theodore Y. Ts'o <tytso@mit.edu> + + * update_utmp.c (pty_update_utmp): Apply platform specific patch + so that HPUX works. (Kludge for 1.0 release) [PR#40] + +Fri Nov 22 11:52:52 1996 Sam Hartman <hartmans@mit.edu> + + * configure.in : Make sure time_t is define [203] + * update_wtmp.c (ptyint_update_wtmp): Use time_t for call to time(2). [203] + Fri Nov 15 08:33:54 1996 Ezra Peisach <epeisach@mit.edu> * update_utmp.c (pty_update_utmp): Handle case where utmp uses diff --git a/src/util/pty/Makefile.in b/src/util/pty/Makefile.in index 080964d..4d4fbf7 100644 --- a/src/util/pty/Makefile.in +++ b/src/util/pty/Makefile.in @@ -7,7 +7,8 @@ SED = sed LIBOBJS= cleanup.o getpty.o init_slave.o open_ctty.o open_slave.o \ - update_utmp.o update_wtmp.o vhangup.o void_assoc.o pty_err.o logwtmp.o init.o + update_utmp.o update_wtmp.o vhangup.o void_assoc.o pty_err.o logwtmp.o \ + init.o sane_hostname.o LIBUPDATE= $(BUILDTOP)/util/libupdate LIBDONE=DONE LIB_SUBDIRS=. @@ -17,10 +18,10 @@ INSTALLFILE = cp LOCALINCLUDE=-I. -I$(srcdir) FILES= Makefile cleanup.c getpty.c init_slave.c open_ctty.c open_slave.c update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.h pty_err.c\ -logwtmp.c init.c +logwtmp.c init.c sane_hostname.c CFILES=cleanup.c getpty.c init_slave.c open_ctty.c open_slave.c\ -update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.c logwtmp.c init.c +update_utmp.c update_wtmp.c vhangup.c void_assoc.c pty_err.c logwtmp.c init.c sane_hostname.c SRCS=pty_err.h $(CFILES) diff --git a/src/util/pty/cleanup.c b/src/util/pty/cleanup.c index 0e9104e..1e109ba 100644 --- a/src/util/pty/cleanup.c +++ b/src/util/pty/cleanup.c @@ -37,7 +37,9 @@ long pty_cleanup (slave, pid, update_utmp) (void)chmod(slave, 0666); (void)chown(slave, 0, 0); #ifdef HAVE_REVOKE +#ifndef _AIX revoke(slave); +#endif /* * Revoke isn't guaranteed to send a SIGHUP to the processes it * dissociates from the terminal. The best solution without a Posix diff --git a/src/util/pty/configure.in b/src/util/pty/configure.in index 2394deb..3c6386a 100644 --- a/src/util/pty/configure.in +++ b/src/util/pty/configure.in @@ -50,6 +50,7 @@ dnl AC_SUBST(LOGINLIBS) dnl AC_TYPE_MODE_T +AC_CHECK_TYPE(time_t, int) AC_FUNC_CHECK(strsave,AC_DEFINE(HAS_STRSAVE)) AC_HAVE_FUNCS(getutent setreuid gettosbyname setsid ttyname line_push ptsname grantpt openpty logwtmp getutmpx) AC_CHECK_HEADERS(unistd.h stdlib.h string.h utmpx.h utmp.h sys/filio.h sys/sockio.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h) diff --git a/src/util/pty/getpty.c b/src/util/pty/getpty.c index 1185f2c..9b18aff 100644 --- a/src/util/pty/getpty.c +++ b/src/util/pty/getpty.c @@ -25,13 +25,13 @@ long pty_getpty (fd, slave, slavelength) int slavelength; int *fd; char *slave; { - char *cp; + char *cp; char *p; int i,ptynum; struct stat stb; -char slavebuf[1024]; + char slavebuf[1024]; #ifdef HAVE__GETPTY -char *slaveret; /*Temporary to hold pointer to slave*/ + char *slaveret; /*Temporary to hold pointer to slave*/ #endif /*HAVE__GETPTY*/ #ifdef HAVE_OPENPTY @@ -39,7 +39,7 @@ char *slaveret; /*Temporary to hold pointer to slave*/ if(openpty(fd, &slavefd, slave, (struct termios *) 0, (struct winsize *) 0)) return 1; -close(slavefd); + close(slavefd); return 0; #else /*HAVE_OPENPTY*/ #ifdef HAVE__GETPTY @@ -51,19 +51,19 @@ close(slavefd); * paths. */ if ((slaveret = _getpty(fd, O_RDWR|O_NDELAY, 0600, 0)) == 0) { - *fd = -1; - return PTY_GETPTY_NOPTY; + *fd = -1; + return PTY_GETPTY_NOPTY; } - if (strlen(slaveret) > slavelength) { - close(*fd); - *fd = -1; - return PTY_GETPTY_SLAVE_TOOLONG; + if (strlen(slaveret) > slavelength - 1) { + close(*fd); + *fd = -1; + return PTY_GETPTY_SLAVE_TOOLONG; } else strcpy(slave, slaveret); return 0; #else /*HAVE__GETPTY*/ - *fd = open(" /dev/ptym/clone", O_RDWR|O_NDELAY); /* HPUX*/ + *fd = open("/dev/ptym/clone", O_RDWR|O_NDELAY); /* HPUX*/ #ifdef HAVE_STREAMS if (*fd < 0) *fd = open("/dev/ptmx",O_RDWR|O_NDELAY); /*Solaris*/ #endif @@ -86,13 +86,11 @@ close(slavefd); #endif #endif if (p) { - if ( strlen(p) > slavelength) - { + if (strlen(p) > slavelength - 1) { close (*fd); *fd = -1; return PTY_GETPTY_SLAVE_TOOLONG; - } - + } strcpy(slave, p); return 0; } @@ -102,21 +100,19 @@ close(slavefd); return PTY_GETPTY_FSTAT; } ptynum = (int)(stb.st_rdev&0xFF); - sprintf(slavebuf, "/dev/ttyp%x", ptynum); - if ( strlen(slavebuf) > slavelength) { - close(*fd); - *fd = -1; - return PTY_GETPTY_SLAVE_TOOLONG; - } - strncpy ( slave, slavebuf, slavelength); + sprintf(slavebuf, "/dev/ttyp%x", ptynum); + if (strlen(slavebuf) > slavelength - 1) { + close(*fd); + *fd = -1; + return PTY_GETPTY_SLAVE_TOOLONG; + } + strncpy(slave, slavebuf, slavelength); return 0; - } else { - - for (cp = "pqrstuvwxyzPQRST";*cp; cp++) { + for (cp = "pqrstuvwxyzPQRST";*cp; cp++) { sprintf(slavebuf,"/dev/ptyXX"); - slavebuf[strlen("/dev/pty")] = *cp; - slavebuf[strlen("/dev/ptyp")] = '0'; + slavebuf[sizeof("/dev/pty") - 1] = *cp; + slavebuf[sizeof("/dev/ptyp") - 1] = '0'; if (stat(slavebuf, &stb) < 0) break; for (i = 0; i < 16; i++) { @@ -125,14 +121,13 @@ close(slavefd); if (*fd < 0) continue; /* got pty */ - slavebuf[strlen("/dev/")] = 't'; - if ( strlen(slavebuf) > slavelength ) { - close ( *fd); + slavebuf[sizeof("/dev/") - 1] = 't'; + if (strlen(slavebuf) > slavelength -1) { + close(*fd); *fd = -1; -return PTY_GETPTY_SLAVE_TOOLONG; + return PTY_GETPTY_SLAVE_TOOLONG; } - strncpy ( slave, slavebuf, slavelength); - + strncpy(slave, slavebuf, slavelength); return 0; } } @@ -141,4 +136,3 @@ return PTY_GETPTY_SLAVE_TOOLONG; #endif /*HAVE__GETPTY*/ #endif /* HAVE_OPENPTY */ } - diff --git a/src/util/pty/libpty.h b/src/util/pty/libpty.h index 51d834a..552a3ef 100644 --- a/src/util/pty/libpty.h +++ b/src/util/pty/libpty.h @@ -41,6 +41,7 @@ long pty_update_utmp (int process_type,int pid, char *user, char *line, char *h long pty_logwtmp (char *tty, char * user, char *host); long pty_cleanup(char *slave, int pid, int update_utmp); +long pty_make_sane_hostname(struct sockaddr_in *, int, int, int, char **); #else /*__STDC__*/ long pty_init(); long pty_getpty(); @@ -52,6 +53,7 @@ long pty_initialize_slave(); long pty_update_utmp(); long pty_logwtmp(); long pty_cleanup(); +long pty_make_sane_hostname(); #endif /* __STDC__*/ #define __LIBPTY_H__ #endif diff --git a/src/util/pty/open_slave.c b/src/util/pty/open_slave.c index 05b83b8..7d28ea2 100644 --- a/src/util/pty/open_slave.c +++ b/src/util/pty/open_slave.c @@ -55,6 +55,8 @@ long pty_open_slave ( slave, fd) #endif + if (slave == NULL || *slave == '\0') + return PTY_OPEN_SLAVE_TOOSHORT; if (chmod(slave, 0)) return PTY_OPEN_SLAVE_CHMODFAIL; if ( chown(slave, 0, 0 ) == -1 ) diff --git a/src/util/pty/pty_err.et b/src/util/pty/pty_err.et index bcdecf4..08c126d 100644 --- a/src/util/pty/pty_err.et +++ b/src/util/pty/pty_err.et @@ -21,7 +21,7 @@ error_table pty - error_code PTY_GETPTY_STREAMS, "Failed to unlock or grant streams pty." +error_code PTY_GETPTY_STREAMS, "Failed to unlock or grant streams pty." error_code PTY_GETPTY_FSTAT, "fstat of master pty failed" @@ -42,3 +42,4 @@ error_code PTY_OPEN_SLAVE_PUSH_FAIL, "Failed to push stream on slave side of pty error_code PTY_OPEN_SLAVE_REVOKEFAIL, "Failed to revoke slave side of pty" error_code PTY_UPDATE_UTMP_PROCTYPE_INVALID, "bad process type passed to pty_update_utmp" +error_code PTY_OPEN_SLAVE_TOOSHORT, "Slave pty name is zero-length" diff --git a/src/util/pty/sane_hostname.c b/src/util/pty/sane_hostname.c new file mode 100644 index 0000000..3f9ed6b --- /dev/null +++ b/src/util/pty/sane_hostname.c @@ -0,0 +1,99 @@ +/* + * pty_make_sane_hostname: Make a sane hostname from an IP address. + * This returns allocated memory! + * + * Copyright 1999 by the Massachusetts Institute of Technology. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appear in all + * copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * M.I.T. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability + * of this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + */ +#include <com_err.h> +#include "pty-int.h" +#include "libpty.h" +#include <arpa/inet.h> + +static long +do_ntoa(struct sockaddr_in *addr, + size_t hostlen, + char **out) +{ + strncpy(*out, inet_ntoa(addr->sin_addr), hostlen); + (*out)[hostlen - 1] = '\0'; + return 0; +} + +long +pty_make_sane_hostname(struct sockaddr_in *addr, + int maxlen, + int strip_ldomain, + int always_ipaddr, + char **out) +{ + struct hostent *hp; +#ifndef NO_UT_HOST + struct utmp ut; +#else + struct utmpx utx; +#endif + char *cp, *domain; + char lhost[MAXHOSTNAMELEN]; + size_t ut_host_len; + + *out = NULL; + if (maxlen && maxlen < 16) + /* assume they meant 16, otherwise IP addr won't fit */ + maxlen = 16; +#ifndef NO_UT_HOST + ut_host_len = sizeof (ut.ut_host); +#else + ut_host_len = sizeof (utx.ut_host); +#endif + if (maxlen == 0) + maxlen = ut_host_len; + *out = malloc(ut_host_len); + if (*out == NULL) + return ENOMEM; + + if (always_ipaddr) { + return do_ntoa(addr, ut_host_len, out); + } + hp = gethostbyaddr((char *)&addr->sin_addr, sizeof (struct in_addr), + addr->sin_family); + if (hp == NULL) { + return do_ntoa(addr, ut_host_len, out); + } + strncpy(*out, hp->h_name, ut_host_len); + (*out)[ut_host_len - 1] = '\0'; + for (cp = *out; *cp != '\0'; cp++) + *cp = tolower(*cp); + + if (strip_ldomain) { + (void) gethostname(lhost, sizeof (lhost)); + hp = gethostbyname(lhost); + if (hp != NULL) { + strncpy(lhost, hp->h_name, sizeof (lhost)); + domain = strchr(lhost, '.'); + if (domain != NULL) { + for (cp = domain; *cp != '\0'; cp++) + *cp = tolower(*cp); + cp = strstr(*out, domain); + if (cp != NULL) + *cp = '\0'; + } + } + } + + if (strlen(*out) >= maxlen) { + return do_ntoa(addr, ut_host_len, out); + } + return 0; +} diff --git a/src/util/pty/update_utmp.c b/src/util/pty/update_utmp.c index 9effab1..d131b04 100644 --- a/src/util/pty/update_utmp.c +++ b/src/util/pty/update_utmp.c @@ -55,11 +55,14 @@ long pty_update_utmp (process_type, pid, username, line, host, flags) strncpy(ent.ut_line, line+sizeof("/dev/")-1, sizeof(ent.ut_line)); ent.ut_time = time(0); -#ifndef NO_UT_PID +#ifdef NO_UT_PID + if (process_type == PTY_LOGIN_PROCESS) + return 0; +#else /* NO_UT_PID */ ent.ut_pid = pid; - switch ( process_type ) { + switch (process_type) { case PTY_LOGIN_PROCESS: - ent . ut_type = LOGIN_PROCESS; + ent.ut_type = LOGIN_PROCESS; break; case PTY_USER_PROCESS: ent.ut_type = USER_PROCESS; @@ -138,7 +141,13 @@ long pty_update_utmp (process_type, pid, username, line, host, flags) #ifdef UT_EXIT_STRUCTURE_DIFFER utx.ut_exit.ut_exit = ent.ut_exit.e_exit; #else - utx.ut_exit = ent.ut_exit; +/* KLUDGE for now; eventually this will be a feature test... See PR#[40] */ +#ifdef __hpux + utx.ut_exit.__e_termination = ent.ut_exit.e_termination; + utx.ut_exit.__e_exit = ent.ut_exit.e_exit; +#else + /*xxx do nothing for now; we don't even know the structure member exists*/ +#endif #endif utx.ut_tv.tv_sec = ent.ut_time; utx.ut_tv.tv_usec = 0; @@ -185,5 +194,9 @@ long pty_update_utmp (process_type, pid, username, line, host, flags) #endif /* HAVE_SETUTENT */ - return ptyint_update_wtmp(&ent, host, userbuf); + /* Don't record LOGIN_PROCESS entries. */ + if (process_type == PTY_LOGIN_PROCESS) + return 0; + else + return ptyint_update_wtmp(&ent, host, userbuf); } diff --git a/src/util/pty/update_wtmp.c b/src/util/pty/update_wtmp.c index c2f9461..b65b870 100644 --- a/src/util/pty/update_wtmp.c +++ b/src/util/pty/update_wtmp.c @@ -25,6 +25,9 @@ #define WTMP_FILE _PATH_WTMP #endif +#if !defined(WTMPX_FILE) && defined(_PATH_WTMPX) && defined(HAVE_UPDWTMPX) +#define WTMPX_FILE _PATH_WTMPX +#endif /* if it is *still* missing, assume SunOS */ #ifndef WTMP_FILE @@ -40,6 +43,7 @@ long ptyint_update_wtmp (ent , host, user) struct utmp ut; struct stat statb; int fd; + time_t uttime; #ifdef HAVE_UPDWTMPX struct utmpx utx; @@ -71,7 +75,8 @@ long ptyint_update_wtmp (ent , host, user) #ifndef NO_UT_HOST (void)strncpy(ut.ut_host, ent->ut_host, sizeof(ut.ut_host)); #endif - (void)time(&ut.ut_time); + (void)time(&uttime); + ut.ut_time = uttime; #if defined(HAVE_GETUTENT) && defined(USER_PROCESS) if (ent->ut_name) { if (!ut.ut_pid) diff --git a/src/util/send-pr/Makefile.in b/src/util/send-pr/Makefile.in index 0c71461..2f29539 100644 --- a/src/util/send-pr/Makefile.in +++ b/src/util/send-pr/Makefile.in @@ -1,7 +1,7 @@ # # Makefile for building a standalone send-pr. # -RELEASE=1.0 +RELEASE=1.0pl1 SUBMITTER=net sendprname = krb5-send-pr EMACS=emacs @@ -24,21 +24,19 @@ install-sid: install-sid.sh sed -e 's,@ADMIN_BINDIR@,$(ADMIN_BINDIR),g' $(srcdir)/install-sid.sh > install-sid install:: all - if [ -d $(prefix) ]; then true ; else mkdir $(prefix) ; fi - if [ -d $(ADMIN_BINDIR) ]; then true ; else mkdir $(ADMIN_BINDIR) ; fi - cp send-pr $(ADMIN_BINDIR)/$(sendprname) - chmod 755 $(ADMIN_BINDIR)/$(sendprname) - cp install-sid $(ADMIN_BINDIR) - chmod 755 $(ADMIN_BINDIR)/install-sid - if [ -d $(datadir) ] ; then true ; else mkdir $(datadir) ; fi - if [ -d $(datadir)/gnats ] ; then true ; else mkdir $(datadir)/gnats ; fi - cp $(srcdir)/categories $(datadir)/gnats/mit - chmod 644 $(datadir)/gnats/mit - -parent=`echo $(man1dir)|sed -e 's@/[^/]*$$@@'`; \ + if [ -d $(DESTDIR)$(prefix) ]; then true ; else mkdir $(DESTDIR)$(prefix) ; fi + if [ -d $(DESTDIR)$(ADMIN_BINDIR) ]; then true ; else mkdir $(DESTDIR)$(ADMIN_BINDIR) ; fi + cp send-pr $(DESTDIR)$(ADMIN_BINDIR)/$(sendprname) + chmod 755 $(DESTDIR)$(ADMIN_BINDIR)/$(sendprname) + if [ -d $(DESTDIR)$(datadir) ] ; then true ; else mkdir $(DESTDIR)$(datadir) ; fi + if [ -d $(DESTDIR)$(datadir)/gnats ] ; then true ; else mkdir $(DESTDIR)$(datadir)/gnats ; fi + cp $(srcdir)/categories $(DESTDIR)$(datadir)/gnats/mit + chmod 644 $(DESTDIR)$(datadir)/gnats/mit + -parent=`echo $(DESTDIR)$(man1dir)|sed -e 's@/[^/]*$$@@'`; \ if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi - if [ -d $(man1dir) ] ; then true ; else mkdir $(man1dir) ; fi - cp $(srcdir)/send-pr.1 $(man1dir)/$(sendprname).1 - chmod 644 $(man1dir)/$(sendprname).1 + if [ -d $(DESTDIR)$(man1dir) ] ; then true ; else mkdir $(DESTDIR)$(man1dir) ; fi + sed -e 's/send-pr/$(sendprname)/g' $(srcdir)/send-pr.1 > $(DESTDIR)$(man1dir)/$(sendprname).1 + chmod 644 $(DESTDIR)$(man1dir)/$(sendprname).1 clean:: rm -f install-sid send-pr send-pr.el* diff --git a/src/util/send-pr/send-pr.sh b/src/util/send-pr/send-pr.sh index 96a9c24..e15ea5d 100644 --- a/src/util/send-pr/send-pr.sh +++ b/src/util/send-pr/send-pr.sh @@ -55,22 +55,30 @@ GNATS_SITE=mit # What mailer to use. This must come after the config file, since it is # host-dependent. -MAIL_AGENT="/usr/sbin/sendmail -oi -t" -if [ ! -x `echo $MAIL_AGENT|sed 's/ .*//'` ] ; then - ( [ -x /usr/lib/sendmail ] && MAIL_AGENT="/usr/lib/sendmail -oi -t" ) || \ - ( [ -x /usr/sbin/sendmail ] && MAIL_AGENT="/usr/sbin/sendmail -oi -t " ) || \ - MAIL_AGENT="sendmail -oi -t " -fi +for dir in /usr/lib /usr/sbin /usr/ucblib; do + if test -f $dir/sendmail; then + MAIL_AGENT="$dir/sendmail -oi -t" + break + fi +done # How to read the passwd database. PASSWD="cat /etc/passwd" +if test -f /bin/domainname && test -n "`/bin/domainname`"; then + if test -f /usr/bin/niscat && + /usr/bin/niscat passwd.org_dir > /dev/null 2>&1; then + PASSWD="/usr/bin/niscat passwd.org_dir" + elif test -f /usr/bin/ypcat && /usr/bin/ypcat passwd > /dev/null 2>&1; then + PASSWD="/usr/bin/ypcat passwd" + fi +fi -ECHON=bsd +# Figure out how to do "echo -n" -if [ $ECHON = bsd ] ; then +if test "`echo -n foo`" = foo; then ECHON1="echo -n" ECHON2= -elif [ $ECHON = sysv ] ; then +elif test "`echo 'foo\c'`" = foo; then ECHON1=echo ECHON2='\c' else |