write.c (92922) | write.c (97454) |
---|---|
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 92922 2002-03-22 01:42:45Z imp $"); | 50__FBSDID("$FreeBSD: head/usr.bin/write/write.c 97454 2002-05-29 13:14:51Z tjr $"); |
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> --- 22 unchanged lines hidden (view full) --- 81 register char *cp; 82 time_t atime; 83 uid_t myuid; 84 int msgsok, myttyfd; 85 char tty[MAXPATHLEN], *mytty; 86 87 (void)setlocale(LC_CTYPE, ""); 88 | 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> --- 22 unchanged lines hidden (view full) --- 81 register char *cp; 82 time_t atime; 83 uid_t myuid; 84 int msgsok, myttyfd; 85 char tty[MAXPATHLEN], *mytty; 86 87 (void)setlocale(LC_CTYPE, ""); 88 |
89 while (getopt(argc, argv, "") != -1) 90 usage(); 91 argc -= optind; 92 argv += optind; 93 |
|
89 /* check that sender has write enabled */ 90 if (isatty(fileno(stdin))) 91 myttyfd = fileno(stdin); 92 else if (isatty(fileno(stdout))) 93 myttyfd = fileno(stdout); 94 else if (isatty(fileno(stderr))) 95 myttyfd = fileno(stderr); 96 else --- 6 unchanged lines hidden (view full) --- 103 exit(1); 104 if (!msgsok) 105 errx(1, "you have write permission turned off"); 106 107 myuid = getuid(); 108 109 /* check args */ 110 switch (argc) { | 94 /* check that sender has write enabled */ 95 if (isatty(fileno(stdin))) 96 myttyfd = fileno(stdin); 97 else if (isatty(fileno(stdout))) 98 myttyfd = fileno(stdout); 99 else if (isatty(fileno(stderr))) 100 myttyfd = fileno(stderr); 101 else --- 6 unchanged lines hidden (view full) --- 108 exit(1); 109 if (!msgsok) 110 errx(1, "you have write permission turned off"); 111 112 myuid = getuid(); 113 114 /* check args */ 115 switch (argc) { |
111 case 2: 112 search_utmp(argv[1], tty, mytty, myuid); | 116 case 1: 117 search_utmp(argv[0], tty, mytty, myuid); |
113 do_write(tty, mytty, myuid); 114 break; | 118 do_write(tty, mytty, myuid); 119 break; |
115 case 3: 116 if (!strncmp(argv[2], _PATH_DEV, strlen(_PATH_DEV))) 117 argv[2] += strlen(_PATH_DEV); 118 if (utmp_chk(argv[1], argv[2])) 119 errx(1, "%s is not logged in on %s", argv[1], argv[2]); 120 if (term_chk(argv[2], &msgsok, &atime, 1)) | 120 case 2: 121 if (!strncmp(argv[1], _PATH_DEV, strlen(_PATH_DEV))) 122 argv[1] += strlen(_PATH_DEV); 123 if (utmp_chk(argv[0], argv[1])) 124 errx(1, "%s is not logged in on %s", argv[0], argv[1]); 125 if (term_chk(argv[1], &msgsok, &atime, 1)) |
121 exit(1); 122 if (myuid && !msgsok) | 126 exit(1); 127 if (myuid && !msgsok) |
123 errx(1, "%s has messages disabled on %s", argv[1], argv[2]); 124 do_write(argv[2], mytty, myuid); | 128 errx(1, "%s has messages disabled on %s", argv[0], argv[1]); 129 do_write(argv[1], mytty, myuid); |
125 break; 126 default: 127 usage(); 128 } 129 done(0); 130 return (0); 131} 132 --- 204 unchanged lines hidden --- | 130 break; 131 default: 132 usage(); 133 } 134 done(0); 135 return (0); 136} 137 --- 204 unchanged lines hidden --- |