<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=Perl_setuid</id>
		<title>Perl setuid - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://freebsdwiki.net/index.php?action=history&amp;feed=atom&amp;title=Perl_setuid"/>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php?title=Perl_setuid&amp;action=history"/>
		<updated>2026-04-06T11:00:26Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://freebsdwiki.net/index.php?title=Perl_setuid&amp;diff=6597&amp;oldid=prev</id>
		<title>Ninereasons: Clarify what &quot;setuid&quot; means. dead-end. link to Perl</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php?title=Perl_setuid&amp;diff=6597&amp;oldid=prev"/>
				<updated>2006-06-12T18:53:31Z</updated>
		
		<summary type="html">&lt;p&gt;Clarify what &amp;quot;setuid&amp;quot; means. dead-end. link to Perl&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 18:53, 12 June 2006&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;first&lt;/del&gt;, you need to recompile perl:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;To make it possible to run [[perl]] with temporarily elevated privileges for a particular task&lt;/ins&gt;, you need to recompile perl:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; # cd /usr/ports/lang/perl5.8 &amp;amp;&amp;amp; make -DENABLE_SUIDPERL=&amp;quot;YES&amp;quot; install clean&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; # cd /usr/ports/lang/perl5.8 &amp;amp;&amp;amp; make -DENABLE_SUIDPERL=&amp;quot;YES&amp;quot; install clean&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key bsdwiki:diff:version:1.11a:oldid:5204:newid:6597 --&gt;
&lt;/table&gt;</summary>
		<author><name>Ninereasons</name></author>	</entry>

	<entry>
		<id>http://freebsdwiki.net/index.php?title=Perl_setuid&amp;diff=5204&amp;oldid=prev</id>
		<title>Jimbo at 11:46, 25 February 2006</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php?title=Perl_setuid&amp;diff=5204&amp;oldid=prev"/>
				<updated>2006-02-25T11:46:50Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;first, you need to recompile perl:&lt;br /&gt;
&lt;br /&gt;
 # cd /usr/ports/lang/perl5.8 &amp;amp;&amp;amp; make -DENABLE_SUIDPERL=&amp;quot;YES&amp;quot; install clean&lt;br /&gt;
&lt;br /&gt;
then you have to make sure your script is chmodded setuid:&lt;br /&gt;
&lt;br /&gt;
 # chmod 4755+s ./myscript.pl&lt;br /&gt;
&lt;br /&gt;
and the ridiculously undocumented part - it still isn't going to &amp;quot;just run setuid.&amp;quot;  you have to change your uid within your perl code, something like this.&lt;br /&gt;
&lt;br /&gt;
 my $real_user_id       = $&amp;lt;; # Grab all the original values&lt;br /&gt;
 my $effective_user_id  = $&amp;gt;; # so we can reset everything &lt;br /&gt;
 my $real_group_id      = $(; # when we are done with root access&lt;br /&gt;
 my $effective_group_id = $); # &lt;br /&gt;
 $&amp;lt;=$&amp;gt;=0;                     # 0 is almost always OWNER root&lt;br /&gt;
 $(=$)=0;                     # 0 is almost always GROUP wheel&lt;br /&gt;
 #&lt;br /&gt;
 # ...SOME PERL CODE...&lt;br /&gt;
 #&lt;br /&gt;
 $&amp;lt; = $real_user_id;          # Set everything back to original&lt;br /&gt;
 $&amp;gt; = $effective_user_id;     # values.&lt;br /&gt;
 $( = $real_group_id;         # &lt;br /&gt;
 $) = $effective_group_id;    # &lt;br /&gt;
&lt;br /&gt;
Of course the neat thing there is that you can easily bounce back and forth between uids.&lt;br /&gt;
&lt;br /&gt;
[[Category:Common Tasks]]&lt;/div&gt;</summary>
		<author><name>Jimbo</name></author>	</entry>

	</feed>