Something missing in chmode.c ?
David C Lawrence
tale at pawl.rpi.edu
Thu Jun 8 09:52:41 AEST 1989
Many thanks to Guy Harris for clearing me up regarding the SYSV issues
and what is really the correct test for a directory (the one I used
was bogus). His comments were very educational and I appreciate them.
Now I think everything here is correct. If you applied the small
patch I gave yesterday then you can apply this one without any
problems. If you just threw the whole permit.c (and chmode.c) away,
I'm not surprised because "chmod 754 prog" still seems quicker for me
to type than "chmod rwxr-xr-- prog". It is handy though when you know
what the permission should look like but you're tired and out of
caffeine and now the dishwasher is overflowing so you can't remember
either the octal or mnemonic for rwsr-lr-x. My dishwasher hasn't
overflowed in at least two years though ....
% diff -c permit.c.old permit.c
*** /home/h/tale/src/permit.c.old Wed Jun 7 19:40:11 1989
--- /home/h/tale/src/permit.c Wed Jun 7 19:34:22 1989
***************
*** 3,19 ****
* 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
*/
/*
* Usage is: permit rwxrwxrwx-pattern file(s)
*
! * This deals fine with all current permission schemes on Sun/BSD
! * (and mostly on SYSV) systems of which I am aware. I'm not sure
! * how portable it is beyond that.
*
* It will accept patterns like rwsr-S--t (bozotic, I realize) without
* complaint and try to permit accordingly. It even gives you a warning
--- 3,25 ----
* 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: Wed Jun 7 19:34:22 1989
! * Update Count : 7
! * Status : Works just fine for BSD/SYSV
*/
+ /* History
+ * 7-Jun-1989 David C Lawrence
+ * Last Modified: Wed Jun 7 19:29:37 1989 #7 (David C Lawrence)
+ * Fixed the test to see if a directory was being chmod'ed
+ * Everything should be fine for SYSV now (Thanks Guy!)
+ */
+
/*
* Usage is: permit rwxrwxrwx-pattern file(s)
*
! * This deals fine with all current permission schemes on SYSV/BSD
! * systems of which I am aware. I'm not sure how portable it is beyond that.
*
* It will accept patterns like rwsr-S--t (bozotic, I realize) without
* complaint and try to permit accordingly. It even gives you a warning
***************
*** 20,29 ****
* message if you try to set the sticky bit on a file without being
* the superuser (the regular chmod doesn't).
*
- * Caveat: I couldn't get to a SYSV machine to try this out; I
- * have a feeling sticky bit stuff might be wrong there, but I am
- * not sure.
- *
* BUGS: none that I know of at the moment, but it does have really
* dorky error messages.
*/
--- 26,31 ----
***************
*** 71,77 ****
break;
case 'S':
case 's':
! case 'l': /* 'l' is SYSV 'S' for setgid (?) */
if (loop%3 != 2 || loop == 8 || (ch == 'l' && loop != 5)) {
(void)fprintf(stderr,"%s: 's'et[ug]id permission misplaced\n",pname);
exit(99);
--- 73,79 ----
break;
case 'S':
case 's':
! case 'l': /* 'l' is SYSV 'S' for group permission */
if (loop%3 != 2 || loop == 8 || (ch == 'l' && loop != 5)) {
(void)fprintf(stderr,"%s: 's'et[ug]id permission misplaced\n",pname);
exit(99);
***************
*** 127,133 ****
(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++;
--- 129,135 ----
(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) != S_IFDIR)) {
(void)fprintf(stderr,
"%s: couldn't set sticky bit for %s\n",pname,argv[argc]);
rc++;
***************
*** 136,139 ****
--- 138,142 ----
}
/* exit with the number of files we were not able to permit as requested */
exit(rc);
+ /*NOTREACHED*/
}
--
(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