Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 94880
b: refs/heads/master
c: 4112622
h: refs/heads/master
v: v3
  • Loading branch information
Miloslav Trmac authored and Al Viro committed Apr 28, 2008
1 parent a293a19 commit deee6c3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 60 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7719e437fac119e57b17588bab3a8e39ff9d22eb
refs/heads/master: 41126226e186d92a45ed664e546abb5204588359
54 changes: 4 additions & 50 deletions trunk/drivers/char/tty_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
if (unlikely(size == 0))
return;

if (tty->driver->type == TTY_DRIVER_TYPE_PTY
&& tty->driver->subtype == PTY_TYPE_MASTER)
return;

buf = tty_audit_buf_get(tty);
if (!buf)
return;
Expand Down Expand Up @@ -295,53 +299,3 @@ void tty_audit_push(struct tty_struct *tty)
tty_audit_buf_put(buf);
}
}

/**
* tty_audit_opening - A TTY is being opened.
*
* As a special hack, tasks that close all their TTYs and open new ones
* are assumed to be system daemons (e.g. getty) and auditing is
* automatically disabled for them.
*/
void tty_audit_opening(void)
{
int disable;

disable = 1;
spin_lock_irq(&current->sighand->siglock);
if (current->signal->audit_tty == 0)
disable = 0;
spin_unlock_irq(&current->sighand->siglock);
if (!disable)
return;

task_lock(current);
if (current->files) {
struct fdtable *fdt;
unsigned i;

/*
* We don't take a ref to the file, so we must hold ->file_lock
* instead.
*/
spin_lock(&current->files->file_lock);
fdt = files_fdtable(current->files);
for (i = 0; i < fdt->max_fds; i++) {
struct file *filp;

filp = fcheck_files(current->files, i);
if (filp && is_tty(filp)) {
disable = 0;
break;
}
}
spin_unlock(&current->files->file_lock);
}
task_unlock(current);
if (!disable)
return;

spin_lock_irq(&current->sighand->siglock);
current->signal->audit_tty = 0;
spin_unlock_irq(&current->sighand->siglock);
}
5 changes: 1 addition & 4 deletions trunk/drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2755,7 +2755,6 @@ static int tty_open(struct inode *inode, struct file *filp)
__proc_set_tty(current, tty);
spin_unlock_irq(&current->sighand->siglock);
mutex_unlock(&tty_mutex);
tty_audit_opening();
return 0;
}

Expand Down Expand Up @@ -2818,10 +2817,8 @@ static int ptmx_open(struct inode *inode, struct file *filp)

check_tty_count(tty, "tty_open");
retval = ptm_driver->open(tty, filp);
if (!retval) {
tty_audit_opening();
if (!retval)
return 0;
}
out1:
release_dev(filp);
return retval;
Expand Down
5 changes: 0 additions & 5 deletions trunk/include/linux/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ extern void tty_hangup(struct tty_struct * tty);
extern void tty_vhangup(struct tty_struct * tty);
extern void tty_unhangup(struct file *filp);
extern int tty_hung_up_p(struct file * filp);
extern int is_tty(struct file *filp);
extern void do_SAK(struct tty_struct *tty);
extern void __do_SAK(struct tty_struct *tty);
extern void disassociate_ctty(int priv);
Expand Down Expand Up @@ -352,7 +351,6 @@ extern void tty_audit_exit(void);
extern void tty_audit_fork(struct signal_struct *sig);
extern void tty_audit_push(struct tty_struct *tty);
extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid);
extern void tty_audit_opening(void);
#else
static inline void tty_audit_add_data(struct tty_struct *tty,
unsigned char *data, size_t size)
Expand All @@ -370,9 +368,6 @@ static inline void tty_audit_push(struct tty_struct *tty)
static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
{
}
static inline void tty_audit_opening(void)
{
}
#endif

/* tty_ioctl.c */
Expand Down

0 comments on commit deee6c3

Please sign in to comment.