Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!csd4.milw.wisc.edu!leah!rpi!rpi.edu!tale From: tale@pawl.rpi.edu (David C Lawrence) Newsgroups: alt.sources Subject: Re: Something missing in chmode.c ? Message-ID: Date: 7 Jun 89 02:46:47 GMT References: <21508@iuvax.cs.indiana.edu> <10152@watcgl.waterloo.edu> Sender: usenet@rpi.edu Reply-To: tale@pawl.rpi.edu Lines: 98 In-reply-to: rpinchback@watpix.waterloo.edu's message of 6 Jun 89 23:25:04 GMT <10152@watcgl.waterloo.edu>, rpinchback@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? 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 * 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 * 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@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet")) "I realize the Internet isn't the whole world, but it is the center of it." -- Greg Woods