[procps] [pull] fix to debian bug 599556 and bug=558044#67 correction

  • From: Sami Kerola <kerolasa@xxxxxx>
  • To: procps-ng <procps@xxxxxxxxxxxxx>
  • Date: Mon, 20 Feb 2012 21:27:38 +0100

Hi Craig,

I guess these two fixes could be included squeezed to upstream git
before next release. If not that's fine as well. There is always some
later release.


The following changes since commit d9c226c6950c433973ee783004923a69bb88e816:

  Merge remote-tracking branch 'sami/2012wk6' (2012-02-12 21:56:05 +1100)

are available in the git repository at:


  git://gitorious.org/~kerolasa/procps/sami-procps-ng.git 2012wk7

for you to fetch changes up to e01765d30b7c4767868d5379fbfb36d1dc15eba4:

  sysctl: deprecate parameters (2012-02-14 11:22:15 +0100)

----------------------------------------------------------------
Sami Kerola (2):
      docs: inform about pkill and --inverse option
      sysctl: deprecate parameters

 pgrep.1  |    4 +++-
 sysctl.8 |   15 +++++++++++++++
 sysctl.c |   31 ++++++++++++++++++++++++++++++-
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/pgrep.1 b/pgrep.1
index 8f7cd8e..2fc1c98 100644
--- a/pgrep.1
+++ b/pgrep.1
@@ -110,7 +110,9 @@ Only match processes whose real user ID is listed.
 Either the numerical or
 symbolical value may be used.
 .TP
 \fB\-v\fR, \fB\-\-inverse\fR\fR
-Negates the matching.  (\fBpgrep\fP only.)
+Negates the matching.  This option usually used in pgrep context.  In
+.B pkill
+context the short option is disabled to avoid accidental usage of the option.
 .TP
 \fB\-x\fR, \fB\-\-exact\fR\fR
 Only match processes whose name (or command line if \-f is specified)
diff --git a/sysctl.8 b/sysctl.8
index 37847d6..d3ceefa 100644
--- a/sysctl.8
+++ b/sysctl.8
@@ -62,6 +62,11 @@ given.  Specifying \- as filename means reading
data from standard input.
 \fB\-a\fR, \fB\-\-all\fR
 Display all values currently available.
 .TP
+\fB\-\-deprecated\fR
+Include deprecated parameters to
+.B \-\-all
+values listing.
+.TP
 \fB\-b\fR, \fB\-\-binary\fR
 Print value without new line.
 .TP
@@ -126,6 +131,16 @@ Display version information and exit.
 /sbin/sysctl \-a \-\-pattern 'net.ipv4.conf.(eth|wlan)0.arp'
 .br
 /sbin/sysctl \-\-system \-\-pattern '^net.ipv6'
+.SH DEPRECATED PARAMETERS
+The
+.B base_reachable_time
+and
+.B retrans_time
+are deprecated.  The sysctl command does not allow changing values of there
+parameters.  Users who insist to use deprecated kernel interfaces should values
+to /proc file system by other means.  For example:
+.PP
+echo 256 > /proc/sys/net/ipv6/neigh/eth0/base_reachable_time
 .SH FILES
 .I /proc/sys
 .br
diff --git a/sysctl.c b/sysctl.c
index eb57058..c27fe02 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -47,6 +47,12 @@ static bool false = 0;
  */
 static const char PROC_PATH[] = "/proc/sys/";
 static const char DEFAULT_PRELOAD[] = "/etc/sysctl.conf";
+static const char *DEPRECATED[] = {
+       "base_reachable_time",
+       "retrans_time",
+       ""
+};
+static bool IgnoreDeprecated;
 static bool NameOnly;
 static bool PrintName;
 static bool PrintNewline;
@@ -96,6 +102,7 @@ static void __attribute__ ((__noreturn__))
        fputs(_("  -a, --all            display all variables\n"
                "  -A                   alias of -a\n"
                "  -X                   alias of -a\n"
+               "      --deprecated     include deprecated parameters to 
listing\n"
                "  -b, --binary         print value without new line\n"
                "  -e, --ignore         ignore unknown variables errors\n"
                "  -N, --names          print variable names without values\n"
@@ -275,6 +282,16 @@ static int ReadSetting(const char *restrict const name)
        return rc;
 }

+int is_deprecated(char *filename)
+{
+       int i;
+       for (i = 0; strlen(DEPRECATED[i]); i++) {
+               if (strcmp(DEPRECATED[i], filename) == 0)
+                       return 1;
+       }
+       return 0;
+}
+
 /*
  * Display all the sysctl settings
  */
@@ -296,6 +313,8 @@ static int DisplayAll(const char *restrict const path)
                readdir(dp);    /* skip .. */
                while ((de = readdir(dp))) {
                        char *restrict tmpdir;
+                       if (IgnoreDeprecated && is_deprecated(de->d_name))
+                               continue;
                        tmpdir =
                            (char *restrict) xmalloc(strlen(path) +
                                                     strlen(de->d_name) +
@@ -369,6 +388,10 @@ static int WriteSetting(const char *setting)
        outname[equals - name] = 0;
        /* change / to . */
        slashdot(outname, '/', '.');
+       if(is_deprecated(strrchr(outname, '.') + 1)) {
+               xwarnx(_("%s is deprecated, value not set"), outname);
+               goto out;
+        }

        if (stat(tmpname, &ts) < 0) {
                if (!IgnoreError) {
@@ -618,10 +641,12 @@ int main(int argc, char *argv[])
        const char *preloadfile = DEFAULT_PRELOAD;

        enum {
-               SYSTEM_OPTION = CHAR_MAX + 1
+               DEPRECATED_OPTION = CHAR_MAX + 1,
+               SYSTEM_OPTION
        };
        static const struct option longopts[] = {
                {"all", no_argument, NULL, 'a'},
+               {"deprecated", no_argument, NULL, DEPRECATED_OPTION},
                {"binary", no_argument, NULL, 'b'},
                {"ignore", no_argument, NULL, 'e'},
                {"names", no_argument, NULL, 'N'},
@@ -645,6 +670,7 @@ int main(int argc, char *argv[])
        PrintNewline = true;
        IgnoreError = false;
        Quiet = false;
+       IgnoreDeprecated = true;

        if (argc < 2)
                Usage(stderr);
@@ -693,6 +719,9 @@ int main(int argc, char *argv[])
                case 'X':       /* same as -a -x */
                        DisplayAllOpt = true;
                        break;
+               case DEPRECATED_OPTION:
+                       IgnoreDeprecated = false;
+                       break;
                case SYSTEM_OPTION:
                        IgnoreError = true;
                        return PreloadSystem();

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

Other related posts: