X if ((S_ISUID & mMode) != (S_ISUID & statb_dest.st_mode)) {
X (void)fprintf(stderr, "%s: `%s\' setuid bit changed, now %s\n", progname, acDestPath, apcOO[0 != (S_ISUID & mMode)]);
X }
X if ((S_ISGID & mMode) != (S_ISGID & statb_dest.st_mode)) {
X (void)fprintf(stderr, "%s: `%s\' setgid bit changed, now %s\n", progname, acDestPath, apcOO[0 != (S_ISGID & mMode)]);
X }
X if ((S_ISVTX & mMode) != (S_ISVTX & statb_dest.st_mode)) {
X (void)fprintf(stderr, "%s: `%s\' sticky bit changed, now %s\n", progname, acDestPath, apcOO[0 != (S_ISVTX & mMode)]);
X }
X }
X
X /* here we really want to check against the default stuff if the
X * modes (owner, group, mode) of the file are not what the default
X * would give, choke a little (and the modes are not from the cmd line)
X * but this would be too much work; let instck -G save us
X * in the broken cases.
X */
X
#if defined(CONFIG)
X /* time to chekc the group and owner against our check list
X */
X if (Check.ffound) {
X register int bFail = FALSE;
X
X if ((char *)0 != Check.pclink) {
X (void)fprintf(stderr, "%s: `%s\' be a %s link to `%s\'\n", progname, acDestPath, ':' == Check.pclink[0] ? "hard" : "symbolic", Check.pclink+1);
X bFail = TRUE;
X goto quit;
X }
X if ('*' == Check.acowner[0]) {
X /* OK no check */;
X } else if (Check.fbangowner) {
X if (Check.uid == pwd->pw_uid) {
X (void)fprintf(stderr, "%s: `%s\' should not have owner %s\n", progname, acDestPath, Check.acowner);
X bFail = TRUE;
X }
X } else if (Check.uid != pwd->pw_uid) {
X (void)fprintf(stderr, "%s: `%s\' should have owner %s (not %s)\n", progname, acDestPath, Check.acowner, pwd->pw_name);
X bFail = TRUE;
X }
X
X if ('*' == Check.acgroup[0]) {
X /*OK */;
X } else if (Check.fbanggroup) {
X if (Check.gid == grp->gr_gid) {
X (void)fprintf(stderr, "%s: `%s\' should not have group %s\n", progname, acDestPath, Check.acgroup);
X bFail = TRUE;
X }
X } else if (Check.gid != grp->gr_gid) {
X (void)fprintf(stderr, "%s: `%s\' should have group %s (not %s)\n", progname, acDestPath, Check.acgroup, grp->gr_name);
X bFail = TRUE;
X }
X
X switch (Check.acmode[0]) {
X case '?':
X case '*':
X /*OK*/;
X case '-':
X if (Check.mmust != (mMode & Check.mmust)) {
X (void)fprintf(stderr, "%s: `%s\' mode %04o doesn\'t have bits to match %s (%04o)\n", progname, acDestPath, mMode, Check.acmode, Check.mmust);
X bFail = TRUE;
X } else if (0 != (mMode &~ (Check.mmust|Check.moptional))) {
X (void)fprintf(stderr, "%s: `%s\' mode %04o has too many bits to match %s (%04o)\n", progname, acDestPath, mMode, Check.acmode, Check.mmust|Check.moptional);
X bFail = TRUE;
X }
X if (0 != (S_ISUID & mMode) ? 0 == (S_ISUID & (Check.mmust|Check.moptional)) : 0 != (S_ISUID & Check.mmust)) {
X (void)fprintf(stderr, "%s: `%s\' setuid bit must be %s\n", progname, acDestPath, apcOO[0 == (S_ISUID & mMode)]);
X bFail = TRUE;
X }
X if (0 != (S_ISGID & mMode) ? 0 == (S_ISGID & (Check.mmust|Check.moptional)) : 0 != (S_ISGID & Check.mmust)) {
X (void)fprintf(stderr, "%s: `%s\' setgid bit must be %s\n", progname, acDestPath, apcOO[0 == (S_ISGID & mMode)]);
X bFail = TRUE;
X }
X if (0 != (S_ISVTX & mMode) ? 0 == (S_ISVTX & (Check.mmust|Check.moptional)) : 0 != (S_ISVTX & Check.mmust)) {
X (void)fprintf(stderr, "%s: `%s\' sticky bit must be %s\n", progname, acDestPath, apcOO[0 == (S_ISVTX & mMode)]);
X bFail = TRUE;
X }
X break;
X default:
X (void)fprintf(stderr, "%s: `%s\' must be a %s\n", progname, acDestPath, NodeType(Check.mtype, (char *)0));
X bFail = TRUE;
X break;
X case '!':
X if (fDelete) {
X break;
X }
X /* fall through */
X case '~':
X (void)fprintf(stderr, "%s: `%s\' should not be %s", progname, acDestPath, fDelete ? "removed" : "installed");
X if ((char *)0 != Check.pcmesg && '\000' != Check.pcmesg[0])
X (void)fprintf(stderr, ", %s", Check.pcmesg);
X (void)fputc('\n', stderr);
X bFail = TRUE;
X break;
X }
X
X switch (Check.chstrip) {
X case CF_ANY:
X break;
X case CF_STRIP:
X if (!fDelete && !Strip) {
X (void)fprintf(stderr, "%s: `%s\' must be strip\'ed (use -s)\n", progname, acDestPath);
X bFail = TRUE;
X }
X break;
X case CF_RANLIB:
X if (!fDelete && !Ranlib) {
X (void)fprintf(stderr, "%s: `%s\' must be ranlib\'ed (use -l)\n", progname, acDestPath);
X bFail = TRUE;
X }
X break;
X case CF_NONE:
X if (!fDelete && (Strip || Ranlib)) {
X (void)fprintf(stderr, "%s: `%s\' must not be strip\'ed or ranlib\'ed (do not use -l or -s)\n", progname, acDestPath);
X bFail = TRUE;
X }
X break;
X }
X
X quit:
X if (FALSE != bFail) {
X (void)fprintf(stderr, "%s: `%s\' failed check in `%s\'\n", progname, acDestPath, pcSpecial);
X (void)fprintf(stderr, "%s: `%s\' will not set%cid based on mode %s and %s %s\n", progname, acDestPath, chSet, apcFrom[iMFrom], pcSet, apcFrom[iFrom]);
X if ('\000' != acNewBack[0]) {
X (void)Rename(acNewBack, acBackPath, "return");
X }
X return FAIL;
X }
X }
X
X /* Unlink the current file (which DoBackup() linked to the backup
X * file) but only if it exists.
X */
X if (FALSE != bDestExists) {
X if (FALSE != fTrace) {
X (void)printf("%s: rm -f %s\n", progname, acDestPath);
X } else if (-1 != unlink(acDestPath)) {
X /* OK */;
X } else if (ETXTBSY != errno) {
X (void)fprintf(stderr, "%s: unlink: %s: %s\n", progname, acDestPath, strerror(errno));
X if ('\000' != acNewBack[0]) {
X (void)Rename(acNewBack, acBackPath, "return");
X }
X return FAIL;
X } else {
X /* might be the last link to a running binary under
X * sys5, sigh, link to a bogus name and try again...
X */
X *pcSlash = '\000';
X (void)sprintf(acBusyPath, "%s/%s", acBackPath, TMPBOGUS);
X *pcSlash = '/';
X MkOld(acBusyPath);
X (void)Mytemp(acBusyPath);
X if (-1 == Rename(acDestPath, acBusyPath, fVerbose ? "moving busy file" : (char *)0)) {
X if ('\000' != acNewBack[0]) {
X (void)Rename(acNewBack, acBackPath, "return");
X }
X return FAIL;
X }
X }
X }
X
X BlockSigs();
X
X if (FAIL == Rename(pcFilePath, acDestPath, (char *)0)) {
X /*
X * OUCH! why can't we rename this puppy? Here we are in
X * big trouble: can't go back in some cases, can't go
X * forward in others. Let the user figure it out.
X */
X (void)fprintf(stderr, "%s: no currently installed file, aborting\n", progname);
X exit(99);
X }
X
X /* We have moved the file in, we are commited.
X * We *must* complete the installation at all costs now.
X * There is no turning back from here on; no more return FAIL.
X */
X if (FALSE != f1Copy && pcFilePath != acNewBack && '\000' != acNewBack[0]) {
X if (FALSE != fTrace) {
X (void)printf("%s: rm -f %s\n", progname, acNewBack);
X } else if (-1 != unlink(acNewBack)) {
X /* OK */;
X } else if (ETXTBSY != errno) {
X (void)fprintf(stderr, "%s: unlink: %s: %s\n", progname, acNewBack, strerror(errno));
X } else {
X /* the last link to a running binary (SYSV)
X * move it to a bogus name
X */
X *pcSlash = '\000';
X (void)sprintf(acBusyPath, "%s/%s", acBackPath, TMPBOGUS);
X *pcSlash = '/';
X /* the MkOld below is unneeded
X * (we know of at least one file in there)
X */
X MkOld(acBusyPath);
X (void)Mytemp(acBusyPath);
X if (-1 == Rename(acNewBack, acBusyPath, "moving busy backup file")) {
X (void)fprintf(stderr, "%s: rename %s to %s: %s\n", progname, acNewBack, acBusyPath, strerror(errno));
X }
X }
X }
X
X /* If requested, strip the installed File or ranlib it. Have to do this
X * before ChOwnGrp and ChGroup or 2.9BSD drops the setuid bits...
X */
X if (FALSE != Strip) {
X if (FALSE != fVerbose) {
X (void)printf("%s: %s %s\n", progname, acStrip, acDestPath);
X }
X if (0 != RunCmd(acStrip, acDestPath, (char *)0)) {
X (void)fprintf(stderr, "%s: `%s %s\' failed, run strip by hand\?\n", progname, acStrip, acDestPath);
X }
X }
X
X if (FALSE != Ranlib) {
#if HAVE_RANLIB
X /* on the pdp11/70 this kludge made the ranlib command work
X * I don't think we ever knew why... now I don't have an 11
X * to find out if we still need it. Maybe chmod changed
X * the times on the file?
X */
#if defined(pdp11)
X ChMode(acDestPath, mMode);
#endif
X if (FALSE != fVerbose) {
X (void)printf("%s: %s %s\n", progname, acRanlib, acDestPath);
X }
X if (0 != RunCmd(acRanlib, acDestPath, (char *)0)) {
X (void)fprintf(stderr, "%s: `%s %s\' failed, run ranlib by hand\?\n", progname, acRanlib, acDestPath);
X }
#else /* on sysV fake it, same cmd that way */
X if (FALSE != fVerbose) {
X (void)printf("%s: ranlib for `%s\' done by ar(1)\n", progname, acDestPath);
X }
#endif /* do we really run ranlib(1) */
X }
X
X if ((char *)0 != pcHLink || (char *)0 != pcSLink) {
X if (LaunchLinks(bDestExists ? & statb_dest : (struct stat *)0, acDestPath, pcHLink, pcSLink, mMode, pwd, grp)) {
X
X (void)fprintf(stderr, "%s: links failed, finishing installation anyway\n", progname);
X }
X }
X
X /* Change ownership, group, timestamp, and mode of installed file
X * (chmod must be done last or setuid bits are dropped under 2.9bsd)
X */
X if (FALSE != bHaveRoot) {
X ChOwnGrp(acDestPath, pwd, grp);
X } else {
X ChGroup(acDestPath, grp);
X }
X if (FALSE != KeepTimeStamp) {
X ChTimeStamp(acDestPath, & statb_file);
X }
X ChMode(acDestPath, mMode);
X
X UnBlockSigs();
X
X /* re-stat, we may have changed link count
X */
X if (-1 != stat(acBackPath, & statb_dest) && 1 != statb_dest.st_nlink) {
X if ((char *)0 != pcHLink) {
X (void)printf("%s: -H option may not have listed all the links to %s, still %d left\n", progname, acDestPath, statb_dest.st_nlink - 1);
X } else {
X (void)printf("%s: %s may still be installed someplace, link count is too big (%d)\n", progname, acBackPath, statb_dest.st_nlink);
X }
X *pcSlash = '\000';
X (void)printf("%s: use `instck -i %s' to repair link counts\n", progname, acBackPath);
X *pcSlash = '/';
X }
X
X /*
X * and turn off special bits on backup -- in case installation
X * was security related
X */
X if (FALSE != bDestExists && FALSE != bBackup && 0 != (statb_dest.st_mode & ~SAFEMASK)) {
X ChMode(acBackPath, (int)statb_dest.st_mode & SAFEMASK);
X }
X
#if defined(INST_FACILITY)
X /*
X * syslog out change if we are the superuser and we really changed
X * something
X */
X if (bHaveRoot && FALSE == fTrace) {
X (void)sprintf(acLogBuf, pcLogStat, acDestPath, pwd->pw_name, grp->gr_name, mMode, pcGuilty);
X syslog(LOG_INFO, acLogBuf);
X }
#endif /* we should syslog changes */
X
#if defined(CONFIG)
X /* if the file is in a check list report installation message
X */
X if (Check.ffound && '\000' != Check.pcmesg[0]) {
X (void)printf("%s: %s: %s\n", progname, acDestPath, Check.pcmesg);
X }
#endif /* have check list to output a comment */
X
X /* if we are supposed to dink it, do it now, else
X * if requested, show the results of the installation with ls(1)
X */
X if (fDelete) {
X if (fTrace) {
X (void)printf("%s: rm -f %s\n", progname, acDestPath);
X } else if (-1 == unlink(acDestPath)) {
X fprintf(stderr, "%s: unlink: %s: %s\n", progname, acDestPath, strerror(errno));
X return FAIL;
X }
X (void)RunCmd(acLs, acLsArgs, acBackPath);
X } else if (FALSE != fVerbose) {
X if (FALSE != bBackup) {
X (void)RunCmd(acLs, acLsArgs, acBackPath);
X }
X (void)RunCmd(acLs, acLsArgs, acDestPath);
X }
X
X return SUCCEED;
}
Purdue
chmod 0444 install.d/file.c ||
echo 'restore of install.d/file.c failed'
Wc_c="`wc -c < 'install.d/file.c'`"
test 46361 -eq "$Wc_c" ||
echo 'install.d/file.c: original size 46361, current size' "$Wc_c"
fi
# ============= instck/instck.h ==============
if test ! -d 'instck'; then
echo 'x - creating directory instck'
mkdir 'instck'
fi
if test -f 'instck/instck.h' -a X"$1" != X"-c"; then