summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a bazillion lint and WARNS warnings. One major fix is the removal ofmarkm2002-07-151-2/+2
| | | | | | | | | | | | | | | | | | semicolons from the end of macros: #define FOO() bar(a,b,c); becomes #define FOO() bar(a,b,c) Thus requiring the semicolon in the invocation of FOO. This is much cleaner syntax and more consistent with expectations when writing function-like things in source. With both peril-sensitive sunglasses and flame-proof undies on, tighten up some types, and work around some warnings generated by this. There are some _horrible_ const/non-const issues in this code.
* more caddr_t removal.alfred2002-06-291-2/+1
|
* Update comment regarding the locking of the sysctl tree.rwatson2002-04-021-10/+10
| | | | | | | | Rename memlock to sysctllock, and MEMLOCK()/MEMUNLOCK() to SYSCTL_LOCK()/ SYSCTL_UNLOCK() and related changes to make the lock names make more sense. Submitted by: Jonathan Mini <mini@haikugeek.com>
* Use sx locks instead of flags+tsleep locks.alfred2002-04-021-31/+11
| | | | Submitted by: Jonathan Mini <mini@haikugeek.com>
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-2/+2
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* In sysctl, req->td is believed always to be non-NULL, so there's no needrwatson2002-03-221-20/+14
| | | | | | | | | | | | | | to test req->td for NULL values and then do somewhat more bizarre things relating to securelevel special-casing and suser checks. Remove the testing and conditional security checks based on req->td!=NULL, and insert a KASSERT that td != NULL. Callers to sysctl must always specify the thread (be it kernel or otherwise) requesting the operation, or a number of current sysctls will fail due to assumptions that the thread exists. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Discussed with: bde
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-1/+1
| | | | reference.
* Add code to export and print the description associated to sysctlluigi2001-12-161-0/+27
| | | | | | | | | | | | | | | | variables. Use the -d flag in sysctl(8) to see this information. Possible extensions to sysctl: + report variables that do not have a description + given a name, report the oid it maps to. Note to developers: have a look at your code, there are a number of variables which do not have a description. Note to developers: do we want this in 4.5 ? It is a very small change and very useful for documentation purposes. Suggested by: Orion Hodson
* Dont print the sysctl node tree unless you're root.peter2001-11-281-0/+5
| | | | Found by: jkb (Yahoo OS troublemaker)
* o Replace reference to 'struct proc' with 'struct thread' in 'structrwatson2001-11-081-6/+6
| | | | | | | | | | | | | | | sysctl_req', which describes in-progress sysctl requests. This permits sysctl handlers to have access to the current thread, permitting work on implementing td->td_ucred, migration of suser() to using struct thread to derive the appropriate ucred, and allowing struct thread to be passed down to other code, such as network code where td is not currently available (and curproc is used). o Note: netncp and netsmb are not updated to reflect this change, as they are not currently KSE-adapted. Reviewed by: julian Obtained from: TrustedBSD Project
* Remove the panic when trying to register a sysctl with an oid too high.roam2001-10-121-2/+6
| | | | | | | | | | | | | | | This stops panics on unloading modules which define their own sysctl sets. However, this also removes the protection against somebody actually defining a static sysctl with an oid in the range of the dynamic ones, which would break badly if there is already a dynamic sysctl with the requested oid. Apparently, the algorithm for removing sysctl sets needs a bit more work. For the present, the panic I introduced only leads to Bad Things (tm). Submitted by: many users of -current :( Pointy hat to: roam (myself) for not testing rev. 1.112 enough.
* o Modify sysctl access control check to use securelevel_gt(), andrwatson2001-09-261-9/+29
| | | | | | clarify sysctl access control logic. Obtained from: TrustedBSD Project
* KSE Milestone 2julian2001-09-121-18/+18
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Giant Pushdowndillon2001-09-011-11/+28
| | | | | | | | clock_gettime() clock_settime() nanosleep() settimeofday() adjtime() getitimer() setitimer() __sysctl() ogetkerninfo() sigaction() osigaction() sigpending() osigpending() osigvec() osigblock() osigsetmask() sigsuspend() osigsuspend() osigstack() sigaltstack() kill() okillpg() trapsignal() nosys()
* Fix the ogetkerninfo() syscall handling of sizes forpeter2001-08-291-10/+12
| | | | | | | | KINFO_BSDI_SYSINFO. This supposedly fixes Netscape 3.0.4 (bsdi binary) on -current. (and is also applicable to RELENG_4) PR: 25476 Submitted by: Philipp Mergenthaler <un1i@rz.uni-karlsruhe.de>
* Make dynamic sysctl entries start at 0x100, not decimal 100 - there areroam2001-07-251-3/+7
| | | | | | | | | | | | static entries with oid's over 100, and defining enough dynamic entries causes an overlap. Move the "magic" value 0x100 into <sys/sysctl.h> where it belongs. PR: 29131 Submitted by: "Alexander N. Kabaev" <kabaev@mail.ru> Reviewed by: -arch, -audit MFC after: 2 weeks
* Style(9): function names on a separate line, max line length 80 chars.roam2001-07-251-4/+8
| | | | | Reviewed by: -arch, -audit MFC after: 2 weeks
* int -> size_t fixmjacob2001-06-221-2/+2
|
* With this commit, I hereby pronounce gensetdefs past its use-by date.peter2001-06-131-22/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the a.out emulation of 'struct linker_set' with something a little more flexible. <sys/linker_set.h> now provides macros for accessing elements and completely hides the implementation. The linker_set.h macros have been on the back burner in various forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()), John Polstra (ELF clue) and myself (cleaned up API and the conversion of the rest of the kernel to use it). The macros declare a strongly typed set. They return elements with the type that you declare the set with, rather than a generic void *. For ELF, we use the magic ld symbols (__start_<setname> and __stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the trick about how to force ld to provide them for kld's. For a.out, we use the old linker_set struct. NOTE: the item lists are no longer null terminated. This is why the code impact is high in certain areas. The runtime linker has a new method to find the linker set boundaries depending on which backend format is in use. linker sets are still module/kld unfriendly and should never be used for anything that may be modular one day. Reviewed by: eivind
* When tring to find out if this is a request for a write indd2001-06-031-2/+2
| | | | | kernel_sysctl and userland_sysctl, check for whether new is NULL, not whether newlen is 0. This allows one to set a string sysctl to "".
* Add convenience function kernel_sysctlbyname() for kernel consumers,jlemon2001-05-191-1/+24
| | | | so they don't have to roll their own sysctlbyname function.
* Make the SYSCTL_OUT handlers sysctl_old_user() and sysctl_old_kernel()tmm2001-03-081-4/+10
| | | | | | | | more robust. They would correctly return ENOMEM for the first time when the buffer was exhausted, but subsequent calls in this case could cause writes ouside of the buffer bounds. Approved by: rwatson
* Mechanical change to use <sys/queue.h> macro API instead ofphk2001-02-041-1/+1
| | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1)
* Remove unused variable 'int n;'peter2001-01-291-1/+0
|
* Never reuse AUTO_OID values.mckusick2001-01-241-7/+5
| | | | Approved by: Alfred Perlstein <bright@wintelcom.net>
* - For dynamic sysctl's added at runtime, don't assume that the name passedjhb2001-01-051-2/+2
| | | | | | | | to the SYSCTL_ADD_FOO() macros is a constant that should be turned into a string via the pre-processor. Instead, require it to be an explicit string so that names can be generated on the fly. - Make some of the char * arguments to sysctl_add_oid() const to quiet warnings.
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-2/+1
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Fix some style nits.peter2000-07-281-10/+13
| | | | Fix(?) some compile warnings regarding const handling.
* These patches implement dynamic sysctls. It's possible now to addabial2000-07-151-0/+252
| | | | | | | | | | | | | | | | | | | | | | and remove sysctl oids at will during runtime - they don't rely on linker sets. Also, the node oids can be referenced by more than one kernel user, which means that it's possible to create partially overlapping trees. Add sysctl contexts to help programmers manage multiple dynamic oids in convenient way. Please see the manpages for detailed discussion, and example module for typical use. This work is based on ideas and code snippets coming from many people, among them: Arun Sharma, Jonathan Lemon, Doug Rabson, Brian Feldman, Kelly Yancey, Poul-Henning Kamp and others. I'd like to specially thank Brian Feldman for detailed review and style fixes. PR: kern/16928 Reviewed by: dfr, green, phk
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.phk2000-07-041-11/+11
| | | | Pointed out by: bde
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:phk2000-07-031-11/+11
| | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS)
* Back out the previous change to the queue(3) interface.jake2000-05-261-1/+1
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-1/+1
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Remove unneeded <sys/buf.h> includes.phk2000-04-181-1/+0
| | | | | Due to some interesting cpp tricks in lockmgr, the LINT kernel shrinks by 924 bytes.
* Remove unused 3rd argument from vsunlock() which abused B_WRITE.phk2000-03-131-2/+2
|
* Separate some common sysctl code into sysctl_find_oid() and callinggreen1999-12-011-68/+65
| | | | | thereof. Also, make the errno returns _correct_, and add a new one which is more appropriate.
* Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for thephk1999-10-301-2/+2
| | | | | | | | | "rw" argument, rather than hijacking B_{READ|WRITE}. Fix two bugs (physio & cam) resulting by the confusion caused by this. Submitted by: Tor.Egge@fast.no Reviewed by: alc, ken (partly)
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Minor tweaks to make sure (new) prerequisites for <sys/buf.h> (mostlypeter1999-06-271-3/+3
| | | | splbio()/splx()) are #included in time.
* This Implements the mumbled about "Jail" feature.phk1999-04-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a seriously beefed up chroot kind of thing. The process is jailed along the same lines as a chroot does it, but with additional tough restrictions imposed on what the superuser can do. For all I know, it is safe to hand over the root bit inside a prison to the customer living in that prison, this is what it was developed for in fact: "real virtual servers". Each prison has an ip number associated with it, which all IP communications will be coerced to use and each prison has its own hostname. Needless to say, you need more RAM this way, but the advantage is that each customer can run their own particular version of apache and not stomp on the toes of their neighbors. It generally does what one would expect, but setting up a jail still takes a little knowledge. A few notes: I have no scripts for setting up a jail, don't ask me for them. The IP number should be an alias on one of the interfaces. mount a /proc in each jail, it will make ps more useable. /proc/<pid>/status tells the hostname of the prison for jailed processes. Quotas are only sensible if you have a mountpoint per prison. There are no privisions for stopping resource-hogging. Some "#ifdef INET" and similar may be missing (send patches!) If somebody wants to take it from here and develop it into more of a "virtual machine" they should be most welcome! Tools, comments, patches & documentation most welcome. Have fun... Sponsored by: http://www.rndassociates.com/ Run for almost a year by: http://www.servetheweb.com/
* Suser() simplification:phk1999-04-271-2/+2
| | | | | | | | | | | | | | | | | | | 1: s/suser/suser_xxx/ 2: Add new function: suser(struct proc *), prototyped in <sys/proc.h>. 3: s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/ The remaining suser_xxx() calls will be scrutinized and dealt with later. There may be some unneeded #include <sys/cred.h>, but they are left as an exercise for Bruce. More changes to the suser() API will come along with the "jail" code.
* Purging lint from the Bruce filter.phk1999-03-301-12/+10
|
* Fix some nasty hangs if garbage were passed.phk1999-03-231-4/+6
| | | | | Noticed by: Emmanuel DELOGET <pixel@DotCom.FR> Remembered by: msmith
* * Change sysctl from using linker_set to construct its tree using SLISTs.dfr1999-02-161-174/+157
| | | | | | | | | | This makes it possible to change the sysctl tree at runtime. * Change KLD to find and register any sysctl nodes contained in the loaded file and to unregister them when the file is unloaded. Reviewed by: Archie Cobbs <archie@whistle.com>, Peter Wemm <peter@netplex.com.au> (well they looked at it anyway)
* Back out last change to sysctl.phk1999-01-101-47/+2
| | | | | | | | | | | | | | | | | | | | | | | It was nay'ed before committing on the grounds that this is not the way to do it, and has been decided as such several times in the past. There is not point in loading gobs of ascii into the kernel when the only use of that ascii is presentation to the user. Next thing we'd be adding all section 4 man pages to the loaded kernel as well. The argument about KLD's is bogus, klds can store a file in /usr/share/doc/sysctl/dev/foo/thisvar.txt with a description and sysctl or other facilities can pick it up there. Proper documentation will take several K worth of text for many sysctl variables, we don't want that in the kernel under any circumstances. I will welcome any well thought out attempt at improving the situation wrt. sysctl documentation, but this wasn't it.
* Add kernel support for sysctl descriptions. The NO_SYSCTL_DESCRIPTIONS optiondes1999-01-101-3/+48
| | | | | | | disables them if they're not wanted; in that case, sysctl_sysctl_descr will always return an empty string. Apporved by: jkh
* Fix some 64bit truncation problems which crept into SYSCTL_LONG() with thedfr1998-12-271-34/+4
| | | | | | | | last cleanup. Since the oid_arg2 field of struct sysctl_oid is not wide enough to hold a long, the SYSCTL_LONG() macro has been modified to only support exporting long variables by pointer instead of by value. Reviewed by: bde
* Add a generic flag, CTLFLAG_SECURE, which can be used to mark a sysctltruckman1998-12-131-2/+3
| | | | | variable unwriteable when securelevel > 0. Reviewed by: jdp, eivind
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()archie1998-12-041-2/+2
| | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com>
* *gulp*. Jordan specifically OK'ed this..peter1998-10-161-1/+3
| | | | | | | | This is the bulk of the support for doing kld modules. Two linker_sets were replaced by SYSINIT()'s. VFS's and exec handlers are self registered. kld is now a superset of lkm. I have converted most of them, they will follow as a seperate commit as samples. This all still works as a static a.out kernel using LKM's.
OpenPOWER on IntegriCloud