SCIENTIFIC-LINUX-USERS Archives

April 2014

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
David Sommerseth <[log in to unmask]>
Reply To:
Date:
Thu, 1 May 2014 01:57:05 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (54 lines)
On 30/04/14 19:32, ToddAndMargo wrote:
> On 04/29/2014 10:21 PM, Nico Kadel-Garcia wrote:
>> On Tue, Apr 29, 2014 at 3:20 PM, ToddAndMargo <[log in to unmask]> wrote:
>>> Hi All,
>>>
>>> I have a bash script that need to be run as root.
>>> In the script, I check to see if it is running as
>>> root and flag the user to run appropriately.
>>>
>>> Is there a way to use "su" to prompt for the password
>>> and continue the script if successful? (I would test for
>>> $? after the prompt.)
>>
>> Is there any reason not to use "sudo", which has more sophisticated
>> options and can better manage providing root privileges, with or
>> without password authentication, for specific tools?
>
> I want the user to either already be root  or to
> be prompted for the root password.
>
> I really don't like sudo.

If you really want to consider security aspects, running via sudo is probably 
one of the more safer variants.  It is also possible to configure sudo to 
allow certain commands (such as your script) to be run explicitly with or 
without password, according the security level you think fits better.

Another, not so flexible approach is to use 'ksu', but I believe that only 
works if you're using Kerberos authentication.

>>> Currently "su" will just open a new shell as root.
>>>
>>> I can run a command inside "su", but what about the
>>> other 200 lines of code?  :'(
>>>
>>> Many thanks,
>>> -T
>>
>> Put the code that must run as root in one file, which is *run* by a
>> wrapper tool or wrapper script.
>
> It all has to be run as root.
>
> I like the call myself option with "su"

I think that's more a hack, which will probably kick-back at you sometime in 
the future.


--
kind regards,

David Sommerseth

ATOM RSS1 RSS2