Project

General

Profile

Download (16.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php 
2
/* $Id$ */
3
/*
4
	services_snmp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6
	
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9
	
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
	
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
	
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
	
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_MODULE:	snmp
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-services-snmp
37
##|*NAME=Services: SNMP page
38
##|*DESCR=Allow access to the 'Services: SNMP' page.
39
##|*MATCH=services_snmp.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43

    
44
if (!is_array($config['snmpd'])) {
45
	$config['snmpd'] = array();
46
	$config['snmpd']['rocommunity'] = "public";
47
	$config['snmpd']['pollport'] = "161";
48
}
49

    
50
if (!is_array($config['snmpd']['modules'])) {
51
	$config['snmpd']['modules'] = array();
52
	$config['snmpd']['modules']['mibii'] = true;
53
	$config['snmpd']['modules']['netgraph'] = true;
54
	$config['snmpd']['modules']['pf'] = true;
55
	$config['snmpd']['modules']['hostres'] = true;
56
	$config['snmpd']['modules']['bridge'] = true;
57
}
58
$pconfig['enable'] = isset($config['snmpd']['enable']);
59
$pconfig['pollport'] = $config['snmpd']['pollport'];
60
$pconfig['syslocation'] = $config['snmpd']['syslocation'];
61
$pconfig['syscontact'] = $config['snmpd']['syscontact'];
62
$pconfig['rocommunity'] = $config['snmpd']['rocommunity'];
63
/* disabled until some docs show up on what this does.
64
$pconfig['rwenable'] = isset($config['snmpd']['rwenable']);
65
$pconfig['rwcommunity'] = $config['snmpd']['rwcommunity'];
66
*/
67
$pconfig['trapenable'] = isset($config['snmpd']['trapenable']);
68
$pconfig['trapserver'] = $config['snmpd']['trapserver'];
69
$pconfig['trapserverport'] = $config['snmpd']['trapserverport'];
70
$pconfig['trapstring'] = $config['snmpd']['trapstring'];
71

    
72
$pconfig['mibii'] = isset($config['snmpd']['modules']['mibii']);
73
$pconfig['netgraph'] = isset($config['snmpd']['modules']['netgraph']);
74
$pconfig['pf'] = isset($config['snmpd']['modules']['pf']);
75
$pconfig['hostres'] = isset($config['snmpd']['modules']['hostres']);
76
$pconfig['bridge'] = isset($config['snmpd']['modules']['bridge']);
77
$pconfig['bindlan'] = isset($config['snmpd']['bindlan']);
78

    
79
if ($_POST) {
80

    
81
	unset($input_errors);
82
	$pconfig = $_POST;
83

    
84
	/* input validation */
85
	if ($_POST['enable']) {
86
		$reqdfields = explode(" ", "rocommunity");
87
		$reqdfieldsn = array(gettext("Community"));
88
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
89

    
90
		$reqdfields = explode(" ", "pollport");
91
		$reqdfieldsn = array(gettext("Polling Port"));
92
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
93
		
94
	
95
	}
96

    
97
	if ($_POST['trapenable']) {
98
		$reqdfields = explode(" ", "trapserver");
99
		$reqdfieldsn = array(gettext("Trap server"));
100
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
101

    
102
		$reqdfields = explode(" ", "trapserverport");
103
		$reqdfieldsn = array(gettext("Trap server port"));
104
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
105

    
106
		$reqdfields = explode(" ", "trapstring");
107
		$reqdfieldsn = array(gettext("Trap string"));
108
		do_input_validation($_POST, $reqdfields, $reqdfields, $reqdfieldsn, &$input_errors);
109
	}
110

    
111

    
112
/* disabled until some docs show up on what this does.
113
	if ($_POST['rwenable']) {
114
               $reqdfields = explode(" ", "rwcommunity");
115
               $reqdfieldsn = explode(",", "Write community string");
116
               do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
117
	}
118
*/
119

    
120
	
121

    
122
	if (!$input_errors) {
123
		$config['snmpd']['enable'] = $_POST['enable'] ? true : false;
124
		$config['snmpd']['pollport'] = $_POST['pollport'];
125
		$config['snmpd']['syslocation'] = $_POST['syslocation'];	
126
		$config['snmpd']['syscontact'] = $_POST['syscontact'];
127
		$config['snmpd']['rocommunity'] = $_POST['rocommunity'];
128
		/* disabled until some docs show up on what this does.
129
		$config['snmpd']['rwenable'] = $_POST['rwenable'] ? true : false;
130
		$config['snmpd']['rwcommunity'] = $_POST['rwcommunity'];
131
		*/
132
		$config['snmpd']['trapenable'] = $_POST['trapenable'] ? true : false;
133
		$config['snmpd']['trapserver'] = $_POST['trapserver'];
134
		$config['snmpd']['trapserverport'] = $_POST['trapserverport'];
135
		$config['snmpd']['trapstring'] = $_POST['trapstring'];
136
		
137
		$config['snmpd']['modules']['mibii'] = $_POST['mibii'] ? true : false;
138
		$config['snmpd']['modules']['netgraph'] = $_POST['netgraph'] ? true : false;
139
		$config['snmpd']['modules']['pf'] = $_POST['pf'] ? true : false;
140
		$config['snmpd']['modules']['hostres'] = $_POST['hostres'] ? true : false;
141
		$config['snmpd']['modules']['bridge'] = $_POST['bridge'] ? true : false;
142
		$config['snmpd']['bindlan'] = $_POST['bindlan'] ? true : false;
143
			
144
		write_config();
145
		
146
		$retval = 0;
147
		$retval = services_snmpd_configure();
148
		$savemsg = get_std_save_message($retval);
149
	}
150
}
151

    
152
$pgtitle = array(gettext("Services"),gettext("SNMP"));
153
include("head.inc");
154

    
155
?>
156
<script language="JavaScript">
157
<!--
158
function enable_change(whichone) {
159

    
160
	if( whichone.name == "trapenable" )
161
        {
162
	    if( whichone.checked == true )
163
	    {
164
	        document.iform.trapserver.disabled = false;
165
	        document.iform.trapserverport.disabled = false;
166
	        document.iform.trapstring.disabled = false;
167
	    }
168
	    else
169
	    {
170
                document.iform.trapserver.disabled = true;
171
                document.iform.trapserverport.disabled = true;
172
                document.iform.trapstring.disabled = true;
173
	    }
174
	}
175

    
176
	/* disabled until some docs show up on what this does.
177
	if( whichone.name == "rwenable"  )
178
	{
179
	    if( whichone.checked == true )
180
	    {
181
		document.iform.rwcommunity.disabled = false;
182
	    }
183
	    else
184
	    {
185
		document.iform.rwcommunity.disabled = true;
186
	    }
187
	}
188
	*/
189

    
190
	if( document.iform.enable.checked == true )
191
	{
192
	    document.iform.pollport.disabled = false;
193
	    document.iform.syslocation.disabled = false;
194
	    document.iform.syscontact.disabled = false;
195
	    document.iform.rocommunity.disabled = false;
196
	    document.iform.trapenable.disabled = false;
197
	    //document.iform.bindlan.disabled = false;
198
	    /* disabled until some docs show up on what this does.
199
	    document.iform.rwenable.disabled = false;
200
	    if( document.iform.rwenable.checked == true )
201
	    {
202
	        document.iform.rwcommunity.disabled = false;
203
	    }
204
	    else
205
	    {
206
		document.iform.rwcommunity.disabled = true;
207
	    }
208
	    */
209
	    if( document.iform.trapenable.checked == true )
210
	    {
211
                document.iform.trapserver.disabled = false;
212
                document.iform.trapserverport.disabled = false;
213
                document.iform.trapstring.disabled = false;
214
	    }
215
	    else
216
	    {
217
                document.iform.trapserver.disabled = true;
218
                document.iform.trapserverport.disabled = true;
219
                document.iform.trapstring.disabled = true;
220
	    }
221
	    document.iform.mibii.disabled = false;
222
	    document.iform.netgraph.disabled = false;
223
	    document.iform.pf.disabled = false;
224
	    document.iform.hostres.disabled = false;
225
	    //document.iform.bridge.disabled = false;
226
	}
227
	else
228
	{
229
            document.iform.pollport.disabled = true;
230
            document.iform.syslocation.disabled = true;
231
            document.iform.syscontact.disabled = true;
232
            document.iform.rocommunity.disabled = true;
233
	    /* 
234
            document.iform.rwenable.disabled = true;
235
	    document.iform.rwcommunity.disabled = true;
236
	    */
237
            document.iform.trapenable.disabled = true;
238
            document.iform.trapserver.disabled = true;
239
            document.iform.trapserverport.disabled = true;
240
            document.iform.trapstring.disabled = true;
241

    
242
            document.iform.mibii.disabled = true;
243
            document.iform.netgraph.disabled = true;
244
            document.iform.pf.disabled = true;
245
            document.iform.hostres.disabled = true;
246
            //document.iform.bridge.disabled = true;
247
	    //document.iform.bindlan.disabled = true;
248
	}
249
}
250
//-->
251
</script>
252
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
253
<?php include("fbegin.inc"); ?>
254
<?php if ($input_errors) print_input_errors($input_errors); ?>
255
<?php if ($savemsg) print_info_box($savemsg); ?>
256
            <form action="services_snmp.php" method="post" name="iform" id="iform">
257
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
258

    
259
                <tr> 
260
  		  <td colspan="2" valign="top" class="optsect_t">
261
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
262
  			<tr><td class="optsect_s"><strong><?=gettext("SNMP Daemon");?></strong></td>
263
					<td align="right" class="optsect_s"><input name="enable" id="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(this)"> <strong><?=gettext("Enable");?></strong></td></tr>
264
  			</table></td>
265
                </tr>
266

    
267
                <tr>
268
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Polling Port ");?></td>
269
                  <td width="78%" class="vtable">
270
                    <input name="pollport" type="text" class="formfld unknown" id="pollport" size="40" value="<?=$pconfig['pollport'] ? htmlspecialchars($pconfig['pollport']) : htmlspecialchars(161);?>">
271
                    <br><?=gettext("Enter the port to accept polling events on (default 161)");?></br>
272
		  </td>
273
                </tr>
274

    
275
                <tr> 
276
                  <td width="22%" valign="top" class="vncell"><?=gettext("System location");?></td>
277
                  <td width="78%" class="vtable"> 
278
                    <input name="syslocation" type="text" class="formfld unknown" id="syslocation" size="40" value="<?=htmlspecialchars($pconfig['syslocation']);?>"> 
279
                  </td>
280
                </tr>
281

    
282
                <tr> 
283
                  <td width="22%" valign="top" class="vncell"><?=gettext("System contact");?></td>
284
                  <td width="78%" class="vtable"> 
285
                    <input name="syscontact" type="text" class="formfld unknown" id="syscontact" size="40" value="<?=htmlspecialchars($pconfig['syscontact']);?>"> 
286
                  </td>
287
                </tr>
288

    
289
                <tr> 
290
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Read Community String");?></td>
291
                  <td width="78%" class="vtable"> 
292
                    <input name="rocommunity" type="text" class="formfld unknown" id="rocommunity" size="40" value="<?=htmlspecialchars($pconfig['rocommunity']);?>"> 
293
                    <br>The community string is like a password, restricting access to querying SNMP to hosts knowing the community string. Use a strong value here to protect from unauthorized information disclosure.</br>
294
		  </td>
295
                </tr>
296

    
297
<?php 
298
			/* disabled until some docs show up on what this does.
299
                <tr>
300
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
301
                  <td width="78%" class="vtable">
302
	 	   <input name="rwenable" id="rwenable" type="checkbox" value="yes" <?php if ($pconfig['rwenable']) echo "checked"; ?> onClick="enable_change(this)">
303
                    <strong>Enable Write Community String</strong>
304
		  </td>
305
                </tr>
306

    
307
		<tr>
308
		  <td width="22%" valign="top" class="vncellreq">Write community string</td>
309
          <td width="78%" class="vtable">
310
                    <input name="rwcommunity" type="text" class="formfld unknown" id="rwcommunity" size="40" value="<?=htmlspecialchars($pconfig['rwcommunity']);?>">
311
		    <br>Please use something other then &quot;private&quot; here</br>
312
		  </td>
313
                </tr>
314
		    	*/ 
315
?>
316

    
317
		<tr><td>&nbsp;</td></tr>
318

    
319
                <tr> 
320
  		  <td colspan="2" valign="top" class="optsect_t">
321
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
322
  			<tr><td class="optsect_s"><strong><?=gettext("SNMP Traps");?></strong></td>
323
			<td align="right" class="optsect_s"><input name="trapenable" id="trapenable" type="checkbox" value="yes" <?php if ($pconfig['trapenable']) echo "checked"; ?> onClick="enable_change(this)"> <strong><?=gettext("Enable");?></strong></td></tr>
324
  			</table></td>
325
                </tr>
326

    
327

    
328
                <tr>
329
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Trap server");?></td>
330
                  <td width="78%" class="vtable">
331
                    <input name="trapserver" type="text" class="formfld unknown" id="trapserver" size="40" value="<?=htmlspecialchars($pconfig['trapserver']);?>">
332
                    <br><?=gettext("Enter trap server name");?></br>
333
		  </td>
334
                </tr>
335

    
336
                <tr>
337
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Trap server port ");?></td>
338
                  <td width="78%" class="vtable">
339
                    <input name="trapserverport" type="text" class="formfld unknown" id="trapserverport" size="40" value="<?=$pconfig['trapserverport'] ? htmlspecialchars($pconfig['trapserverport']) : htmlspecialchars(162);?>">
340
                    <br><?=gettext("Enter the port to send the traps to (default 162)");?></br>
341
		  </td>
342
                </tr>
343

    
344
                <tr>
345
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Enter the SNMP trap string");?></td>
346
                  <td width="78%" class="vtable">
347
                    <input name="trapstring" type="text" class="formfld unknown" id="trapstring" size="40" value="<?=htmlspecialchars($pconfig['trapstring']);?>">
348
                    <br><?=gettext("Trap string");?></br>
349
		  </td>
350
                </tr>
351

    
352
		<tr><td>&nbsp;</td></tr>
353

    
354
                <tr> 
355
  		  <td colspan="2" valign="top" class="optsect_t">
356
  			<table border="0" cellspacing="0" cellpadding="0" width="100%">
357
  			<tr><td class="optsect_s"><strong><?=gettext("Modules");?></strong></td>
358
			<td align="right" class="optsect_s">&nbsp;</td></tr>
359
  			</table></td>
360
                </tr>
361

    
362
		<tr>
363
		  <td width="22%" valign="top" class="vncellreq"><?=gettext("SNMP Modules");?></td>
364
		  <td width="78%" class="vtable">
365
		    <input name="mibii" type="checkbox" id="mibii" value="yes" <?php if ($pconfig['mibii']) echo "checked"; ?> ><?=gettext("MibII"); ?>
366
		    <br />
367
		    <input name="netgraph" type="checkbox" id="netgraph" value="yes" <?php if ($pconfig['netgraph']) echo "checked"; ?> ><?=gettext("Netgraph"); ?>
368
		    <br />
369
		    <input name="pf" type="checkbox" id="pf" value="yes" <?php if ($pconfig['pf']) echo "checked"; ?> ><?=gettext("PF"); ?>
370
		    <br />
371
		    <input name="hostres" type="checkbox" id="hostres" value="yes" <?php if ($pconfig['hostres']) echo "checked"; ?> ><?=gettext("Host Resources");?>
372
		  </td>
373
		</tr>
374
<?php if(!$config['interfaces']['lan']): ?>
375
		 <tr> 
376
		   <td width="22%" valign="top" class="vtable"></td>
377
		   <td width="78%" class="vtable"> 
378
		     <input name="bindlan" type="checkbox" value="yes" <?php if ($pconfig['bindlan']) echo "checked"; ?>> <strong><?=gettext("Bind to LAN interface only");?></strong>
379
		     <br>
380
		     <?=gettext("This option can be useful when trying to access the SNMP agent".
381
            	    " by the LAN interface's IP address through a VPN tunnel terminated on the WAN interface.");?></td>
382
		 </tr>
383
<?php endif; ?>
384
		 <tr> 
385
		   <td width="22%" valign="top">&nbsp;</td>
386
		   <td width="78%"> 
387
		     <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onClick="enable_change(true)"> 
388
		   </td>
389
		 </tr>
390
		</table>
391
</form>
392
<script language="JavaScript">
393
<!--
394
enable_change(this);
395
//-->
396
</script>
397
<?php include("fend.inc"); ?>
398
</body>
399
</html>
(146-146/222)