View | Details | Raw Unified | Return to bug 18879
Collapse All | Expand All

(-)debian/changelog (+7 lines)
 Lines 1-3    Link Here 
1
univention-thin-client-login (6.1.1-1) unstable; urgency=low
2
3
  * Fix file descriptor leak in univention-session (Bug #18879)
4
  * Fix compiler warning and typo in Makefile.
5
6
 -- Philipp Hahn <hahn@univention.de>  Thu, 08 Jul 2010 15:42:23 +0200
7
1
univention-thin-client-login (6.1.0-1) unstable; urgency=low
8
univention-thin-client-login (6.1.0-1) unstable; urgency=low
2
9
3
  * bump version for UCS TCS compatibility (Bug #17543)
10
  * bump version for UCS TCS compatibility (Bug #17543)
(-)src/script.c (-1 / +1 lines)
 Lines 78-84    Link Here 
78
78
79
  get_command_args ( buffer, p, MAX_CMD_ARGS );
79
  get_command_args ( buffer, p, MAX_CMD_ARGS );
80
80
81
  if (debug_level && argv )
81
  if (debug_level)
82
    {
82
    {
83
      int i;
83
      int i;
84
      debug_printf ( "args: ");
84
      debug_printf ( "args: ");
(-)src/command_socket.c (-2 / +2 lines)
 Lines 85-91    Link Here 
85
85
86
  get_command_args ( buffer, p, MAX_CMD_ARGS );
86
  get_command_args ( buffer, p, MAX_CMD_ARGS );
87
87
88
  if (debug_level && argv )
88
  if (debug_level)
89
    {
89
    {
90
      int i;
90
      int i;
91
      debug_printf ( "args: ");
91
      debug_printf ( "args: ");
 Lines 102-108    Link Here 
102
/* create a new connection */
102
/* create a new connection */
103
int command_socket_handler ( int fd )
103
int command_socket_handler ( int fd )
104
{
104
{
105
  int len = sizeof ( sock_name );
105
  socklen_t len = sizeof ( sock_name );
106
  int new_fd = accept ( sock_fd, (struct sockaddr*) &sock_name, &len );
106
  int new_fd = accept ( sock_fd, (struct sockaddr*) &sock_name, &len );
107
  if (new_fd != -1) {
107
  if (new_fd != -1) {
108
    add_read_fd ( new_fd, command_socket_client_handler );
108
    add_read_fd ( new_fd, command_socket_client_handler );
(-)src/Makefile (-1 / +1 lines)
 Lines 42-45    Link Here 
42
	install -m 755 client-run ${DESTDIR}/usr/bin/univention-client-run
42
	install -m 755 client-run ${DESTDIR}/usr/bin/univention-client-run
43
43
44
clean:
44
clean:
45
	rm -f ${OBJS} ${OBJS} ${SRV_OBJS} ${CL_OBJS} {$CLR_OBJS} *~ ${PROGS} ${LIB} 
45
	${RM} ${OBJS} ${OBJS} ${SRV_OBJS} ${CL_OBJS} ${CLR_OBJS} *~ ${PROGS} ${LIB}
(-)src/connection.c (-10 / +62 lines)
 Lines 40-45    Link Here 
40
#include <wait.h>
40
#include <wait.h>
41
#include <errno.h>
41
#include <errno.h>
42
#include <string.h>
42
#include <string.h>
43
#include <fcntl.h>
43
44
44
extern int errno;
45
extern int errno;
45
46
 Lines 71-93    Link Here 
71
	return 0;
72
	return 0;
72
}
73
}
73
74
75
/*
76
 * Move file descriptor and mark as CLOSE-ON-EXEC.
77
 */
78
static int move_fd(int oldfd, int newfd) {
79
	int flags;
80
	int tmpfd;
81
82
	if (oldfd != newfd)
83
		tmpfd = dup2(oldfd, newfd);
84
	else
85
		tmpfd = newfd;
86
	if (tmpfd != newfd)
87
		fatal_perror("Error dup2 failed\n");
88
	flags = fcntl(tmpfd, F_GETFD);
89
	if (flags == -1)
90
		fatal_perror("Error getting tmpfd status\n");
91
	flags |= FD_CLOEXEC;
92
	if (fcntl(tmpfd, F_SETFD, flags) == -1)
93
		fatal_perror("Error setting tmpfd status\n");
94
95
	return tmpfd;
96
}
97
98
/*
99
 * Open /dev/null on fd in mode given by flags.
100
 */
101
static void open_dev_null(int fd, int flags) {
102
	int tmpfd;
103
104
	close(fd); /* ignore error if already closed. */
105
	tmpfd = open("/dev/null", flags);
106
	if (tmpfd < 0)
107
		fatal_perror("Error opening /dev/null\n");
108
	if (tmpfd != fd) {
109
		int ret;
110
111
		ret = dup2(tmpfd, fd);
112
		if (ret < 0)
113
			fatal_perror("Error dup2 failed\n");
114
		ret = close(tmpfd);
115
		if (ret < 0)
116
			fatal_perror("Error closing fd\n");
117
	}
118
}
119
120
/*
121
 * Clone FDs for client<->server communication inherited from SESSION_RSH
122
 * to private FDs and mark them as CLOSE-ON-EXEC.
123
 * Re-open STDIN and STDOUT as /dev/null to protect channel from non-protocol
124
 * data. STDERR uses a separate channel and needs not to be changed; keep it
125
 * for debugging.
126
 *
127
 * FD 3 and 4 are used to not mix with STDIN=0, STDOUT=1 and STDERR=2.
128
 * Don't use dup() after closing previous FDs with close()!
129
 */
74
void init_server_pipes ( void )
130
void init_server_pipes ( void )
75
{
131
{
76
	/* FIXME: what is fd 3? maybe use dup() instead */
132
	send_fd = move_fd(STDOUT_FILENO, 3);
77
	send_fd = dup2 ( STDOUT_FILENO, 3 );
78
	if ( send_fd < 0 )
79
		fatal_perror ( "dup failed" );
80
	close ( STDOUT_FILENO );
81
	if ( debug_level )
133
	if ( debug_level )
82
		debug_printf ( "to_client fd=%d\n", send_fd );
134
		debug_printf ( "to_client fd=%d\n", send_fd );
83
	/* FIXME: see above */
135
	open_dev_null(STDOUT_FILENO, O_WRONLY);
84
	recv_fd = dup2 ( STDIN_FILENO, 4);
136
85
	if ( recv_fd < 0 )
137
	recv_fd = move_fd(STDIN_FILENO, 4);
86
		fatal_perror ( "dup failed" );
87
	close ( STDIN_FILENO );
88
	add_read_fd ( recv_fd, connection_read_handler );
138
	add_read_fd ( recv_fd, connection_read_handler );
89
	if ( debug_level )
139
	if ( debug_level )
90
		debug_printf ( "from_client fd=%d\n", recv_fd );
140
		debug_printf ( "from_client fd=%d\n", recv_fd );
141
	open_dev_null(STDIN_FILENO, O_RDONLY);
142
91
	return;
143
	return;
92
}
144
}
93
145
(-)src/signals.c (+2 lines)
 Lines 67-73    Link Here 
67
67
68
void __unblock_signals ( void )
68
void __unblock_signals ( void )
69
{
69
{
70
  /*
70
  sigset_t sigset;
71
  sigset_t sigset;
72
  */
71
73
72
  if ( (sig_block_count--) != 0 ) return;
74
  if ( (sig_block_count--) != 0 ) return;
73
  sigprocmask ( SIG_UNBLOCK, &block_mask, NULL );
75
  sigprocmask ( SIG_UNBLOCK, &block_mask, NULL );
(-)src/protocol.h (+1 lines)
 Lines 34-36    Link Here 
34
void send_command ( char * buffer );
34
void send_command ( char * buffer );
35
void recv_command_fd ( char * buffer, int buflen, int recv_fd, int send_fd );
35
void recv_command_fd ( char * buffer, int buflen, int recv_fd, int send_fd );
36
void recv_command ( char * buffer, int buflen );
36
void recv_command ( char * buffer, int buflen );
37
void init_server ( void );

Return to bug 18879