Many thanks to
-----------------------------------------------------
Ronald D. Bowman <rdbowma_at_tsi.clemson.edu>
alan_at_nabeth.cxo.dec.com
Stanley Horwitz <stan_at_astro.ocis.temple.edu
Scott L. McCracken <scottm_at_synergex.com>
Bob Otterson <Robert.Otterson_at_digital.com>
K.McManus_at_greenwich.ac.uk
pricha - Phil Richardson <PRICHA_at_acxiom.co.uk>
"Dr. Tom Blinn, 603-884-0646" <tpb_at_doctor.zk3.dec.com>
Jean-Loup Risler <risler_at_genetique.uvsq.fr>
kenny <kenny_at_genesis.com.tw>
Maik Bachmann <maik_at_ironmaik.com>
-------------------------------------------------------
My question was if there is a straightforward way for non priviledged
users to mount CDROMs.
As many pointed out the short answer is no but ...
1) A proposal was to change the priviledges of my CDROM device.
It didn't work for me.
2) Some they suggested the use of sudo.
I downloaded sudo_v1.5.7 and installed it. No luck.
My box kept complaining about mount:Cannot load cdfs module
mount() is looking the real and not the effective uid in DU 4.0D and may
be this is the problem.
3) Another popular solution is to write a script which runs as su ...
and open up a major security hole as Dr Kevin McManus noticed.
4) There is circulating a C program written by EMANUELE LOMBARDI
lele_at_mantegna.casaccia.enea.it named monta.c
I compiled it using cc (not gcc) and it works fine.
The program follows :
---------------CUT HERE---------------------------------
/*
monta.c
Program to allow users to mount CDROM without the need to be root.
Users can choose among a list of availabel devices (devs) the first
of which is the default one
See the section code referring the -h switch for the usage of monta.
don't forget to chmod 4555 the executeble!
by EMANUELE LOMBARDI lele_at_mantegna.casaccia.enea.it
*/
#include <stdio.h>
main(argc,argv,en)
int argc;
char *argv[];
char *en[];
{
#define ARGS "o:ud:h"
#define NDEVS 2
#define MAXNS 20
char *al[MAXNS] = NULL;
char *devs[NDEVS],*dev;
int umount,ns,i,c,okdev;
extern int errno;
setruid(0);
devs[0]="/dev/rz8c"; /* default device*/
devs[1]="/dev/gd0c";
dev=devs[0];
al[0] = "/usr/sbin/mount";
al[1] = "-t";
al[2] = "cdfs";
al[3] = "-r" ;
ns=4;
umount=0;
while (((c = getopt(argc, argv, ARGS)) != -1))
switch (c) {
case 'd':
okdev=0;
for (i=0;i<NDEVS;i++){
if (strcmp(devs[i],optarg)==0) {dev=devs[i];okdev=1;}
}
if (okdev==0) {
fprintf(stderr,"ERROR: device %s NOT available\n",optarg);
for (i=0;i<NDEVS;i++){fprintf(stderr,"available:%s\n",devs[i]);}
exit(1);}
break;
case 'o':
if (ns<MAXNS) {
al[ns]="-o";ns++;al[ns]=optarg;ns++;} else {
fprintf(stderr,"ERROR too many options!\n");
exit (1);}
break;
case 'u':
umount=1;
break;
case 'h':
fprintf(stderr,"MOUNTS/UMOUNTS CDrom (-t cdfs -r)\n");
fprintf(stderr,"to mount: %s [-d dev] [-o opts] ... [-o opts] dir\n",argv[0]);
fprintf(stderr,"to umount: %s [-d dev] -u\n",argv[0]);
fprintf(stderr,"defaults: dev=%s opts=NONE\n",dev);
for (i=0;i<NDEVS;i++){fprintf(stderr,"available: %s\n",devs[i]);}
exit (1);
break;
default :
break;
}
if (umount==0) {
al[ns]=dev;ns++;
if (argc != optind) {al[ns]=argv[argc-1];}
else
{al[ns] = "/cdrom";}
} else {
for (i=0;i<=10;i++){al[i]=NULL;}
al[0]="/usr/sbin/umount";
al[1]=dev;
ns=1;}
for (i=0;i<=ns;i++){fprintf(stderr,"%s ",al[i]);}
fprintf(stderr,"\n");
if (execve(al[0],al,en) != 0) {
fprintf(stderr,"ERROR: errno=%d",errno);
perror (" ");
exit(1);
}
}
---------------CUT HERE---------------------------------
Pantelis Topalis
PS. Modifying appropriately monta.c you can let any user to mount any
removable media. Volume daemon (vold) does the same in some unix flavors
but it is not available for digital unix.
Received on Thu Jan 28 1999 - 20:24:18 NZDT