Commit Graph

707 Commits

Author SHA1 Message Date
Pedro F. Giffuni
1ab5381860 fparseln(3): Update from NetBSD sources.
-fix a condition so that fparseln() doesn't report spurious empty lines
 eg after 2 comment lines, or on EOF after a single comment line
-no escape character means no escaped characters

modify the previous fix so that no pointless realloc()s are done in
the case of multiple empty continuation lines, and comment the code
to make the logics obvious

fparseln is now part of libc in NetBSD so this changes the previous
revision numbering.

Obtained from:	NetBSD (CVS Rev. 1.6-1.7)
MFC after:	2 weeks
2014-07-23 14:57:15 +00:00
Joel Dahl
df2d82e003 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
Baptiste Daroussin
2b7af31cf5 use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Mark Johnston
0eca77fd24 Fix a typo.
MFC after:	3 days
2014-05-03 16:18:42 +00:00
Simon J. Gerraty
9d2ab4a62d Merge head 2014-04-27 08:13:43 +00:00
Eitan Adler
1748334408 libutil/pw_util.3: Fix two prototypes.
Reported by:	marino
Obtained from:	DragonFlyBSD (e82b5d3dfa969bfcda5ffadceccc682b6bdcd077)
MFC After:	3 days
2014-02-13 05:13:22 +00:00
Eitan Adler
69b2d025a0 Indicate that expand_number is case-insensitive.
Reviewed by:	-scsi
2013-11-12 00:56:22 +00:00
Eitan Adler
efac066db1 Mention in login.conf.5 which fields may be infinite and how to specifify infinity.
The number of ways to indicate this confuses people.

PR:		docs/100196
Reported by:	"Dr. Markus Waldeck" <waldeck@gmx.de>
Reported by:	Jamie Landeg Jones <jamie.landeg.jones@gmail.com>
2013-10-27 04:59:18 +00:00
Eitan Adler
23f182d7fe All man pages refer to FreeBSD so there is no need to mention "In .Fx" 2013-10-27 04:49:40 +00:00
Konstantin Belousov
85a0ddfd0b Add a resource limit for the total number of kqueues available to the
user.  Kqueue now saves the ucred of the allocating thread, to
correctly decrement the counter on close.

Under some specific and not real-world use scenario for kqueue, it is
possible for the kqueues to consume memory proportional to the square
of the number of the filedescriptors available to the process.  Limit
allows administrator to prevent the abuse.

This is kernel-mode side of the change, with the user-mode enabling
commit following.

Reported and tested by:	pho
Discussed with:	jmg
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2013-10-21 16:46:12 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
John-Mark Gurney
44f01c419d don't assert on bad args, instead return an error..
Since so many programs don't check return value, always NUL terminate
the buf...

fix rounding when using base 1024 (the bug that started it all)...

add a set of test cases so we can make sure that things don't break
in the future...

Thanks to Clifton Royston for testing and the test program...

Approved by:	re (hrs, glebius)
MFC after:	1 week
2013-10-07 22:22:57 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Sergey Kandaurov
8d99b9cebd The round of expand_number() cleanups.
o Fix range error checking to detect overflow when uint64_t < uintmax_t.
o Remove a non-functional check for no valid digits as pointed out by Bruce.
o Remove a rather pointless comment describing what the function does.
o Clean up a bunch of style bugs.

Brucified by:	bde
2013-08-30 11:21:52 +00:00
Jilles Tjoelker
d1d4d95209 libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
Sergey Kandaurov
7261b203c6 Reset errno before strtoumax() call to properly detect ERANGE.
Restore saved errno if strtoumax() call is successful.

Reported by:	ache
Reviewed by:	jilles
MFC after:	1 week
2013-08-21 22:37:15 +00:00
Sergey Kandaurov
869f276295 Check strtoumax(3) for ERANGE in case of non-prefixed string.
OK'd by:	silence on current@
MFC after:	1 week
2013-08-21 16:46:06 +00:00
Tim Kientzle
64330eb00f Fix -Wunsequenced warning
Submitted by:	dt71@gmx.com
2013-06-29 15:52:48 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Pawel Jakub Dawidek
36a00a3f38 When pidptr was passed as NULL to pidfile_open(3), we were returning
EAGAIN/EWOULDBLOCK when another daemon was running and had the pidfile open.
We should return EEXIST in that case, fix it.

Reported by:	Dirk Engling <erdgeist@erdgeist.org>
Reviewed by:	jhb, Dirk Engling <erdgeist@erdgeist.org>
MFC after:	1 week
2013-03-14 20:22:52 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Diane Bruce
5e87983769 commit correct tested fix for gr_util.c
Approved by:	theraven
2013-03-09 13:30:06 +00:00
Diane Bruce
86e2f99d40 Cleanup gr_add() so it does not leak mem
This is part of ongoing work on sbin/pw

M    libutil.h
M    gr_util.c

Approved by:	theraven
2013-03-07 19:00:00 +00:00
Ruslan Ermilov
d1a0cea48b Fixed documented prototype of kinfo_getproc(3). 2013-03-01 07:39:14 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Mateusz Guzik
08ecf0cc41 libutil: fix typo in comment for gr_fini.
Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
2013-01-13 22:08:18 +00:00
Mateusz Guzik
49013fb476 libutil: utilize strsep instead of strcat in a loop in gr_make
Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
2013-01-13 21:28:47 +00:00
Mateusz Guzik
fe75b0f0e5 libutil: move group_line_format into the scop of its only user.
Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
2013-01-13 21:26:57 +00:00
Mateusz Guzik
29365f023a libutil: eliminate 'found' variable in gr_equal
Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
2013-01-13 21:25:43 +00:00
Baptiste Daroussin
7780953ee4 Simplify pointing dst after the end of all the gr_mem pointers in newgr
Submitted by:	pjd
Reviewed by:	db
2012-12-28 20:44:10 +00:00
Baptiste Daroussin
fe390747e4 errno = ENOMEM was supposed to be removed not return (NULL);
Submitted by:	gcooper
2012-12-28 20:30:04 +00:00
Baptiste Daroussin
d00489b70f malloc() sets errno to ENOMEM already.
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2012-12-28 20:21:14 +00:00
Baptiste Daroussin
167145a17d Do not leave parts of the new group uninitialized in gr_dup().
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
Reported by:	pjd
2012-12-28 20:19:54 +00:00
Baptiste Daroussin
5019747579 avoid arithmetic on uintptr_t
Submitted by:	pjd
Reviewed by:	jilles
2012-12-27 20:47:34 +00:00
Baptiste Daroussin
7d90019877 cast to uintptr_t to properly calculate offset
Reported by:	mdf
Submitted by:	db
2012-12-27 20:31:12 +00:00
Baptiste Daroussin
ede89d5db2 Add O_CLOEXEC to flopen
Requested by:	jilles
2012-12-27 20:24:44 +00:00
Baptiste Daroussin
1067c64a19 gr_dup: simplify duplication of group
Submitted by:	db
2012-12-27 19:33:43 +00:00
Baptiste Daroussin
2bfeb4fe75 - Clean up previous gr_add use malloc instead of calloc
- Fix tinderbox error

Submitted by:	db
2012-12-27 16:51:29 +00:00
Baptiste Daroussin
be49c83011 New gr_add function to provide a clean and safe method to append a new member
into an existing group.

Submitted by:	db
2012-12-27 14:30:19 +00:00
Baptiste Daroussin
98e79fb122 Use flopen(3) instead of open(2) + flock(2) 2012-12-27 14:09:50 +00:00
Baptiste Daroussin
09259e6c48 only rename(2) after chmod(2) has succeed
report error if chmod(2) fails

Reported by:	jh
2012-11-20 14:03:09 +00:00
Baptiste Daroussin
2d2b6ad74d change mode the group file to 0644 after a successfull rename(2) 2012-11-20 07:22:07 +00:00
Simon J. Gerraty
7cd2dcf076 Updated/new Makefile.depend 2012-11-08 21:24:17 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Baptiste Daroussin
46f8c63df6 Fix typo 2012-11-03 00:30:22 +00:00
Dag-Erling Smørgrav
192bc3edf4 Correct attribution. 2012-10-31 15:04:27 +00:00
Joel Dahl
2acb4741ca Minor mdoc and language fixes. 2012-10-30 22:30:30 +00:00
Baptiste Daroussin
f5a05b2ba4 Removed unnecessary bits in the header that shows where I stole the template 2012-10-30 22:26:19 +00:00
Baptiste Daroussin
42818163b4 Document the pw_util(3) functions
Reviewed by:	des, gjb
2012-10-30 22:18:08 +00:00
Baptiste Daroussin
b3d9795c98 backout r242319, racy and not done in the right place
Reported by:	Garrett Cooper  <yanegomi@gmail.com>
2012-10-29 18:06:09 +00:00
Baptiste Daroussin
29e575503c make pw_init and gr_init fail if the specified master password or group file is
a directory.

MFC after:	1 month
2012-10-29 17:19:43 +00:00
Baptiste Daroussin
de0bfe73b9 Fix IEC / SI binary prefixes (Ki, Mi, Gi, etc) production by humanize_number(3)
PR:		bin/171487
Submitted by:	matthew
MFC after:	1 week
2012-09-12 11:41:03 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Dag-Erling Smørgrav
b4f560356a Switch the default password hash from md5 to sha512.
MFC after:	1 week
2012-06-19 14:46:18 +00:00
Baptiste Daroussin
2f1b1e91a3 Revert user comparison back to user names as some user can share uids (root/toor
for example)

get the username information from old_pw structures to still allow renaming of a
user.

Reported by:	Claude Buisson <clbuisson@orange.fr>
Approved by:	des (mentor)
MFC after:	3 weeks
2012-06-19 11:39:56 +00:00
Dag-Erling Smørgrav
7c5a921699 Finally nuke auth.conf, nine years after it was deprecated. The only
thing it was still used for was to set the "global default" password
hash.  Since the stock auth.conf contained nothing but comments, the
global default was actually the first algorithm in crypt(3)'s list,
which happens to be DES; I take the fact that nobody noticed as proof
that it was not used outside of crypt(3).

The only other use in our tree was in the Kerberos support code in
in tinyware's passwd(1).  I removed that code in an earlier commit;
it would not have compiled anyway, as it only supported Kerberos IV.

The auth_getval() function is now a stub that always returns NULL,
which has the same effect as a functional auth_getval() with an
empty auth.conf.

MFC after:	3 weeks
2012-06-12 17:02:53 +00:00
Dag-Erling Smørgrav
fb374358bf Document that we also support sha256 and sha512.
MFC after:	1 week
2012-06-08 12:36:08 +00:00
Glen Barber
7b1d17a1bc General mdoc(7) and typo fixes.
PR:		167804
Submitted by:	Nobuyuki Koganemaru (kogane!jp.freebsd.org)
MFC after:	3 days
2012-05-12 15:08:22 +00:00
Joel Dahl
66265da747 mdoc: terminate quoted strings. 2012-03-30 12:34:34 +00:00
Joel Dahl
288eac5aed mandoc complains loudly when <TAB>s are misused in columnated lists. Fix
this syntax violation and while I'm here also convert <TAB> to Ta and adjust
quotation marks in order to prevent this problem in the future.
2012-03-29 16:02:40 +00:00
Eitan Adler
50d675f7a9 Remove trailing whitespace per mdoc lint warning
Disussed with:	gavin
No objection from:	doc
Approved by:	joel
MFC after:	3 days
2012-03-29 05:02:12 +00:00
Joel Dahl
bea977e7f6 mdoc: sort prologue macros. 2012-03-26 19:23:57 +00:00
Joel Dahl
61a0bf2af8 This string should be quoted.
Noticed by:	brueffer
2012-03-26 15:29:02 +00:00
Joel Dahl
c2965cd185 mdoc: terminate quoted strings.
Reviewed by:	brueffer
2012-03-26 15:18:14 +00:00
Glen Barber
3102cfe2e2 Fix various typos in manual pages.
Submitted by:	amdmi3
PR:		165431
MFC after:	1 week
2012-02-25 14:31:25 +00:00
Guy Helmer
fde4439701 Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the
file descriptor via exec(3).

Now that daemon(8) has been fixed to resolve the issue noted by trociny,
the consensus is that this change should be OK.
2012-02-20 13:59:24 +00:00
Ed Schouten
e6ad3d22f4 Detect file modification properly by using tv_nsec.
POSIX 2008 standardizes st_mtim, meaning we can simply use nanosecond
precision to detect file modification.

MFC after:	2 weeks
2012-02-10 13:40:32 +00:00
Eitan Adler
0bdc3ecf11 Fix NULL ptr dereference in setusercontext if pwd is null,
LOGIN_SETPRIORITY is set, and setting the priority (rtprio or
setpriority) fails.

PR:		kern/164238
Submitted by:	Alexander Wittig <alexander@wittig.name>
Reviewed by:	des
Approved by:	cperciva
MFC after:	1 month
2012-02-09 21:06:47 +00:00
Pawel Jakub Dawidek
cc1ddd46b2 Add a comment to the example that pidfile_* functions can handle pfh being NULL.
MFC after:	3 days
2012-02-08 08:49:30 +00:00
Pawel Jakub Dawidek
7f8d054f8a Note that calling pidfile_write(3) multiple times is fine.
MFC after:	3 days
2012-02-08 08:43:41 +00:00
Guy Helmer
000d6ce285 Using the O_CLOEXEC flag on open(2) caused the pidfile lock to be lost
when the child process execs daemon's target program thanks to flock(2)
semantics. So, we apparently have to leak the open pidfile's file
descriptor to keep the lock for the pidfile(3) functions to work properly.

Test case demonstrated by trociny:

ref8-amd64:/home/trociny% uname -r
8.2-STABLE
ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10
ref8-amd64:/home/trociny% daemon -p /tmp/sleep.pid sleep 10
daemon: process already running, pid: 19799

kopusha:~% uname -r
10.0-CURRENT
kopusha:~% daemon -p /tmp/sleep.pid sleep 10
kopusha:~% daemon -p /tmp/sleep.pid sleep 10
kopusha:~%
2012-02-06 14:11:24 +00:00
Guy Helmer
0e4b06c859 Consensus between bde and pjd seemed to be that if the function names
are lined up, then any * after a long type should appear after the
type instead of being in front of the function name on the following
line.
2012-01-26 20:40:22 +00:00
Guy Helmer
56db75745d Make the comments consistent (capitalization, punctuation, and
format).

Requested by bde
2012-01-26 20:35:01 +00:00
Guy Helmer
edd38b5148 Restore the parenthesis that are necessary around the constant values.
Requested by bde.
2012-01-26 20:33:08 +00:00
Guy Helmer
5c005f0000 Remove unnecessary includes from these libutil man pages.
Requested by bde (as was the previous commit).
2012-01-16 21:25:41 +00:00
Guy Helmer
34775f8907 Fix more disorder in prototypes and constants.
Fix header comments for each section of constants.
Fix whitespace in #define lines.
Fix unnecessary parenthesis in constants.
2012-01-16 21:19:23 +00:00
Guy Helmer
47b3924be0 Move struct pidfh definition into pidfile.c, and leave a forward declaration
for pidfh in libutil.h in its place.
This allows us to hide the contents of the pidfh structure, and also
allowed removal of the "#ifdef _SYS_PARAM_H" guard from around the
pidfile_* function prototypes.

Suggested by pjd.
2012-01-12 22:49:36 +00:00
Guy Helmer
72c131535d Fix disorder in MAN and MLINKS lists.
Requested by bde.
2012-01-12 15:45:08 +00:00
Guy Helmer
8afc5005d8 More prototype formatting fixes, struct member formatting fixes,
and namespace fix for property_find() prototype.

Provided by bde.
2012-01-12 14:40:25 +00:00
Guy Helmer
50636e133d pidfile_open() no longer uses fcntl() to set the close-on-exec flag. 2012-01-12 14:13:49 +00:00
Guy Helmer
744c415775 Fix prototype formatting (indentation, long lines, and continued lines).
Requested by bde.
2012-01-11 22:45:15 +00:00
Guy Helmer
a8cada5425 Fix namespace issues with prototype parameter names.
Add missing prototype parameter names.

Requested by bde.
2012-01-11 22:33:41 +00:00
Guy Helmer
46719410f3 Fix forward structure declaration and prototype disorder.
Requested by bde.
2012-01-11 22:12:45 +00:00
Guy Helmer
656b6da7e3 jilles pointed out that O_CLOEXEC could be used in the open(2) flags
rather than using fcntl(2) later, and in addition to saving a system
call, removes a possible race with fork/exec from threads or signal
handlers.
2012-01-11 16:35:26 +00:00
Pawel Jakub Dawidek
9de091f2ef Constify arguments. 2012-01-11 00:31:04 +00:00
Guy Helmer
bd4df56c71 Add link for pidfile_fileno.3 to pidfile.3 - thanks again pjd! 2012-01-10 22:22:35 +00:00
Guy Helmer
4a25aa061a Style fixes courtesy of pjd. 2012-01-10 21:47:58 +00:00
Guy Helmer
719060e911 Document that pidfile_open() now sets the FD_CLOEXEC flag on the open
file descriptor, and that errors can be returned as a result of the
fcntl(2) system call.
2012-01-10 21:39:43 +00:00
Guy Helmer
f295618d06 Add pidfile_fileno() to obtain the file descriptor for an open
pidfile.
2012-01-10 19:53:25 +00:00
Guy Helmer
0dc6d4d19c Set the FD_CLOEXEC flag on the open pidfile file descriptor.
Discussed with: pjd, des
2012-01-10 18:43:27 +00:00
Ulrich Spörlein
bf3f9db657 Convert files to UTF-8 and add some copyright markers where missing. 2012-01-07 16:13:56 +00:00
Baptiste Daroussin
a9e4a4780a Add new pw_make_v7 to make a passwd line (in v7 format) out of a struct passwd
while here, fix missing parentheses of the return statement of pw_make.

Approved by:	des (mentor)
2012-01-05 10:40:24 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Baptiste Daroussin
1926f2f6fa Modify pw_copy:
- if pw is NULL and oldpw is not NULL then the oldpw is deleted
- if pw->pw_name != oldpw->pw_name but pw->pw_uid == oldpw->pw_uid
then it renames the user

add new gr_* functions so now gr_util API is similar to pw_util API,
this allow to manipulate groups in a safe way.

Reviewed by:	des
Approved by:	des
MFC after:	1 month
2011-12-15 22:07:36 +00:00
Pawel Jakub Dawidek
e8cc80c0a0 In pidfile_open(), if the pidfile is locked, but empty (PID is not stored yet)
and the caller requested other process' PID by passing non-NULL pidptr
argument, we will wait at most 100ms for the PID to show up in the file and if
it won't, we will store -1 in *pidptr.

From now on, pidfile_open() function never sets errno to EAGAIN on failure.

In collaboration with:	des
MFC after:		1 week
2011-10-16 21:30:15 +00:00
Edward Tomasz Napierala
55f0bfbadc Add missing "swapuse" resource limit. 2011-07-09 08:42:23 +00:00
Stanislav Sedov
0daf62d9f5 - Commit work from libprocstat project. These patches add support for runtime
file and processes information retrieval from the running kernel via sysctl
  in the form of new library, libprocstat.  The library also supports KVM backend
  for analyzing memory crash dumps.  Both procstat(1) and fstat(1) utilities have
  been modified to take advantage of the library (as the bonus point the fstat(1)
  utility no longer need superuser privileges to operate), and the procstat(1)
  utility is now able to display information from memory dumps as well.

  The newly introduced fuser(1) utility also uses this library and able to operate
  via sysctl and kvm backends.

  The library is by no means complete (e.g. KVM backend is missing vnode name
  resolution routines, and there're no manpages for the library itself) so I
  plan to improve it further.  I'm commiting it so it will get wider exposure
  and review.

  We won't be able to MFC this work as it relies on changes in HEAD, which
  was introduced some time ago, that break kernel ABI.  OTOH we may be able
  to merge the library with KVM backend if we really need it there.

Discussed with:	rwatson
2011-05-12 10:11:39 +00:00
David E. O'Brien
b928a692c2 Don't duplicate define the stdint types. 2011-05-05 14:45:24 +00:00
Xin LI
7d14df1a2d Add support for IEE/IEC (and now also SI) power of two notions of
prefixes (Ki, Mi, Gi...) for humanize_number(3).

Note that applications has to pass HN_IEC_PREFIXES to use this
feature for backward compatibility reasons.

Reviewed by:	arundel
MFC after:	2 weeks
2011-04-12 22:48:03 +00:00
Sergey Kandaurov
c6b2aa689a Add missing resource limits:
- RLIMIT_NPTS
- RLIMIT_SWAP

MFC after:	1 week
2011-03-24 16:06:57 +00:00
Xin LI
a699e14f45 humanize_number(3) multiply the input number by 100, which could cause an
integer overflow when the input is very large (for example, 100 Pi would
become about 10 Ei which exceeded signed int64_t).

Solve this issue by splitting the division into two parts and avoid the
multiplication.

PR:		bin/146205
Reviewed by:	arundel
MFC after:	1 month
2011-03-23 22:08:01 +00:00
Glen Barber
5f2e9efbf9 s/buffer/buf as is used in the code.
Submitted by:	arundel (via doc@)
MFC after:	3 days
2011-03-21 23:59:20 +00:00
Pawel Jakub Dawidek
fdf6b12d1c expand_number() needs uint64_t, declare it here if not already declared.
MFC after:	3 days
2011-03-06 17:46:06 +00:00
Edward Tomasz Napierala
ffa5101067 Mention setloginclass(2) in login_class(3). 2011-03-06 08:56:44 +00:00
Edward Tomasz Napierala
2bfc50bc4f Add two new system calls, setloginclass(2) and getloginclass(2). This makes
it possible for the kernel to track login class the process is assigned to,
which is required for RCTL.  This change also make setusercontext(3) call
setloginclass(2) and makes it possible to retrieve current login class using
id(1).

Reviewed by:	kib (as part of a larger patch)
2011-03-05 12:40:35 +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
Dag-Erling Smørgrav
b8370f59bd UTFize my name. 2010-08-22 11:48:32 +00:00
Joel Dahl
c2025a7660 Fix typos, spelling, formatting and mdoc mistakes found by Nobuyuki while
translating these manual pages.  Minor corrections by me.

Submitted by:	Nobuyuki Koganemaru <n-kogane@syd.odn.ne.jp>
2010-08-16 15:18:30 +00:00
Dag-Erling Smørgrav
35305a8dc1 In setusercontext(), do not apply user settings unless running as the
user in question (usually but not necessarily because we were called
with LOGIN_SETUSER).  This plugs a hole where users could raise their
resource limits and expand their CPU mask.

MFC after:	3 weeks
2010-08-16 11:32:20 +00:00
Dag-Erling Smørgrav
f4fda7679a Old patch I had lying around: clean up and use stpcpy(3) instead of
sprintf(3).
2010-08-16 11:22:12 +00:00
Dag-Erling Smørgrav
a2e0c5ae31 Further simplify the code, and update the manpage.
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2010-08-15 18:32:06 +00:00
Dag-Erling Smørgrav
b6fbd4d50d no-op commit to note that the example given in the previous commit is
a very bad one, since the shift does not actually overflow.  This is
a better example (assuming uint64_t = unsigned long long):

  ~0LLU >> 9             =   0x7fffffffffffffLLU
  ~0LLU >> 9 << 10       = 0xfffffffffffffc00LLU
  ~0LLU >> 9 << 10 >> 10 =   0x3fffffffffffffLLU
2010-08-15 14:55:32 +00:00
Dag-Erling Smørgrav
1035d74025 Fix the overflow test. It is possible for the result of an
overflowing shift to be larger than the original value, e.g.

         (uint64_t)1 << 53 = 0x20000000000000
 ((uint64_t)1 << 53) << 10 = 0x8000000000000000
2010-08-15 14:50:03 +00:00
Dag-Erling Smørgrav
bbb2703b4f Simplify expand_number() by combining the (unrolled) loop with the
switch.  Since expand_number() does not accept negative numbers, switch
from int64_t to uint64_t; this makes it easier to check for overflow.

MFC after:	3 weeks
2010-08-14 14:34:36 +00:00
Joel Dahl
f6ac23919b Fix typos and spelling mistakes. 2010-08-06 14:33:42 +00:00
Joel Dahl
799162a628 Spelling fixes. 2010-08-03 17:40:09 +00:00
Kirk McKusick
a4bf5fb987 Update to current version of head. 2010-04-28 05:33:59 +00:00
Ulrich Spörlein
aa12cea2cc mdoc: order prologue macros consistently by Dd/Dt/Os
Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by:	ru
Approved by:	philip, ed (mentors)
2010-04-14 19:08:06 +00:00
Kirk McKusick
516ad57b74 Debugging nits found while testing the new 64-bit quota code. 2010-03-16 06:12:30 +00:00
Dag-Erling Smørgrav
1a0fda2b54 IFH@204581 2010-03-04 13:35:57 +00:00
Joel Dahl
f20b6c8575 The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from:	NetBSD
2010-03-02 17:06:40 +00:00
Ed Schouten
2c8d07a874 Fix a regression that was introduced in r191882.
I changed login_tty() to only work when the application is not a session
leader yet. This works fine for applications in the base system, but it
turns out various applications call this function after daemonizing,
which means they already use their own session.

If setsid() fails, just call tcsetsid() on the current session.
tcsetsid() will already perform proper security checks.

Reported by:	Oliver Lehmann
MFC after:	1 week
2010-01-17 17:52:35 +00:00
Ed Schouten
21470ecd91 Remove login(3), logout(3) and logwtmp(3) from libutil.
These functions only apply to utmp(5). They cannot be kept intact when
moving towards utmpx. The login(3) function would break, because its
argument is an utmp structure. The logout(3) and logwtmp(3) functions
cannot be used, since they provide a functionality which partially
overlaps.

Increment SHLIB_MAJOR to 9 to indicate the removal.
2010-01-13 18:59:51 +00:00
Ed Schouten
daaf575910 Build lib/ with WARNS=6 by default.
Similar to libexec/, do the same with lib/. Make WARNS=6 the norm and
lower it when needed.

I'm setting WARNS?=0 for secure/. It seems secure/ includes the
Makefile.inc provided by lib/. I'm not going to touch that directory.
Most of the code there is contributed anyway.
2010-01-02 09:58:07 +00:00
Kirk McKusick
aee785babd Add and document the quota_convert function which converts between the
old 32-bit and the new 64-bit formats.
2009-12-28 22:44:19 +00:00
Kirk McKusick
c3616249ab Minor bugs turned up during conversion of quotacheck. 2009-12-27 06:26:04 +00:00
Sean Farley
0dd84a53d7 Remove a dead store.
MFC after:	5 days
2009-12-12 00:11:40 +00:00
Ed Schouten
8b8ec2e2b1 Make <libutil.h> work when included by itself.
There are several reasons why it didn't work:

- It was missing <sys/cdefs.h> for __BEGIN_DECLS.
- It uses various primitive types that were not declared.
2009-12-02 15:56:18 +00:00
Konstantin Belousov
5dc1529c34 sigset() is the name of function specified by SUSv4.
Replace it to avoid conflict.

MFC after:	3 weeks
2009-11-26 13:41:15 +00:00
Kirk McKusick
e525d16a80 Add and document new quoat_on and quota_off functions. 2009-11-16 18:59:04 +00:00
Kirk McKusick
6197731d81 Add quota_maxid which returns the maximum user (or group) identifier
in an associated quotafile. Needed by repquota.

Bug fix in quota_read.
2009-10-20 05:37:54 +00:00
Dag-Erling Smørgrav
5666aadb3d Further extend the quotafile API. 2009-09-26 23:16:06 +00:00
Dag-Erling Smørgrav
fdd356a8d1 Style 2009-09-25 23:27:07 +00:00
Dag-Erling Smørgrav
10b3b54548 Merge from head 2009-09-17 16:16:44 +00:00
Dag-Erling Smørgrav
7d4b968b0f Merge from head up to r188941 (last revision before the USB stack switch) 2009-09-17 13:31:39 +00:00
Ken Smith
3ca3047aee Bump the version of all non-symbol-versioned shared libraries in
preparation for 8.0-RELEASE.  Add the previous version of those
libraries to ObsoleteFiles.inc and bump __FreeBSD_Version.

Reviewed by:    kib
Approved by:    re (rwatson)
2009-07-19 17:25:24 +00:00
Robert Watson
63d9261ab2 Fix copy-and-paste-o's from kinfo_getfile.3 in kinfo_getvmmap.3.
MFC after:	3 days
2009-06-24 12:52:59 +00:00
Xin LI
75d2ea6c50 Merge NetBSD revision 1.14: humanize_number.c is now 2-clause BSD licensed.
(humanize_number.3 intentionally hold back until I make sure why we didn't
merged dehumanize_number(3)).

Obtained from:	NetBSD
2009-06-23 23:27:35 +00:00
Konstantin Belousov
c9253e931d Usermode portion of the support for swap allocation accounting:
- update for getrlimit(2) manpage;
- support for setting RLIMIT_SWAP in login class;
- addition to the limits(1) and sh and csh limit-setting builtins;
- tuning(7) documentation on the sysctls controlling overcommit.

In collaboration with:	pho
Reviewed by:	alc
Approved by:	re (kensmith)
2009-06-23 20:57:27 +00:00
John Baldwin
7b593c5d9d Note that the structures are defined in <sys/user.h> in the text (using
language from stat(2)) rather than in the synopsis.

Requested by:	bde
2009-06-15 15:43:00 +00:00
John Baldwin
6a3401c5dc - Note that these interfaces require <sys/user.h> for the structure
definitions.
- Note that these functions return NULL on failure.

MFC after:	3 days
2009-06-12 18:13:34 +00:00
Dag-Erling Smørgrav
5649afd028 Revert (once again, and hopefully for the last time) to flock(2) locks.
The problem with fcntl(2) locks is that they are not inherited by child
processes.  This breaks pidfile(3), where the common idiom is to open
and lock the PID file before daemonizing.
2009-06-06 18:47:03 +00:00
Dag-Erling Smørgrav
a27c52a943 Add missing .Pp 2009-06-06 17:34:49 +00:00
Ed Schouten
46b303e83d Add tcsetsid(3).
The entire world seems to use the non-standard TIOCSCTTY ioctl to make a
TTY a controlling terminal of a session. Even though tcsetsid(3) is also
non-standard, I think it's a lot better to use in our own source code,
mainly because it's similar to tcsetpgrp(), tcgetpgrp() and tcgetsid().

I stole the idea from QNX. They do it the other way around; their
TIOCSCTTY is just a wrapper around tcsetsid(). tcsetsid() then calls
into an IPC framework.
2009-05-07 13:49:48 +00:00
Kirk McKusick
8bd6a3ab4b Update the quotafile library to manage both active quotas via the
quotactl(2) interface and inactive quotas by accessing the quota
files directly.

Update the edquota program to use this new interface as proof of
concept.
2009-02-14 08:08:08 +00:00