summaryrefslogtreecommitdiff
path: root/sysctl.c
Commit message (Collapse)AuthorAgeFilesLines
* sysctl: fix typo in help __________________ (catch up)Jim Warner2018-05-061-1/+1
| | | | | | | | | | --------------- Original Master Branch Commit Message: Changed "a variables" to "the given variable(s)" References: procps-ng/procps#84 Signed-off-by: Jim Warner <james.warner@comcast.net>
* sysctl: relocate the procio code to a more proper homeJim Warner2018-05-061-1/+1
| | | | | | | | | | | | | | Now that the procio logic was removed from the library we must move the header file, lest we break make dist. In the process, we will relocate that source file too. [ we'll take a slightly different approach than that ] [ used under the master branch by exploiting those 2 ] [ non-library directories 'include' and 'lib', while ] [ avoiding any sysctl hard coded function prototype. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
* Use new standard I/O for reading/writing sysctl valuesWerner Fink2018-03-011-32/+23
| | | | | | | | thereby use one allocated buffer for I/O which now might be increased by the stdio function getline(3) on the file if required. Signed-off-by: Werner Fink <werner@suse.de>
* Preload sysctl lines even if longer than stdio bufferWerner Fink2018-03-011-7/+24
| | | | | | | by using getline(3) to use a dynamically increased buffer if required by the input found in sysctl configuration files. Signed-off-by: Werner Fink <werner@suse.de>
* sysctl: Don't crash file fopen failsCraig Small2018-01-071-3/+3
| | | | | | | | | | | | | The commit referenced below put a setvbuf() before checking what fopen() returned. If the file could not be opened then the file handle was NULL at setvbuf() crashed. setvbuf() is now called after checking what fopen() returns and only when it was successful. References: procps-ng/procps#76 commit 58ae084c2737cdee395915d45dbcb364648ac615
* Allow empty string for valueTheodore Dubois2017-12-291-1/+1
|
* Avoid confusing messages caused by EIO on readingWerner Fink2017-08-201-0/+6
| | | | | | /proc/sys/net/ipv6/conf/*/stable_secret if those are not set yet. Signed-off-by: Werner Fink <werner@suse.de>
* Increase standard I/O buffer a lot to be able toWerner Fink2017-08-201-0/+10
| | | | | | | | read huge informations at once as otherwise all files below /proc/sys, not using the seq_file API at the kernel side, will return EOF on a second read. Signed-off-by: Werner Fink <werner@suse.de>
* sysctl: Print lines longer than 1024 charsWerner Fink2017-05-221-18/+24
| | | | | | | | as well do not open /proc/sys files if only the names of the system control names of the kernel parameters should be shown. Avoid leaking tmpname in case of a pattern mismatch. Signed-off-by: Werner Fink <werner@suse.de>
* sysctl.c: use strchr() instead of index()Yann E. MORIN2016-08-151-1/+1
| | | | | | | | | index() is a legacy function, which is no longer implemented by all C libraries (example: uClibc). Instead, use the POSIX defined strchr() function. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* Merge branch 'master' into newlibCraig Small2015-10-281-1/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: pgrep.c proc/sysinfo.c ps/output.c skill.c top/top.c top/top.h w.c
| * sysctl: Correct stat on /etc/sysctl.confVictor Ananjevsky2015-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | sysctl --system fails when the file /etc/sysctl.conf doesn't exists. This happens due to wrong check of stat(2) return code. Reference: https://www.freelists.org/post/procps/sysctl Signed-off-by: Craig Small <csmall@enc.com.au>
* | sysctl: Remove links to libraryCraig Small2015-09-011-2/+0
|/ | | | | sysctl doesn't use any symbols from the libprocps library so this update removes those dependencies.
* sysctl: finalizing the GLOB_* flags checkJaromir Capik2014-08-281-2/+7
| | | | | | | This commit properly resolves the merge conflict caused by the following two commits: fb6d4e6cb42ffacfbe300021f062b5057ba7015d f8128568d671d2c07b7d2faf0bc399fb9b7bd69e
* Support libc's without GLOB_TILDEMichael Forney2014-08-281-0/+8
| | | | | | | | | | GLOB_TILDE is a GNU extension and may not be present on all systems. Note (jcapik): The original patch from Michael Forney didn't apply cleanly due to my recent addition of the GLOB_BRACE flag in the list of flags. I had to edit the patch to make it apply, but that produces an inconsistent state. It's gonna be fixed in the next commit.
* sysctl: support expansion of csh style braces with -pJaromir Capik2014-07-161-1/+1
| | | | | | | This commit adds the GLOB_BRACE flag in the glob flags. That allows to expand the csh style braces {a,b} and define multiple independent patterns for config file locations.
* sysctl: increase max supported line length of the conf fileSami Farin2014-03-141-2/+4
| | | | | | | | | | | I ran into this limit with net.ipv4.ip_local_reserved_ports , sysctl complained about the line after the long line, further slowing down my error hunting. Due to fgets usage, increase buffer size to 4096 chars with minimum amount of code changes. Signed-off-by: Sami Farin <hvtaifwkbgefbaei@gmail.com>
* sysctl: Fixing memory leaks in PreloadSystem()Jaromir Capik2014-01-021-0/+7
|
* sysctl --system loads default config fileCraig Small2013-12-271-1/+1
| | | | | | Commit cdca71e94506fbb921ab2c626be3ad05c4287498 fixed the loading the sysctl.conf file, but had the logic for checking the file exists reversed incorrectly.
* Update options to single stringsCraig Small2013-10-111-18/+18
| | | | | | | To assist the translators, each option is a separate string. This means if we add/change/delete an option the remaining ones will just keep working and only the impacted option needs some translation work on it.
* sysctl --system ignores missing /etc/sysctl.confCraig Small2013-09-201-4/+10
| | | | | | | | | | | | | | sysctl --system would not correctly return the RC for files in subdirectories and would insist on having /etc/sysctl.conf This update makes two changes when using sysctl --system: - The RC status is ORed for each config file, meaning an error in any file is propated to the RC - If /etc/sysctl.conf doesn't exist we just don't load it References: https://bbs.archlinux.org/viewtopic.php?id=170005 http://www.freelists.org/post/procps/wrong-defaults-for-sysctl-on-arch-linux
* Merge commit 'refs/merge-requests/10' of git://gitorious.org/procps/procps ↵Craig Small2013-04-071-0/+2
|\ | | | | | | into merge-requests/10
| * configure: check for program_invocation_nameRainer Müller2013-03-201-0/+2
| | | | | | | | | | | | | | | | | | | | For portabiliy, check for program_invocation_name during configure and define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is now enclosed with the appropriate #ifdef block. The symbol program_invocation_name is only used for error message handling using error(), so it's safe to omit this if it is not available.
* | sysctl return valueCraig Small2013-04-071-3/+3
|/ | | | | | | | | | | | | Gilles brought up a warning message in sysctl.c sysctl.c: In function 'main': sysctl.c:767: warning: value computed is not used The return value of Preload was not being applied correctly to ret meaning sysctl would not return the correct value. Reference: http://www.freelists.org/post/procps/procpsng-337,18 Signed-off-by: Craig Small <csmall@enc.com.au>
* sysctl: fix compiler warningsSami Kerola2012-11-061-6/+4
| | | | | | | | | sysctl.c:293:5: warning: no previous declaration for 'is_deprecated' [-Wmissing-declarations] sysctl.c:472:58: warning: declaration of 'pattern' shadows a global declaration [-Wshadow] sysctl.c:67:14: warning: shadowed declaration is here [-Wshadow] sysctl.c:650:7: warning: variable 'SwitchesAllowed' set but not used [-Wunused-but-set-variable] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: avoid crash when -p file has unexpected inputSami Kerola2012-05-071-1/+4
| | | | | | | | | | | | | Commit e01765d30b7c4767868d5379fbfb36d1dc15eba4 added is_deprecated(), which crashed when user had input without without /proc/sys/ subdirectory. The below should illustrate how exactly the bug got to be trickered. $ cat ~/foo cause = crash $ ./sysctl -p ~/foo Segmentation fault Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: restore old -p handlingMike Frysinger2012-05-071-40/+63
| | | | | | | | | | | | | | | | | | | | | | The previous version of sysctl had the form: sysctl -p [file] In other words, it required a space between the -p and the [file]. Omitting the space would lead to an error. The new version though is the opposite: sysctl -p[file] In other words, it requires there to not be a space. Considering the old behavior has been around for a decade, and runtime checking for this mismatch in behavior is silly, and supporting the old syntax is trivial, add support for it. When '-p regexp' is glob is used to make reqular expression to be expanded to argument list, which also means that -p option will allow multiple files being specified as input. Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* sysctl: fix broken .conf suffix matchingMike Frysinger2012-05-071-2/+2
| | | | | | | | | | | There's an off-by-one error in the count (".conf" is 5 bytes, not 6), and the logic is inverted for the strcmp return value -- we want to skip the files when they *don't* end in .conf, not when they *do*. Also fix the off-by-one len check. Bug-Debian: http://bugs.debian.org/669128 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* sysctl: use stdbool.hMike Frysinger2012-05-031-5/+1
| | | | | | | The stdbool.h header is part of C99 and has been usable on systems for more than a decade. Let's drop these manual hacks. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* sysctl: simplify file close error checkingSami Kerola2012-04-061-7/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* all: check stdout and stderr status at exitSami Kerola2012-03-231-0/+2
| | | | | | | | | | | | | | | If stream status is not checked at the end of execution below problem would not report error, or non-zero exit code. The uptime is just an example same was true with all commands of the project. $ uptime >&- ; echo $? uptime: write error: Bad file descriptor 1 $ uptime >/dev/full ; echo $? uptime: write error: No space left on device 1 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: fix argument parsing regressionJim Warner2012-03-081-6/+9
| | | | | | | | | | | | | | | | | | | | Any key=value pair following the first one are dropped after commit 81df8e26300b35968e3702decc02e9413d5389fc, due to changing from the while loop to using getopt. Broken behavior: sysctl net.ipv6.conf.tun0.optimistic_dad net.ipv6.conf.tun0.mc_forwarding net.ipv6.conf.tun0.optimistic_dad = 0 Good behavior: sysctl net.ipv6.conf.tun0.optimistic_dad net.ipv6.conf.tun0.mc_forwarding net.ipv6.conf.tun0.optimistic_dad = 0 net.ipv6.conf.tun0.mc_forwarding = 0 Reference: http://www.freelists.org/post/procps/BUG-Commit-81df8e2-allows-only-one-keyvalue-arg Reported-By: Sven Ulland <sveniu@opera.com> Signed-off-by: Jim Warner <james.warner@comcast.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: clarification to license headers in filesSami Kerola2012-03-031-6/+14
| | | | | | | | | | | | | | | Add license header to all files. The summary of licensing is below, taken from Craig Small's email which is referred in commit message tail. sysctl and pgrep are GPL 2+ The rest is LGPL 2.1+ Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8 Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962 CC: Craig Small <csmall@enc.com.au> CC: Jaromir Capik <jcapik@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: print new line explicitelySami Kerola2012-03-031-0/+2
| | | | | | | In some cases sysctl does not print new line after the last line. This commit fixes that behavior. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: deprecate parametersSami Kerola2012-02-141-1/+30
| | | | | | | | | | | | According to arp(7) manual page base_reachable_time and retrans_time are obsolete since kernel 2.6.12. Based on that the print all listing will not show these two parameters, and attempt to set them will fail. Reported-by: Alexandre Cavalcante Alencar <alexandre.alencar@gmail.com> Bug-Debian: http://bugs.debian.org/599556 Reference: http://www.mail-archive.com/bk-commits-head@vger.kernel.org/msg03396.html Reference: http://www.opensubscriber.com/message/linux-kernel@vger.kernel.org/7344177.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: fix potential null derefence [smatch scan]Sami Kerola2012-02-051-13/+23
| | | | | | sysctl.c:560 PreloadSystem(29) error: potential null derefence 'cfgs'. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: fix coding styleSami Kerola2012-01-251-596/+610
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ps: unify cases and remove trailing dots in messagesSami Kerola2012-01-151-1/+1
| | | | | | | | Strings with lower caps & no trailing dots have greater change to have multiple occurences, meaning less effort for translators, than strings with them. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Changed the err and warns to macrosCraig Small2012-01-031-28/+29
| | | | | | | | | | | | err and warn are BSD format but they are not recommended by library developers. However their consiseness is useful! The solution is to use some macros that create xerr etc which then just map to the error() function. The next problem is error() uses program_invocation_name so we set this to program_invovation_short_name This is a global set but seems to be the convention (or at least errors are on the short name only) used everywhere else.
* translations: group usage textsSami Kerola2012-01-021-17/+17
| | | | | Reference: http://www.freelists.org/post/procps/backporting,5 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: enable pattern matching with pathSami Kerola2011-12-201-5/+5
| | | | | | | | | | | | Pattern matching support in `sysctl: implement --pattern option' commit did not work when variable path was defined, for example $ sysctl net.ipv4 -r arp.ignore gave no output. Reason being was tht the pattern was matched agains the specified argument and not the output variable list. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: exit with error message instead of usage()Sami Kerola2011-12-201-16/+16
| | | | | | Printing usage() output at error is too noisy. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* nls: improve translations and provide translator help commentsSami Kerola2011-12-201-1/+1
| | | | | | Reference: http://www.freelists.org/post/procps/backporting,1 Reported-by: Jim Warner <james.warner@comcast.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* nls: add functions which take translations to be usedSami Kerola2011-12-201-0/+4
| | | | | | | | | | | | Add the following three functions to most of the commands. setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); Reference: http://www.freelists.org/post/procps/backporting,1 Reported-by: Jim Warner <james.warner@comcast.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: warn when separators are repeatedSami Kerola2011-12-201-0/+5
| | | | | | | | | | | | | | | | | | | For some reason sysctl earlier allowed quite strange separators. % sysctl kernel./.pty.nr kernel./.pty.nr = 6 % sysctl kernel///pty//////////nr kernel...pty..........nr = 6 This commit does not disallow that sort of constructs, but will warn about them. In future disallowing these might be reasonable thing to do. % sysctl kernel./.pty.nr sysctl: separators should not be repeated: ./.pty.nr kernel./.pty.nr = 6 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: use libc error printing facilitiesSami Kerola2011-12-201-22/+22
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* includes: add xalloc.h to unify memory allocationsSami Kerola2011-12-201-9/+10
| | | | | | | The xalloc.h provides necessary error checking. Signed-off-by: Jim Warner <james.warner@comcast.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: add gettext supportSami Kerola2011-12-201-58/+51
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: implement --pattern optionLudwig Nussel2011-12-201-3/+39
| | | | | | | | Useful for e.g network hook scripts together with --system to only apply sysctls for a specific network interface. Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sysctl: add --system switchLudwig Nussel2011-12-201-0/+79
| | | | | | | | | | | | | instead of requiring distributions to construct a loop around sysctl in boot scripts just scan a set of default directories if the --system switch is used. Config files are applied in alphabetic order of their base name. Each base name is only applied once according to the directory preference. /etc/sysctl.conf is always applied last. Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de> Signed-off-by: Sami Kerola <kerolasa@iki.fi>