Welcome to unix. A bit of convolution, but still far simpler than the Windows security model, IMO. (Though still not perfect, but I digress.)

First off, just because you can't log in as root doesn't mean you can't log in as root. ;-) It just means you can't log in via gdm (the GUI) as root - a good thing by any security-minded definition. You should be able to gain root access in any number of other ways, some requiring a password, others have the password as optional.

What I've done in the past is set up sudo to allow running of a particular command without a password. In my case, I want to run it as a particular user, so I have:

%build ALL=(nobody) NOPASSWD: /full/path/to/script
With this, anyone can run "sudo -u nobody /full/path/to/script" and not be asked for a password. Well, that's great, but a bit cumbersome. So my script does this:
# Are we the right user? use User::pwent; my $user_wanted = 'nobody'; my $user = getpwnam($user_wanted); if ($< != $user->uid()) { exec(qw(sudo -u), $user_wanted, $0, @ARGV); } [...]
Now I can just run /full/path/to/script, and it will exec itself as the right user if it isn't already.

Hope that helps.


In reply to Re: Executing unix command from script by Tanktalus
in thread Executing unix command from script by Neminath

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.