- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using Mount / UnMount Commands in Shell Scrips
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 04:40 AM
03-20-2002 04:40 AM
This script has to be executed by a non root user. The script is owned by root and i have given suid. When this executes i see the disk getting mounted. But during umount it says "permision denied for /etc/mnttab".
when i do a "bdf" i can see the disk mounted and entry is there in "/etc/mnttab" also.
I have created a c program and gave the same permissions and tested. still i get the same error.
What's wrong with the approach? How to get the umount to work. The effective user id is root in both scenarios.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 05:08 AM
03-20-2002 05:08 AM
Re: Using Mount / UnMount Commands in Shell Scrips
You need to be very clear here. In your C program, are you using the umount() system call or are you simply do something like
system("umount filesys1"); I would use the system call itself and if it returns a non-zero value then examine errno. It is very important to know what errno is set to. My best guess is that for some reason your setuid is not working as you expect.
It would also help to know what OS you are running and the type of filesystem. Are you using pfs_mount/pfs_umount? Are you running OmniStorage?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 05:48 AM
03-20-2002 05:48 AM
SolutionHere is a couple of programs I wrote some time
ago after getting tired of doing su every
time I wanted to mount/unmount a cd.
I would think you can use this for your
purpose. As you see the device-file and
mount-point is hardcoded. You can easily
rewrite the programs to take these as
arguments.
/* Program that gives a regular user the ability to mount a cd.
. Compile the program
. Make root the owner of the executable.
. chmod 4755 executable
Olav Baadsvik Oslo Norway.
*/
#include
#include
#include
#include
main ()
{
int ios;
struct cdfs_args cda;
char buf[128];
setuid(geteuid());
setgid(getegid());
cda.fspec="/dev/dsk/cdrom";
ios=sysfs(GETFSIND, MNTTYPE_CDFS);
/* printf ("sysfs for %s er 0x%x\n", cda.fspec, ios); */
sysfs(GETFSTYP, ios, buf);
/* printf ("sysfs fstyp er >%s<\n", buf); */
ios = mount ( cda.fspec, "/CDROM",
( MS_DATA|MS_RDONLY),
MNTTYPE_CDFS,&cda, sizeof(cda) );
/* printf ("ios=%d\n", ios); */
if (ios) perror ("cdmount");
}
Here is the unmout-code:
#include
#include
#include
main ()
{
setuid(geteuid());
setgid(getegid());
umount("/CDROM");
}
Regards
Olav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 05:52 AM
03-20-2002 05:52 AM
Re: Using Mount / UnMount Commands in Shell Scrips
I thought mount ignores the effective user id, and *always* uses the real user id to determine privileges.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 05:58 AM
03-20-2002 05:58 AM
Re: Using Mount / UnMount Commands in Shell Scrips
umount doesn't use suid, it uses effective uid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 06:16 AM
03-20-2002 06:16 AM
Re: Using Mount / UnMount Commands in Shell Scrips
I just wrote a 3-minute setuid C program that mounted and unmounted a filesystem with absolutely no problem as a regular user.
I also used my dangerous version of a setuid wrapper which does a setuid and then can exec a command and it worked as well.
e.g.
cemexec root /usr/sbin/umount /filesys1
cemexec root /usr/sbin/mount /filesys1
Both of these worked exactly as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 06:28 AM
03-20-2002 06:28 AM
Re: Using Mount / UnMount Commands in Shell Scrips
We use a simple script that is owned by root:sys and executable by all with access to the shell. The scripts even run by cron.
The cdoff script:
umount /dev/dsk/c0t2d0
unount /dev/dsk/c0t2d1
umount /dev/dsk/c0t2d2
The cdon script is just the opposite of cdoff. mount instead of umount.
Simple, works for us as the users have to change CDs once a month as new CDs are distributed.
HTH,
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 06:39 AM
03-20-2002 06:39 AM
Re: Using Mount / UnMount Commands in Shell Scrips
maybe you should consider of using sudo, downloadable at http://hpux.cs.utah.edu/
Heiner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2002 07:33 AM
03-20-2002 07:33 AM
Re: Using Mount / UnMount Commands in Shell Scrips
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2002 12:09 AM
03-21-2002 12:09 AM
Re: Using Mount / UnMount Commands in Shell Scrips
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2002 06:22 AM
03-21-2002 06:22 AM
Re: Using Mount / UnMount Commands in Shell Scrips
create file name:
vi /usr/bin/mountcd
#!/usr/bin/sh
/usr/sbin/mount /dev/dsk/... /mountdir
save file,
chown root /usr/bin/mountcd
chgrp sys /usr/bin/mountcd
chmod 4555 /usr/bin/mountcd
" root user to execute file"
Regards
Bruno