Newsgroups: fj.questions.unix
Path: galaxy.trc.rwcp.or.jp!sparky!uunet!ccut!wnoc-tyo-news!etl.go.jp!tacho!tinygw!takahasi
From: takahasi@tiny.or.jp (Hironobu Takahashi)
Subject: Re: Change password
Organization: Tsukuba internet Club (TINY net)
Distribution: fj
Date: Tue, 9 Jun 1992 12:02:48 GMT
Message-ID: <1992Jun9.120248.15550@tiny.or.jp>
References: <365@kocb.kocb.astem.or.jp> <1992Jun7.084211.10433@tiny.or.jp> <268@lupin.src.ricoh.co.jp>
Lines: 155
Xref: galaxy.trc.rwcp.or.jp fj.questions.unix:2748
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.questions.unix&nb=2748&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

>set UID $B$7$?%W%m%0%i%`Cf$G(B system $B$r;H$C$F$O$$$1$^$;$s!%M-L>$J%;%-%e%j%F(B
>$B%#%[!<%k$G$9!%(Bexecl $B$J$I$r;H$$$^$7$g$&!%(B

$B$H$$$&$o$1$G!"D($j$b$;$:(B C $BHG$N(B version up $B$G$9!#(B
$B$J$K$7$m!"A0$N$O4m81$@$+$i(B Cancel $B$M(B :-)

# $B$5$F!"$3$l$G$b7j$O$"$k$+$J!)!)(B

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#"End of archive 1 (of 1)."
# Contents:  Makefile Readme cpass.c
# Wrapped by takahasi@tinygw on Tue Jun  9 20:56:13 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(187 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile of cpass
X
XBINDIR=/usr/local/bin
X
Xcpass: cpass.c
Xcc -o cpass cpass.c
X
Xinstall: cpass
Xstrip cpass
Xmv cpass ${BINDIR}/
Xchown root ${BINDIR}/cpass
Xchmod 04711 ${BINDIR}/cpass
END_OF_FILE
if test 187 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'Readme' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Readme'\"
else
echo shar: Extracting \"'Readme'\" \(558 characters\)
sed "s/^X//" >'Readme' <<'END_OF_FILE'
X$B!{(B cpass $B$N(B install 
X
X1. cpass $B$r%$%s%9%H!<%k$9$k>l=j$r7h$a!"(BMakefile $B$N(B BINDIR $B$K5-F~$9$k(B
X
X2. % make
X
X3. % su
X   # make install
X
X$B!{(B cpass $B$N(B authorize file
X
X/etc/passwd.authority $B$K0J2<$N$h$&$K5-F~$9$k!#Nc$($P6541$N(B ID $B$,(B takahasi
X$B$G3X@8$,(B e0001.... $B$@$H$9$k$H(B
X
Xtakahasi  e0001
Xtakahasi  e0002
Xtakahasi  e0003
Xtakahasi  e0004
Xtakahasi  e0005
Xtakahasi  e0006
Xtakahasi  e0007
X
X$B$N$h$&$K=q$/!#$b$7$b$3$l0J30$N9T$,8+$D$+$l$P!"(Bcpass $B$O(B error $B%a%C%;!<%8(B
X$B$r=P$7$F=*N;$9$k!#(B
X
END_OF_FILE
if test 558 -ne `wc -c <'Readme'`; then
    echo shar: \"'Readme'\" unpacked with wrong size!
fi
# end of 'Readme'
fi
if test -f 'cpass.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cpass.c'\"
else
echo shar: Extracting \"'cpass.c'\" \(1375 characters\)
sed "s/^X//" >'cpass.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <pwd.h>
X#include <sys/types.h>
X
X#define BSIZE 256
X#define AUTHFILE "/etc/passwd.authority"
X
Xstruct passwd *getpwuid();
Xuid_t getuid();
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X    char buffer[BSIZE], authority[BSIZE], user[BSIZE];
X    struct passwd *pw;
X    FILE *auth;
X
X    if (argc != 2) {
Xfprintf(stderr, "Usage: %s userid\n", argv[0]);
Xexit (1); }
X    if ((pw = getpwuid((int)getuid())) == NULL) {
Xfprintf(stderr, "Not found: your id  No. = %d\n", getuid());
Xexit (2); }
X    if ((auth = fopen(AUTHFILE, "r")) == NULL) {
Xfprintf(stderr, "Cant open authorize file %s\n", AUTHFILE);
Xexit (3); }
X    if (strlen(argv[1]) > 8) {
Xfprintf(stderr, "userid id is too long! %s\n", argv[1]);
Xexit (4); }
X    while(fgets(buffer, BSIZE, auth) != NULL) {
Xif (strlen(buffer) >= BSIZE-1) {
X    fprintf(stderr, "Too long line in the authorize file %s\n", AUTHFILE);
X    exit (5); }
Xif (sscanf(buffer, "%s%s", authority, user) != 2) {
X    fprintf(stderr, "Illegal line in authorize file: %s\n", buffer);
X    exit (6); }
Xif ((strcmp(authority, pw->pw_name) == 0) &&
X    (strcmp(user, argv[1]) == 0)) {
X    if (setuid(0) != 0) {
Xfprintf(stderr, "Fail to set uid\n");
Xexit (7); }
X    execl("/bin/passwd", "/bin/passwd", argv[1], 0);
X    system(buffer);
X    exit(0);}
X    }
X    fprintf(stderr, "You are not authorized\n");
X    exit (8);
X}
END_OF_FILE
if test 1375 -ne `wc -c <'cpass.c'`; then
    echo shar: \"'cpass.c'\" unpacked with wrong size!
fi
chmod +x 'cpass.c'
# end of 'cpass.c'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
