aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/lpr/lpd/printjob.c
diff options
context:
space:
mode:
authorGarance A Drosehn <gad@FreeBSD.org>2001-06-15 22:03:07 +0000
committerGarance A Drosehn <gad@FreeBSD.org>2001-06-15 22:03:07 +0000
commitcc3fd56f96f5726a445a8a6090bda47a94122df6 (patch)
tree34bd9934cba11944407fb52a6d7f9c516d667752 /usr.sbin/lpr/lpd/printjob.c
parent7474a22698a1e190f752da548c73b6a9505cd1e1 (diff)
Rename a few global variables which hold hostname-related values to be
more sensible/understandable. 'from'->'from_host' 'host'->'local_host' 'fromb'->'frombuf' 'fromhost'->'origin_host' and a local-variable named 'host'->'hostbuf'. This fixes some compile-time warnings about local variables shadowing global variables. Other than renaming variables, the only actual code changes are to call strlcpy() instead of strncpy() when setting those (renamed) variables, and that 'from_ip' is now a strdup()-created buffer instead of being a static buffer compiled in as 1025 bytes. Reviewed by: freebsd-print@bostonradio.org (an earlier version) MFC after: 1 week
Notes
Notes: svn path=/head/; revision=78300
Diffstat (limited to 'usr.sbin/lpr/lpd/printjob.c')
-rw-r--r--usr.sbin/lpr/lpd/printjob.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index 14dc49c6873d..b46d2782f304 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -107,7 +107,7 @@ static char title[80]; /* ``pr'' title */
static char locale[80]; /* ``pr'' locale */
static char class[32]; /* classification field */
-static char fromhost[MAXHOSTNAMELEN]; /* user's host machine */
+static char origin_host[MAXHOSTNAMELEN]; /* user's host machine */
/* indentation size in static characters */
static char indent[10] = "-i0";
static char jobname[100]; /* job or file name */
@@ -417,8 +417,7 @@ printit(struct printer *pp, char *file)
while (getline(cfp))
switch (line[0]) {
case 'H':
- strncpy(fromhost, line+1, sizeof(fromhost) - 1);
- fromhost[sizeof(fromhost) - 1] = '\0';
+ strlcpy(origin_host, line + 1, sizeof(origin_host));
if (class[0] == '\0') {
strncpy(class, line+1, sizeof(class) - 1);
class[sizeof(class) - 1] = '\0';
@@ -747,7 +746,7 @@ print(struct printer *pp, int format, char *file)
av[n++] = "-n";
av[n++] = logname;
av[n++] = "-h";
- av[n++] = fromhost;
+ av[n++] = origin_host;
av[n++] = pp->acct_file;
av[n] = 0;
fo = pfd;
@@ -874,8 +873,7 @@ sendit(struct printer *pp, char *file)
i = i * 10 + (*cp++ - '0');
fino = i;
} else if (line[0] == 'H') {
- strncpy(fromhost, line+1, sizeof(fromhost) - 1);
- fromhost[sizeof(fromhost) - 1] = '\0';
+ strlcpy(origin_host, line + 1, sizeof(origin_host));
if (class[0] == '\0') {
strncpy(class, line+1, sizeof(class) - 1);
class[sizeof(class) - 1] = '\0';
@@ -1005,7 +1003,7 @@ sendfile(struct printer *pp, int type, char *file, char format)
av[++n] = "-n";
av[++n] = logname;
av[++n] = "-h";
- av[++n] = fromhost;
+ av[++n] = origin_host;
av[++n] = pp->acct_file;
av[++n] = 0;
if ((ifilter = dofork(pp, DORETURN)) == 0) { /* child */
@@ -1166,7 +1164,7 @@ sendfile(struct printer *pp, int type, char *file, char format)
openpr(pp);
if (type == '\3')
trstat_write(pp, TR_SENDING, stb.st_size, logname,
- pp->remote_host, fromhost);
+ pp->remote_host, origin_host);
return(OK);
}
@@ -1321,10 +1319,10 @@ sendmail(struct printer *pp, char *user, int bombed)
_exit(0);
} else if (s > 0) { /* parent */
dup2(p[1], 1);
- printf("To: %s@%s\n", user, fromhost);
+ printf("To: %s@%s\n", user, origin_host);
printf("Subject: %s printer job \"%s\"\n", pp->printer,
*jobname ? jobname : "<unknown>");
- printf("Reply-To: root@%s\n\n", host);
+ printf("Reply-To: root@%s\n\n", local_host);
printf("Your printer job ");
if (*jobname)
printf("(%s) ", jobname);
@@ -1341,7 +1339,8 @@ sendmail(struct printer *pp, char *user, int bombed)
cp = "FATALERR";
break;
case NOACCT:
- printf("\ncould not be printed without an account on %s\n", host);
+ printf("\ncould not be printed without an account on %s\n",
+ local_host);
cp = "NOACCT";
break;
case FILTERERR: