Re: bash using unknown tmp - library based? static link on linux? (was Re: bash not using pipes or /tmp @ boot?)

2014-10-08 Thread Linda Walsh



Chet Ramey wrote:

On 10/8/14, 1:17 AM, Linda Walsh wrote:

P_tmpdir?  in ENV?


No.  P_tmpdir is a #define in stdio.h that holds the full pathname of the
compilation environment's preferred temporary directory.


I don't have TMP or TMPDIR in my env during normal runtime
and tmp's were put in /tmp... 


Then P_tmpdir is probaby "/tmp".


I don't know where they were going
@ boot time, as /tmp and /var/tmp were writeable, but still
TMP/TMPDIR were unset.  


Did you verify $TMPDIR?

---
As mentioned above, I verified that that TMP,TMPDIR were both unset.

Since the thing that differs is $TMPDIR, presumably its value when
executing in the boot-time environment, you might want to start with
looking at that.

---
It is empty or null:

/etc/init.d/boot.assign_netif_names#212(read_actuals)> echo 'TMP=, TMPDIR='

TMP=, TMPDIR=

My "runtime" (same as boot time) /bin/bash shows linking only against
rootfs files:

  linux-vdso.so.1 (0x7fffecb96000)
  libreadline.so.6 => /lib64/libreadline.so.6 (0x003033c0)
  libtinfo.so.5 => /lib64/libtinfo.so.5 (0x7f8e7fb41000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00300280)
  libc.so.6 => /lib64/libc.so.6 (0x00300200)
  /lib64/ld-linux-x86-64.so.2 (0x0030)

So I'm doubting the library... but the process-substitution works now,
which is what I started with -- I'm thinking this script ran earlier, before
(the order has changed, putting most files in step 50 now), but
udev runs (and likely finishes) much earlier than before.


the original suse boot sequence used "tmpfs" and let
udev populate it from there, vs. I mount 'devtmpfs' which
already has an entry for /dev/fd.

I remember moving changing /dev's initial mount type to "devtmpfs"
from "tmpfs" under the reasoning that it was better to
have some funcionality than none.
But suse does all their /dev init on an empty "tmpfs" from
their ram disk.  They likely feel (or felt) safe in letting
udev do all the initialization, as they can wait until it is
done before doing their kexec or pivot to the hard-disk root.


That's another diff tween my sys and suse's.
I boot from HD, w/o an initdisk), so I need to ensure the
disk image supports booting directly (thus devtmpfs instead
of tmpfs).  That makes for a good reason for the differences I saw, since any
interactive pausing on my part would allow udev to complete its basic
setup and thus /dev/fd would have pointed correctly to /proc/self/fd.
I.e. if the bash-script needing /dev/fd ran too early, udev wouldn't have
finished populating /dev on an empty tmpfs.

Only way to boot faster now would be a special mount script to
allow parallel mounts by dependencies (current mount's parallel
option isn't smart enough to mount by deps), since out of a 33s
boot, 18s are taken by localfs mount in "mount -v -a"


I guess what I would like is a more robust proc-subst -- so if /dev/fd
wasn't there, then bash would fall back to pipes and emulate the same
functionality (trap open of /dev/fd/63 in child, and redirect it directly to
parent pipe) -- that's what I mean by circumventing the stdlibc and doing
that bit (interception) on your own.

That's also what I mean by "voodoo feature" referring to proc-subst.
It's a feature that's not really there until it is -- but a script writer
really should be careful about using it in portable code as it may be
there or may not.  Sorta like Reagan's voodoo economics -- spend more money
to help the economy -- but he spent money that wasn't really there... he
just created an additional 2T debt to fund his high-on-the-hog presidency...

So it's not that voodoo might not work in some situations -- just that you
probably can't or shouldn't rely on it, "portably" given its current
fallback behavior when it can't find /dev/fd (you might get
zombie processes or ...)  :-O







Re: bash using unknown tmp - library based? static link on linux? (was Re: bash not using pipes or /tmp @ boot?)

2014-10-08 Thread Chet Ramey
On 10/8/14, 1:17 AM, Linda Walsh wrote:

>>> Yeah... where?
>>
>> Wherever $TMPDIR says to.  If $TMPDIR doesn't name a writable directory,
>> bash looks for various system definitions (P_tmpdir), finally defaulting
>> to /tmp or /var/tmp.
> 
> P_tmpdir?  in ENV?

No.  P_tmpdir is a #define in stdio.h that holds the full pathname of the
compilation environment's preferred temporary directory.

> I don't have TMP or TMPDIR in my env during normal runtime
> and tmp's were put in /tmp... 

Then P_tmpdir is probaby "/tmp".

> I don't know where they were going
> @ boot time, as /tmp and /var/tmp were writeable, but still
> TMP/TMPDIR were unset.  

Did you verify $TMPDIR?

>> Please.  Your assumptions about what is going on make your conclusions
>> shaky at best.
> 
> Um...assumptions were that tmp files weren't getting created
> in standard locations of /tmp or /var/tmp for unknown reasons.  Interactively
> and @ run time, it works fine... it's probably some library bash is linking
> with...

Since the thing that differs is $TMPDIR, presumably its value when
executing in the boot-time environment, you might want to start with
looking at that.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



bash using unknown tmp - library based? static link on linux? (was Re: bash not using pipes or /tmp @ boot?)

2014-10-07 Thread Linda Walsh



Chet Ramey wrote:

On 10/6/14, 6:03 PM, Linda Walsh wrote:

Not sure how but this went off into space, sorta...

Greg Wooledge wrote:

On Mon, Oct 06, 2014 at 12:14:57PM -0700, Linda Walsh wrote:

   done <<<"$(get_net_IFnames_hwaddrs)"
Where am I using a HERE doc?

<<< and << both create temporary files.



Yeah... where?


Wherever $TMPDIR says to.  If $TMPDIR doesn't name a writable directory,
bash looks for various system definitions (P_tmpdir), finally defaulting
to /tmp or /var/tmp.


P_tmpdir?  in ENV?

I don't have TMP or TMPDIR in my env during normal runtime
and tmp's were put in /tmp... I don't know where they were going
@ boot time, as /tmp and /var/tmp were writeable, but still
TMP/TMPDIR were unset.  (anyway -- went back to the process substitution)
since that actually worked -- when trying to debug it earlier, it was
thought that might be the problem... but it *seemed* to be a local
redefinition of a global -- which actually doesn't make complete sense, as
the script worked interactively.

Hmmm...oh well... even if /var/tmp and /tmp were not mounted,
bash running as root could still create files in it so not
sure what the problem was.






Maybe if bash didn't create tmp files in non-standard locations,
this never would have been an issue (or just use pipes)..


Please.  Your assumptions about what is going on make your conclusions
shaky at best.


Um...assumptions were that tmp files weren't getting created
in standard locations of /tmp or /var/tmp for unknown reasons.  Interactively
and @ run time, it works fine... it's probably some library bash is linking
with...

speaking of which ... does anyone have static link working on linux these days,
or is the static link break a suse-special?  I wanted  a safe shell to put
on root, since the way things are going, I'm expecting bash to be the next
piece of software that has to be merged with systemd...