Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C set-user-ID program wrapper for Perl script and security

Reply
Thread Tools

C set-user-ID program wrapper for Perl script and security

 
 
Peter Michaux
Guest
Posts: n/a
 
      08-30-2008
I have a Perl script that I want to run as a set-user-ID program. Many
OSes don't allow scripts run as set-user-ID. To make this script
portable, it seems I need to write a C wrapper program that calls exec
or system to give the Perl script the necessary effective permissions.
How can I make the C wrapper program secure? or "more" secure?

The Perl script, which is "-rwsr-xr-x root root" will look at the real
user id and then check a permissions file that is "-rw------- root
root" to determine if the real user can carry out the subcommand to
the script.

Is it futile to attempt to solve my problem with a C wrapper program
around a Perl script? Writing this particular program all in C is
appealing from a purity point of view but I was going to be just
gluing together a bunch of command line tools like wget, chmod, tar
and a parser for YAML. Writing it all in C seems like overkill. If I
write this all in C then I suppose I need to find good libraries to
emulate all of these features.

Any suggestions?

Thanks,
Peter
 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      08-30-2008
On 30 Aug 2008 at 18:43, Peter Michaux wrote:
> I have a Perl script that I want to run as a set-user-ID program.

[snip]
> Is it futile to attempt to solve my problem with a C wrapper program
> around a Perl script?


Not at all. There's a discussion in the page got from
perldoc perlsec
and you might be able to find a wrapsuid script in your distribution
that generates a C wrapper automatically.

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      08-30-2008
Peter Michaux wrote:
>
> Any suggestions?
>

comp.unix.programmer

--
Ian Collins.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-31-2008
Peter Michaux <> writes:
> I have a Perl script that I want to run as a set-user-ID program. Many
> OSes don't allow scripts run as set-user-ID. To make this script
> portable, it seems I need to write a C wrapper program that calls exec
> or system to give the Perl script the necessary effective permissions.
> How can I make the C wrapper program secure? or "more" secure?
>
> The Perl script, which is "-rwsr-xr-x root root" will look at the real
> user id and then check a permissions file that is "-rw------- root
> root" to determine if the real user can carry out the subcommand to
> the script.
>
> Is it futile to attempt to solve my problem with a C wrapper program
> around a Perl script? Writing this particular program all in C is
> appealing from a purity point of view but I was going to be just
> gluing together a bunch of command line tools like wget, chmod, tar
> and a parser for YAML. Writing it all in C seems like overkill. If I
> write this all in C then I suppose I need to find good libraries to
> emulate all of these features.


Yes, ask in either a Perl newsgroup or a Unix newsgroup. Standard C
has no concept of accounts or permissions.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Peter Michaux
Guest
Posts: n/a
 
      08-31-2008
On Aug 30, 3:03*pm, "Malcolm McLean" <regniz...@btinternet.com> wrote:

> it is reasonable to hardcode paths in a Perl script,
> much less sensible to do so in a C program.


Why is that?

Peter
 
Reply With Quote
 
Andrew Poelstra
Guest
Posts: n/a
 
      08-31-2008
On 2008-08-31, Richard Heathfield <> wrote:
> Peter Michaux said:
>
>> On Aug 30, 3:03 pm, "Malcolm McLean" <regniz...@btinternet.com> wrote:
>>
>>> it is reasonable to hardcode paths in a Perl script,
>>> much less sensible to do so in a C program.

>>
>> Why is that?

>
> No reason whatsoever. Malcolm is wrong. If you want to hardcode paths in a
> C program, go to it. There will be an impact on portability (because the
> path might not have the same semantics or might not even exist on another
> machine), but that argument applies just as much to the Perl script.
>


Not really - a C program is almost always compiled, which means to change
a hardcoded path one needs to have access to the source code. By nature,
a Perl script is itself the source, meaning that any hardcoded paths are
going to be human-readable and mutable.

--
Andrew Poelstra
To email me, use the above email addresss with .com set to .net
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-31-2008
Peter Michaux <> writes:
> On Aug 30, 3:03*pm, "Malcolm McLean" <regniz...@btinternet.com> wrote:
>> it is reasonable to hardcode paths in a Perl script,
>> much less sensible to do so in a C program.

>
> Why is that?


Speaking as both a C programmer and a Perl programmer, I can't think
of any good reason.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
s0suk3@gmail.com
Guest
Posts: n/a
 
      08-31-2008
On Aug 31, 3:18 am, Keith Thompson <kst-> wrote:
> Peter Michaux <> writes:
> > On Aug 30, 3:03 pm, "Malcolm McLean" <regniz...@btinternet.com> wrote:
> >> it is reasonable to hardcode paths in a Perl script,
> >> much less sensible to do so in a C program.

>
> > Why is that?

>
> Speaking as both a C programmer and a Perl programmer, I can't think
> of any good reason.
>


Perl is typically used as a "scripting language", i.e., a glue
language, a language to automate typical tasks, a test driver, etc.

C programs are usually targeted at more serious tasks and are
therefore better structured and developed with maintainability and
reusability in mind. Thus, there's no reason why such a program would
have hard-coded paths, except for example during testing.

Sebastian

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-31-2008
"Malcolm McLean" <> writes:
[...]
> That's the answer. Hardcoded paths are a nuisance in a C
> program. Typically C source is thousands of lines long, and the
> executable might be detached from the source for use. So its a big job
> to change the paths.
> On the other hand users expect Perl scripts to contain
> paths. Typically they are quite short and farm out most of the
> "serious" work to other programs. Perl started as a glorified shell
> script, after all.


Perl has its own newsgroups.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      08-31-2008
"Malcolm McLean" <> writes:

> <> wrote in message news:
>> On Aug 31, 3:18 am, Keith Thompson <kst-> wrote:
>>> Peter Michaux <> writes:
>>> > On Aug 30, 3:03 pm, "Malcolm McLean" <regniz...@btinternet.com> wrote:
>>> >> it is reasonable to hardcode paths in a Perl script,
>>> >> much less sensible to do so in a C program.
>>>
>>> > Why is that?
>>>
>>> Speaking as both a C programmer and a Perl programmer, I can't think
>>> of any good reason.
>>>

>>
>> Perl is typically used as a "scripting language", i.e., a glue
>> language, a language to automate typical tasks, a test driver, etc.
>>
>> C programs are usually targeted at more serious tasks and are
>> therefore better structured and developed with maintainability and
>> reusability in mind. Thus, there's no reason why such a program would
>> have hard-coded paths, except for example during testing.
>>

> That's the answer. Hardcoded paths are a nuisance in a C
> program. Typically C source is thousands of lines long, and the
> executable might be detached from the source for use. So its a big job
> to change the paths.
> On the other hand users expect Perl scripts to contain
> paths. Typically they are quite short and farm out most of the
> "serious" work to other programs. Perl started as a glorified shell
> script, after all.


You have just stated that they exist. There is still no good reason why
hard coded paths *should* exist in Perl any more than they should in C.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wrapper script calling anotherr script bjlockie Perl Misc 1 09-15-2012 06:27 PM
Anyone willing to share an SUID wrapper program to take/passarguments to a shell script on Unbuntu? bobm3@worthless.info C Programming 3 01-15-2012 05:53 PM
Perl form as a wrapper to a C program. Dave Perl Misc 2 07-12-2005 07:05 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57