diff options
author | Kai Makisara <Kai.Makisara@kolumbus.fi> | 2005-05-01 11:11:55 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-05-20 13:53:46 -0400 |
commit | 16c4b3e2071ad73e5cd2aa82961eed0414df6a7d (patch) | |
tree | 4083223806465884f775c6df142b8772e51073f7 /drivers/scsi | |
parent | f80ed139343c37c897ae89c70f7736a6937172f5 (diff) |
[SCSI] SCSI tape: fix permissions for SG_IO, etc.
This patch is against 2.6.12-rc3 + linus-patch from April 30. The patch
contains the following fixes:
- CAP_SYS_RAWIO is used instead of CAP_SYS_ADMIN; fix from Alan Cox
- only direct sending of SCSI commands requires this permission
- the st status is modified is successful unload is performed using
SCSI_IOCTL_STOP_UNIT
Signed-off-by: Kai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/st.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 265d1eed64fa..03b902c20e09 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -17,7 +17,7 @@ | |||
17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support | 17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support |
18 | */ | 18 | */ |
19 | 19 | ||
20 | static char *verstr = "20050312"; | 20 | static char *verstr = "20050501"; |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
@@ -29,6 +29,7 @@ static char *verstr = "20050312"; | |||
29 | #include <linux/string.h> | 29 | #include <linux/string.h> |
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/mtio.h> | 31 | #include <linux/mtio.h> |
32 | #include <linux/cdrom.h> | ||
32 | #include <linux/ioctl.h> | 33 | #include <linux/ioctl.h> |
33 | #include <linux/fcntl.h> | 34 | #include <linux/fcntl.h> |
34 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
@@ -50,6 +51,7 @@ static char *verstr = "20050312"; | |||
50 | #include <scsi/scsi_host.h> | 51 | #include <scsi/scsi_host.h> |
51 | #include <scsi/scsi_ioctl.h> | 52 | #include <scsi/scsi_ioctl.h> |
52 | #include <scsi/scsi_request.h> | 53 | #include <scsi/scsi_request.h> |
54 | #include <scsi/sg.h> | ||
53 | 55 | ||
54 | 56 | ||
55 | /* The driver prints some debugging information on the console if DEBUG | 57 | /* The driver prints some debugging information on the console if DEBUG |
@@ -3463,7 +3465,10 @@ static int st_ioctl(struct inode *inode, struct file *file, | |||
3463 | case SCSI_IOCTL_GET_BUS_NUMBER: | 3465 | case SCSI_IOCTL_GET_BUS_NUMBER: |
3464 | break; | 3466 | break; |
3465 | default: | 3467 | default: |
3466 | if (!capable(CAP_SYS_ADMIN)) | 3468 | if ((cmd_in == SG_IO || |
3469 | cmd_in == SCSI_IOCTL_SEND_COMMAND || | ||
3470 | cmd_in == CDROM_SEND_PACKET) && | ||
3471 | !capable(CAP_SYS_RAWIO)) | ||
3467 | i = -EPERM; | 3472 | i = -EPERM; |
3468 | else | 3473 | else |
3469 | i = scsi_cmd_ioctl(file, STp->disk, cmd_in, p); | 3474 | i = scsi_cmd_ioctl(file, STp->disk, cmd_in, p); |
@@ -3471,10 +3476,12 @@ static int st_ioctl(struct inode *inode, struct file *file, | |||
3471 | return i; | 3476 | return i; |
3472 | break; | 3477 | break; |
3473 | } | 3478 | } |
3474 | if (!capable(CAP_SYS_ADMIN) && | 3479 | retval = scsi_ioctl(STp->device, cmd_in, p); |
3475 | (cmd_in == SCSI_IOCTL_START_UNIT || cmd_in == SCSI_IOCTL_STOP_UNIT)) | 3480 | if (!retval && cmd_in == SCSI_IOCTL_STOP_UNIT) { /* unload */ |
3476 | return -EPERM; | 3481 | STp->rew_at_close = 0; |
3477 | return scsi_ioctl(STp->device, cmd_in, p); | 3482 | STp->ready = ST_NO_TAPE; |
3483 | } | ||
3484 | return retval; | ||
3478 | 3485 | ||
3479 | out: | 3486 | out: |
3480 | up(&STp->lock); | 3487 | up(&STp->lock); |