You could go suid, chmod 4111, but that is ALL to dangerous.
Well you cannot execute a script on either FreeBSD or Linux that has the SUID bit set ..

OK, you still end up with an SUID program, but what about putting the real Perl script in a directory that users cannot read, then calling it with this wrapper:
/* wrapper.c */ #define REAL_PATH "/usr/local/bin/secret/secret.pl" main(ac, av) char **av; { execv(REAL_PATH, av); }

Compile it:  cc -o secret wrapper.c

Put the real script in the unreadable directory:
# mkdir /usr/local/bin/secret # cp secret.pl /usr/local/bin/secret/ # chmod -R 0711 /usr/local/bin/secret/

Make the wrapper you just compiled SUID root:
# chown root:root secret # chmod 4711 secret

A unprivileged user should be able to execute the "secret" program, but not read the real Perl code.. so how dangerous would it be to have this suid program around? Maybe in the Perl script you could make sure no arguments are passed in as a first level precaution.. ? I know, it's a Bad Thing.

You could also just compile the perl script into an executable with perlcc - I don't believe you can see the source code.


In reply to Re^2: Execute But Not Read by hsinclai
in thread Execute But Not Read by Gorby

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.