:: Re: [DNG] Mini init script written …
Góra strony
Delete this message
Reply to this message
Autor: Irrwahn
Data:  
Dla: dng
Temat: Re: [DNG] Mini init script written in Perl boots.
On Thu, 16 Jun 2016 22:01:32 +0200, Edward Bartolo wrote:

> The Perl script:
> ----------------------
>
> #!/usr/bin/perl -w
>
> if ($<) {
>     printf "Only root can run this program.\n";
>     exit 1;
> }


The real user ID the script is running under (represented
by "$<") should be of no concern. Similar for the effective
user ID ("$>").

However, and to match Felker's init, it would be a *really*
good idea to check for the process ID, and abort if it's not
equal to 1, in order to avoid the script running at any
time other then system initialization. I believe in Perl
that would read something like:

  if ($$ != 1) {
     exit 1;
  }


[...]
> # We are in the child which must load the operating system by executing a script


One could argue the OS is already running, otherwise there
would be no Perl interpreter available to run your script.
But that's merely hairsplitting on definition of terms.

Regards
Urban