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 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{ |
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"); |
102 if (!strncmp(mytty, _PATH_DEV, strlen(_PATH_DEV))) 103 mytty += strlen(_PATH_DEV); |
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 --- |