tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: CDROM mounting
@ 1999-01-28 20:26 Pantelis Topalis
  0 siblings, 0 replies; only message in thread
From: Pantelis Topalis @ 1999-01-28 20:26 UTC (permalink / raw)
  To: tru64-unix-managers


Many thanks to 

-----------------------------------------------------
Ronald D. Bowman <rdbowma@tsi.clemson.edu>
alan@nabeth.cxo.dec.com
Stanley Horwitz <stan@astro.ocis.temple.edu
Scott L. McCracken <scottm@synergex.com>
Bob Otterson <Robert.Otterson@digital.com>
K.McManus@greenwich.ac.uk
pricha - Phil Richardson <PRICHA@acxiom.co.uk>
"Dr. Tom Blinn, 603-884-0646" <tpb@doctor.zk3.dec.com>
Jean-Loup Risler <risler@genetique.uvsq.fr>
kenny <kenny@genesis.com.tw>
Maik Bachmann <maik@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@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@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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-01-28 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-01-28 20:26 SUMMARY: CDROM mounting Pantelis Topalis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox