~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/snmp/src/manager/snmpm_config.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%% 
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
 
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%% 
 
11
%%
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%% 
19
19
%% -------------------------------------------------------------------------
28
28
-behaviour(gen_server).
29
29
 
30
30
%% External exports
 
31
%% Avoid warning for local function error/1 clashing with autoimported BIF.
 
32
-compile({no_auto_import,[error/1]}).
31
33
-export([start_link/1, stop/0, is_started/0]).
32
34
-export([register_user/4, unregister_user/1, 
33
35
         which_users/0, 
63
65
 
64
66
         cre_counter/2,
65
67
         incr_counter/2,
 
68
         increment_counter/3, increment_counter/4, 
66
69
 
67
70
         cre_stats_counter/2,
68
71
         maybe_cre_stats_counter/2,
792
795
    end.
793
796
 
794
797
 
 
798
%% <ATL Sequence Number>
 
799
increment_counter(Counter, Initial, Max) ->
 
800
    Increment = 1, 
 
801
    increment_counter(Counter, Initial, Increment, Max).
 
802
 
 
803
increment_counter(Counter, Initial, Increment, Max) ->
 
804
    %% This is to make sure no one else increments our counter
 
805
    Key = {Counter, self()},
 
806
 
 
807
    %% Counter data
 
808
    Position  = 2,
 
809
    Threshold = Max,
 
810
    SetValue  = Initial,
 
811
    UpdateOp  = {Position, Increment, Threshold, SetValue},
 
812
 
 
813
    %% And now for the actual increment
 
814
    Tab = snmpm_counter_table, 
 
815
    case (catch ets:update_counter(Tab, Key, UpdateOp)) of
 
816
        {'EXIT', {badarg, _}} ->
 
817
            %% Oups, first time
 
818
            ets:insert(Tab, {Key, Initial}),
 
819
            Initial;
 
820
        Next when is_integer(Next) ->
 
821
            Next
 
822
    end.
 
823
%% </ATL Sequence Number>
 
824
 
 
825
 
795
826
maybe_cre_stats_counter(Counter, Initial) ->
796
827
    case ets:lookup(snmpm_stats_table, Counter) of
797
828
        [_] ->
1013
1044
        AuditTrailLogOpts ->
1014
1045
            ?vtrace("ATL options: ~p", [AuditTrailLogOpts]),
1015
1046
            ets:insert(snmpm_config_table, {audit_trail_log, true}),
1016
 
            LogDir  = get_atl_dir(AuditTrailLogOpts),
1017
 
            LogType = get_atl_type(AuditTrailLogOpts),
1018
 
            LogSize = get_atl_size(AuditTrailLogOpts),
1019
 
            LogRep  = get_atl_repair(AuditTrailLogOpts),
 
1047
            LogDir   = get_atl_dir(AuditTrailLogOpts),
 
1048
            LogType  = get_atl_type(AuditTrailLogOpts),
 
1049
            LogSize  = get_atl_size(AuditTrailLogOpts),
 
1050
            LogRep   = get_atl_repair(AuditTrailLogOpts),
 
1051
            LogSeqNo = get_atl_seqno(AuditTrailLogOpts),
1020
1052
            ets:insert(snmpm_config_table, {audit_trail_log_dir,    LogDir}),
1021
1053
            ets:insert(snmpm_config_table, {audit_trail_log_type,   LogType}),
1022
1054
            ets:insert(snmpm_config_table, {audit_trail_log_size,   LogSize}),
1023
 
            ets:insert(snmpm_config_table, {audit_trail_log_repair, LogRep})
 
1055
            ets:insert(snmpm_config_table, {audit_trail_log_repair, LogRep}),
 
1056
            ets:insert(snmpm_config_table, {audit_trail_log_seqno,  LogSeqNo})
1024
1057
    end,
1025
1058
 
1026
1059
    %% -- System default agent config --
1398
1431
verify_audit_trail_log_opts([{repair, Repair}|Opts]) ->
1399
1432
    verify_log_repair(Repair),
1400
1433
    verify_audit_trail_log_opts(Opts);
 
1434
verify_audit_trail_log_opts([{seqno, SeqNo}|Opts]) ->
 
1435
    verify_log_seqno(SeqNo),
 
1436
    verify_audit_trail_log_opts(Opts);
1401
1437
verify_audit_trail_log_opts([Opt|_Opts]) ->
1402
1438
    error({invalid_audit_trail_log_option, Opt}).
1403
1439
 
1440
1476
verify_log_repair(Repair) ->
1441
1477
    error({invalid_audit_trail_log_repair, Repair}).
1442
1478
 
 
1479
verify_log_seqno(true) -> ok;
 
1480
verify_log_seqno(false) -> ok;
 
1481
verify_log_seqno(SeqNo) ->
 
1482
    error({invalid_audit_trail_log_seqno, SeqNo}).
 
1483
 
1443
1484
 
1444
1485
verify_module(_, Mod) when is_atom(Mod) ->
1445
1486
    ok;
1618
1659
        {ok, Addr} ->
1619
1660
            snmp_conf:check_integer(Port, {gt, 0}),
1620
1661
            Conf = 
1621
 
                [{address,          Addr},
 
1662
                [{reg_type,         target_name},
 
1663
                 {address,          Addr},
1622
1664
                 {port,             Port},
1623
1665
                 {community,        Comm}, 
1624
1666
                 {engine_id,        EngineId},
3040
3082
get_atl_repair(Opts) ->
3041
3083
    get_opt(repair, Opts, truncate).
3042
3084
 
 
3085
get_atl_seqno(Opts) ->
 
3086
    get_opt(seqno, Opts, false).
 
3087
 
3043
3088
 
3044
3089
%%----------------------------------------------------------------------
3045
3090