You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Heiss, Christian" <Ch...@Datentechnik-Moll.De> on 2002/07/24 13:55:13 UTC

Mount something with my perl script

Hello,

I don't know if this is the right mailing list, but well...

How can I mount something with my perl script?
I've got always the error: mount: only root can do this

So I changed my script something like this:

#! /usr/bin/perl -w
`su - root <password> -c 'mount -t smbfs -o  credentials=<some.file>
//<windows/share> /<mount/point>'`;

If I start the script in the shell as root, it works fine.

If I start the script in the shell as some other user, it asked me for the
password.

If I start the script in via the Internet-Browser, in the log files it first
asked for the password and after one second it completes to "incorrect
password"

How can I change my script to execute the mount command as root
automatically, or to mount something within my perl script???


Thanks


Regards


Christian Heiss

_________________________________________________

LANconcept Moll GmbH 
Benzstrasse 1
88074 Meckenbeuren 
 
Voice:	+49 (0) 7542 940 3 - 18 
Fax:	+49 (0) 7542 218 24 
Mobil:	+49 (0) 171  80 64 254
<mailto:Christian.Heiss@datentechnik-moll.de
<ma...@datentechnik-moll.de> > 
visit our website <http://www.datentechnik-moll.de
<http://www.datentechnik-moll.de> > 
_________________________________________________ 




Re: Mount something with my perl script

Posted by st...@nsk.yi.org.
As Dominic Mitchell already pointed out, you're better using sudo than su.

Or just add the option "owner" (and optionally "uid=uid") to /etc/fstab.

Or just chgrp scriptegid /usr/bin/smbmnt ; chmod 04750 /usr/bin/smbmnt.

Regards,
Luciano Rocha

-- 
Consciousness: that annoying time between naps.

Re: Mount something with my perl script

Posted by Michael Jacob <mo...@modperl.j-e-b.net>.
Hi,

ouch, bad idea, wrong list, but:

4 solutions:

1.) let your webserver run as root (NEVER, NEVER 
do this!!)

2.) write a daemon that runs as root and does such 
things for your normal programs. (Overkill in this 
case)

3.) use sudo to allow the webserver's user to run 
exactly that command (with exactly that 
parameters)

4.) put that mount into your /etc/fstab with 
parameters "noauto, user" (noauto = don't mount at 
system boot time, user = allow any user to mount)

cu
Michael

24.07.2002 13:55:13, "Heiss, Christian" 
<Ch...@Datentechnik-Moll.De> wrote:

>
>
>  From:   "Heiss, Christian" 
<Ch...@Datentechnik-Moll.De>
>
>  To:     "'modperl@perl.apache.org'" 
<mo...@perl.apache.org>
>  Subject:Mount something with my perl script
>  Date:   Wed, 24 Jul 2002 13:55:13 +0200
>
>
>
>
>  Hello,
>
>
>  I don't know if this is the right mailing list, 
but well...
>
>
>  How can I mount something with my perl script?
>  I've got always the error: mount: only root can 
do this
>
>
>  So I changed my script something like this:
>
>
>  #! /usr/bin/perl -w
>  `su - root <password> -c 'mount -t smbfs -o  
credentials=<some.file> //
>  <windows/share> /<mount/point>'`;
>
>
>  If I start the script in the shell as root, it 
works fine.
>
>
>  If I start the script in the shell as some 
other user, it asked me for the
>  password.
>
>
>  If I start the script in via the Internet-
Browser, in the log files it first
>  asked for the password and after one second it 
completes to "incorrect
>  password"
>
>
>  How can I change my script to execute the mount 
command as root
>  automatically, or to mount something within my 
perl script???
>
>
>
>
>  Thanks
>
>
>
>
>
>  Regards
>
>
>
>
>  Christian Heiss
>
>
>  _______________________________________________
__
>
>  LANconcept Moll GmbH
>
>  Benzstrasse 1
>  88074 Meckenbeuren
>   
>  Voice:  +49 (0) 7542 940 3 - 18
>
>  Fax:    +49 (0) 7542 218 24
>  Mobil:  +49 (0) 171  80 64 254
>  <ma...@datentechnik-moll.de>
>  visit our website <http://www.datentechnik-
moll.de>
>
>  _______________________________________________
__