Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 19 Jun 2012 09:45:40 +0200
From: Daniel Cegiełka <daniel.cegielka@...il.com>
To: owl-dev@...ts.openwall.com
Subject: Re: procps-3.2.8

BAD_PROCFS_MESSAGE from checkproc() is the same as BAD_OPEN_MESSAGE:

procps-3.2.5-owl-proc.diff:

-#define BAD_OPEN_MESSAGE					\
-"Error: /proc must be mounted\n"				\
-"  To mount /proc at boot you need an /etc/fstab line like:\n"	\
-"      /proc   /proc   proc    defaults\n"			\
-"  In the meantime, mount /proc /proc -t proc\n"
-

diff -urk.orig procps-3.2.5.orig/proc/checkproc.c procps-3.2.5/proc/checkproc.c
--- procps-3.2.5.orig/proc/checkproc.c	1970-01-01 00:00:00 +0000
+++ procps-3.2.5/proc/checkproc.c	2005-08-30 13:21:15 +0000
@@ -0,0 +1,29 @@
+#ifdef HAVE_CONFIG_H

(...)

+#include "checkproc.h"
+
+#define BAD_PROCFS_MESSAGE					\
+"Error: /proc must be mounted\n"				\
+"  To mount /proc at boot you need an /etc/fstab line like:\n"	\
+"      proc   /proc   proc    defaults\n"			\
+"  In the meantime, mount proc /proc -t proc\n"
+
+// Check whether procfs is available.
+// If yes, returns 0.
+// If not, outputs error message and exit with specified return code,
+// unless rc is zero.  In later case, returns -1.
+extern int checkproc(int rc) {
+    if (access("/proc/self/stat", R_OK) == 0)
+	return 0;
+    fprintf(stderr, "%s", BAD_PROCFS_MESSAGE);

(...)


fprintf(stderr, "%s", BAD_OPEN_MESSAGE) equivalent is included in the
checkproc.c, so (procps-3.2.5-owl-proc.diff). I remove the
fprintf(stderr, "%s", BAD_OPEN_MESSAGE) code and leave only
checkproc(). This means that procps-3.2.5-owl-format.diff will also be
corrected. The current solution introduces some confusion and makes it
more difficult to analyze. Do you agree with this solution?

Daniel




2012/6/18 Daniel Cegiełka <daniel.cegielka@...il.com>:
> Hi,
>
> I try to prepare an update owl patches to procps-3.2.8., but I'm a bit
> confused. We have in procps-3.2.5-owl-proc.diff:
>
>
> diff -urk.orig procps-3.2.5.orig/proc/sysinfo.c procps-3.2.5/proc/sysinfo.c
> --- procps-3.2.5.orig/proc/sysinfo.c    2005-08-30 12:25:06 +0000
> +++ procps-3.2.5/proc/sysinfo.c 2005-08-30 13:19:36 +0000
>
> (...)
>
> @@ -52,7 +47,7 @@
>  #define FILE_TO_BUF(filename, fd) do{                          \
>     static int local_n;                                                \
>     if (fd == -1 && (fd = open(filename, O_RDONLY)) == -1) {   \
> -       fprintf(stderr, "%s", BAD_OPEN_MESSAGE);                \
> +       checkproc(0);                                           \
>        fflush(NULL);                                           \
>        _exit(102);                                             \
>     }
>
>
> and then in procps-3.2.5-owl-format.diff:
>
> diff -urk.orig procps-3.2.5.orig/proc/sysinfo.c procps-3.2.5/proc/sysinfo.c
> --- procps-3.2.5.orig/proc/sysinfo.c    2005-08-30 13:44:12 +0000
> +++ procps-3.2.5/proc/sysinfo.c 2005-08-30 13:44:24 +0000
> @@ -52,7 +52,7 @@
>  #define FILE_TO_BUF(filename, fd) do{                          \
>     static int local_n;                                                \
>     if (fd == -1 && (fd = open(filename, O_RDONLY)) == -1) {   \
> -       fprintf(stderr, BAD_OPEN_MESSAGE);                      \
> +       fprintf(stderr, "%s", BAD_OPEN_MESSAGE);                \
>        fflush(NULL);                                           \
>        _exit(102);                                             \
>     }
>
>
> Should I write "fprintf(stderr, "%s", BAD_OPEN_MESSAGE);\" or
> "checkproc(0); \" or both???
>
> In a few days I will try to send a whole...
>
> Best regards,
> Daniel

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ