biff.c (92920) | biff.c (99632) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#if 0 41#ifndef lint 42static char sccsid[] = "@(#)biff.c 8.1 (Berkeley) 6/6/93"; 43#endif 44#endif 45 46#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39 40#if 0 41#ifndef lint 42static char sccsid[] = "@(#)biff.c 8.1 (Berkeley) 6/6/93"; 43#endif 44#endif 45 46#include <sys/cdefs.h> |
47__FBSDID("$FreeBSD: head/usr.bin/biff/biff.c 92920 2002-03-22 01:22:50Z imp $"); | 47__FBSDID("$FreeBSD: head/usr.bin/biff/biff.c 99632 2002-07-09 02:16:49Z johan $"); |
48 49#include <sys/stat.h> 50 51#include <err.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <unistd.h> 55 --- 20 unchanged lines hidden (view full) --- 76 77 if ((name = ttyname(STDERR_FILENO)) == NULL) 78 err(2, "unknown tty"); 79 80 if (stat(name, &sb)) 81 err(2, "stat"); 82 83 if (*argv == NULL) { | 48 49#include <sys/stat.h> 50 51#include <err.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <unistd.h> 55 --- 20 unchanged lines hidden (view full) --- 76 77 if ((name = ttyname(STDERR_FILENO)) == NULL) 78 err(2, "unknown tty"); 79 80 if (stat(name, &sb)) 81 err(2, "stat"); 82 83 if (*argv == NULL) { |
84 (void)printf("is %s\n", sb.st_mode & S_IXUSR ? "y" : "n"); 85 return(sb.st_mode & S_IXUSR ? 0 : 1); | 84 (void)printf("is %s%s\n", 85 sb.st_mode & S_IXUSR ? "y" : 86 sb.st_mode & S_IXGRP ? "b" : "n"); 87 return(sb.st_mode & (S_IXUSR | S_IXGRP) ? 0 : 1); 88 |
86 } 87 88 switch(argv[0][0]) { 89 case 'n': | 89 } 90 91 switch(argv[0][0]) { 92 case 'n': |
90 if (chmod(name, sb.st_mode & ~S_IXUSR) < 0) | 93 if (chmod(name, sb.st_mode & ~(S_IXUSR | S_IXGRP)) < 0) |
91 err(2, "%s", name); 92 break; 93 case 'y': | 94 err(2, "%s", name); 95 break; 96 case 'y': |
94 if (chmod(name, sb.st_mode | S_IXUSR) < 0) | 97 if (chmod(name, (sb.st_mode & ~(S_IXUSR | S_IXGRP)) | S_IXUSR) < 0) |
95 err(2, "%s", name); 96 break; | 98 err(2, "%s", name); 99 break; |
100 case 'b': 101 if (chmod(name, (sb.st_mode & ~(S_IXUSR | S_IXGRP)) | S_IXGRP) < 0) 102 err(2, "%s", name); 103 break; |
|
97 default: 98 usage(); 99 } | 104 default: 105 usage(); 106 } |
100 return(sb.st_mode & S_IXUSR ? 0 : 1); | 107 return(sb.st_mode & (S_IXUSR | S_IXGRP) ? 0 : 1); |
101} 102 103static void 104usage() 105{ | 108} 109 110static void 111usage() 112{ |
106 (void)fprintf(stderr, "usage: biff [y | n]\n"); | 113 (void)fprintf(stderr, "usage: biff [n | y | b]\n"); |
107 exit(2); 108} | 114 exit(2); 115} |