From 7bc71354c309798b718a10367a412127a5ee5917 Mon Sep 17 00:00:00 2001 From: Thomas Ferrin Date: Mon, 20 Feb 1989 22:48:09 -0800 Subject: [PATCH] check whether local machine is same as remote machine (a la printjob.c) SCCS-vsn: usr.sbin/lpr/common_source/rmjob.c 5.4 --- usr/src/usr.sbin/lpr/common_source/rmjob.c | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/usr/src/usr.sbin/lpr/common_source/rmjob.c b/usr/src/usr.sbin/lpr/common_source/rmjob.c index d43eac26d0..178e9d136a 100644 --- a/usr/src/usr.sbin/lpr/common_source/rmjob.c +++ b/usr/src/usr.sbin/lpr/common_source/rmjob.c @@ -16,7 +16,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)rmjob.c 5.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)rmjob.c 5.4 (Berkeley) %G%"; #endif /* not lint */ /* @@ -60,6 +60,36 @@ rmjob() if ((RP = pgetstr("rp", &bp)) == NULL) RP = DEFLP; RM = pgetstr("rm", &bp); + /* + * Figure out whether the local machine is the same as the remote + * machine entry (if it exists). If not, then ignore the local + * queue information. + */ + if (RM != (char *) NULL) { + char name[256]; + struct hostent *hp; + + /* get the standard network name of the local host */ + gethostname(name, sizeof(name)); + name[sizeof(name)-1] = '\0'; + hp = gethostbyname(name); + if (hp == (struct hostent *) NULL) { + printf("unable to get network name for local machine %s", + name); + goto localcheck_done; + } else strcpy(name, hp->h_name); + + /* get the standard network name of RM */ + hp = gethostbyname(RM); + if (hp == (struct hostent *) NULL) { + printf("unable to get hostname for remote machine %s", RM); + goto localcheck_done; + } + + /* if printer is not on local machine, ignore LP */ + if (strcmp(name, hp->h_name) != 0) *LP = '\0'; + } +localcheck_done: /* * If the format was `lprm -' and the user isn't the super-user, -- 2.20.1