Deleted Added
full compact
kern_mib.c (86189) kern_mib.c (86190)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Karels at Berkeley Software Design, Inc.
7 *
8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Mike Karels at Berkeley Software Design, Inc.
7 *
8 * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
40 * $FreeBSD: head/sys/kern/kern_mib.c 86189 2001-11-08 15:20:00Z rwatson $
40 * $FreeBSD: head/sys/kern/kern_mib.c 86190 2001-11-08 15:31:19Z rwatson $
41 */
42
43#include "opt_global.h"
41 */
42
43#include "opt_global.h"
44#include "opt_posix.h"
44
45#include <sys/param.h>
46#include <sys/kernel.h>
47#include <sys/systm.h>
48#include <sys/sysctl.h>
49#include <sys/proc.h>
50#include <sys/jail.h>
51#include <sys/smp.h>

--- 18 unchanged lines hidden (view full) ---

70 "machine dependent");
71SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0,
72 "user-level");
73SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0,
74 "p1003_1b, (see p1003_1b.h)");
75
76SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0,
77 "Compatibility code");
45
46#include <sys/param.h>
47#include <sys/kernel.h>
48#include <sys/systm.h>
49#include <sys/sysctl.h>
50#include <sys/proc.h>
51#include <sys/jail.h>
52#include <sys/smp.h>

--- 18 unchanged lines hidden (view full) ---

71 "machine dependent");
72SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0,
73 "user-level");
74SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0,
75 "p1003_1b, (see p1003_1b.h)");
76
77SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0,
78 "Compatibility code");
79#ifdef REGRESSION
80SYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0,
81 "Regression test MIB");
82#endif
78
79SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD,
80 osrelease, 0, "Operating system type");
81
82SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD,
83 0, BSD, "Operating system revision");
84
85SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD,

--- 53 unchanged lines hidden (view full) ---

139
140SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD,
141 0, PAGE_SIZE, "System memory page size");
142
143static char machine_arch[] = MACHINE_ARCH;
144SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
145 machine_arch, 0, "System architecture");
146
83
84SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD,
85 osrelease, 0, "Operating system type");
86
87SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD,
88 0, BSD, "Operating system revision");
89
90SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD,

--- 53 unchanged lines hidden (view full) ---

144
145SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD,
146 0, PAGE_SIZE, "System memory page size");
147
148static char machine_arch[] = MACHINE_ARCH;
149SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
150 machine_arch, 0, "System architecture");
151
147#ifdef REGRESSION
148SYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0, "Regression test MIB");
149#endif /* !REGRESSION */
150
151char hostname[MAXHOSTNAMELEN];
152
153static int
154sysctl_hostname(SYSCTL_HANDLER_ARGS)
155{
156 int error;
157
158 if (jailed(req->td->td_proc->p_ucred)) {
159 if (!jail_set_hostname_allowed && req->newptr)
152char hostname[MAXHOSTNAMELEN];
153
154static int
155sysctl_hostname(SYSCTL_HANDLER_ARGS)
156{
157 int error;
158
159 if (jailed(req->td->td_proc->p_ucred)) {
160 if (!jail_set_hostname_allowed && req->newptr)
160 return(EPERM);
161 return (EPERM);
161 error = sysctl_handle_string(oidp,
162 req->td->td_proc->p_ucred->cr_prison->pr_host,
163 sizeof req->td->td_proc->p_ucred->cr_prison->pr_host, req);
164 } else
165 error = sysctl_handle_string(oidp,
166 hostname, sizeof hostname, req);
167 return (error);
168}
169
170SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname,
171 CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON,
172 0, 0, sysctl_hostname, "A", "Hostname");
173
174#ifdef REGRESSION
162 error = sysctl_handle_string(oidp,
163 req->td->td_proc->p_ucred->cr_prison->pr_host,
164 sizeof req->td->td_proc->p_ucred->cr_prison->pr_host, req);
165 } else
166 error = sysctl_handle_string(oidp,
167 hostname, sizeof hostname, req);
168 return (error);
169}
170
171SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname,
172 CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON,
173 0, 0, sysctl_hostname, "A", "Hostname");
174
175#ifdef REGRESSION
175int regression_securelevel_nonmonotonic=0;
176static int regression_securelevel_nonmonotonic = 0;
176
177SYSCTL_INT(_regression, OID_AUTO, securelevel_nonmonotonic, CTLFLAG_RW,
178 &regression_securelevel_nonmonotonic, 0, "securelevel may be lowered");
177
178SYSCTL_INT(_regression, OID_AUTO, securelevel_nonmonotonic, CTLFLAG_RW,
179 &regression_securelevel_nonmonotonic, 0, "securelevel may be lowered");
179#endif /* !REGRESSION */
180#endif
180
181int securelevel = -1;
182
183static int
184sysctl_kern_securelvl(SYSCTL_HANDLER_ARGS)
185{
186 struct prison *pr;
187 int error, level;

--- 13 unchanged lines hidden (view full) ---

201 return (error);
202 /*
203 * Permit update only if the new securelevel exceeds the
204 * global level, and local level if any.
205 */
206 if (pr != NULL) {
207#ifdef REGRESSION
208 if (!regression_securelevel_nonmonotonic)
181
182int securelevel = -1;
183
184static int
185sysctl_kern_securelvl(SYSCTL_HANDLER_ARGS)
186{
187 struct prison *pr;
188 int error, level;

--- 13 unchanged lines hidden (view full) ---

202 return (error);
203 /*
204 * Permit update only if the new securelevel exceeds the
205 * global level, and local level if any.
206 */
207 if (pr != NULL) {
208#ifdef REGRESSION
209 if (!regression_securelevel_nonmonotonic)
209#endif /* !REGRESSION */
210#endif
210 if (level < imax(securelevel, pr->pr_securelevel))
211 return (EPERM);
212 pr->pr_securelevel = level;
213 } else {
214#ifdef REGRESSION
215 if (!regression_securelevel_nonmonotonic)
211 if (level < imax(securelevel, pr->pr_securelevel))
212 return (EPERM);
213 pr->pr_securelevel = level;
214 } else {
215#ifdef REGRESSION
216 if (!regression_securelevel_nonmonotonic)
216#endif /* !REGRESSION */
217#endif
217 if (level < securelevel)
218 return (EPERM);
219 securelevel = level;
220 }
221 return (error);
222}
223
224SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
225 CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl,
226 "I", "Current secure level");
227
228char domainname[MAXHOSTNAMELEN];
229SYSCTL_STRING(_kern, KERN_NISDOMAINNAME, domainname, CTLFLAG_RW,
230 &domainname, sizeof(domainname), "Name of the current YP/NIS domain");
231
218 if (level < securelevel)
219 return (EPERM);
220 securelevel = level;
221 }
222 return (error);
223}
224
225SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
226 CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl,
227 "I", "Current secure level");
228
229char domainname[MAXHOSTNAMELEN];
230SYSCTL_STRING(_kern, KERN_NISDOMAINNAME, domainname, CTLFLAG_RW,
231 &domainname, sizeof(domainname), "Name of the current YP/NIS domain");
232
232unsigned long hostid;
233u_long hostid;
233SYSCTL_ULONG(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID");
234
235/*
236 * This is really cheating. These actually live in the libc, something
237 * which I'm not quite sure is a good idea anyway, but in order for
238 * getnext and friends to actually work, we define dummies here.
239 */
240SYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD,

--- 61 unchanged lines hidden ---
234SYSCTL_ULONG(_kern, KERN_HOSTID, hostid, CTLFLAG_RW, &hostid, 0, "Host ID");
235
236/*
237 * This is really cheating. These actually live in the libc, something
238 * which I'm not quite sure is a good idea anyway, but in order for
239 * getnext and friends to actually work, we define dummies here.
240 */
241SYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD,

--- 61 unchanged lines hidden ---