summaryrefslogtreecommitdiff
path: root/lib/libutil
Commit message (Collapse)AuthorAgeFilesLines
* MFC r202500:Ed Schouten2010-01-241-1/+1
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/stable/8/; revision=202929
* Merge from head to stable/8:Sean Farley2009-12-181-2/+2
| | | | | | | | r200423: Remove a dead store. Notes: svn path=/stable/8/; revision=200683
* MFC r199826:Konstantin Belousov2009-12-171-4/+4
| | | | | | | | sigset() is the name of function specified by SUSv4. Replace it to avoid conflict. Notes: svn path=/stable/8/; revision=200643
* Bump the version of all non-symbol-versioned shared libraries inKen Smith2009-07-191-1/+1
| | | | | | | | | | | 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) Notes: svn path=/head/; revision=195767
* Fix copy-and-paste-o's from kinfo_getfile.3 in kinfo_getvmmap.3.Robert Watson2009-06-241-2/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=194831
* Merge NetBSD revision 1.14: humanize_number.c is now 2-clause BSD licensed.Xin LI2009-06-231-8/+1
| | | | | | | | | | (humanize_number.3 intentionally hold back until I make sure why we didn't merged dehumanize_number(3)). Obtained from: NetBSD Notes: svn path=/head/; revision=194794
* Usermode portion of the support for swap allocation accounting:Konstantin Belousov2009-06-231-0/+1
| | | | | | | | | | | | | | - 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) Notes: svn path=/head/; revision=194767
* Note that the structures are defined in <sys/user.h> in the text (usingJohn Baldwin2009-06-152-4/+4
| | | | | | | | | language from stat(2)) rather than in the synopsis. Requested by: bde Notes: svn path=/head/; revision=194240
* - Note that these interfaces require <sys/user.h> for the structureJohn Baldwin2009-06-122-2/+12
| | | | | | | | | | definitions. - Note that these functions return NULL on failure. MFC after: 3 days Notes: svn path=/head/; revision=194071
* Revert (once again, and hopefully for the last time) to flock(2) locks.Dag-Erling Smørgrav2009-06-062-23/+14
| | | | | | | | | 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. Notes: svn path=/head/; revision=193591
* Add missing .PpDag-Erling Smørgrav2009-06-061-0/+1
| | | | Notes: svn path=/head/; revision=193589
* Add tcsetsid(3).Ed Schouten2009-05-071-3/+7
| | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=191882
* Include param.h instead of types.h when using user.h. Otherwise there isRobert Watson2008-12-272-2/+2
| | | | | | | | | | a dependence on ucred.h including audit.h including param.h, which we would like to eliminate. MFC after: 3 weeks Notes: svn path=/head/; revision=186512
* Initialize the cntp pointer to 0 prior to doing any work so that callersJoe Marcus Clarke2008-12-192-8/+10
| | | | | | | | | | | don't try to iterate through garbage or NULL memory. Additionally, return NULL instead of 0 on error. Reviewed by: peter Approved by: peter Notes: svn path=/head/; revision=186314
* Add filler man pages for the kinfo functions I added recently.Peter Wemm2008-12-073-1/+149
| | | | | | | While here, hook up the hexdump(3) man page which wasn't being installed. Notes: svn path=/head/; revision=185729
* Attempt a quick bandaid for arm build breakage. I went to the trouble ofPeter Wemm2008-12-022-4/+4
| | | | | | | maintaining alignment, but I'm not sure how to tell gcc this. Notes: svn path=/head/; revision=185553
* Merge user/peter/kinfo branch as of r185547 into head.Peter Wemm2008-12-024-1/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes struct kinfo_filedesc and kinfo_vmentry such that they are same on both 32 and 64 bit platforms like i386/amd64 and won't require sysctl wrapping. Two new OIDs are assigned. The old ones are available under COMPAT_FREEBSD7 - but it isn't that simple. The superceded interface was never actually released on 7.x. The other main change is to pack the data passed to userland via the sysctl. kf_structsize and kve_structsize are reduced for the copyout. If you have a process with 100,000+ sockets open, the unpacked records require a 132MB+ copyout. With packing, it is "only" ~35MB. (Still seriously unpleasant, but not quite as devastating). A similar problem exists for the vmentry structure - have lots and lots of shared libraries and small mmaps and its copyout gets expensive too. My immediate problem is valgrind. It traditionally achieves this functionality by parsing procfs output, in a packed format. Secondly, when tracing 32 bit binaries on amd64 under valgrind, it uses a cross compiled 32 bit binary which ran directly into the differing data structures in 32 vs 64 bit mode. (valgrind uses this to track file descriptor operations and this therefore affected every single 32 bit binary) I've added two utility functions to libutil to unpack the structures into a fixed record length and to make it a little more convenient to use. Notes: svn path=/head/; revision=185548
* Fixing !INET6 builds.Tai-hwa Liang2008-11-251-0/+2
| | | | Notes: svn path=/head/; revision=185277
* Fixed style issues with variable ordering and naming, spacing andSean Farley2008-11-232-77/+99
| | | | | | | | | | | | | | | | | | | | parentheses. Fixed alignment issue in gr_dup() in its assignment of gr_mem using a struct to force alignment without performing alignment mathematics. This was noticed recently with libutil was built with WARNS=6 on platform such as sparc64. Added checks to gr_dup(), gr_equal() and gr_make() to prevent segfaults when examining struct group's with the struct members pointing to NULL's. With fix of alignment issue, restore WARNS?=6. Reviewed by: des MFC after: 1 week Notes: svn path=/head/; revision=185237
* style(9) fixes.Sean Farley2008-11-111-20/+14
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=184831
* Like many other functions that handle sockaddrs, realhostname_sa() takes aDag-Erling Smørgrav2008-11-051-5/+18
| | | | | | | | | | | | | | | | | | | | struct sockaddr * that it casts internally to the appropriate type based on sa_family. However, struct sockaddr has very lax alignment requirements, which causes the compiler to complain when you cast a struct sockaddr * to, say, a struct sockaddr_in6 *. I find it reasonable to assume that the pointer we received is in fact correctly aligned. Therefore, we can work around the compiler warnings by casting to void * before casting to the desired type. For readability's sake, this is done with macros. The same technique should prove useful in other parts of the tree that deal with socket addresses. MFC after: 3 weeks Notes: svn path=/head/; revision=184683
* Comment out WARNS. There are too many alignment issues in libutil.Dag-Erling Smørgrav2008-11-051-1/+1
| | | | Notes: svn path=/head/; revision=184677
* Disconnect gr_util.c from the build. It isn't documented or used anywhereDag-Erling Smørgrav2008-11-051-1/+1
| | | | | | | | in the tree, and due to unsafe pointer arithmetic, it will most likely crash on architectures with strict alignment requirements. Notes: svn path=/head/; revision=184676
* libutil now builds at WARNS level 6.Dag-Erling Smørgrav2008-11-041-0/+2
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=184635
* Add missing header.Dag-Erling Smørgrav2008-11-041-0/+1
| | | | Notes: svn path=/head/; revision=184634
* Avoid assigning a const char * to a char *.Dag-Erling Smørgrav2008-11-042-10/+10
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=184633
* Remove unneeded call to revoke() inside openpty().Ed Schouten2008-10-281-4/+0
| | | | | | | | | | | | | | | | | As discussed on the commits list, there is no need to call revoke() inside openpty(). On RELENG_6 and RELENG_7 unlockpt() will call revoke(). On HEAD we create pseudo-terminals on demand, so there is no need to revoke the slave device node. This change should never be MFC'd, because the implementation we have in RELENG_6 and RELENG_7 should work flawlessly with older versions of libc. Discussed with: jhb MFC after: never Notes: svn path=/head/; revision=184389
* Diff reduction against Varnish, including one important fix: use a sharedDag-Erling Smørgrav2008-10-201-12/+12
| | | | | | | lock if the file is opened with O_RDONLY. Notes: svn path=/head/; revision=184094
* Reimplement flopen(3) using fcntl(2) locks instead of flock(2) locks.Dag-Erling Smørgrav2008-10-202-13/+16
| | | | Notes: svn path=/head/; revision=184093
* pidfile(3) uses flopen(3) - don't make any assumptions about how theDag-Erling Smørgrav2008-10-201-9/+8
| | | | | | | latter is implemented. Notes: svn path=/head/; revision=184092
* There is no point in releasing a lock on a file which we've unlinked andDag-Erling Smørgrav2008-10-201-4/+0
| | | | | | | | are about to close, so don't. As a bonus, pidfile_remove(3) will now work with an fcntl(2)-based flopen(3). Notes: svn path=/head/; revision=184091
* Since in_lt() and in_lts() are not static, assume that they are intended toDag-Erling Smørgrav2008-10-202-2/+22
| | | | | | | be part of the public API. Accordingly, add prototypes and document them. Notes: svn path=/head/; revision=184088
* Additional style and whitespace fixes.Dag-Erling Smørgrav2008-10-201-1/+3
| | | | Notes: svn path=/head/; revision=184087
* Style and whitespaceDag-Erling Smørgrav2008-10-201-17/+17
| | | | Notes: svn path=/head/; revision=184086
* UnbreakDag-Erling Smørgrav2008-10-201-3/+3
| | | | Notes: svn path=/head/; revision=184085
* Since setclasscpumask() is not static, assume that it is intended to beDag-Erling Smørgrav2008-10-202-5/+10
| | | | | | | part of the public API. Accordingly, add a prototype and document it. Notes: svn path=/head/; revision=184084
* Style and whitespace.Dag-Erling Smørgrav2008-10-201-15/+19
| | | | Notes: svn path=/head/; revision=184083
* Parenthesize return values.Dag-Erling Smørgrav2008-10-201-11/+11
| | | | Notes: svn path=/head/; revision=184082
* include and whitespace cleanup.Dag-Erling Smørgrav2008-10-201-7/+8
| | | | Notes: svn path=/head/; revision=184081
* Use strlcpy() when we mean it.Xin LI2008-10-173-6/+3
| | | | Notes: svn path=/head/; revision=183989
* Small cleanups to openpty().Ed Schouten2008-10-031-23/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Pass O_NOCTTY to posix_openpt(2). This makes the implementation work consistently on implementations that make the PTY the controlling TTY by default. - Call unlockpt() before opening the slave device. POSIX mentions that de slave device should only be opened after grantpt() and unlockpt() have been called. - Replace some redundant code by a label. In theory we could remove a lot of code from openpty() on FreeBSD -CURRENT, because grantpt(), unlockpt() and revoke() are not needed in our implementation. We'd better keep them there. This makes the code still work with older FreeBSD releases and even makes it work on other non-BSD operating systems. I've compiled openpty() on Linux. You only need to remove the revoke() call, because revoke() on Linux always returns -1. Apart from that, it seems to work like it should. Reviewed by: jhb Notes: svn path=/head/; revision=183565
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.Ed Schouten2008-08-202-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following: - Improved driver model: The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers. If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver. - Improved hotplugging: With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc). The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly. - Improved performance: One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters. Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING. Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan Notes: svn path=/head/; revision=181905
* Add support for a new login capability, cpumask which allows loginBrooks Davis2008-07-254-1/+132
| | | | | | | sessions to be pinned to cpus by login class. Notes: svn path=/head/; revision=180815
* Add #include <inttypes.h> for the strtoimax().Konstantin Belousov2008-07-071-0/+1
| | | | | | | | Submitted by: Jilles Tjoelker <jilles stack nl> MFC after: 3 days Notes: svn path=/head/; revision=180347
* Merge hexdump(9) to userland as hexdump(3) in libutil. I'm tired of doingJohn Baldwin2008-07-014-3/+201
| | | | | | | | | this by hand in userland utilities. MFC after: 1 month Notes: svn path=/head/; revision=180161
* Add four utility functions related to struct grp processing modeled in-partSean Farley2008-04-233-1/+242
| | | | | | | | | | | | | | | | | | | | | | after similar calls related to struct pwd in libutil/pw_util.c: - gr_equal() Perform a deep comparison of two struct grp's. It does a thorough, yet unoptimized comparison of all the members regardless of order. - gr_make() Create a string (see group(5)) from a struct grp. - gr_dup() Duplicate a struct grp. Returns a value that is a single contiguous block of memory. - gr_scan() Create a struct grp from a string (as produced by gr_make()). MFC after: 3 weeks Notes: svn path=/head/; revision=178431
* Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13Antoine Brodin2008-03-081-5/+10
| | | | | | | | | | | | | | | | | Significant changes: - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print an int64_t. - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it should be "1.0G" or "1.0M". The bug reported by Greg Troxel. PR: 118461 PR: 102694 Approved by: rwatson (mentor) Obtained from: NetBSD MFC after: 1 month Notes: svn path=/head/; revision=176954
* Put back the openpty(3) and ptsname(3) fixes but don't disable ptsname(3)John Baldwin2008-01-151-55/+3
| | | | | | | | on pts(4) devices this time. This fixes the issues while leaving pts(4) enabled on HEAD. Notes: svn path=/head/; revision=175352
* Back out last commit, since it accidentally broke pts.Colin Percival2008-01-151-3/+55
| | | | | | | | The security fix will be re-committed soon, hopefully without breaking anything. Notes: svn path=/head/; revision=175350
* Update the manpage for openpty(3) to account for the recent fixes.John Baldwin2008-01-141-18/+14
| | | | | | | | | | | | | Specifically, remove the BUGS section and note that openpty(3) now always does the various security-related steps. Also, update the error return value section. The PR below is for the original bug rather than the doc updates. MFC after: 1 week PR: bin/9770 Notes: svn path=/head/; revision=175336