Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by David Lee Lamber » Tue, 21 Apr 1998 04:00:00





> > *Where* can I get some info on *exactly* which
> > files/package/tar-files does Linux needed to get running? I been
> > spending all this week searching on Internet, going to bookstore
> > (even book from O'Reilly doesnt cover that area), and looking thru
> > FTP Archive on CD and find nothing what Im looking for.

> Depends on what you want.  The kernel wants to be able to mount a root
> directory and run init.  Beyond that, whatever init wants to do -- the
> kernel doesn't particularly care.

How hard would it be to put together a distro that used no shell but
/bin/perl?  Would it do anything useful?

I've been gathering stuff for my own stripped-down distribution.
Question:  is there an editor out there,  either a vi or a pico
look-alike,  written totally in perl?  I guess I already have termcap
dependency (in telnet),  so vi might be OK,  but I want to be different
with this.

I just have what seem to be basic tools,  plus the libs they need,  and I
already have 4 MB of stuff.  Hrm...

--
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Peter Samuels » Wed, 22 Apr 1998 04:00:00



Quote:> How hard would it be to put together a distro that used no shell but
> /bin/perl?  Would it do anything useful?

Hmmm, perl is a great programming tool but it's not too much fun to use
interactively.  The distribution would take awhile to write since you'd
have to rewrite all the init scripts et al, but it would work OK.  But
I don't think it'd be too useful -- perl as an interactive shell would
be really cumbersome.  Unless you managed to write an interactive shell
_in_ perl (conceptually like perldb, I guess).

It would be an interesting excercise, but `ash' (the Bourne-shell clone
Debian uses for its install disk) is less than 100K anyway, so you
wouldn't be buying much if any space.

Quote:> I just have what seem to be basic tools,  plus the libs they need,
> and I already have 4 MB of stuff.  Hrm...

I like the way the Debian project did this -- they apparently (I
haven't looked at their source to see exactly how) wrote really
stripped-down versions of a lot of basic utilities (very few options,
pipe i/o only, few error messages, etc) for their boot image.  Most of
the utils even share code by being hardlinks to each other.

--
Peter Samuelson
<sampo.creighton.edu ! psamuels>

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Shimpei Yamashit » Mon, 27 Apr 1998 04:00:00





>> > *Where* can I get some info on *exactly* which
>> > files/package/tar-files does Linux needed to get running? I been
>> > spending all this week searching on Internet, going to bookstore
>> > (even book from O'Reilly doesnt cover that area), and looking thru
>> > FTP Archive on CD and find nothing what Im looking for.

>> Depends on what you want.  The kernel wants to be able to mount a root
>> directory and run init.  Beyond that, whatever init wants to do -- the
>> kernel doesn't particularly care.

>How hard would it be to put together a distro that used no shell but
>/bin/perl?  Would it do anything useful?

perl uses tcsh for globbing, so you will have to come up with a
stripped-down replacement that does csh-style globbing. More
importantly, libc also calls /bin/sh in several locations (most
notably in some of the exec() family of calls), so you will also need
to patch libc. (Does messing around with libc scare you? It should.)
It isn't as trivial as you might think.

--
Shimpei Yamashita               <http://www.patnet.caltech.edu/%7Eshimpei/>
perl -w -e '$_="not a perl hacker\n";$q=qq;(.);x9;$qq=qq;345123h896789,;;;$s=
pack(qq;H6;,q;6a7573;);$qq=qq;s,^$q,$s$qq;;$qq=~s;(\d);\$$1;g;eval$qq;print;'

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by David Lee Lamber » Mon, 27 Apr 1998 04:00:00






> >> > *Where* can I get some info on *exactly* which
> >> > files/package/tar-files does Linux needed to get running? I been
> >> > spending all this week searching on Internet, going to bookstore
> >> > (even book from O'Reilly doesnt cover that area), and looking thru
> >> > FTP Archive on CD and find nothing what Im looking for.

> >> Depends on what you want.  The kernel wants to be able to mount a root
> >> directory and run init.  Beyond that, whatever init wants to do -- the
> >> kernel doesn't particularly care.

> >How hard would it be to put together a distro that used no shell but
> >/bin/perl?  Would it do anything useful?

> perl uses tcsh for globbing, so you will have to come up with a
> stripped-down replacement that does csh-style globbing. More
> importantly, libc also calls /bin/sh in several locations (most
> notably in some of the exec() family of calls), so you will also need
> to patch libc. (Does messing around with libc scare you? It should.)
> It isn't as trivial as you might think.

Aren't unexpected calls to sh from obscure places rather the definition of
a security hole?  Anyway,  messing around with libc doesn't scare me as
long as it's not written in assembler.

Where exactly does perl do globbing?

--
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Jonathan Feinber » Mon, 27 Apr 1998 04:00:00



Quote:> Where exactly does perl do globbing?

perldoc -f glob

--

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Peter Samuels » Mon, 27 Apr 1998 04:00:00


  [Shimpei Yamashita]

Quote:> > perl uses tcsh for globbing, so you will have to come up with a
> > stripped-down replacement that does csh-style globbing.


Quote:> Where exactly does perl do globbing?

As mentioned, in the glob() function, normally called implicitly using
<globpattern> syntax.  Read "perldoc -f glob" for details.  Anyway, I
think Perl borrows sh to glob if csh is not available.

Also, Perl uses sh for system() (sometimes -- it also has a builtin
version depending on how you invoke it) and for open() on pipelines.
(And open() derivatives such as open3().)

Quote:> > More importantly, libc also calls /bin/sh in several locations
> > (most notably in some of the exec() family of calls),

Are you sure about exec*() using sh?  That sounds awfully expensive as
well as insecure.  (Not to mention the chicken/egg in sh itself.)

Quote:> > so you will also need to patch libc. (Does messing around with libc
> > scare you?  It should.)  It isn't as trivial as you might think.
> Aren't unexpected calls to sh from obscure places rather the
> definition of a security hole?  Anyway, messing around with libc
> doesn't scare me as long as it's not written in assembler.

One definition, yes.

Anyway, libc _does_ use sh for popen() and system() (but these are not
"unexpected" -- everybody knows they use the shell so in secure
programming you avoid them like gets()).  Those calls can make use of
advanced functionality in the shell, unlike the Perl glob() situation,
so in order not to break things you pretty much have to have a fully
functional sh, for whatever definition of "fully functional".

--
Peter Samuelson
<sampo.creighton.edu ! psamuels>

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Russ Allber » Mon, 27 Apr 1998 04:00:00


In comp.lang.perl.misc,


> More importantly, libc also calls /bin/sh in several locations (most
> notably in some of the exec() family of calls), so you will also need to
> patch libc.

I believe /bin/sh is only used in system() and popen() (and perhaps a few
other places).  exec*() should only be running the binary that you
specifically told it to run.

--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker



 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Russ Allber » Mon, 27 Apr 1998 04:00:00



Quote:> I believe /bin/sh is only used in system() and popen() (and perhaps a
> few other places).  exec*() should only be running the binary that you
> specifically told it to run.

Doh.  Ignore me.  execlp() and execvp() will pass the contents of files
with unknown magic numbers to /bin/sh by default.

--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker



 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Tom Christianse » Tue, 28 Apr 1998 04:00:00


 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc,

:I believe /bin/sh is only used in system() and popen() (and perhaps a few
:other places).  exec*() should only be running the binary that you
:specifically told it to run.

Ah, no.

--tom
--

    Emacs is a fine programming language, but I still prefer perl.

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Uri Guttma » Tue, 28 Apr 1998 04:00:00


  RA> In comp.lang.perl.misc, Shimpei Yamashita

  >> More importantly, libc also calls /bin/sh in several locations
  >> (most notably in some of the exec() family of calls), so you will
  >> also need to patch libc.

  RA> I believe /bin/sh is only used in system() and popen() (and
  RA> perhaps a few other places).  exec*() should only be running the
  RA> binary that you specifically told it to run.

exec will call /bin/sh if there are shell metachars in the single string
arg. multiple arg calls to exec bypass the shell. system uses the same
algorithm to decide to call the shell beforehand so it is not guaranteed
to use /bin/sh.

open seems to use the same check for metachars to decide if a shell is
called when opening a pipe e.g. open( F, '| foo | bar') will call the shell.

qx() or backticks will also call the shell to execute the command.
according to camel2 it always calls it unlike system and exec.

so there are many places perl uses the shell and it would be very
difficult to track them all down.  if you replaced /bin/sh with a shell
script (maybe another shell!) it could be used to log any calls so you
could find the calls from perl.

uri

--
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately

Use the Best Search Engine on the Net  --------  http://www.northernlight.com

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by Martien Verbrugg » Tue, 28 Apr 1998 04:00:00




> In comp.lang.perl.misc,

>> More importantly, libc also calls /bin/sh in several locations (most
>> notably in some of the exec() family of calls), so you will also need to
>> patch libc.

> I believe /bin/sh is only used in system() and popen() (and perhaps a few
> other places).  exec*() should only be running the binary that you
> specifically told it to run.

To avoid confusion about perl builtins and system calls:

The perl functions:

# perldoc -f exec
[snip]
The exec() function executes a system command I<AND NEVER RETURNS> -
use system() instead of exec() if you want it to return. It fails and
returns FALSE only if the command does not exist I<and> it is executed
directly instead of via your system's command shell (see below).
[snip]

# perldoc -f system
Does exactly the same thing as "exec LIST" except that a fork is done
first, and the parent process waits for the child process to complete.
[snip]

The system calls (on Solaris, might be different on others:

# man execvp
[snip]
    If the  new process  file is not an executable object file,
    execlp() and execvp() use the contents of that file as standard
    input  to the  shell.  In a standard-conforming application (see
    standards(5)), the exec family  of  functions  use  /usr/bin/ksh
    (see ksh(1)); otherwise, they use /usr/bin/sh (see sh(1)).
[snip]

Martien
--
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by David Lee Lamber » Tue, 28 Apr 1998 04:00:00





> > In comp.lang.perl.misc,

> >> More importantly, libc also calls /bin/sh in several locations (most
> >> notably in some of the exec() family of calls), so you will also need to
> >> patch libc.

> > I believe /bin/sh is only used in system() and popen() (and perhaps a few
> > other places).  exec*() should only be running the binary that you
> > specifically told it to run.

> To avoid confusion about perl builtins and system calls:

> The perl functions:

> # perldoc -f exec
> [snip]
> The exec() function executes a system command I<AND NEVER RETURNS> -
> use system() instead of exec() if you want it to return. It fails and
> returns FALSE only if the command does not exist I<and> it is executed
> directly instead of via your system's command shell (see below).
> [snip]

> # perldoc -f system
> Does exactly the same thing as "exec LIST" except that a fork is done
> first, and the parent process waits for the child process to complete.
> [snip]

> The system calls (on Solaris, might be different on others:

> # man execvp
> [snip]
>     If the  new process  file is not an executable object file,
>     execlp() and execvp() use the contents of that file as standard
>     input  to the  shell.  In a standard-conforming application (see
>     standards(5)), the exec family  of  functions  use  /usr/bin/ksh
>     (see ksh(1)); otherwise, they use /usr/bin/sh (see sh(1)).
> [snip]

Under Linux (at least,  according to the comments in the kernel source in
fs/exec.c),  the kernel takes care of #! processing within itself.
Perhaps it calls /bin/sh if it can't figure out which interpreter to use,
but on most current Linux distributions /bin/sh is a symlink to /bin/bash.
My idea is to make a file /bin/plsh (for example),  to which /bin/sh will
be linked in my distribution.

--
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20

 
 
 

Perl-only distribution (was Re: How do I build Linux from stratch?? (w/o distribution of course!!))

Post by David Lee Lamber » Tue, 28 Apr 1998 04:00:00



Quote:> Anyway, libc _does_ use sh for popen() and system() (but these are not
> "unexpected" -- everybody knows they use the shell so in secure
> programming you avoid them like gets()).  Those calls can make use of
> advanced functionality in the shell, unlike the Perl glob() situation,
> so in order not to break things you pretty much have to have a fully
> functional sh, for whatever definition of "fully functional".

My school's library has a couple of copies of an inch-thick book entitled
'POSIX.2' (I think the IEEE publishes it) -- would that count?

--
m/lamber45\100(egr|pilot)\.msu\.edu/ and print <<MHM16x20
David Lee Lambert -- Just another perl hacker
webstuph at http://web.egr.msu.edu/~lamber45
MHM16x20

 
 
 

1. How to build Debian binary distribution from source distribution?

Hello all!

Is there a way to automatically build *.deb files in binary-i386
subdirectories (ie. admin, base etc) from the files in source
subdirectories (again admin, base, etc)?

I wish to constantly update binary distribution, but downloading
binary packages requires a lot of bandwidth. I hope to able to
download only "*.diff.gz" files and rebuild binary packages from the
sources, saving on bandwidth and time.

Is this possible?
Is this documented somewhere?

Regards,
Milan

2. Mouse pointer customisation - KDE menus

3. How do I build Linux from stratch?? (w/o distribution of course!!)

4. STB-PCI video cards and Linux

5. distrib a system for software distribution - an idea for software distribution

6. CONFERENCE: Atlanta Linux Showcase

7. How to build my own linux distribution iso by customizing the redhat 7.0 linux

8. Network setup problem

9. how to upgrade a Linux distribution so PERL's DBI likes it?

10. Building a linux distribution does a how-to exist?

11. How can I build a Linux system from scratch - NO distribution?

12. I am fed up with Gate$ and need some advice on which distribution to get!

13. I am having troubles installing StarOffice 5.2 from the RedHat 7.2 distribution