Skip Menu |

This queue is for tickets about the Config-General CPAN distribution.

Report information
The Basics
Id: 93860
Status: rejected
Priority: 0/
Queue: Config-General

People
Owner: Nobody in particular
Requestors: kanbyen [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in SaveConfig
Date: Fri, 14 Mar 2014 09:36:59 -0700 (PDT)
To: "bug-Config-General [...] rt.cpan.org" <bug-Config-General [...] rt.cpan.org>
From: Kanbyen GreyDawn <kanbyen [...] yahoo.com>
When saving a file that has been loaded the settings:  my %config = ParseConfig(                           -ConfigFile => "$CONFIGFILE",                           -SplitDelimiter => '\s*=\s*',                           -StoreDelimiter => ' = ',                           -SplitPolicy =>'custom'                           );   are not passed to the new line:    (new Config::General(-ConfigHash => $hash))->save_file($file); At this point forward it uses the defaults set in: new() self= setup. resetting to this:           SplitPolicy           => 'guess', # also possible: whitespace, equalsign and custom           SplitDelimiter        => 0,       # must be set by the user if SplitPolicy is 'custom'           StoreDelimiter        => 0,       # will be set by me unless user uses 'custom' policy This pretty much makes it useless for anything that doesn't use 3 spaces and breaks all other files, examples here: parsing works, changing a setting and resaving breaks the file.  improvement suggestion: It might be useful to add ability to save anything between each parsed item as comments to be rewritten, as an improvement. ###################################### testscript.pl:(file) #!/usr/bin/perl $CONFIGFILE='/tmp/sysctl.conf'; use Data::Dumper; #  # the procedural way  use Config::General qw(ParseConfig SaveConfig SaveConfigString);  my %config = ParseConfig(                           -ConfigFile => "$CONFIGFILE",                           -SplitDelimiter => '\s*=\s*',                           -StoreDelimiter => ' = ',                           -SplitPolicy =>'custom'                           );    # How to load and how to change sysctl file.  $config{'net.ipv4.tcp_congestion_control'}='cubic';   print Dumper(\%config);   # the save is broken as its ignoring the delimiters on saveback.   SaveConfig($CONFIGFILE, \%config  ); ###################################### sysctl.conf:(file) # Disable syncookies (syncookies are not RFC compliant and can use too muche resources) net.ipv4.tcp_syncookies = 0 # Basic TCP tuning net.ipv4.tcp_keepalive_time = 600 net.ipv4.tcp_synack_retries = 3 net.ipv4.tcp_syn_retries = 3 # RFC1337 net.ipv4.tcp_rfc1337 = 1 # Defines the local port range that is used by TCP and UDP # to choose the local port net.ipv4.ip_local_port_range = 1024 65535 # Log packets with impossible addresses to kernel log net.ipv4.conf.all.log_martians = 1 # Minimum interval between garbage collection passes This interval is # in effect under high memory pressure on the pool net.ipv4.inet_peer_gc_mintime = 5 # Disable Explicit Congestion Notification in TCP net.ipv4.tcp_ecn = 0 # Enable window scaling as defined in RFC1323 net.ipv4.tcp_window_scaling = 1 # Enable timestamps (RFC1323) net.ipv4.tcp_timestamps = 1 # DISable select acknowledgments net.ipv4.tcp_sack = 0 # Enable FACK congestion avoidance and fast restransmission net.ipv4.tcp_fack = 1 # DISABLE Allows TCP to send "duplicate" SACKs net.ipv4.tcp_dsack = 0 # Controls IP packet forwarding net.ipv4.ip_forward = 0 # No controls source route verification (RFC1812) net.ipv4.conf.default.rp_filter = 0 # Enable fast recycling TIME-WAIT sockets net.ipv4.tcp_tw_recycle = 1 # TODO : change TCP_SYNQ_HSIZE in include/net/tcp.h # to keep TCP_SYNQ_HSIZE*16<=tcp_max_syn_backlog net.ipv4.tcp_max_syn_backlog = 20000 # tells the kernel how many TCP sockets that are not attached # to any user file handle to maintain net.ipv4.tcp_max_orphans = 12590 # How may times to retry before killing TCP connection, closed by our side net.ipv4.tcp_orphan_retries = 1 # how long to keep sockets in the state FIN-WAIT-2 # if we were the one closing the socket net.ipv4.tcp_fin_timeout = 20 # maximum number of sockets in TIME-WAIT to be held simultaneously net.ipv4.tcp_max_tw_buckets = 1007104 # don't cache ssthresh from previous connection net.ipv4.tcp_no_metrics_save = 1 net.ipv4.tcp_moderate_rcvbuf = 1 # increase Linux autotuning TCP buffer limits net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 # increase TCP max buffer size net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 2500 net.core.somaxconn = 65000 vm.swappiness = 0 # You can monitor the kernel behavior with regard to the dirty # pages by using grep -A 1 dirty /proc/vmstat vm.dirty_background_ratio = 5 vm.dirty_ratio = 15 # required free memory (set to 1% of physical ram) vm.min_free_kbytes = 80577 # system open file limit fs.file-max = 503552 # Core dump suidsafe fs.suid_dumpable = 2 kernel.printk = 4 4 1 7 kernel.core_uses_pid = 1 kernel.sysrq = 0 kernel.msgmax = 65536 kernel.msgmnb = 65536 # Maximum shared segment size in bytes kernel.shmmax = 7426027929 # Maximum number of shared memory segments in pages kernel.shmall = 2014439 net.ipv4.tcp_congestion_control=reno ################################### Thanks for Sharing. Dave M
Well, that's actually not a bug. If you call ParseConfig(), you'll only get back a plain hash, not a Config::General object. So to fix your issue, you'll need to use the OOP method like: my $cfg = Config::General->new(...); [..] $cfg->save(...). best regards, Tom