write.c (139718) | write.c (173572) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 33 unchanged lines hidden (view full) --- 42 43#if 0 44#ifndef lint 45static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93"; 46#endif 47#endif 48 49#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 33 unchanged lines hidden (view full) --- 42 43#if 0 44#ifndef lint 45static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93"; 46#endif 47#endif 48 49#include <sys/cdefs.h> |
50__FBSDID("$FreeBSD: head/usr.bin/write/write.c 139718 2005-01-05 11:52:40Z cognet $"); | 50__FBSDID("$FreeBSD: head/usr.bin/write/write.c 173572 2007-11-12 20:02:21Z jhb $"); |
51 52#include <sys/param.h> 53#include <sys/signal.h> 54#include <sys/stat.h> 55#include <sys/file.h> 56#include <sys/time.h> 57#include <ctype.h> 58#include <err.h> --- 12 unchanged lines hidden (view full) --- 71int term_chk(char *, int *, time_t *, int); 72void wr_fputs(unsigned char *s); 73void search_utmp(char *, char *, char *, uid_t); 74int utmp_chk(char *, char *); 75 76int 77main(int argc, char **argv) 78{ | 51 52#include <sys/param.h> 53#include <sys/signal.h> 54#include <sys/stat.h> 55#include <sys/file.h> 56#include <sys/time.h> 57#include <ctype.h> 58#include <err.h> --- 12 unchanged lines hidden (view full) --- 71int term_chk(char *, int *, time_t *, int); 72void wr_fputs(unsigned char *s); 73void search_utmp(char *, char *, char *, uid_t); 74int utmp_chk(char *, char *); 75 76int 77main(int argc, char **argv) 78{ |
79 char *cp; | |
80 time_t atime; 81 uid_t myuid; 82 int msgsok, myttyfd; 83 char tty[MAXPATHLEN], *mytty; 84 85 (void)setlocale(LC_CTYPE, ""); 86 87 while (getopt(argc, argv, "") != -1) --- 7 unchanged lines hidden (view full) --- 95 else if (isatty(fileno(stdout))) 96 myttyfd = fileno(stdout); 97 else if (isatty(fileno(stderr))) 98 myttyfd = fileno(stderr); 99 else 100 errx(1, "can't find your tty"); 101 if (!(mytty = ttyname(myttyfd))) 102 errx(1, "can't find your tty's name"); | 79 time_t atime; 80 uid_t myuid; 81 int msgsok, myttyfd; 82 char tty[MAXPATHLEN], *mytty; 83 84 (void)setlocale(LC_CTYPE, ""); 85 86 while (getopt(argc, argv, "") != -1) --- 7 unchanged lines hidden (view full) --- 94 else if (isatty(fileno(stdout))) 95 myttyfd = fileno(stdout); 96 else if (isatty(fileno(stderr))) 97 myttyfd = fileno(stderr); 98 else 99 errx(1, "can't find your tty"); 100 if (!(mytty = ttyname(myttyfd))) 101 errx(1, "can't find your tty's name"); |
103 if ((cp = rindex(mytty, '/'))) 104 mytty = cp + 1; | 102 if (!strncmp(mytty, _PATH_DEV, strlen(_PATH_DEV))) 103 mytty += strlen(_PATH_DEV); |
105 if (term_chk(mytty, &msgsok, &atime, 1)) 106 exit(1); 107 if (!msgsok) 108 errx(1, "you have write permission turned off"); 109 110 myuid = getuid(); 111 112 /* check args */ --- 217 unchanged lines hidden --- | 104 if (term_chk(mytty, &msgsok, &atime, 1)) 105 exit(1); 106 if (!msgsok) 107 errx(1, "you have write permission turned off"); 108 109 myuid = getuid(); 110 111 /* check args */ --- 217 unchanged lines hidden --- |