Commit Graph

359 Commits

Author SHA1 Message Date
Kevin Lo
3dedcef753 Remove unused values 2012-09-11 07:54:41 +00:00
Warren Block
44d8663ddb Correct description of minfree to kilobytes rather than blocks.
PR:		125921
Submitted by:	Andre Albsmeier <Andre.Albsmeier@siemens.com>
MFC after:	3 days
2012-08-13 15:16:25 +00:00
Jaakko Heinonen
e0d20e6615 Make sure that arraysz is initialized to a value larger than zero.
arraysz could get initialized to zero on ZFS because ZFS reports
directory sizes differently compared to UFS.

PR:		bin/169493
Tested by:	swills
MFC after:	2 weeks
2012-07-17 09:34:52 +00:00
Jaakko Heinonen
f9fbbdf95b Remove trailing whitespace.
MFC after:	2 weeks
2012-07-17 09:31:05 +00:00
Eitan Adler
31fd5c1101 Relax security permissions on '.seq' file creation - the strict,
but odd permissions resulted in a security alert from 110.neggrpperm

PR:		kern/165533
Submitted by:	Anton Shterenlikht <mexas@bristol.ac.uk>
Submitted by:	J B <jb.1234abcd@gmail.com>
Approved by:	cperciva
MFC after:	1 week
2012-05-30 04:08:29 +00:00
Gleb Kurtsou
0bb2aabf26 Hide DIR definition by making it an opaque struct typedef.
Introduce dirfd() libc exported symbol replacing macro with same name,
preserve _dirfd() macro for internal use.

Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable
name to prevent shadowing global symbol.

Sponsored by:	Google Summer Of Code 2011
2012-05-19 12:44:27 +00:00
Garance A Drosehn
7574a1c16e Print out a warning message if a `lpc setstatus' is done when
the queue is not 'lpc stop'-ed.  In that situation `lpq' will
not display the status message to the user, and the operator
may think the queue is already stopped when it is not.

MFC after:	3 weeks
2012-04-30 01:10:13 +00:00
Garance A Drosehn
aa318fd726 Catch the user-error when no queue name was specified on an
lpc-command which supports '-msg' (e.g.: setstatus).  Print
out a helpful error message instead hitting a seg-fault.

MFC after:	3 weeks
2012-04-30 00:54:10 +00:00
Xin LI
2c81fb6a72 The scandir(3) function expects fourth parameter, compar, be in type of:
int (*compar)(const struct dirent **, const struct dirent **)

The current code defines sortq() to accept two void *, then cast them
to const struct dirent **.  Because the code does not really need this
cast, we can eliminate the casts by changing the function prototype
to match scandir(3) expectation.

MFC after:	1 month
2012-04-13 22:34:01 +00:00
Joel Dahl
c2965cd185 mdoc: terminate quoted strings.
Reviewed by:	brueffer
2012-03-26 15:18:14 +00:00
Kevin Lo
6e807fa629 - Remove some unnecessary cast when assigning NULL to a handle.
- Silent a warning
2012-02-15 02:01:24 +00:00
Kevin Lo
a3a2bf4b67 fgets(3) returns a pointer, so compare against NULL, not integer 0. 2012-01-13 06:51:15 +00:00
Ulrich Spörlein
3df5ecac8c Spelling fixes for usr.sbin/ 2011-12-30 10:58:14 +00:00
Dimitry Andric
97fbdc11ea In usr.sbin/lpr/lpd/printjob.c, use the correct printf length modifiers
for off_t (aka int64_t).

MFC after:	1 week
2011-12-17 22:05:28 +00:00
Dimitry Andric
7ae1a27825 In usr.sbin/lpr/filters/lpf.c, use a less obtuse way of clearing the
buffer, that also avoids warnings.

MFC after:	1 week
2011-12-17 21:37:21 +00:00
Garance A Drosehn
ad1f7851dd - Fix the code that matches userids in match_jobspec(). It needs to check
the username-for-accounting field (P), not the username-for-headerpage (L).
  These are usually the same value, except that control files do not have
  the username-for-headerpage field if the user has requested no header page.
- Also rename the cji_username field to cji_headruser, to make it clear that
  the value should only be used for the header page.  (aka banner page)

MFC after:	3 weeks
2011-04-13 00:36:19 +00:00
Joel Dahl
914e11a72b Remove the advertising clause from UCB copyrighted files in usr.sbin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
2010-12-11 09:38:12 +00:00
Ulrich Spörlein
cded07a878 Move most of the remaining USD/PSD/SMM papers into share/doc 2010-12-04 10:11:20 +00:00
Edwin Groothuis
e782099404 Fix printing of files located on ZFS filesystem with an st_dev or
st_ino larger than 2**31.

From the PR:

   Printing from a ZFS filesystem using 'lp' fails and returns an
   email reporting "Your printer job was not printed because it was
   not linked to the original file".

   In order to protect against files being switched when files
   are printed using 'lp' or 'lpr -s', the st_dev and st_ino
   values for the original file are saved by lpr and verified
   by lpd before the file is printed. Unfortunately, lpr prints
   both values using '%d' (although both fields are unsigned)
   and lpd(8) assumes a string of decimal digits.

   ZFS (at least) generates st_dev values greater than 2^31-1,
   resulting in negative values being printed - which lpd cannot
   parse, leading it to report that the file has been switched.

   A similar problem would occur with large inode numbers.

   How-To-Repeat:

   Find a file with either st_dev or st_ino greater than 2^31-1
   (stat(1) will report both numbers) and print it with 'lpq -s'.
   This should generate an email reporting that the file could
   not be printed because it was not linked to the original file

PR:		bin/151567
Submitted by:	Peter Jeremy <Peter.Jeremy@alcatel-lucent.com>
MFC after:	1 week
2010-10-21 06:52:14 +00:00
Ulrich Spörlein
0d9deed52c mdoc: drop redundant .Pp and .LP calls
They have no effect when coming in pairs, or before .Bl/.Bd
2010-10-08 12:40:16 +00:00
Garance A Drosehn
422605a3b9 - Improve the wait4data() routine so it behaves better when checking
print-jobs which have last-modification times that are in the future.
  This shouldn't happen, of course, but it can.  And when it did happen,
  the previous check could cause completely-spooled jobs to sit in the
  queue for 20 minutes per job.  The new code waits until the last-modify
  time is not changing, instead of making decisions based on the specific
  value of last-modify.

MFC after:	2 weeks
2010-08-11 19:32:49 +00:00
Joel Dahl
f6ac23919b Fix typos and spelling mistakes. 2010-08-06 14:33:42 +00:00
Konstantin Belousov
4176dd5267 Modernize scandir(3) and alphasort(3) interfaces according to the IEEE
Std 1003.1-2008. Both Linux and Solaris conforms to the new definitions,
so we better follow too (older glibc used old BSDish alphasort prototype
and corresponding type of the comparision function for scandir). While
there, change the definitions of the functions to ANSI C and fix several
style issues nearby.

Remove requirement for "sys/types.h" include for functions from manpage.

POSIX also requires that alphasort(3) sorts as if strcoll(3) was used,
but leave the strcmp(3) call in the function for now.

Adapt in-tree callers of scandir(3) to new declaration. The fact that
select_sections() from catman(1) could modify supplied struct dirent is
a bug.

PR:	standards/142255
MFC after:	2 weeks
2010-01-04 15:40:17 +00:00
Ed Schouten
71ccf09269 The last big commit: let usr.sbin/ use WARNS=6 by default. 2010-01-02 11:07:44 +00:00
Jilles Tjoelker
072a126d12 Fix using lp(1) without the new -t option after r194171.
PR:		standards/129554
Tested by:	Steve Kargl
MFC after:	1 week
2009-09-29 21:28:32 +00:00
Garance A Drosehn
46bfa198cf Fix end-of-line issues that can come up when `lpq' reads information
about a queue from a remote host.  That remote host may use \r, \r\n,
or \n\r as the line-ending character.  In some cases the remote host
will write a single line of information without *any* EOL sequence.

Translate all the non-unix EOL's to the standard newline, and make
sure the final line includes a terminating newline.  Logic is also
added to translate all unprintable characters to '?', but that is
#if-ed out for now.

PR:		bin/104731
MFC after:	3 weeks
2009-06-24 16:57:33 +00:00
Brooks Davis
54404cfb13 In preparation for raising NGROUPS and NGROUPS_MAX, change base
system callers of getgroups(), getgrouplist(), and setgroups() to
allocate buffers dynamically.  Specifically, allocate a buffer of size
sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow).

This (or similar gymnastics) is required for the code to actually follow
the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime
and where getgroups may return {NGROUPS_MAX}+1 results on systems like
FreeBSD which include the primary group.

In id(1), don't pointlessly add the primary group to the list of all
groups, it is always the first result from getgroups().  In principle
the old code was more portable, but this was only done in one of the two
places where getgroups() was called to the overall effect was pointless.

Document the actual POSIX requirements in the getgroups(2) and
setgroups(2) manpages.  We do not yet support a dynamic NGROUPS, but we
may in the future.

MFC after:	2 weeks
2009-06-19 15:58:24 +00:00
Brian Somers
a0347c7148 Add -m and -t options.
PR:		129554
Submitted by:	gavin
MFC after:	3 weeks
2009-06-14 06:47:21 +00:00
Bernd Walter
ee9069d1d9 use bigger local variable to calculate free space
int overflows at 1T free space
2008-09-01 12:32:40 +00:00
Kevin Lo
784bddbc5b Cleanup of userland __P use 2007-11-07 10:53:41 +00:00
Kevin Lo
d069140339 Use sizeof() for calculating the buffer size instead of hard-coded values. 2007-03-06 09:32:41 +00:00
Yaroslav Tykhiy
6884810944 Obey MK_INET6_SUPPORT. 2006-07-27 14:52:12 +00:00
Garance A Drosehn
ae39ffc92e Fix checking of the "lock" file in the spool directory for a queue,
so that the checking will wind up with the correct mode-bits in
the case where the initial open() of that lock file will create it.
Due to this bug, the first job ever sent to a queue could leave
that queue in a "printing is disabled" state.

PR:		93469
Submitted by:	Michael Szklarski of kco.com.pl
MFC after:	1 week
2006-07-07 01:12:26 +00:00
Garance A Drosehn
1f6676cf8f Rever the previous changes. It turns out that it perfectly correct
for a makefile to set 'NO_MAN=' when the makefile is for a program
that will not create a man page.

Based on reaction from:		ru bde
2006-03-09 19:52:44 +00:00
Garance A Drosehn
e325eb526c Switch these makefiles to use 'MAN=' to indicate they will not generate
a man page, instead of 'NO_MAN='.  'NO_MAN=' is something users would
set, not something a makefile should be using.

Based on comments by:	des
2006-03-08 22:28:12 +00:00
Stefan Farfeleder
6b6c96661e Use the new name H_SETSIZE instead of the old H_EVENT to set the history
size.

PR:		86355
Approved by:	gad
2005-10-19 16:37:52 +00:00
Dag-Erling Smørgrav
ee66677a7a Remove kludges intended to support src trees with partial obj trees.
Discussed with:	ru
2005-06-10 06:12:53 +00:00
Hajimu UMEMOTO
9ccf2f38c1 NI_WITHSCOPEID cleanup
Reviewed by:	gad
2005-05-13 16:43:28 +00:00
Xin LI
943b456e6a MFS5: Minor style(9) tweak. 2005-02-22 02:56:42 +00:00
Xin LI
c7cc259656 Be more careful when doing el_parse() - only do it when el is
properly initialized, that happens when lpc is called from a tty.
Without this change, it's possible to get SIGSEGV simply doing:
	echo "..:" | lpc

Reported by:	Wojciech A. Koszek <dunstan at freebsd czest pl>
PR:		77462 (patch rewritten by myself)
MFC After:	1 week
2005-02-15 10:23:01 +00:00
Ruslan Ermilov
0227791b40 Expand *n't contractions. 2005-02-13 22:25:33 +00:00
Ruslan Ermilov
2bae942814 Fixed .Xr call. 2005-01-21 09:07:47 +00:00
Ruslan Ermilov
59a3c79da6 Sort sections. 2005-01-18 20:02:45 +00:00
Garance A Drosehn
c547dbe854 Fix so all parts of lpd, lpc, lpq, and lprm will use the same algorithm
for calculating the job number for a job based on the control-file name.
We might receive cf-files named by other implementations of lpr, where
the job number shown by lpq would not match the job number that other
commands expected for the same name.

This also uses a newer algorithm for determining a job number, to avoid
problems caused when a control-file is named using an IP address, instead
of the hostname.

This also moved the declaration if isowner() from lp.h to rmjob.c.  When I
went to change the parameters, I noticed that rmjob.c was the only source
file which uses it.

MFC after:	2 weeks
2004-12-31 00:36:28 +00:00
Garance A Drosehn
e357c6ec8e Do more extensive checking of the userid field which is read in from the
control-file for each print job.  This is partially because the previous
checks still let through some characters which would cause trouble for
other applications which try to process the resulting userid -- such as
accounting programs.

But the main reason is to handle the case where some remote host sends a
print job where the given userid is an uppercase-version of the real userid.
For that case, lpd will now check for uppercase letters in the userid.  If
there are any, it will check to see if the given userid (with the uppercase
letters) is a valid one.  If it is *not* valid, then lpd will change the
userid to all-lowercase right when the job is received.

MFC after:	2 weeks
2004-12-31 00:18:42 +00:00
Ruslan Ermilov
e653b48c80 Start the dreaded NOFOO -> NO_FOO conversion.
OK'ed by:	core
2004-12-21 08:47:35 +00:00
Garance A Drosehn
a6ed151d3c Call umask() before opening the lock-file for a queue, to make sure
the file will be created with the right access, if the call to open()
does create it.  Also fix the other call to umask() to turn off
"write others", just as a matter of general safety.

PR:		74418
MFC after:	4 days
2004-12-19 05:14:29 +00:00
Garance A Drosehn
bea5945e6f When printing a data file received from some other host, check to make
sure the data file has been completely transfered before starting to
print it.  This is needed because some implementations of lpr will send
the control-file for a print job before sending the matching data-files,
and that can cause problems if the receiving host is a busy print-server.

MFC after:	2 weeks
2004-12-17 01:54:50 +00:00
Ruslan Ermilov
a35d88931c For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
Poul-Henning Kamp
eb7b5f46a3 Stop on write error. 2004-09-27 08:24:05 +00:00