Something missing in chmode.c ?
David C Lawrence
tale at pawl.rpi.edu
Wed Jun 7 12:46:47 AEST 1989
<10152 at watcgl.waterloo.edu>, rpinchback at watpix.waterloo.edu (Reid M Pinchback):
> The file whoami.h is included in line 22 of the chmode.c program, but
> this is not a standard include file (at least not at U of Waterloo).
> Is this an oversight in the submission, or a reliance on a System V
> characteristic, or what? Could somebody post the contents of this
> file, or describe what the consequences are of not including it are?
<whoami.h> is not in the SYSV that I know; it was, I believe, in
TOPS-20 (twenex) systems. For what I could tell by glancing at the
code for chmode I could not see anything that looks like it would have
come out of whoami.h, unless that is where chmod is declared.
For those few people who actually thought that permit.c, which I
posted about a week ago, was worth saving this patch corrects an
oversight which caused it to core dump if you tried to set the sticky
bit when you weren't the superuser and it was compiled with "gcc -g".
In the wee hours of the morning I had only made space for the stat
struct pointer and not the whole struct itself. Oh well.
I should probably change the SYSV comments (about not being sure
whether it was SYSV-ok) since I finally did get on a SYSV machine and
try it. It worked fine but, for the machine I was on, would never set
the sticky bit on anything (including directories). I wasn't
superuser and I wasn't sure whether non-superuser can set the sticky
bit for SYSV anything. Strangely enough it always told me that it
couldn't set the sticky bit and I am not sure how it made it through
the tests to get to the message (presumably it should have told me it
was working on directories). I didn't ponder on it for more than 30
seconds or so though because the 3b2 I was on didn't even have a
debugger that I could find. AT&T lint doesn't like that second arg to
stat, but BSD doesn't say anything about it. (Can someone tell me why?)
% diff -c src/permit.c.orig src/permit.c
*** src/permit.c.orig Sat Jun 3 20:37:26 1989
--- src/permit.c Sat Jun 3 15:00:41 1989
***************
*** 3,10 ****
* Author : David C Lawrence <tale at pawl.rpi.edu>
* Created On : Sat Jun 3 03:32:10 1989
* Last Modified By: David C Lawrence
! * Last Modified On: Sat Jun 3 04:04:08 1989
! * Update Count : 4
* Status : Works just fine for BSD/Sun, maybe SYSV
*/
--- 3,10 ----
* Author : David C Lawrence <tale at pawl.rpi.edu>
* Created On : Sat Jun 3 03:32:10 1989
* Last Modified By: David C Lawrence
! * Last Modified On: Sat Jun 3 15:00:41 1989
! * Update Count : 5
* Status : Works just fine for BSD/Sun, maybe SYSV
*/
***************
*** 107,113 ****
{
int permission, rc=0;
! struct stat *statbuf;
if (argc < 3 || strlen(argv[1]) != 9) {
(void)fprintf(stderr,"Usage: %s 9-char-permission file(s)\n",argv[0]);
--- 107,113 ----
{
int permission, rc=0;
! struct stat statbuf;
if (argc < 3 || strlen(argv[1]) != 9) {
(void)fprintf(stderr,"Usage: %s 9-char-permission file(s)\n",argv[0]);
***************
*** 124,133 ****
(void)fprintf(stderr,"%s: %s: %s\n",pname,argv[argc],sys_errlist[errno]);
rc++;
} else {
! (void)stat(argv[argc], statbuf); /* since chmod succeeded, stat should */
/* could possibly check here for clearing of setgid, too */
if ((geteuid() != 0) && (permission & S_ISVTX) &&
! !(statbuf->st_mode & S_IFDIR)) {
(void)fprintf(stderr,
"%s: couldn't set sticky bit for %s\n",pname,argv[argc]);
rc++;
--- 124,133 ----
(void)fprintf(stderr,"%s: %s: %s\n",pname,argv[argc],sys_errlist[errno]);
rc++;
} else {
! (void)stat(argv[argc],&statbuf); /* since chmod succeeded, stat should */
/* could possibly check here for clearing of setgid, too */
if ((geteuid() != 0) && (permission & S_ISVTX) &&
! !(statbuf.st_mode & S_IFDIR)) {
(void)fprintf(stderr,
"%s: couldn't set sticky bit for %s\n",pname,argv[argc]);
rc++;
--
(setq mail '("tale at pawl.rpi.edu" "tale at itsgw.rpi.edu" "tale at rpitsmts.bitnet"))
"I realize the Internet isn't the whole world, but it is the center of it."
-- Greg Woods
More information about the Alt.sources
mailing list