Solved

non-root to umount /mnt/cdrom ?

Posted on 2000-04-05
9
366 Views
Last Modified: 2010-08-05
Along similar lines as my question above, what would be the correct way to allow a non-root user to umount /mnt/cdrom ?
thanks,
0
Comment
Question by:frenomulax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2688716
Change the entry in fstab to include "owner". Something like:

/dev/cdrom              /cdrom                  iso9660 noauto,owner,ro 0 0
0
 
LVL 1

Expert Comment

by:caramilk
ID: 2688841
Give the user permissions to unmount the cdrom
0
 
LVL 4

Expert Comment

by:Robson
ID: 2689194
Add option 'user' to /dev/cdrom's entry in /etc/fstab (man fstab tells everything).
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:frenomulax
ID: 2692246
Sorry,
I probably wasn't explicit enough. What I maent was, what is the best way to let a specific user do this, not all users.
thanks,
0
 

Author Comment

by:frenomulax
ID: 2692247
Adjusted points from 50 to 100
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2693066
For that, you need something that runs the mount/unmount commands as root only for that user. You can do it with a suid script, but I prefer to use a small executable (as it's a bit more secure). I've got one that could be modified slightly to do it if you are interested.
0
 

Author Comment

by:frenomulax
ID: 2695459
I don't know much yet about suid. I know that there are security concerns w/ such scripts, but don't really know much about why. I'm not afraid of compiling a little code, if it is something a beginning programmer could understand. The truth is, on my home machine I am the only user, so modifying /etc/fstab would be acceptable, but what I'd like to do is learn the best way to handle this, in preperation of someday administering a system w/ multiple users.

I'll take your advise as to the best way to proceed.
thanks,
0
 
LVL 40

Accepted Solution

by:
jlevie earned 100 total points
ID: 2695536
I don't like suid scripts either. There's no way to hide their contents like there is with a properly installed executable and it takes extreme caution to make sure that the script can't be abused. As far as I've been able to determine (and that includes peer review) my C code is safe if properly installed. And, in fact, there are numerous suid programs on Linux or any other Unix. There have to be for certain things, so it's a necessary evil that we put up with. As long as the executable is properly written and installed it doesn't create a security risk.

I'll modify the code and post it tomorrow. It's pretty late where I am right now...
0
 
LVL 40

Expert Comment

by:jlevie
ID: 2720635
Well, shucky darn. Either I didn't manage to get my comment containing the code posted or it got lost... One more time... If you have trouble getting the code out of the comment and into a file, send me an email and I'll mail it to you (jlevie@bellsouth.net)

---begin cdutil.c---
/*
 * NAME
 *              cdutil - User level CD mount/umount
 *
 * SYNOPSIS
 *              cdutil mount | umount
 *
 * DESCRIPTION
 *              Allows those users listed in the "names" array access to "mount/umount"
 *              with root privs. You can include one or more users as desired as long as "NULL"
 *              terminates the array. You certainly will need to edit the "names" array to
 *              suit local use.
 *
 *              This utility is safe if installed properly. The executable should be placed in
 *              the user's PATH (/usr/bin comes to mind), owned by root, group root or bin,
 *              suid to root, and executable only by group & other. This can be easily done
 *              with:
 *
 *              root> cc -o cdutil cdutil.c
 *              root> cp cdutil /usr/bin
 *              root> chown root:root /usr/bin/cdutil
 *              root> chmod 6511 /usr/bin/cdutil
 *
 * AUTHOR; Jim Levie
 */

#include <stdio.h>
#include <pwd.h>

struct passwd *getpwuid();
extern char **environ;

char *names[] =
{ "first-user", "second-user", NULL};

char *mount[] = {"/bin/mount", "/mnt/cdrom", '\0'};
char *umount[] = {"/bin/umount", "/mnt/cdrom", '\0'};

char **cmd;

main(argc, argv)
int argc;
char **argv;
{
  char user[9];
  register int okay = 0, i;

  if(argc != 2)
  {
    puts("Usage: cdutil mount | umount\n");
    exit(1);
  }

  /*
     * Get and check the users name against our builtin names.
     */
  strcpy(user, getpwuid(getuid())->pw_name);
  for(i = 0; names[i]; i++)
  {
    if(!strcmp(user, names[i]))
    {
      okay = 1;
      break;
    }
  }  
  if(okay)
  {
    if(!strcmp(argv[1], "mount"))
    {
      cmd = mount;
    }
    else if(!strcmp(argv[1], "umount"))
    {  
      cmd = umount;      
    }
    else
    {
      puts("Usage: cdutil [mount | umount]\n");
      exit(1);
    }
    setuid(0);
    execvp(*cmd, cmd);
    puts("\nCan't execute.\n");
  }
  else
  {
    puts("Not by the hair of my chinny chin chin!\n");
  }
}
---end cdutil.c---
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question