Use err(3). Add protos for -Wall.
This commit is contained in:
parent
a3ea3db575
commit
fa82bf4e17
@ -29,12 +29,14 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -57,6 +59,9 @@ static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95";
|
||||
|
||||
extern char hostname[];
|
||||
|
||||
int print_mesg __P((char *, FILE *, CTL_MSG *, char *));
|
||||
char *ttymsg __P((struct iovec *, int, char *, int));
|
||||
|
||||
/*
|
||||
* Announce an invitation to talk.
|
||||
*/
|
||||
@ -65,6 +70,7 @@ extern char hostname[];
|
||||
* See if the user is accepting messages. If so, announce that
|
||||
* a talk is requested.
|
||||
*/
|
||||
int
|
||||
announce(request, remote_machine)
|
||||
CTL_MSG *request;
|
||||
char *remote_machine;
|
||||
@ -90,6 +96,7 @@ announce(request, remote_machine)
|
||||
* try to keep the message in one piece if the recipient
|
||||
* in in vi at the time
|
||||
*/
|
||||
int
|
||||
print_mesg(tty, tf, request, remote_machine)
|
||||
char *tty;
|
||||
FILE *tf;
|
||||
|
@ -29,12 +29,14 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/* debug print routines */
|
||||
@ -42,8 +44,8 @@ static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <protocols/talkd.h>
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
static char *types[] =
|
||||
{ "leave_invite", "look_up", "delete", "announce" };
|
||||
@ -53,6 +55,7 @@ static char *answers[] =
|
||||
"unknown_request", "badversion", "badaddr", "badctladdr" };
|
||||
#define NANSWERS (sizeof (answers) / sizeof (answers[0]))
|
||||
|
||||
void
|
||||
print_request(cp, mp)
|
||||
char *cp;
|
||||
register CTL_MSG *mp;
|
||||
@ -68,6 +71,7 @@ print_request(cp, mp)
|
||||
cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
|
||||
}
|
||||
|
||||
void
|
||||
print_response(cp, rp)
|
||||
char *cp;
|
||||
register CTL_RESPONSE *rp;
|
||||
|
@ -29,12 +29,14 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -50,16 +52,26 @@ static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93";
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <protocols/talkd.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <netdb.h>
|
||||
#include <syslog.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <paths.h>
|
||||
#include <syslog.h>
|
||||
|
||||
int announce __P((CTL_MSG *, char *));
|
||||
int delete_invite __P((int));
|
||||
void do_announce __P((CTL_MSG *, CTL_RESPONSE *));
|
||||
CTL_MSG *find_request();
|
||||
CTL_MSG *find_match();
|
||||
int find_user __P((char *, char *));
|
||||
void insert_table __P((CTL_MSG *, CTL_RESPONSE *));
|
||||
int new_id __P((void));
|
||||
void print_request __P((char *, CTL_MSG *));
|
||||
void print_response __P((char *, CTL_RESPONSE *));
|
||||
|
||||
void
|
||||
process_request(mp, rp)
|
||||
register CTL_MSG *mp;
|
||||
register CTL_RESPONSE *rp;
|
||||
@ -72,28 +84,28 @@ process_request(mp, rp)
|
||||
rp->type = mp->type;
|
||||
rp->id_num = htonl(0);
|
||||
if (mp->vers != TALK_VERSION) {
|
||||
syslog(LOG_WARNING, "Bad protocol version %d", mp->vers);
|
||||
syslog(LOG_WARNING, "bad protocol version %d", mp->vers);
|
||||
rp->answer = BADVERSION;
|
||||
return;
|
||||
}
|
||||
mp->id_num = ntohl(mp->id_num);
|
||||
mp->addr.sa_family = ntohs(mp->addr.sa_family);
|
||||
if (mp->addr.sa_family != AF_INET) {
|
||||
syslog(LOG_WARNING, "Bad address, family %d",
|
||||
syslog(LOG_WARNING, "bad address, family %d",
|
||||
mp->addr.sa_family);
|
||||
rp->answer = BADADDR;
|
||||
return;
|
||||
}
|
||||
mp->ctl_addr.sa_family = ntohs(mp->ctl_addr.sa_family);
|
||||
if (mp->ctl_addr.sa_family != AF_INET) {
|
||||
syslog(LOG_WARNING, "Bad control address, family %d",
|
||||
syslog(LOG_WARNING, "bad control address, family %d",
|
||||
mp->ctl_addr.sa_family);
|
||||
rp->answer = BADCTLADDR;
|
||||
return;
|
||||
}
|
||||
for (s = mp->l_name; *s; s++)
|
||||
if (!isprint(*s)) {
|
||||
syslog(LOG_NOTICE, "Illegal user name. Aborting");
|
||||
syslog(LOG_NOTICE, "illegal user name. Aborting");
|
||||
rp->answer = FAILED;
|
||||
return;
|
||||
}
|
||||
@ -138,6 +150,7 @@ process_request(mp, rp)
|
||||
print_response("process_request", rp);
|
||||
}
|
||||
|
||||
void
|
||||
do_announce(mp, rp)
|
||||
register CTL_MSG *mp;
|
||||
CTL_RESPONSE *rp;
|
||||
@ -185,6 +198,7 @@ do_announce(mp, rp)
|
||||
/*
|
||||
* Search utmp for the local user
|
||||
*/
|
||||
int
|
||||
find_user(name, tty)
|
||||
char *name, *tty;
|
||||
{
|
||||
@ -197,7 +211,7 @@ find_user(name, tty)
|
||||
char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)];
|
||||
|
||||
if ((fd = fopen(_PATH_UTMP, "r")) == NULL) {
|
||||
fprintf(stderr, "talkd: can't read %s.\n", _PATH_UTMP);
|
||||
warnx("can't read %s", _PATH_UTMP);
|
||||
return (FAILED);
|
||||
}
|
||||
#define SCMPN(a, b) strncmp(a, b, sizeof (a))
|
||||
|
@ -29,12 +29,14 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -49,11 +51,11 @@ static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <protocols/talkd.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */
|
||||
|
||||
@ -73,8 +75,12 @@ struct table_entry {
|
||||
};
|
||||
|
||||
TABLE_ENTRY *table = NIL;
|
||||
|
||||
void delete __P((TABLE_ENTRY *));
|
||||
CTL_MSG *find_request();
|
||||
CTL_MSG *find_match();
|
||||
int new_id __P((void));
|
||||
void print_request __P((char *, CTL_MSG *));
|
||||
|
||||
/*
|
||||
* Look in the table for an invitation that matches the current
|
||||
@ -152,6 +158,7 @@ find_request(request)
|
||||
return ((CTL_MSG *)0);
|
||||
}
|
||||
|
||||
void
|
||||
insert_table(request, response)
|
||||
CTL_MSG *request;
|
||||
CTL_RESPONSE *response;
|
||||
@ -181,6 +188,7 @@ insert_table(request, response)
|
||||
/*
|
||||
* Generate a unique non-zero sequence number
|
||||
*/
|
||||
int
|
||||
new_id()
|
||||
{
|
||||
static int current_id = 0;
|
||||
@ -195,6 +203,7 @@ new_id()
|
||||
/*
|
||||
* Delete the invitation with id 'id_num'
|
||||
*/
|
||||
int
|
||||
delete_invite(id_num)
|
||||
int id_num;
|
||||
{
|
||||
@ -219,6 +228,7 @@ delete_invite(id_num)
|
||||
/*
|
||||
* Classic delete from a double-linked list
|
||||
*/
|
||||
void
|
||||
delete(ptr)
|
||||
register TABLE_ENTRY *ptr;
|
||||
{
|
||||
|
@ -56,11 +56,13 @@ type
|
||||
This causes the server to search its invitation
|
||||
tables to check if an invitation currently exists for the caller
|
||||
(to speak to the callee specified in the message).
|
||||
.Pp
|
||||
If the lookup fails,
|
||||
the caller then sends an
|
||||
.Tn ANNOUNCE
|
||||
message causing the server to
|
||||
broadcast an announcement on the callee's login ports requesting contact.
|
||||
.Pp
|
||||
When the callee responds, the local server uses the
|
||||
recorded invitation to respond with the appropriate rendezvous
|
||||
address and the caller and callee client programs establish a
|
||||
|
@ -29,18 +29,20 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1983, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)talkd.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -53,22 +55,22 @@ static char sccsid[] = "@(#)talkd.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <sys/socket.h>
|
||||
#include <sys/param.h>
|
||||
#include <protocols/talkd.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <paths.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
CTL_MSG request;
|
||||
CTL_RESPONSE response;
|
||||
|
||||
int sockt;
|
||||
int debug = 0;
|
||||
void timeout();
|
||||
long lastmsgtime;
|
||||
|
||||
char hostname[MAXHOSTNAMELEN + 1];
|
||||
@ -76,6 +78,10 @@ char hostname[MAXHOSTNAMELEN + 1];
|
||||
#define TIMEOUT 30
|
||||
#define MAXIDLE 120
|
||||
|
||||
void process_request __P((CTL_MSG *, CTL_RESPONSE *));
|
||||
void timeout();
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
@ -83,10 +89,8 @@ main(argc, argv)
|
||||
register CTL_MSG *mp = &request;
|
||||
int cc;
|
||||
|
||||
if (getuid()) {
|
||||
fprintf(stderr, "%s: getuid: not super-user\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (getuid())
|
||||
errx(1, "getuid: not super-user");
|
||||
openlog("talkd", LOG_PID, LOG_DAEMON);
|
||||
if (gethostname(hostname, sizeof (hostname) - 1) < 0) {
|
||||
syslog(LOG_ERR, "gethostname: %m");
|
||||
@ -101,8 +105,6 @@ main(argc, argv)
|
||||
signal(SIGALRM, timeout);
|
||||
alarm(TIMEOUT);
|
||||
for (;;) {
|
||||
extern int errno;
|
||||
|
||||
cc = recv(0, (char *)mp, sizeof (*mp), 0);
|
||||
if (cc != sizeof (*mp)) {
|
||||
if (cc < 0 && errno != EINTR)
|
||||
|
Loading…
Reference in New Issue
Block a user