Bug#474956: Status of this policycoreutils bug?

2012-06-25 Thread Václav Ovsík
Hi,

On Thu, May 17, 2012 at 08:51:42PM +0300, Touko Korpela wrote:
 Can you send new patch against current version if this issue is still
 present? Sorry for extra work, maintainer sent latest mail only to bug
 address (that isn't cc:d automatically to submitter).

sorry for a delay.
It is quite long time I wrote the code. :)

Ok, I have updated Debian Sid in the virtual machine and tried to run
se_aptitude. It still eats all the CPU thread.

The unified diff between the original version of open_init_pty.c I based
my rewrite on and the version in the current package 2.1.10-8 is:


--- open_init_pty.c.orig2008-04-07 18:17:14.0 +0200
+++ /tmp/policycoreutils-2.1.10/run_init/open_init_pty.c2012-06-25 
00:11:23.0 +0200
@@ -153,7 +153,7 @@
}
 
if (child_pid  0) {
-   perror(Fork:);
+   perror(forkpty():);
fflush(stdout);
fflush(stderr);
exit(EX_OSERR);
@@ -162,7 +162,7 @@
/* in the child */
struct termios s_tty_attr;
if (tcgetattr(fileno(stdin), s_tty_attr)) {
-   perror(Child:);
+   perror(forkpty child:);
fflush(stdout);
fflush(stderr);
exit(EXIT_FAILURE);

So almost nothing changed.
First chunk is OK, because the error condition is caused during the call
to forkpty(). The second chunk is IMO not correct and my original
perror(tcgetattr(stdout,...)) seems to be more legit (error in the
tcgetattr()).
I'm attaching the open_init_pty.c with the cosmetic change of the first
error message. (BTW: no semicolon in the perror(), it is appended
always by perror()).

BTW: I already tried to post the code upstream in the past:
http://marc.info/?l=selinuxm=120826832520733w=2
... and reactions.

Thanks for your time!
Kindly regards
-- 
Zito
/*   -*- Mode: C -*- 
 * open_init_pty.c --- 
 * Author   : Manoj Srivastava ( sriva...@glaurung.internal.golden-gryphon.com ) 
 * Created On   : Fri Jan 14 10:48:28 2005
 * Created On Node  : glaurung.internal.golden-gryphon.com
 * Last Modified By : Manoj Srivastava
 * Last Modified On : Thu Sep 15 00:57:00 2005
 * Last Machine Used: glaurung.internal.golden-gryphon.com
 * Update Count : 92
 * Status   : Unknown, Use with caution!
 * HISTORY  : 
 * Description  : 
 *
 * Distributed under the terms of the GNU General Public License v2
 *
 * open_init_pty
 *
 * SYNOPSIS:
 *
 * This program allows a systems administrator to execute daemons
 * which need to work in the initrc domain, and which need to have
 * pty's as system_u:system_r:initrc_t
 *
 * USAGE:
 *
 * * arch-tag: a5583d39-72b9-4cdf-ba1b-5678ea4cbe20
 */

#include stdio.h
#include stdlib.h
#include string.h
#include unistd.h
#include signal.h
#include errno.h

#include sysexits.h

#include pty.h		/* for openpty and forkpty */
#include utmp.h		/* for login_tty */
#include termios.h
#include fcntl.h

#include sys/select.h
#include sys/wait.h


#define MAXRETR 3		/* The max number of IO retries on a fd */
#define BUFSIZE 2048	/* The ring buffer size */

static struct termios saved_termios;
static int saved_fd = -1;
static enum { RESET, RAW, CBREAK } tty_state = RESET;

static int tty_semi_raw(int fd)
{
	struct termios buf;

	if (tty_state == RESET) {
		if (tcgetattr(fd, saved_termios)  0) {
			return -1;
		}
	}

	buf = saved_termios;
	/*
	 * echo off, canonical mode off, extended input processing off,
	 * signal chars off 
	 */
	buf.c_lflag = ~(ECHO | ICANON | IEXTEN | ISIG);
	/*
	 * no SIGINT on break, CR-to-NL off, input parity check off, do not
	 * strip 8th bit on input,output flow control off
	 */
	buf.c_iflag = ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
	/* Clear size bits, parity checking off */
	buf.c_cflag = ~(CSIZE | PARENB);
	/* set 8 bits/char */
	buf.c_cflag |= CS8;
	/* Output processing off 
	   buf.c_oflag= ~(OPOST); */

	buf.c_cc[VMIN] = 1;	/* one byte at a time, no timer */
	buf.c_cc[VTIME] = 0;
	if (tcsetattr(fd, TCSANOW, buf)  0) {
		return -1;
	}
	tty_state = RAW;
	saved_fd = fd;
	return 0;
}

static void tty_atexit(void)
{
	if (tty_state != CBREAK  tty_state != RAW) {
		return;
	}

	if (tcsetattr(saved_fd, TCSANOW, saved_termios)  0) {
		return;
	}
	tty_state = RESET;
	return;
}


/* The simple ring buffer */
struct ring_buffer
{
char *buf;
char *wptr;
char *rptr;
size_t size;
size_t count;
};

static void ringbuf_init(struct ring_buffer *b, char *buf, size_t size)
{
b-buf = b-wptr = b-rptr = buf;
b-size = size;
b-count = 0;
}

static int ringbuf_isempty(struct ring_buffer *b)
{
return b-count == 0;
}

static size_t ringbuf_space(struct ring_buffer *b)
{
if ( b-rptr  b-wptr )
		return b-rptr - b-wptr;
if ( b-rptr  b-wptr || b-count == 0 )
		return b-buf + b-size - b-wptr;
return 0;
}

static size_t 

Bug#474956: [DSE-Dev] Bug#474956: Status of this policycoreutils bug?

2012-06-25 Thread Laurent Bigonville
tag 474956 + upstream
thanks

Le Mon, 25 Jun 2012 12:36:06 +0200,
Václav Ovsík vaclav.ov...@i.cz a écrit :

Hi,

 I'm attaching the open_init_pty.c with the cosmetic change of the
 first error message. (BTW: no semicolon in the perror(), it is
 appended always by perror()).

When doing a diff myself between the version you have attached here,
and the version in the package (2.1.10-8), I have more than 500 lines
of changes:

 open_init_pty.c |  510 ++--
 1 file changed, 244 insertions(+), 266 deletions(-)

If there are so much changes, this should definitely go upstream and
not in the debian package only as we are trying to keep the delta with
upstream as small as possible.

Could please reping upstream about this?

Cheers

Laurent Bigonville



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#474956: Status of this policycoreutils bug?

2012-05-17 Thread Touko Korpela
Can you send new patch against current version if this issue is still
present? Sorry for extra work, maintainer sent latest mail only to bug
address (that isn't cc:d automatically to submitter).



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org